mirror of https://github.com/FOME-Tech/openblt.git
- implemented USB bulk device support for ARMCM4_TM4C.
git-svn-id: https://svn.code.sf.net/p/openblt/code/trunk@75 5dc33758-31d5-4daf-9ae8-b24bf3d40d73
This commit is contained in:
parent
754d8ecb5c
commit
e8ed20a6d4
Binary file not shown.
Binary file not shown.
|
@ -55,7 +55,7 @@
|
|||
/** \brief Motorola or Intel style byte ordering. */
|
||||
#define BOOT_CPU_BYTE_ORDER_MOTOROLA (0)
|
||||
/** \brief Enable/disable hook function call right before user program start. */
|
||||
#define BOOT_CPU_USER_PROGRAM_START_HOOK (0)
|
||||
#define BOOT_CPU_USER_PROGRAM_START_HOOK (1)
|
||||
/** \brief Compiler specific variable prefix to prevent its initialization during startup. */
|
||||
#define BOOT_CPU_CONNECT_STATE_PREFIX __no_init
|
||||
|
||||
|
@ -72,7 +72,7 @@
|
|||
*
|
||||
*/
|
||||
/** \brief Enable/disable UART transport layer. */
|
||||
#define BOOT_COM_UART_ENABLE (1)
|
||||
#define BOOT_COM_UART_ENABLE (0)
|
||||
/** \brief Configure the desired communication speed. */
|
||||
#define BOOT_COM_UART_BAUDRATE (57600)
|
||||
/** \brief Configure number of bytes in the target->host data packet. */
|
||||
|
@ -82,6 +82,19 @@
|
|||
/** \brief Select the desired UART peripheral as a zero based index. */
|
||||
#define BOOT_COM_UART_CHANNEL_INDEX (0)
|
||||
|
||||
/* The USB communication interface is selected by setting the BOOT_COM_USB_ENABLE
|
||||
* configurable to 1. The maximum amount of data bytes in a message for data transmission
|
||||
* and reception is set through BOOT_COM_USB_TX_MAX_DATA and BOOT_COM_USB_RX_MAX_DATA,
|
||||
* respectively.
|
||||
*
|
||||
*/
|
||||
/** \brief Enable/disable USB transport layer. */
|
||||
#define BOOT_COM_USB_ENABLE (1)
|
||||
/** \brief Configure number of bytes in the target->host data packet. */
|
||||
#define BOOT_COM_USB_TX_MAX_DATA (63)
|
||||
/** \brief Configure number of bytes in the host->target data packet. */
|
||||
#define BOOT_COM_USB_RX_MAX_DATA (63)
|
||||
|
||||
|
||||
/****************************************************************************************
|
||||
* F I L E S Y S T E M I N T E R F A C E C O N F I G U R A T I O N
|
||||
|
@ -111,7 +124,7 @@
|
|||
#define BOOT_FILE_SYS_ENABLE (1)
|
||||
/** \brief Enable/disable logging messages during firmware updates. */
|
||||
#define BOOT_FILE_LOGGING_ENABLE (1)
|
||||
/** \brief Enable/disable a hook function that is called upon detection of an error. */
|
||||
/** \brief Enable/disable a hook functionthat is called upon detection of an error. */
|
||||
#define BOOT_FILE_ERROR_HOOK_ENABLE (1)
|
||||
/** \brief Enable/disable a hook function that is called at the start of the update. */
|
||||
#define BOOT_FILE_STARTED_HOOK_ENABLE (1)
|
||||
|
@ -133,7 +146,7 @@
|
|||
/** \brief Enable/disable the backdoor override hook functions. */
|
||||
#define BOOT_BACKDOOR_HOOKS_ENABLE (0)
|
||||
|
||||
|
||||
|
||||
/****************************************************************************************
|
||||
* N O N - V O L A T I L E M E M O R Y D R I V E R C O N F I G U R A T I O N
|
||||
****************************************************************************************/
|
||||
|
|
|
@ -42,6 +42,66 @@
|
|||
#include "inc/hw_types.h"
|
||||
#include "driverlib/uartlib.h"
|
||||
#endif
|
||||
#include "inc/hw_memmap.h"
|
||||
#include "inc/hw_types.h"
|
||||
#include "driverlib/sysctl.h"
|
||||
#include "driverlib/gpio.h"
|
||||
|
||||
|
||||
/****************************************************************************************
|
||||
* U S B C O M M U N I C A T I O N I N T E R F A C E H O O K F U N C T I O N S
|
||||
****************************************************************************************/
|
||||
|
||||
#if (BOOT_COM_USB_ENABLE > 0)
|
||||
/************************************************************************************//**
|
||||
** \brief Callback that gets called whenever the USB device should be connected
|
||||
** to the USB bus.
|
||||
** \param connect BLT_TRUE to connect and BLT_FALSE to disconnect.
|
||||
** \return none.
|
||||
**
|
||||
****************************************************************************************/
|
||||
void UsbConnectHook(blt_bool connect)
|
||||
{
|
||||
/* the connection to the USB bus is typically controlled by software through a digital
|
||||
* output. the GPIO pin for this must be configured as such. the DK-TM4C123G does not
|
||||
* have a digital output for this feature, so nothing to do here.
|
||||
*/
|
||||
|
||||
/* determine if the USB should be connected or disconnected */
|
||||
if (connect == BLT_TRUE)
|
||||
{
|
||||
/* enable connection to the USB bus */
|
||||
}
|
||||
else
|
||||
{
|
||||
/* disable connection to the USB bus */
|
||||
}
|
||||
} /*** end of UsbConnect ***/
|
||||
|
||||
|
||||
/************************************************************************************//**
|
||||
** \brief Callback that gets called whenever the USB host requests the device
|
||||
** to enter a low power mode.
|
||||
** \return none.
|
||||
**
|
||||
****************************************************************************************/
|
||||
void UsbEnterLowPowerModeHook(void)
|
||||
{
|
||||
/* support to enter a low power mode can be implemented here */
|
||||
} /*** end of UsbEnterLowPowerMode ***/
|
||||
|
||||
|
||||
/************************************************************************************//**
|
||||
** \brief Callback that gets called whenever the USB host requests the device to
|
||||
** exit low power mode.
|
||||
** \return none.
|
||||
**
|
||||
****************************************************************************************/
|
||||
void UsbLeaveLowPowerModeHook(void)
|
||||
{
|
||||
/* support to leave a low power mode can be implemented here */
|
||||
} /*** end of UsbLeaveLowPowerMode ***/
|
||||
#endif /* BOOT_COM_USB_ENABLE > 0 */
|
||||
|
||||
|
||||
/****************************************************************************************
|
||||
|
@ -66,8 +126,8 @@ void BackDoorInitHook(void)
|
|||
****************************************************************************************/
|
||||
blt_bool BackDoorEntryHook(void)
|
||||
{
|
||||
/* default implementation always activates the bootloader after a reset */
|
||||
return BLT_TRUE;
|
||||
/* no backdoor entry requested */
|
||||
return BLT_FALSE;
|
||||
} /*** end of BackDoorEntryHook ***/
|
||||
#endif /* BOOT_BACKDOOR_HOOKS_ENABLE > 0 */
|
||||
|
||||
|
@ -88,6 +148,12 @@ blt_bool BackDoorEntryHook(void)
|
|||
****************************************************************************************/
|
||||
blt_bool CpuUserProgramStartHook(void)
|
||||
{
|
||||
/* bootloader should remain active when SELECT button is pressed */
|
||||
if (GPIOPinRead(GPIO_PORTM_BASE, GPIO_PIN_4) == 0)
|
||||
{
|
||||
/* keep bootloader active */
|
||||
return BLT_FALSE;
|
||||
}
|
||||
/* okay to start the user program */
|
||||
return BLT_TRUE;
|
||||
} /*** end of CpuUserProgramStartHook ***/
|
||||
|
|
|
@ -83,14 +83,14 @@
|
|||
|
||||
|
||||
|
||||
<Pane><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\..\main.c</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>52</YPos2><SelStart2>3081</SelStart2><SelEnd2>3081</SelEnd2></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\..\..\..\..\Source\ARMCM4_TM4C\flash.c</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>552</YPos2><SelStart2>26708</SelStart2><SelEnd2>26708</SelEnd2></Tab><ActiveTab>1</ActiveTab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\..\blt_conf.h</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>48</YPos2><SelStart2>4103</SelStart2><SelEnd2>4103</SelEnd2></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\..\..\..\..\Source\ARMCM4_TM4C\IAR\vectors.c</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>42</YPos2><SelStart2>2414</SelStart2><SelEnd2>2414</SelEnd2></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\..\..\..\..\Source\xcp.c</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>1219</YPos2><SelStart2>43432</SelStart2><SelEnd2>43439</SelEnd2></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\..\..\..\..\Source\ARMCM4_TM4C\uart.c</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>111</YPos2><SelStart2>6242</SelStart2><SelEnd2>6242</SelEnd2></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\..\..\..\..\Source\assert.c</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>17</YPos2><SelStart2>3091</SelStart2><SelEnd2>3091</SelEnd2></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\..\..\..\..\Source\backdoor.c</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>116</YPos2><SelStart2>6882</SelStart2><SelEnd2>6882</SelEnd2></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\..\..\..\..\Source\com.c</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>143</YPos2><SelStart2>7570</SelStart2><SelEnd2>7570</SelEnd2></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\..\..\..\..\Source\ARMCM4_TM4C\nvm.c</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>174</YPos2><SelStart2>8038</SelStart2><SelEnd2>8038</SelEnd2></Tab></Pane><ActivePane>0</ActivePane><Sizes><Pane><X>1000000</X><Y>1000000</Y></Pane></Sizes><SplitMode>1</SplitMode></Editor>
|
||||
<Pane><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\..\blt_conf.h</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>112</YPos2><SelStart2>8821</SelStart2><SelEnd2>8821</SelEnd2></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\..\main.c</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>42</YPos2><SelStart2>3081</SelStart2><SelEnd2>3081</SelEnd2></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\..\..\..\..\Source\ARMCM4_TM4C\usb.h</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>0</YPos2><SelStart2>0</SelStart2><SelEnd2>0</SelEnd2></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\..\..\..\..\Source\ARMCM4_TM4C\usb.c</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>228</YPos2><SelStart2>10720</SelStart2><SelEnd2>10720</SelEnd2></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\..\..\..\..\Source\ARMCM4_TM4C\IAR\vectors.c</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>0</YPos2><SelStart2>2348</SelStart2><SelEnd2>2348</SelEnd2></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\..\..\..\..\Source\ARMCM4_TM4C\cpu.c</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>63</YPos2><SelStart2>4211</SelStart2><SelEnd2>4211</SelEnd2></Tab><ActiveTab>5</ActiveTab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\..\..\..\..\Source\ARMCM4_TM4C\flash.c</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>0</YPos2><SelStart2>202</SelStart2><SelEnd2>202</SelEnd2></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\..\lib\usblib\device\usbdhandler.c</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>29</YPos2><SelStart2>2622</SelStart2><SelEnd2>2622</SelEnd2></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\..\lib\usblib\usbbuffer.c</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>686</YPos2><SelStart2>25604</SelStart2><SelEnd2>25612</SelEnd2></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\..\..\..\..\Source\xcp.c</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>1291</YPos2><SelStart2>45892</SelStart2><SelEnd2>45900</SelEnd2></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\..\lib\usblib\device\usbdenum.c</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>2778</YPos2><SelStart2>93171</SelStart2><SelEnd2>93171</SelEnd2></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\..\hooks.c</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>129</YPos2><SelStart2>6239</SelStart2><SelEnd2>6239</SelEnd2></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\..\..\..\..\Source\ARMCM4_TM4C\uart.c</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>0</YPos2><SelStart2>2182</SelStart2><SelEnd2>2300</SelEnd2></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\..\lib\driverlib\gpio.c</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>836</YPos2><SelStart2>32449</SelStart2><SelEnd2>32449</SelEnd2></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\..\..\..\..\Source\backdoor.c</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>85</YPos2><SelStart2>4619</SelStart2><SelEnd2>4619</SelEnd2></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\..\..\..\..\Source\ARMCM4_TM4C\IAR\cstart.s</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>12</YPos2><SelStart2>2448</SelStart2><SelEnd2>2461</SelEnd2></Tab></Pane><ActivePane>0</ActivePane><Sizes><Pane><X>1000000</X><Y>1000000</Y></Pane></Sizes><SplitMode>1</SplitMode></Editor>
|
||||
<Positions>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<Top><Row0><Sizes><Toolbar-02a5fc58><key>iaridepm.enu1</key></Toolbar-02a5fc58></Sizes></Row0><Row1><Sizes><Toolbar-034788b0><key>debuggergui.enu1</key></Toolbar-034788b0></Sizes></Row1></Top><Left><Row0><Sizes><Wnd1><Rect><Top>-2</Top><Left>-2</Left><Bottom>741</Bottom><Right>341</Right><x>-2</x><y>-2</y><xscreen>200</xscreen><yscreen>200</yscreen><sizeHorzCX>104167</sizeHorzCX><sizeHorzCY>198413</sizeHorzCY><sizeVertCX>178646</sizeVertCX><sizeVertCY>737103</sizeVertCY></Rect></Wnd1></Sizes></Row0></Left><Right><Row0><Sizes><Wnd2><Rect><Top>-2</Top><Left>-2</Left><Bottom>741</Bottom><Right>198</Right><x>-2</x><y>-2</y><xscreen>200</xscreen><yscreen>200</yscreen><sizeHorzCX>104167</sizeHorzCX><sizeHorzCY>198413</sizeHorzCY><sizeVertCX>104167</sizeVertCX><sizeVertCY>737103</sizeVertCY></Rect></Wnd2></Sizes></Row0></Right><Bottom><Row0><Sizes><Wnd0><Rect><Top>-2</Top><Left>-2</Left><Bottom>198</Bottom><Right>1922</Right><x>-2</x><y>-2</y><xscreen>1924</xscreen><yscreen>200</yscreen><sizeHorzCX>1002083</sizeHorzCX><sizeHorzCY>198413</sizeHorzCY><sizeVertCX>104167</sizeVertCX><sizeVertCY>198413</sizeVertCY></Rect></Wnd0></Sizes></Row0></Bottom><Float><Sizes/></Float></Positions>
|
||||
<Top><Row0><Sizes><Toolbar-02acef28><key>iaridepm.enu1</key></Toolbar-02acef28></Sizes></Row0><Row1><Sizes><Toolbar-035cf898><key>debuggergui.enu1</key></Toolbar-035cf898></Sizes></Row1><Row2><Sizes/></Row2></Top><Left><Row0><Sizes><Wnd1><Rect><Top>-2</Top><Left>-2</Left><Bottom>741</Bottom><Right>341</Right><x>-2</x><y>-2</y><xscreen>200</xscreen><yscreen>200</yscreen><sizeHorzCX>104167</sizeHorzCX><sizeHorzCY>198413</sizeHorzCY><sizeVertCX>178646</sizeVertCX><sizeVertCY>737103</sizeVertCY></Rect></Wnd1></Sizes></Row0></Left><Right><Row0><Sizes><Wnd2><Rect><Top>-2</Top><Left>-2</Left><Bottom>741</Bottom><Right>198</Right><x>-2</x><y>-2</y><xscreen>200</xscreen><yscreen>200</yscreen><sizeHorzCX>104167</sizeHorzCX><sizeHorzCY>198413</sizeHorzCY><sizeVertCX>104167</sizeVertCX><sizeVertCY>737103</sizeVertCY></Rect></Wnd2></Sizes></Row0></Right><Bottom><Row0><Sizes><Wnd0><Rect><Top>-2</Top><Left>-2</Left><Bottom>198</Bottom><Right>1922</Right><x>-2</x><y>-2</y><xscreen>1924</xscreen><yscreen>200</yscreen><sizeHorzCX>1002083</sizeHorzCX><sizeHorzCY>198413</sizeHorzCY><sizeVertCX>104167</sizeVertCX><sizeVertCY>198413</sizeVertCY></Rect></Wnd0></Sizes></Row0></Bottom><Float><Sizes/></Float></Positions>
|
||||
</Desktop>
|
||||
</Project>
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ ShowSource=1
|
|||
[LMIFTDIDriver]
|
||||
LMI_ResetMode=0x00000000
|
||||
[DebugChecksum]
|
||||
Checksum=-743962560
|
||||
Checksum=-1346733608
|
||||
[Exceptions]
|
||||
StopOnUncaught=_ 0
|
||||
StopOnThrow=_ 0
|
||||
|
|
|
@ -12,9 +12,9 @@
|
|||
|
||||
|
||||
|
||||
<Column0>327</Column0><Column1>27</Column1><Column2>27</Column2><Column3>27</Column3></ColumnWidths>
|
||||
<Column0>329</Column0><Column1>27</Column1><Column2>27</Column2><Column3>27</Column3></ColumnWidths>
|
||||
</Workspace>
|
||||
<Build><ColumnWidth0>20</ColumnWidth0><ColumnWidth1>1395</ColumnWidth1><ColumnWidth2>372</ColumnWidth2><ColumnWidth3>93</ColumnWidth3></Build><Find-All-Declarations><ColumnWidth0>142</ColumnWidth0><ColumnWidth1>20</ColumnWidth1><ColumnWidth2>243</ColumnWidth2></Find-All-Declarations><TerminalIO/><Debug-Log><ColumnWidth0>18</ColumnWidth0><ColumnWidth1>371</ColumnWidth1></Debug-Log></Static>
|
||||
<Build><ColumnWidth0>20</ColumnWidth0><ColumnWidth1>1395</ColumnWidth1><ColumnWidth2>372</ColumnWidth2><ColumnWidth3>93</ColumnWidth3></Build><Find-All-Declarations><ColumnWidth0>142</ColumnWidth0><ColumnWidth1>20</ColumnWidth1><ColumnWidth2>243</ColumnWidth2></Find-All-Declarations><TerminalIO/><Debug-Log><ColumnWidth0>18</ColumnWidth0><ColumnWidth1>371</ColumnWidth1></Debug-Log><Find-in-Files><ColumnWidth0>136</ColumnWidth0><ColumnWidth1>19</ColumnWidth1><ColumnWidth2>234</ColumnWidth2></Find-in-Files><PROJECT_GUI_CALL_GRAPH><PreferedWindows><Position>3</Position><ScreenPosX>0</ScreenPosX><ScreenPosY>0</ScreenPosY><Windows/></PreferedWindows><col-names><item>File</item><item>Function</item><item>Line</item></col-names><col-widths><item>200</item><item>700</item><item>100</item></col-widths></PROJECT_GUI_CALL_GRAPH><Select-Ambiguous-Definitions><ColumnWidth0>136</ColumnWidth0><ColumnWidth1>19</ColumnWidth1><ColumnWidth2>234</ColumnWidth2></Select-Ambiguous-Definitions></Static>
|
||||
<Windows>
|
||||
|
||||
<Wnd2>
|
||||
|
@ -25,24 +25,24 @@
|
|||
<Factory>Workspace</Factory>
|
||||
<Session>
|
||||
|
||||
<NodeDict><ExpandedNode>tm4c123g</ExpandedNode><ExpandedNode>tm4c123g/Boot</ExpandedNode><ExpandedNode>tm4c123g/Boot/lib</ExpandedNode><ExpandedNode>tm4c123g/Boot/lib/fatfs</ExpandedNode><ExpandedNode>tm4c123g/Libraries</ExpandedNode><ExpandedNode>tm4c123g/Output</ExpandedNode><ExpandedNode>tm4c123g/Source</ExpandedNode></NodeDict></Session>
|
||||
<NodeDict><ExpandedNode>tm4c123g</ExpandedNode><ExpandedNode>tm4c123g/Boot</ExpandedNode><ExpandedNode>tm4c123g/Libraries</ExpandedNode><ExpandedNode>tm4c123g/Output</ExpandedNode><ExpandedNode>tm4c123g/Source</ExpandedNode></NodeDict></Session>
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
<SelectedTab>0</SelectedTab></Wnd2><Wnd3><Tabs><Tab><Identity>TabID-11003-23003</Identity><TabName>Build</TabName><Factory>Build</Factory><Session/></Tab><Tab><Identity>TabID-13665-29690</Identity><TabName>Find All Declarations</TabName><Factory>Find-All-Declarations</Factory><Session/></Tab><Tab><Identity>TabID-2562-1429</Identity><TabName>Debug Log</TabName><Factory>Debug-Log</Factory><Session/></Tab></Tabs><SelectedTab>0</SelectedTab></Wnd3></Windows>
|
||||
<SelectedTab>0</SelectedTab></Wnd2><Wnd3><Tabs><Tab><Identity>TabID-11003-23003</Identity><TabName>Build</TabName><Factory>Build</Factory><Session/></Tab><Tab><Identity>TabID-13665-29690</Identity><TabName>Find All Declarations</TabName><Factory>Find-All-Declarations</Factory><Session/></Tab><Tab><Identity>TabID-2562-1429</Identity><TabName>Debug Log</TabName><Factory>Debug-Log</Factory><Session/></Tab><Tab><Identity>TabID-23273-22207</Identity><TabName>Find in Files</TabName><Factory>Find-in-Files</Factory><Session/></Tab><Tab><Identity>TabID-14368-8233</Identity><TabName>Ambiguous Definitions</TabName><Factory>Select-Ambiguous-Definitions</Factory><Session/></Tab></Tabs><SelectedTab>3</SelectedTab></Wnd3></Windows>
|
||||
<Editor>
|
||||
|
||||
|
||||
|
||||
|
||||
<Pane><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\..\main.c</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>52</YPos2><SelStart2>3130</SelStart2><SelEnd2>3130</SelEnd2></Tab><ActiveTab>0</ActiveTab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\..\..\..\..\Source\ARMCM4_TM4C\flash.c</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>87</YPos2><SelStart2>2281</SelStart2><SelEnd2>2281</SelEnd2></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\..\blt_conf.h</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>96</YPos2><SelStart2>7138</SelStart2><SelEnd2>7138</SelEnd2></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\..\..\..\..\Source\ARMCM4_TM4C\IAR\vectors.c</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>42</YPos2><SelStart2>2414</SelStart2><SelEnd2>2414</SelEnd2></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\..\..\..\..\Source\xcp.c</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>1219</YPos2><SelStart2>43432</SelStart2><SelEnd2>43439</SelEnd2></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\..\..\..\..\Source\ARMCM4_TM4C\uart.c</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>111</YPos2><SelStart2>6242</SelStart2><SelEnd2>6242</SelEnd2></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\..\..\..\..\Source\assert.c</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>17</YPos2><SelStart2>3091</SelStart2><SelEnd2>3091</SelEnd2></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\..\..\..\..\Source\backdoor.c</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>116</YPos2><SelStart2>6882</SelStart2><SelEnd2>6882</SelEnd2></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\..\..\..\..\Source\com.c</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>143</YPos2><SelStart2>7570</SelStart2><SelEnd2>7570</SelEnd2></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\..\..\..\..\Source\ARMCM4_TM4C\nvm.c</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>160</YPos2><SelStart2>8038</SelStart2><SelEnd2>8038</SelEnd2></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\..\lib\fatfs\mmc.c</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>164</YPos2><SelStart2>6505</SelStart2><SelEnd2>6505</SelEnd2></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\..\hooks.c</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>231</YPos2><SelStart2>10763</SelStart2><SelEnd2>10763</SelEnd2></Tab></Pane><ActivePane>0</ActivePane><Sizes><Pane><X>1000000</X><Y>1000000</Y></Pane></Sizes><SplitMode>1</SplitMode></Editor>
|
||||
<Pane><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\..\blt_conf.h</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>78</YPos2><SelStart2>5494</SelStart2><SelEnd2>5494</SelEnd2></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\..\main.c</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>63</YPos2><SelStart2>5358</SelStart2><SelEnd2>5358</SelEnd2></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\..\..\..\..\Source\ARMCM4_TM4C\usb.h</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>0</YPos2><SelStart2>0</SelStart2><SelEnd2>0</SelEnd2></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\..\..\..\..\Source\ARMCM4_TM4C\usb.c</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>117</YPos2><SelStart2>7202</SelStart2><SelEnd2>7202</SelEnd2></Tab><ActiveTab>3</ActiveTab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\..\hooks.c</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>108</YPos2><SelStart2>5729</SelStart2><SelEnd2>5729</SelEnd2></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\..\lib\usblib\device\usbdbulk.c</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>991</YPos2><SelStart2>34592</SelStart2><SelEnd2>34618</SelEnd2></Tab></Pane><ActivePane>0</ActivePane><Sizes><Pane><X>1000000</X><Y>1000000</Y></Pane></Sizes><SplitMode>1</SplitMode></Editor>
|
||||
<Positions>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<Top><Row0><Sizes><Toolbar-029cfc58><key>iaridepm.enu1</key></Toolbar-029cfc58></Sizes></Row0></Top><Left><Row0><Sizes><Wnd2><Rect><Top>-2</Top><Left>-2</Left><Bottom>579</Bottom><Right>418</Right><x>-2</x><y>-2</y><xscreen>200</xscreen><yscreen>200</yscreen><sizeHorzCX>104167</sizeHorzCX><sizeHorzCY>198413</sizeHorzCY><sizeVertCX>218750</sizeVertCX><sizeVertCY>576389</sizeVertCY></Rect></Wnd2><Wnd3><Rect><Top>0</Top><Left>0</Left><Bottom>6881384</Bottom><Right>7536751</Right><x>-2</x><y>577</y><xscreen>1924</xscreen><yscreen>200</yscreen><sizeHorzCX>1002083</sizeHorzCX><sizeHorzCY>198413</sizeHorzCY><sizeVertCX>218750</sizeVertCX><sizeVertCY>382937</sizeVertCY></Rect></Wnd3></Sizes></Row0></Left><Right><Row0><Sizes/></Row0></Right><Bottom><Row0><Sizes/></Row0></Bottom><Float><Sizes/></Float></Positions>
|
||||
<Top><Row0><Sizes><Toolbar-02acef28><key>iaridepm.enu1</key></Toolbar-02acef28></Sizes></Row0><Row1><Sizes/></Row1><Row2><Sizes/></Row2></Top><Left><Row0><Sizes><Wnd2><Rect><Top>-2</Top><Left>-2</Left><Bottom>579</Bottom><Right>403</Right><x>-2</x><y>-2</y><xscreen>200</xscreen><yscreen>200</yscreen><sizeHorzCX>104167</sizeHorzCX><sizeHorzCY>198413</sizeHorzCY><sizeVertCX>210938</sizeVertCX><sizeVertCY>576389</sizeVertCY></Rect></Wnd2><Wnd3><Rect><Top>0</Top><Left>0</Left><Bottom>0</Bottom><Right>7</Right><x>-2</x><y>577</y><xscreen>1924</xscreen><yscreen>200</yscreen><sizeHorzCX>1002083</sizeHorzCX><sizeHorzCY>198413</sizeHorzCY><sizeVertCX>210938</sizeVertCX><sizeVertCY>382937</sizeVertCY></Rect></Wnd3></Sizes></Row0></Left><Right><Row0><Sizes/></Row0></Right><Bottom><Row0><Sizes/></Row0></Bottom><Float><Sizes/></Float></Positions>
|
||||
</Desktop>
|
||||
</Workspace>
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -297,13 +297,17 @@
|
|||
<name>CCIncludePath2</name>
|
||||
<state>$PROJ_DIR$\..\..\..\..\Source</state>
|
||||
<state>$PROJ_DIR$\..\..\..\..\Source\third_party\fatfs\src</state>
|
||||
<state>$PROJ_DIR$\..\..\..\..\Source\ARMCM3_LM3S</state>
|
||||
<state>$PROJ_DIR$\..\..\..\..\Source\ARMCM3_LM3S\IAR</state>
|
||||
<state>$PROJ_DIR$\..\..\..\..\Source\ARMCM4_TM4C</state>
|
||||
<state>$PROJ_DIR$\..\..\..\..\Source\ARMCM4_TM4C\IAR</state>
|
||||
<state>$PROJ_DIR$\..</state>
|
||||
<state>$PROJ_DIR$\..\lib</state>
|
||||
<state>$PROJ_DIR$\..\lib\inc</state>
|
||||
<state>$PROJ_DIR$\..\lib\driverlib</state>
|
||||
<state>$PROJ_DIR$\..\lib\fatfs</state>
|
||||
<state>$PROJ_DIR$\..\lib\usblib</state>
|
||||
<state>$PROJ_DIR$\..\lib\usblib\config</state>
|
||||
<state>$PROJ_DIR$\..\lib\usblib\device</state>
|
||||
<state>$PROJ_DIR$\..\lib\usblib\host</state>
|
||||
</option>
|
||||
<option>
|
||||
<name>CCStdIncCheck</name>
|
||||
|
@ -1084,10 +1088,10 @@
|
|||
<name>$PROJ_DIR$\..\lib\driverlib\udma.h</name>
|
||||
</file>
|
||||
<file>
|
||||
<name>$PROJ_DIR$\..\lib\driverlib\usb.c</name>
|
||||
<name>$PROJ_DIR$\..\lib\driverlib\usbdrv.c</name>
|
||||
</file>
|
||||
<file>
|
||||
<name>$PROJ_DIR$\..\lib\driverlib\usb.h</name>
|
||||
<name>$PROJ_DIR$\..\lib\driverlib\usbdrv.h</name>
|
||||
</file>
|
||||
<file>
|
||||
<name>$PROJ_DIR$\..\lib\driverlib\watchdog.c</name>
|
||||
|
@ -1189,6 +1193,192 @@
|
|||
<name>$PROJ_DIR$\..\lib\inc\tm4c123gh6pge.h</name>
|
||||
</file>
|
||||
</group>
|
||||
<group>
|
||||
<name>usblib</name>
|
||||
<group>
|
||||
<name>config</name>
|
||||
<file>
|
||||
<name>$PROJ_DIR$\..\lib\usblib\config\usb_bulk_structs.c</name>
|
||||
</file>
|
||||
<file>
|
||||
<name>$PROJ_DIR$\..\lib\usblib\config\usb_bulk_structs.h</name>
|
||||
</file>
|
||||
</group>
|
||||
<group>
|
||||
<name>device</name>
|
||||
<file>
|
||||
<name>$PROJ_DIR$\..\lib\usblib\device\usbdaudio.c</name>
|
||||
</file>
|
||||
<file>
|
||||
<name>$PROJ_DIR$\..\lib\usblib\device\usbdaudio.h</name>
|
||||
</file>
|
||||
<file>
|
||||
<name>$PROJ_DIR$\..\lib\usblib\device\usbdbulk.c</name>
|
||||
</file>
|
||||
<file>
|
||||
<name>$PROJ_DIR$\..\lib\usblib\device\usbdbulk.h</name>
|
||||
</file>
|
||||
<file>
|
||||
<name>$PROJ_DIR$\..\lib\usblib\device\usbdcdc.c</name>
|
||||
</file>
|
||||
<file>
|
||||
<name>$PROJ_DIR$\..\lib\usblib\device\usbdcdc.h</name>
|
||||
</file>
|
||||
<file>
|
||||
<name>$PROJ_DIR$\..\lib\usblib\device\usbdcdesc.c</name>
|
||||
</file>
|
||||
<file>
|
||||
<name>$PROJ_DIR$\..\lib\usblib\device\usbdcomp.c</name>
|
||||
</file>
|
||||
<file>
|
||||
<name>$PROJ_DIR$\..\lib\usblib\device\usbdcomp.h</name>
|
||||
</file>
|
||||
<file>
|
||||
<name>$PROJ_DIR$\..\lib\usblib\device\usbdconfig.c</name>
|
||||
</file>
|
||||
<file>
|
||||
<name>$PROJ_DIR$\..\lib\usblib\device\usbddfu-rt.c</name>
|
||||
</file>
|
||||
<file>
|
||||
<name>$PROJ_DIR$\..\lib\usblib\device\usbddfu-rt.h</name>
|
||||
</file>
|
||||
<file>
|
||||
<name>$PROJ_DIR$\..\lib\usblib\device\usbdenum.c</name>
|
||||
</file>
|
||||
<file>
|
||||
<name>$PROJ_DIR$\..\lib\usblib\device\usbdevice.h</name>
|
||||
</file>
|
||||
<file>
|
||||
<name>$PROJ_DIR$\..\lib\usblib\device\usbdevicepriv.h</name>
|
||||
</file>
|
||||
<file>
|
||||
<name>$PROJ_DIR$\..\lib\usblib\device\usbdhandler.c</name>
|
||||
</file>
|
||||
<file>
|
||||
<name>$PROJ_DIR$\..\lib\usblib\device\usbdhid.c</name>
|
||||
</file>
|
||||
<file>
|
||||
<name>$PROJ_DIR$\..\lib\usblib\device\usbdhid.h</name>
|
||||
</file>
|
||||
<file>
|
||||
<name>$PROJ_DIR$\..\lib\usblib\device\usbdhidkeyb.c</name>
|
||||
</file>
|
||||
<file>
|
||||
<name>$PROJ_DIR$\..\lib\usblib\device\usbdhidkeyb.h</name>
|
||||
</file>
|
||||
<file>
|
||||
<name>$PROJ_DIR$\..\lib\usblib\device\usbdhidmouse.c</name>
|
||||
</file>
|
||||
<file>
|
||||
<name>$PROJ_DIR$\..\lib\usblib\device\usbdhidmouse.h</name>
|
||||
</file>
|
||||
<file>
|
||||
<name>$PROJ_DIR$\..\lib\usblib\device\usbdmsc.c</name>
|
||||
</file>
|
||||
<file>
|
||||
<name>$PROJ_DIR$\..\lib\usblib\device\usbdmsc.h</name>
|
||||
</file>
|
||||
</group>
|
||||
<group>
|
||||
<name>host</name>
|
||||
<file>
|
||||
<name>$PROJ_DIR$\..\lib\usblib\host\usbhaudio.c</name>
|
||||
</file>
|
||||
<file>
|
||||
<name>$PROJ_DIR$\..\lib\usblib\host\usbhaudio.h</name>
|
||||
</file>
|
||||
<file>
|
||||
<name>$PROJ_DIR$\..\lib\usblib\host\usbhhid.c</name>
|
||||
</file>
|
||||
<file>
|
||||
<name>$PROJ_DIR$\..\lib\usblib\host\usbhhid.h</name>
|
||||
</file>
|
||||
<file>
|
||||
<name>$PROJ_DIR$\..\lib\usblib\host\usbhhidkeyboard.c</name>
|
||||
</file>
|
||||
<file>
|
||||
<name>$PROJ_DIR$\..\lib\usblib\host\usbhhidkeyboard.h</name>
|
||||
</file>
|
||||
<file>
|
||||
<name>$PROJ_DIR$\..\lib\usblib\host\usbhhidmouse.c</name>
|
||||
</file>
|
||||
<file>
|
||||
<name>$PROJ_DIR$\..\lib\usblib\host\usbhhidmouse.h</name>
|
||||
</file>
|
||||
<file>
|
||||
<name>$PROJ_DIR$\..\lib\usblib\host\usbhhub.c</name>
|
||||
</file>
|
||||
<file>
|
||||
<name>$PROJ_DIR$\..\lib\usblib\host\usbhhub.h</name>
|
||||
</file>
|
||||
<file>
|
||||
<name>$PROJ_DIR$\..\lib\usblib\host\usbhmsc.c</name>
|
||||
</file>
|
||||
<file>
|
||||
<name>$PROJ_DIR$\..\lib\usblib\host\usbhmsc.h</name>
|
||||
</file>
|
||||
<file>
|
||||
<name>$PROJ_DIR$\..\lib\usblib\host\usbhost.h</name>
|
||||
</file>
|
||||
<file>
|
||||
<name>$PROJ_DIR$\..\lib\usblib\host\usbhostenum.c</name>
|
||||
</file>
|
||||
<file>
|
||||
<name>$PROJ_DIR$\..\lib\usblib\host\usbhostpriv.h</name>
|
||||
</file>
|
||||
<file>
|
||||
<name>$PROJ_DIR$\..\lib\usblib\host\usbhscsi.c</name>
|
||||
</file>
|
||||
<file>
|
||||
<name>$PROJ_DIR$\..\lib\usblib\host\usbhscsi.h</name>
|
||||
</file>
|
||||
</group>
|
||||
<file>
|
||||
<name>$PROJ_DIR$\..\lib\usblib\usb-ids.h</name>
|
||||
</file>
|
||||
<file>
|
||||
<name>$PROJ_DIR$\..\lib\usblib\usbaudio.h</name>
|
||||
</file>
|
||||
<file>
|
||||
<name>$PROJ_DIR$\..\lib\usblib\usbbuffer.c</name>
|
||||
</file>
|
||||
<file>
|
||||
<name>$PROJ_DIR$\..\lib\usblib\usbcdc.h</name>
|
||||
</file>
|
||||
<file>
|
||||
<name>$PROJ_DIR$\..\lib\usblib\usbdesc.c</name>
|
||||
</file>
|
||||
<file>
|
||||
<name>$PROJ_DIR$\..\lib\usblib\usbdfu.h</name>
|
||||
</file>
|
||||
<file>
|
||||
<name>$PROJ_DIR$\..\lib\usblib\usbdma.c</name>
|
||||
</file>
|
||||
<file>
|
||||
<name>$PROJ_DIR$\..\lib\usblib\usbhid.h</name>
|
||||
</file>
|
||||
<file>
|
||||
<name>$PROJ_DIR$\..\lib\usblib\usbkeyboardmap.c</name>
|
||||
</file>
|
||||
<file>
|
||||
<name>$PROJ_DIR$\..\lib\usblib\usblib.h</name>
|
||||
</file>
|
||||
<file>
|
||||
<name>$PROJ_DIR$\..\lib\usblib\usblibpriv.h</name>
|
||||
</file>
|
||||
<file>
|
||||
<name>$PROJ_DIR$\..\lib\usblib\usbmode.c</name>
|
||||
</file>
|
||||
<file>
|
||||
<name>$PROJ_DIR$\..\lib\usblib\usbmsc.h</name>
|
||||
</file>
|
||||
<file>
|
||||
<name>$PROJ_DIR$\..\lib\usblib\usbringbuf.c</name>
|
||||
</file>
|
||||
<file>
|
||||
<name>$PROJ_DIR$\..\lib\usblib\usbtick.c</name>
|
||||
</file>
|
||||
</group>
|
||||
</group>
|
||||
<file>
|
||||
<name>$PROJ_DIR$\..\blt_conf.h</name>
|
||||
|
@ -1246,6 +1436,12 @@
|
|||
<file>
|
||||
<name>$PROJ_DIR$\..\..\..\..\Source\ARMCM4_TM4C\uart.h</name>
|
||||
</file>
|
||||
<file>
|
||||
<name>$PROJ_DIR$\..\..\..\..\Source\ARMCM4_TM4C\usb.c</name>
|
||||
</file>
|
||||
<file>
|
||||
<name>$PROJ_DIR$\..\..\..\..\Source\ARMCM4_TM4C\usb.h</name>
|
||||
</file>
|
||||
</group>
|
||||
<group>
|
||||
<name>third_party</name>
|
||||
|
|
|
@ -55,7 +55,7 @@
|
|||
#include "driverlib/interrupt.h"
|
||||
#include "driverlib/sysctl.h"
|
||||
#include "driverlib/udma.h"
|
||||
#include "driverlib/usb.h"
|
||||
#include "driverlib/usbdrv.h"
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
|
@ -0,0 +1,200 @@
|
|||
//*****************************************************************************
|
||||
//
|
||||
// usb_bulk_structs.c - Data structures defining this bulk USB device.
|
||||
//
|
||||
// Copyright (c) 2008-2013 Texas Instruments Incorporated. All rights reserved.
|
||||
// Software License Agreement
|
||||
//
|
||||
// Texas Instruments (TI) is supplying this software for use solely and
|
||||
// exclusively on TI's microcontroller products. The software is owned by
|
||||
// TI and/or its suppliers, and is protected under applicable copyright
|
||||
// laws. You may not combine this software with "viral" open-source
|
||||
// software in order to form a larger program.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
|
||||
// NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
|
||||
// NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
|
||||
// CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
|
||||
// DAMAGES, FOR ANY REASON WHATSOEVER.
|
||||
//
|
||||
// This is part of revision 1.1 of the DK-TM4C123G Firmware Package.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "inc/hw_types.h"
|
||||
#include "driverlib/usbdrv.h"
|
||||
#include "usblib/usblib.h"
|
||||
#include "usblib/usb-ids.h"
|
||||
#include "usblib/device/usbdevice.h"
|
||||
#include "usblib/device/usbdbulk.h"
|
||||
#include "usb_bulk_structs.h"
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// The languages supported by this device.
|
||||
//
|
||||
//*****************************************************************************
|
||||
const uint8_t g_pui8LangDescriptor[] =
|
||||
{
|
||||
4,
|
||||
USB_DTYPE_STRING,
|
||||
USBShort(USB_LANG_EN_US)
|
||||
};
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// The manufacturer string.
|
||||
//
|
||||
//*****************************************************************************
|
||||
const uint8_t g_pui8ManufacturerString[] =
|
||||
{
|
||||
(12 + 1) * 2,
|
||||
USB_DTYPE_STRING,
|
||||
'O', 0, 'p', 0, 'e', 0, 'n', 0, 'B', 0, 'L', 0, 'T', 0,
|
||||
' ', 0, 'U', 0, 's', 0, 'e', 0, 'r', 0
|
||||
};
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// The product string.
|
||||
//
|
||||
//*****************************************************************************
|
||||
const uint8_t g_pui8ProductString[] =
|
||||
{
|
||||
(18 + 1) * 2,
|
||||
USB_DTYPE_STRING,
|
||||
'W', 0, 'i', 0, 'n', 0, 'U', 0, 'S', 0, 'B', 0, ' ', 0,
|
||||
'B', 0, 'u', 0, 'l', 0, 'k', 0, ' ', 0,
|
||||
'D', 0, 'e', 0, 'v', 0, 'i', 0, 'c', 0, 'e', 0
|
||||
};
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// The serial number string.
|
||||
//
|
||||
//*****************************************************************************
|
||||
const uint8_t g_pui8SerialNumberString[] =
|
||||
{
|
||||
(8 + 1) * 2,
|
||||
USB_DTYPE_STRING,
|
||||
'1', 0, '2', 0, '3', 0, '4', 0, '5', 0, '6', 0, '7', 0, '8', 0
|
||||
};
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// The data interface description string.
|
||||
//
|
||||
//*****************************************************************************
|
||||
const uint8_t g_pui8DataInterfaceString[] =
|
||||
{
|
||||
(21 + 1) * 2,
|
||||
USB_DTYPE_STRING,
|
||||
'W', 0, 'i', 0, 'n', 0, 'U', 0, 'S', 0, 'B', 0, ' ', 0,
|
||||
'B', 0, 'u', 0, 'l', 0, 'k', 0, ' ', 0,
|
||||
'I', 0, 'n', 0, 't', 0, 'e', 0, 'r', 0, 'f', 0, 'a', 0, 'c', 0, 'e', 0
|
||||
};
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// The configuration description string.
|
||||
//
|
||||
//*****************************************************************************
|
||||
const uint8_t g_pui8ConfigString[] =
|
||||
{
|
||||
(23 + 1) * 2,
|
||||
USB_DTYPE_STRING,
|
||||
'B', 0, 'u', 0, 'l', 0, 'k', 0, ' ', 0, 'D', 0, 'a', 0, 't', 0,
|
||||
'a', 0, ' ', 0, 'C', 0, 'o', 0, 'n', 0, 'f', 0, 'i', 0, 'g', 0,
|
||||
'u', 0, 'r', 0, 'a', 0, 't', 0, 'i', 0, 'o', 0, 'n', 0
|
||||
};
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// The descriptor string table.
|
||||
//
|
||||
//*****************************************************************************
|
||||
const uint8_t *const g_ppui8StringDescriptors[] =
|
||||
{
|
||||
g_pui8LangDescriptor,
|
||||
g_pui8ManufacturerString,
|
||||
g_pui8ProductString,
|
||||
g_pui8SerialNumberString,
|
||||
g_pui8DataInterfaceString,
|
||||
g_pui8ConfigString
|
||||
};
|
||||
|
||||
#define NUM_STRING_DESCRIPTORS (sizeof(g_ppui8StringDescriptors) / \
|
||||
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.
|
||||
//
|
||||
//*****************************************************************************
|
||||
extern const tUSBBuffer g_sTxBuffer;
|
||||
extern const tUSBBuffer g_sRxBuffer;
|
||||
|
||||
tUSBDBulkDevice g_sBulkDevice =
|
||||
{
|
||||
0x0145,
|
||||
0x0023,
|
||||
500,
|
||||
USB_CONF_ATTR_SELF_PWR,
|
||||
USBBufferEventCallback,
|
||||
(void *)&g_sRxBuffer,
|
||||
USBBufferEventCallback,
|
||||
(void *)&g_sTxBuffer,
|
||||
g_ppui8StringDescriptors,
|
||||
NUM_STRING_DESCRIPTORS
|
||||
};
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Receive buffer (from the USB perspective).
|
||||
//
|
||||
//*****************************************************************************
|
||||
uint8_t g_pui8USBRxBuffer[BULK_BUFFER_SIZE];
|
||||
uint8_t g_pui8RxBufferWorkspace[USB_BUFFER_WORKSPACE_SIZE];
|
||||
const tUSBBuffer g_sRxBuffer =
|
||||
{
|
||||
false, // This is a receive buffer.
|
||||
UsbBulkRxHandler, // pfnCallback
|
||||
(void *)&g_sBulkDevice, // Callback data is our device pointer.
|
||||
USBDBulkPacketRead, // pfnTransfer
|
||||
USBDBulkRxPacketAvailable, // pfnAvailable
|
||||
(void *)&g_sBulkDevice, // pvHandle
|
||||
g_pui8USBRxBuffer, // pi8Buffer
|
||||
BULK_BUFFER_SIZE, // ui32BufferSize
|
||||
g_pui8RxBufferWorkspace // pvWorkspace
|
||||
};
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Transmit buffer (from the USB perspective).
|
||||
//
|
||||
//*****************************************************************************
|
||||
uint8_t g_pui8USBTxBuffer[BULK_BUFFER_SIZE];
|
||||
uint8_t g_pui8TxBufferWorkspace[USB_BUFFER_WORKSPACE_SIZE];
|
||||
const tUSBBuffer g_sTxBuffer =
|
||||
{
|
||||
true, // This is a transmit buffer.
|
||||
UsbBulkTxHandler, // pfnCallback
|
||||
(void *)&g_sBulkDevice, // Callback data is our device pointer.
|
||||
USBDBulkPacketWrite, // pfnTransfer
|
||||
USBDBulkTxPacketAvailable, // pfnAvailable
|
||||
(void *)&g_sBulkDevice, // pvHandle
|
||||
g_pui8USBTxBuffer, // pi8Buffer
|
||||
BULK_BUFFER_SIZE, // ui32BufferSize
|
||||
g_pui8TxBufferWorkspace // pvWorkspace
|
||||
};
|
|
@ -0,0 +1,48 @@
|
|||
//*****************************************************************************
|
||||
//
|
||||
// usb_bulk_structs.h - Data structures defining this bulk USB device.
|
||||
//
|
||||
// Copyright (c) 2008-2013 Texas Instruments Incorporated. All rights reserved.
|
||||
// Software License Agreement
|
||||
//
|
||||
// Texas Instruments (TI) is supplying this software for use solely and
|
||||
// exclusively on TI's microcontroller products. The software is owned by
|
||||
// TI and/or its suppliers, and is protected under applicable copyright
|
||||
// laws. You may not combine this software with "viral" open-source
|
||||
// software in order to form a larger program.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
|
||||
// NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
|
||||
// NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
|
||||
// CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
|
||||
// DAMAGES, FOR ANY REASON WHATSOEVER.
|
||||
//
|
||||
// This is part of revision 1.1 of the DK-TM4C123G Firmware Package.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
#ifndef _USB_BULK_STRUCTS_H_
|
||||
#define _USB_BULK_STRUCTS_H_
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// 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 BULK_BUFFER_SIZE 64
|
||||
|
||||
extern uint32_t UsbBulkRxHandler(void *pvCBData, uint32_t ui32Event,
|
||||
uint32_t ui32MsgValue, void *pvMsgData);
|
||||
extern uint32_t UsbBulkTxHandler(void *pvi32CBData, uint32_t ui32Event,
|
||||
uint32_t ui32MsgValue, void *pvMsgData);
|
||||
|
||||
extern const tUSBBuffer g_sTxBuffer;
|
||||
extern const tUSBBuffer g_sRxBuffer;
|
||||
extern tUSBDBulkDevice g_sBulkDevice;
|
||||
extern uint8_t g_pui8USBTxBuffer[];
|
||||
extern uint8_t g_pui8USBRxBuffer[];
|
||||
|
||||
#endif
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,382 @@
|
|||
//*****************************************************************************
|
||||
//
|
||||
// usbdaudio.h - USB audio device class driver.
|
||||
//
|
||||
// Copyright (c) 2009-2013 Texas Instruments Incorporated. All rights reserved.
|
||||
// Software License Agreement
|
||||
//
|
||||
// Texas Instruments (TI) is supplying this software for use solely and
|
||||
// exclusively on TI's microcontroller products. The software is owned by
|
||||
// TI and/or its suppliers, and is protected under applicable copyright
|
||||
// laws. You may not combine this software with "viral" open-source
|
||||
// software in order to form a larger program.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
|
||||
// NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
|
||||
// NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
|
||||
// CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
|
||||
// DAMAGES, FOR ANY REASON WHATSOEVER.
|
||||
//
|
||||
// This is part of revision 1.1 of the Tiva USB Library.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
#ifndef __USBDAUDIO_H__
|
||||
#define __USBDAUDIO_H__
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// If building with a C++ compiler, make all of the definitions in this header
|
||||
// have a C binding.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! \addtogroup audio_device_class_api
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
typedef void (* tUSBAudioBufferCallback)(void *pvBuffer, uint32_t ui32Param,
|
||||
uint32_t ui32Event);
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// PRIVATE
|
||||
//
|
||||
// This structure defines the private instance data and state variables for the
|
||||
// audio device class. The memory for this structure is pointed to by
|
||||
// the pi16PrivateData field in the tUSBDAudioDevice structure passed on
|
||||
// USBDAudioInit() and should not be modified by any code outside of the audio
|
||||
// device.
|
||||
//
|
||||
//*****************************************************************************
|
||||
typedef struct
|
||||
{
|
||||
//
|
||||
// Base address for the USB controller.
|
||||
//
|
||||
uint32_t ui32USBBase;
|
||||
|
||||
//
|
||||
// The device info to interact with the lower level DCD code.
|
||||
//
|
||||
tDeviceInfo sDevInfo;
|
||||
|
||||
//
|
||||
// The maximum volume expressed as an 8.8 signed value.
|
||||
//
|
||||
int16_t i16VolumeMax;
|
||||
|
||||
//
|
||||
// The minimum volume expressed as an 8.8 signed value.
|
||||
//
|
||||
int16_t i16VolumeMin;
|
||||
|
||||
//
|
||||
// The minimum volume step expressed as an 8.8 signed value.
|
||||
//
|
||||
int16_t i16VolumeStep;
|
||||
|
||||
struct
|
||||
{
|
||||
//
|
||||
// Pointer to a buffer provided by caller.
|
||||
//
|
||||
void *pvData;
|
||||
|
||||
//
|
||||
// Size of the data area provided in pvData in bytes.
|
||||
//
|
||||
uint32_t ui32Size;
|
||||
|
||||
//
|
||||
// Number of valid bytes copied into the pvData area.
|
||||
//
|
||||
uint32_t ui32NumBytes;
|
||||
|
||||
//
|
||||
// The buffer callback for this function.
|
||||
//
|
||||
tUSBAudioBufferCallback pfnCallback;
|
||||
}
|
||||
sBuffer;
|
||||
|
||||
//
|
||||
// Pending request type.
|
||||
//
|
||||
uint16_t ui16RequestType;
|
||||
|
||||
//
|
||||
// Pending request.
|
||||
//
|
||||
uint8_t ui8Request;
|
||||
|
||||
//
|
||||
// Pending update value.
|
||||
//
|
||||
uint16_t ui16Update;
|
||||
|
||||
//
|
||||
// Current Volume setting.
|
||||
//
|
||||
int16_t i16Volume;
|
||||
|
||||
//
|
||||
// Current Mute setting.
|
||||
//
|
||||
uint8_t ui8Mute;
|
||||
|
||||
//
|
||||
// Current Sample rate, this is not writable but the host will try.
|
||||
//
|
||||
uint32_t ui32SampleRate;
|
||||
|
||||
//
|
||||
// The OUT endpoint in use by this instance.
|
||||
//
|
||||
uint8_t ui8OUTEndpoint;
|
||||
|
||||
//
|
||||
// The OUT endpoint DMA channel in use by this instance.
|
||||
//
|
||||
uint8_t ui8OUTDMA;
|
||||
|
||||
//
|
||||
// The control interface number associated with this instance.
|
||||
//
|
||||
uint8_t ui8InterfaceControl;
|
||||
|
||||
//
|
||||
// The audio interface number associated with this instance.
|
||||
//
|
||||
uint8_t ui8InterfaceAudio;
|
||||
|
||||
//
|
||||
// A copy of the DMA instance data used with calls to USBLibDMA functions.
|
||||
//
|
||||
tUSBDMAInstance *psDMAInstance;
|
||||
}
|
||||
tAudioInstance;
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// This is the size of the g_pui8IADAudioDescriptor array in bytes.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define AUDIODESCRIPTOR_SIZE (8)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// This is the size of the g_pui8AudioControlInterface array in bytes.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define CONTROLINTERFACE_SIZE (52)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// This is the size of the g_pui8AudioStreamInterface array in bytes.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define STREAMINTERFACE_SIZE (52)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! The size of the memory that should be allocated to create a configuration
|
||||
//! descriptor for a single instance of the USB Audio Device.
|
||||
//! This does not include the configuration descriptor which is automatically
|
||||
//! ignored by the composite device class.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define COMPOSITE_DAUDIO_SIZE (AUDIODESCRIPTOR_SIZE + \
|
||||
CONTROLINTERFACE_SIZE + STREAMINTERFACE_SIZE)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! The structure used by the application to define operating parameters for
|
||||
//! the device audio class.
|
||||
//
|
||||
//*****************************************************************************
|
||||
typedef struct
|
||||
{
|
||||
//
|
||||
//! The vendor ID that this device is to present in the device descriptor.
|
||||
//
|
||||
const uint16_t ui16VID;
|
||||
|
||||
//
|
||||
//! The product ID that this device is to present in the device descriptor.
|
||||
//
|
||||
const uint16_t ui16PID;
|
||||
|
||||
//
|
||||
//! 8 byte vendor string.
|
||||
//
|
||||
const char pcVendor[8];
|
||||
|
||||
//
|
||||
//! 16 byte vendor string.
|
||||
//
|
||||
const char pcProduct[16];
|
||||
|
||||
//
|
||||
//! 4 byte vendor string.
|
||||
//
|
||||
const char pcVersion[4];
|
||||
|
||||
//
|
||||
//! The maximum power consumption of the device, expressed in mA.
|
||||
//
|
||||
const uint16_t ui16MaxPowermA;
|
||||
|
||||
//
|
||||
//! Indicates whether the device is self or bus-powered and whether or not
|
||||
//! it supports remote wake up. Valid values are USB_CONF_ATTR_SELF_PWR or
|
||||
//! USB_CONF_ATTR_BUS_PWR, optionally ORed with USB_CONF_ATTR_RWAKE.
|
||||
//
|
||||
const uint8_t ui8PwrAttributes;
|
||||
|
||||
//
|
||||
//! A pointer to the callback function which will be called to notify
|
||||
//! the application of events relating to the operation of the audio
|
||||
//! device.
|
||||
//
|
||||
const tUSBCallback pfnCallback;
|
||||
|
||||
//
|
||||
//! A pointer to the string descriptor array for this device. This array
|
||||
//! must contain the following string descriptor pointers in this order.
|
||||
//! Language descriptor, Manufacturer name string (language 1), Product
|
||||
//! name string (language 1), Serial number string (language 1), Audio
|
||||
//! Interface description string (language 1), Configuration description
|
||||
//! string (language 1).
|
||||
//!
|
||||
//! If supporting more than 1 language, the descriptor block (except for
|
||||
//! string descriptor 0) must be repeated for each language defined in the
|
||||
//! language descriptor.
|
||||
//!
|
||||
//
|
||||
const uint8_t * const *ppui8StringDescriptors;
|
||||
|
||||
//
|
||||
//! The number of descriptors provided in the ppStringDescriptors
|
||||
//! array. This must be 1 + ((5 + (number of strings)) *
|
||||
//! (number of languages)).
|
||||
//
|
||||
const uint32_t ui32NumStringDescriptors;
|
||||
|
||||
//
|
||||
//! The maximum volume expressed as an 8.8 signed value.
|
||||
//
|
||||
const int16_t i16VolumeMax;
|
||||
|
||||
//
|
||||
//! The minimum volume expressed as an 8.8 signed value.
|
||||
//
|
||||
const int16_t i16VolumeMin;
|
||||
|
||||
//
|
||||
//! The minimum volume step expressed as an 8.8 signed value.
|
||||
//
|
||||
const int16_t i16VolumeStep;
|
||||
|
||||
//
|
||||
//! The private instance data for the audio device.
|
||||
//
|
||||
tAudioInstance sPrivateData;
|
||||
}
|
||||
tUSBDAudioDevice;
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Audio specific device class driver events
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! This USB audio event indicates that the device is connected but not active.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define USBD_AUDIO_EVENT_IDLE (USBD_AUDIO_EVENT_BASE + 0)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! This USB audio event indicates that the device is connected and is now
|
||||
//! active.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define USBD_AUDIO_EVENT_ACTIVE (USBD_AUDIO_EVENT_BASE + 1)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! This USB audio event indicates that the device is returning a data buffer
|
||||
//! provided by the USBAudioBufferOut() function back to the application with
|
||||
//! valid audio data received from the USB host controller. The \e pvBuffer
|
||||
//! parameter holds the pointer to the buffer with the new audio data and
|
||||
//! the \e ui32Param value holds the amount of valid data in bytes that are
|
||||
//! contained in the \e pvBuffer parameter.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define USBD_AUDIO_EVENT_DATAOUT (USBD_AUDIO_EVENT_BASE + 2)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! This USB audio event indicates that a volume change has occurred. The
|
||||
//! \e ui32Param value contains a signed 8.8 fixed point value that represents
|
||||
//! the current volume gain/attenuation in decibels(dB). The provided message
|
||||
//! handler should be prepared to handle negative and positive values with the
|
||||
//! value 0x8000 indicating maximum attenuation. The \e pvBuffer parameter
|
||||
//! should be ignored.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define USBD_AUDIO_EVENT_VOLUME (USBD_AUDIO_EVENT_BASE + 4)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! This USB audio event indicates that a mute request has occurred. The
|
||||
//! \e ui32Param value will either be a 1 to indicate that the audio is now
|
||||
//! muted, and a value of 0 indicates that the audio has been unmuted.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define USBD_AUDIO_EVENT_MUTE (USBD_AUDIO_EVENT_BASE + 5)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// API Function Prototypes
|
||||
//
|
||||
//*****************************************************************************
|
||||
extern void *USBDAudioInit(uint32_t ui32Index,
|
||||
tUSBDAudioDevice *psAudioDevice);
|
||||
extern void *USBDAudioCompositeInit(uint32_t ui32Index,
|
||||
tUSBDAudioDevice *psAudioDevice,
|
||||
tCompositeEntry *psCompEntry);
|
||||
extern void USBDAudioTerm(void *pvAudioDevice);
|
||||
extern int32_t USBAudioBufferOut(void *pvAudioDevice, void *pvBuffer,
|
||||
uint32_t ui32Size,
|
||||
tUSBAudioBufferCallback pfnCallback);
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Close the Doxygen group.
|
||||
//! @}
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Mark the end of the C bindings section for C++ compilers.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,292 @@
|
|||
//*****************************************************************************
|
||||
//
|
||||
// usbdcdc.h - USBLib support for a generic bulk device.
|
||||
//
|
||||
// Copyright (c) 2008-2013 Texas Instruments Incorporated. All rights reserved.
|
||||
// Software License Agreement
|
||||
//
|
||||
// Texas Instruments (TI) is supplying this software for use solely and
|
||||
// exclusively on TI's microcontroller products. The software is owned by
|
||||
// TI and/or its suppliers, and is protected under applicable copyright
|
||||
// laws. You may not combine this software with "viral" open-source
|
||||
// software in order to form a larger program.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
|
||||
// NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
|
||||
// NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
|
||||
// CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
|
||||
// DAMAGES, FOR ANY REASON WHATSOEVER.
|
||||
//
|
||||
// This is part of revision 1.1 of the Tiva USB Library.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
#ifndef __USBDBULK_H__
|
||||
#define __USBDBULK_H__
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// If building with a C++ compiler, make all of the definitions in this header
|
||||
// have a C binding.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! \addtogroup bulk_device_class_api
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// PRIVATE
|
||||
//
|
||||
// The first few sections of this header are private defines that are used by
|
||||
// the USB Bulk example code and are here only to help with the application
|
||||
// allocating the correct amount of memory for the Bulk example device code.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// PRIVATE
|
||||
//
|
||||
// This enumeration holds the various states that the device can be in during
|
||||
// normal operation.
|
||||
//
|
||||
//*****************************************************************************
|
||||
typedef enum
|
||||
{
|
||||
//
|
||||
// Not configured.
|
||||
//
|
||||
eBulkStateUnconfigured,
|
||||
|
||||
//
|
||||
// No outstanding transaction remains to be completed.
|
||||
//
|
||||
eBulkStateIdle,
|
||||
|
||||
//
|
||||
// Waiting on completion of a send or receive transaction.
|
||||
//
|
||||
eBulkStateWaitData,
|
||||
|
||||
//
|
||||
// Waiting for client to process data.
|
||||
//
|
||||
eBulkStateWaitClient
|
||||
}
|
||||
tBulkState;
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// PRIVATE
|
||||
//
|
||||
// This structure defines the private instance data and state variables for the
|
||||
// Bulk only example device. The memory for this structure is inlcluded in
|
||||
// the sPrivateData field in the tUSBDBulkDevice structure passed on
|
||||
// USBDBulkInit().
|
||||
//
|
||||
//*****************************************************************************
|
||||
typedef struct
|
||||
{
|
||||
//
|
||||
// Base address for the USB controller.
|
||||
//
|
||||
uint32_t ui32USBBase;
|
||||
|
||||
//
|
||||
// The device info to interact with the lower level DCD code.
|
||||
//
|
||||
tDeviceInfo sDevInfo;
|
||||
|
||||
//
|
||||
// The state of the bulk receive channel.
|
||||
//
|
||||
volatile tBulkState iBulkRxState;
|
||||
|
||||
//
|
||||
// The state of the bulk transmit channel.
|
||||
//
|
||||
volatile tBulkState iBulkTxState;
|
||||
|
||||
//
|
||||
// State of any pending operations that could not be handled immediately
|
||||
// upon receipt.
|
||||
//
|
||||
volatile uint16_t ui16DeferredOpFlags;
|
||||
|
||||
//
|
||||
// Size of the last transmit.
|
||||
//
|
||||
uint16_t ui16LastTxSize;
|
||||
|
||||
//
|
||||
// The connection status of the device.
|
||||
//
|
||||
volatile bool bConnected;
|
||||
|
||||
//
|
||||
// The IN endpoint number, this is modified in composite devices.
|
||||
//
|
||||
uint8_t ui8INEndpoint;
|
||||
|
||||
//
|
||||
// The OUT endpoint number, this is modified in composite devices.
|
||||
//
|
||||
uint8_t ui8OUTEndpoint;
|
||||
|
||||
//
|
||||
// The bulk class interface number, this is modified in composite devices.
|
||||
//
|
||||
uint8_t ui8Interface;
|
||||
}
|
||||
tBulkInstance;
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// This is the size of the g_pui8BulkInterface array in bytes.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define BULKINTERFACE_SIZE (23)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! The size of the memory that should be allocated to create a configuration
|
||||
//! descriptor for a single instance of the USB Bulk Device.
|
||||
//! This does not include the configuration descriptor which is automatically
|
||||
//! ignored by the composite device class.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define COMPOSITE_DBULK_SIZE (BULKINTERFACE_SIZE)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! The structure used by the application to define operating parameters for
|
||||
//! the bulk device.
|
||||
//
|
||||
//*****************************************************************************
|
||||
typedef struct
|
||||
{
|
||||
//
|
||||
//! The vendor ID that this device is to present in the device descriptor.
|
||||
//
|
||||
const uint16_t ui16VID;
|
||||
|
||||
//
|
||||
//! The product ID that this device is to present in the device descriptor.
|
||||
//
|
||||
const uint16_t ui16PID;
|
||||
|
||||
//
|
||||
//! The maximum power consumption of the device, expressed in milliamps.
|
||||
//
|
||||
const uint16_t ui16MaxPowermA;
|
||||
|
||||
//
|
||||
//! Indicates whether the device is self- or bus-powered and whether or not
|
||||
//! it supports remote wakeup. Valid values are USB_CONF_ATTR_SELF_PWR or
|
||||
//! USB_CONF_ATTR_BUS_PWR, optionally ORed with USB_CONF_ATTR_RWAKE.
|
||||
//
|
||||
const uint8_t ui8PwrAttributes;
|
||||
|
||||
//
|
||||
//! A pointer to the callback function which will be called to notify
|
||||
//! the application of events related to the device's data receive channel.
|
||||
//
|
||||
const tUSBCallback pfnRxCallback;
|
||||
|
||||
//
|
||||
//! A client-supplied pointer which will be sent as the first
|
||||
//! parameter in all calls made to the receive channel callback,
|
||||
//! pfnRxCallback.
|
||||
//
|
||||
void *pvRxCBData;
|
||||
|
||||
//
|
||||
//! A pointer to the callback function which will be called to notify
|
||||
//! the application of events related to the device's data transmit
|
||||
//! channel.
|
||||
//
|
||||
const tUSBCallback pfnTxCallback;
|
||||
|
||||
//
|
||||
//! A client-supplied pointer which will be sent as the first
|
||||
//! parameter in all calls made to the transmit channel callback,
|
||||
//! pfnTxCallback.
|
||||
//
|
||||
void *pvTxCBData;
|
||||
|
||||
//
|
||||
//! A pointer to the string descriptor array for this device. This array
|
||||
//! must contain pointers to the following string descriptors in this
|
||||
//! order. Language descriptor, Manufacturer name string (language 1),
|
||||
//! Product name string (language 1), Serial number string (language 1),
|
||||
//! Interface description string (language 1) and Configuration description
|
||||
//! string (language 1).
|
||||
//!
|
||||
//! If supporting more than 1 language, the strings for indices 1 through 5
|
||||
//! must be repeated for each of the other languages defined in the
|
||||
//! language descriptor.
|
||||
//
|
||||
const uint8_t * const *ppui8StringDescriptors;
|
||||
|
||||
//
|
||||
//! The number of descriptors provided in the ppStringDescriptors array.
|
||||
//! This must be 1 + (5 * number of supported languages).
|
||||
//
|
||||
const uint32_t ui32NumStringDescriptors;
|
||||
|
||||
//
|
||||
//! The private instance data for this device. This memory must
|
||||
//! not be modified by any code outside the bulk class driver.
|
||||
//
|
||||
tBulkInstance sPrivateData;
|
||||
}
|
||||
tUSBDBulkDevice;
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// API Function Prototypes
|
||||
//
|
||||
//*****************************************************************************
|
||||
extern void *USBDBulkInit(uint32_t ui32Index, tUSBDBulkDevice *psBulkDevice);
|
||||
extern void *USBDBulkCompositeInit(uint32_t ui32Index,
|
||||
tUSBDBulkDevice *psBulkDevice,
|
||||
tCompositeEntry *psCompEntry);
|
||||
extern void USBDBulkTerm(void *pvBulkInstance);
|
||||
extern void *USBDBulkSetRxCBData(void *pvBulkInstance, void *pvCBData);
|
||||
extern void *USBDBulkSetTxCBData(void *pvBulkInstance, void *pvCBData);
|
||||
extern uint32_t USBDBulkPacketWrite(void *pvBulkInstance, uint8_t *pi8Data,
|
||||
uint32_t ui32Length, bool bLast);
|
||||
extern uint32_t USBDBulkPacketRead(void *pvBulkInstance, uint8_t *pi8Data,
|
||||
uint32_t ui32Length, bool bLast);
|
||||
extern uint32_t USBDBulkTxPacketAvailable(void *pvBulkInstance);
|
||||
extern uint32_t USBDBulkRxPacketAvailable(void *pvBulkInstance);
|
||||
extern void USBDBulkPowerStatusSet(void *pvBulkInstance, uint8_t ui8Power);
|
||||
extern bool USBDBulkRemoteWakeupRequest(void *pvBulkInstance);
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Close the Doxygen group.
|
||||
//! @}
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Mark the end of the C bindings section for C++ compilers.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // __USBDBULK_H__
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,434 @@
|
|||
//*****************************************************************************
|
||||
//
|
||||
// usbdcdc.h - USBLib support for generic CDC ACM (serial) device.
|
||||
//
|
||||
// Copyright (c) 2008-2013 Texas Instruments Incorporated. All rights reserved.
|
||||
// Software License Agreement
|
||||
//
|
||||
// Texas Instruments (TI) is supplying this software for use solely and
|
||||
// exclusively on TI's microcontroller products. The software is owned by
|
||||
// TI and/or its suppliers, and is protected under applicable copyright
|
||||
// laws. You may not combine this software with "viral" open-source
|
||||
// software in order to form a larger program.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
|
||||
// NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
|
||||
// NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
|
||||
// CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
|
||||
// DAMAGES, FOR ANY REASON WHATSOEVER.
|
||||
//
|
||||
// This is part of revision 1.1 of the Tiva USB Library.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
#ifndef __USBDCDC_H__
|
||||
#define __USBDCDC_H__
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// If building with a C++ compiler, make all of the definitions in this header
|
||||
// have a C binding.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! \addtogroup cdc_device_class_api
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// PRIVATE
|
||||
//
|
||||
// The first few sections of this header are private defines that are used by
|
||||
// the USB CDC Serial code and are here only to help with the application
|
||||
// allocating the correct amount of memory for the CDC Serial device code.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// PRIVATE
|
||||
//
|
||||
// This enumeration holds the various states that the device can be in during
|
||||
// normal operation.
|
||||
//
|
||||
//*****************************************************************************
|
||||
typedef enum
|
||||
{
|
||||
//
|
||||
// Unconfigured.
|
||||
//
|
||||
eCDCStateUnconfigured,
|
||||
|
||||
//
|
||||
// No outstanding transaction remains to be completed.
|
||||
//
|
||||
eCDCStateIdle,
|
||||
|
||||
//
|
||||
// Waiting on completion of a send or receive transaction.
|
||||
//
|
||||
eCDCStateWaitData,
|
||||
|
||||
//
|
||||
// Waiting for client to process data.
|
||||
//
|
||||
eCDCStateWaitClient
|
||||
}
|
||||
tCDCState;
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// PRIVATE
|
||||
//
|
||||
// This structure defines the private instance data and state variables for the
|
||||
// CDC Serial device. The memory for this structure is allocated in the
|
||||
// tUSBDCDCDevice structure passed on USBDCDCInit().
|
||||
//
|
||||
//*****************************************************************************
|
||||
typedef struct
|
||||
{
|
||||
//
|
||||
// Base address for the USB controller.
|
||||
//
|
||||
uint32_t ui32USBBase;
|
||||
|
||||
//
|
||||
// The device info to interact with the lower level DCD code.
|
||||
//
|
||||
tDeviceInfo sDevInfo;
|
||||
|
||||
//
|
||||
// The state of the serial receive state.
|
||||
//
|
||||
volatile tCDCState iCDCRxState;
|
||||
|
||||
//
|
||||
// The state of the serial transmit state.
|
||||
//
|
||||
volatile tCDCState iCDCTxState;
|
||||
|
||||
//
|
||||
// The state of the serial request state.
|
||||
//
|
||||
volatile tCDCState iCDCRequestState;
|
||||
|
||||
//
|
||||
// The state of the serial interrupt state.
|
||||
//
|
||||
volatile tCDCState iCDCInterruptState;
|
||||
|
||||
//
|
||||
// The current pending request.
|
||||
//
|
||||
volatile uint8_t ui8PendingRequest;
|
||||
|
||||
//
|
||||
// The current break duration used during send break requests.
|
||||
//
|
||||
uint16_t ui16BreakDuration;
|
||||
|
||||
//
|
||||
// The current line control state for the serial port.
|
||||
//
|
||||
uint16_t ui16ControlLineState;
|
||||
|
||||
//
|
||||
// The general serial state.
|
||||
//
|
||||
uint16_t ui16SerialState;
|
||||
|
||||
//
|
||||
// State of any pending operations that could not be handled immediately
|
||||
// upon receipt.
|
||||
//
|
||||
volatile uint16_t ui16DeferredOpFlags;
|
||||
|
||||
//
|
||||
// Size of the last transmit.
|
||||
//
|
||||
uint16_t ui16LastTxSize;
|
||||
|
||||
//
|
||||
// The current serial line coding.
|
||||
//
|
||||
tLineCoding sLineCoding;
|
||||
|
||||
//
|
||||
// Serial port receive is blocked.
|
||||
//
|
||||
volatile bool bRxBlocked;
|
||||
|
||||
//
|
||||
// Serial control port is blocked.
|
||||
//
|
||||
volatile bool bControlBlocked;
|
||||
|
||||
//
|
||||
// The connection status of the device.
|
||||
//
|
||||
volatile bool bConnected;
|
||||
|
||||
//
|
||||
// The control endpoint number, this is modified in composite devices.
|
||||
//
|
||||
uint8_t ui8ControlEndpoint;
|
||||
|
||||
//
|
||||
// The IN endpoint number, this is modified in composite devices.
|
||||
//
|
||||
uint8_t ui8BulkINEndpoint;
|
||||
|
||||
//
|
||||
// The OUT endpoint number, this is modified in composite devices.
|
||||
//
|
||||
uint8_t ui8BulkOUTEndpoint;
|
||||
|
||||
//
|
||||
// The interface number for the control interface, this is modified in
|
||||
// composite devices.
|
||||
//
|
||||
uint8_t ui8InterfaceControl;
|
||||
|
||||
//
|
||||
// The interface number for the data interface, this is modified in
|
||||
// composite devices.
|
||||
//
|
||||
uint8_t ui8InterfaceData;
|
||||
}
|
||||
tCDCSerInstance;
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// The following defines are used when working with composite devices.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// This is the size of the g_pui8IADSerDescriptor array in bytes.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define SERDESCRIPTOR_SIZE (8)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// This is the size of the g_pui8CDCSerCommInterface array in bytes.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define SERCOMMINTERFACE_SIZE (35)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// This is the size of the g_pui8CDCSerDataInterface array in bytes.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define SERDATAINTERFACE_SIZE (23)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! The size of the memory that should be allocated to create a configuration
|
||||
//! descriptor for a single instance of the USB Serial CDC Device.
|
||||
//! This does not include the configuration descriptor which is automatically
|
||||
//! ignored by the composite device class.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define COMPOSITE_DCDC_SIZE (SERDESCRIPTOR_SIZE + SERCOMMINTERFACE_SIZE + \
|
||||
SERDATAINTERFACE_SIZE)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// CDC-specific events These events are provided to the application in the
|
||||
// \e ui32Msg parameter of the tUSBCallback function.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//
|
||||
//! The host requests that the device send a BREAK condition on its
|
||||
//! serial communication channel. The BREAK should remain active until
|
||||
//! a USBD_CDC_EVENT_CLEAR_BREAK event is received.
|
||||
//
|
||||
#define USBD_CDC_EVENT_SEND_BREAK (USBD_CDC_EVENT_BASE + 0)
|
||||
|
||||
//
|
||||
//! The host requests that the device stop sending a BREAK condition on its
|
||||
//! serial communication channel.
|
||||
//
|
||||
#define USBD_CDC_EVENT_CLEAR_BREAK (USBD_CDC_EVENT_BASE + 1)
|
||||
|
||||
//
|
||||
//! The host requests that the device set the RS232 signaling lines to
|
||||
//! a particular state. The ui32MsgValue parameter contains the RTS and
|
||||
//! DTR control line states as defined in table 51 of the USB CDC class
|
||||
//! definition and is a combination of the following values:
|
||||
//!
|
||||
//! (RTS) USB_CDC_DEACTIVATE_CARRIER or USB_CDC_ACTIVATE_CARRIER
|
||||
//! (DTR) USB_CDC_DTE_NOT_PRESENT or USB_CDC_DTE_PRESENT
|
||||
//
|
||||
#define USBD_CDC_EVENT_SET_CONTROL_LINE_STATE (USBD_CDC_EVENT_BASE + 2)
|
||||
|
||||
//
|
||||
//! The host requests that the device set the RS232 communication
|
||||
//! parameters. The pvMsgData parameter points to a tLineCoding structure
|
||||
//! defining the required number of bits per character, parity mode,
|
||||
//! number of stop bits and the baud rate.
|
||||
//
|
||||
#define USBD_CDC_EVENT_SET_LINE_CODING (USBD_CDC_EVENT_BASE + 3)
|
||||
|
||||
//
|
||||
//! The host is querying the current RS232 communication parameters. The
|
||||
//! pvMsgData parameter points to a tLineCoding structure that the
|
||||
//! application must fill with the current settings prior to returning
|
||||
//! from the callback.
|
||||
//
|
||||
#define USBD_CDC_EVENT_GET_LINE_CODING (USBD_CDC_EVENT_BASE + 4)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! The structure used by the application to define operating parameters for
|
||||
//! the CDC device.
|
||||
//
|
||||
//*****************************************************************************
|
||||
typedef struct
|
||||
{
|
||||
//
|
||||
//! The vendor ID that this device is to present in the device descriptor.
|
||||
//
|
||||
const uint16_t ui16VID;
|
||||
|
||||
//
|
||||
//! The product ID that this device is to present in the device descriptor.
|
||||
//
|
||||
const uint16_t ui16PID;
|
||||
|
||||
//
|
||||
//! The maximum power consumption of the device, expressed in milliamps.
|
||||
//
|
||||
const uint16_t ui16MaxPowermA;
|
||||
|
||||
//
|
||||
//! Indicates whether the device is self- or bus-powered and whether or not
|
||||
//! it supports remote wakeup. Valid values are USB_CONF_ATTR_SELF_PWR or
|
||||
//! USB_CONF_ATTR_BUS_PWR, optionally ORed with USB_CONF_ATTR_RWAKE.
|
||||
//
|
||||
const uint8_t ui8PwrAttributes;
|
||||
|
||||
//
|
||||
//! A pointer to the callback function which will be called to notify
|
||||
//! the application of all asynchronous control events related to the
|
||||
//! operation of the device.
|
||||
//
|
||||
const tUSBCallback pfnControlCallback;
|
||||
|
||||
//
|
||||
//! A client-supplied pointer which will be sent as the first
|
||||
//! parameter in all calls made to the control channel callback,
|
||||
//! pfnControlCallback.
|
||||
//
|
||||
void *pvControlCBData;
|
||||
|
||||
//
|
||||
//! A pointer to the callback function which will be called to notify
|
||||
//! the application of events related to the device's data receive channel.
|
||||
//
|
||||
const tUSBCallback pfnRxCallback;
|
||||
|
||||
//
|
||||
//! A client-supplied pointer which will be sent as the first
|
||||
//! parameter in all calls made to the receive channel callback,
|
||||
//! pfnRxCallback.
|
||||
//
|
||||
void *pvRxCBData;
|
||||
|
||||
//
|
||||
//! A pointer to the callback function which will be called to notify
|
||||
//! the application of events related to the device's data transmit
|
||||
//! channel.
|
||||
//
|
||||
const tUSBCallback pfnTxCallback;
|
||||
|
||||
//
|
||||
//! A client-supplied pointer which will be sent as the first
|
||||
//! parameter in all calls made to the transmit channel callback,
|
||||
//! pfnTxCallback.
|
||||
//
|
||||
void *pvTxCBData;
|
||||
|
||||
//
|
||||
//! A pointer to the string descriptor array for this device. This array
|
||||
//! must contain the following string descriptor pointers in this order.
|
||||
//! Language descriptor, Manufacturer name string (language 1), Product
|
||||
//! name string (language 1), Serial number string (language 1),
|
||||
//! Control interface description string (language 1), Configuration
|
||||
//! description string (language 1).
|
||||
//!
|
||||
//! If supporting more than 1 language, the strings for indices 1 through 5
|
||||
//! must be repeated for each of the other languages defined in the
|
||||
//! language descriptor.
|
||||
//
|
||||
const uint8_t * const *ppui8StringDescriptors;
|
||||
|
||||
//
|
||||
//! The number of descriptors provided in the ppStringDescriptors
|
||||
//! array. This must be 1 + (5 * number of supported languages).
|
||||
//
|
||||
const uint32_t ui32NumStringDescriptors;
|
||||
|
||||
//
|
||||
//! The private instance data for this device. This memory
|
||||
//! must remain accessible for as long as the CDC device is in use and
|
||||
//! must not be modified by any code outside the CDC class driver.
|
||||
//
|
||||
tCDCSerInstance sPrivateData;
|
||||
}
|
||||
tUSBDCDCDevice;
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// API Function Prototypes
|
||||
//
|
||||
//*****************************************************************************
|
||||
extern void *USBDCDCCompositeInit(uint32_t ui32Index,
|
||||
tUSBDCDCDevice *psCDCDevice,
|
||||
tCompositeEntry *psCompEntry);
|
||||
extern void *USBDCDCInit(uint32_t ui32Index,
|
||||
tUSBDCDCDevice *psCDCDevice);
|
||||
extern void USBDCDCTerm(void *pvCDCDevice);
|
||||
extern void *USBDCDCSetControlCBData(void *pvCDCDevice, void *pvCBData);
|
||||
extern void *USBDCDCSetRxCBData(void *pvCDCDevice, void *pvCBData);
|
||||
extern void *USBDCDCSetTxCBData(void *pvCDCDevice, void *pvCBData);
|
||||
extern uint32_t USBDCDCPacketWrite(void *pvCDCDevice, uint8_t *pi8Data,
|
||||
uint32_t ui32Length, bool bLast);
|
||||
extern uint32_t USBDCDCPacketRead(void *pvCDCDevice, uint8_t *pi8Data,
|
||||
uint32_t ui32Length, bool bLast);
|
||||
extern uint32_t USBDCDCTxPacketAvailable(void *pvCDCDevice);
|
||||
extern uint32_t USBDCDCRxPacketAvailable(void *pvCDCDevice);
|
||||
extern void USBDCDCSerialStateChange(void *pvCDCDevice, uint16_t ui16State);
|
||||
extern void USBDCDCPowerStatusSet(void *pvCDCDevice, uint8_t ui8Power);
|
||||
extern bool USBDCDCRemoteWakeupRequest(void *pvCDCDevice);
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Close the Doxygen group.
|
||||
//! @}
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Mark the end of the C bindings section for C++ compilers.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // __USBDCDC_H__
|
|
@ -0,0 +1,643 @@
|
|||
//*****************************************************************************
|
||||
//
|
||||
// usbcdesc.c - Config descriptor parsing functions.
|
||||
//
|
||||
// Copyright (c) 2007-2013 Texas Instruments Incorporated. All rights reserved.
|
||||
// Software License Agreement
|
||||
//
|
||||
// Texas Instruments (TI) is supplying this software for use solely and
|
||||
// exclusively on TI's microcontroller products. The software is owned by
|
||||
// TI and/or its suppliers, and is protected under applicable copyright
|
||||
// laws. You may not combine this software with "viral" open-source
|
||||
// software in order to form a larger program.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
|
||||
// NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
|
||||
// NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
|
||||
// CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
|
||||
// DAMAGES, FOR ANY REASON WHATSOEVER.
|
||||
//
|
||||
// This is part of revision 1.1 of the Tiva USB Library.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "inc/hw_types.h"
|
||||
#include "driverlib/debug.h"
|
||||
#include "driverlib/usbdrv.h"
|
||||
#include "usblib/usblib.h"
|
||||
#include "usblib/usblibpriv.h"
|
||||
#include "usblib/device/usbdevice.h"
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// The functions in this file mirror the descriptor parsing APIs available
|
||||
// in usblib.h but parse configuration descriptors defined in terms of a list
|
||||
// of sections rather than as a single block of descriptor data.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! \addtogroup device_api
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! \internal
|
||||
//!
|
||||
//! Walk to the next descriptor after the supplied one within a section-based
|
||||
//! config descriptor.
|
||||
//!
|
||||
//! \param psConfig points to the header structure for the configuration
|
||||
//! descriptor which contains \e pi16Desc.
|
||||
//! \param pui32Sec points to a variable containing the section within
|
||||
//! \e psConfig which contains \e pi16Desc.
|
||||
//! \param pi16Desc points to the descriptor that we want to step past.
|
||||
//!
|
||||
//! This function walks forward one descriptor within a configuration
|
||||
//! descriptor. The value returned is a pointer to the header of the next
|
||||
//! descriptor after the descriptor supplied in \e pi16Desc. If the next
|
||||
//! descriptor is in the next section, \e *pui32Sec will be incremented
|
||||
//! accordingly.
|
||||
//!
|
||||
//! \return Returns a pointer to the next descriptor in the configuration
|
||||
//! descriptor.
|
||||
//
|
||||
//*****************************************************************************
|
||||
static tDescriptorHeader *
|
||||
NextConfigDescGet(const tConfigHeader *psConfig, uint32_t *pui32Sec,
|
||||
tDescriptorHeader *psDesc)
|
||||
{
|
||||
//
|
||||
// Determine where the next descriptor after the supplied one should be
|
||||
// assuming it is within the current section.
|
||||
//
|
||||
psDesc = NEXT_USB_DESCRIPTOR(psDesc);
|
||||
|
||||
//
|
||||
// Did we run off the end of the section?
|
||||
//
|
||||
if((uint8_t *)psDesc >= (psConfig->psSections[*pui32Sec]->pui8Data +
|
||||
psConfig->psSections[*pui32Sec]->ui16Size))
|
||||
{
|
||||
//
|
||||
// Yes - move to the next section.
|
||||
//
|
||||
(*pui32Sec)++;
|
||||
|
||||
//
|
||||
// Are we still within the configuration descriptor?
|
||||
//
|
||||
if(*pui32Sec < psConfig->ui8NumSections)
|
||||
{
|
||||
//
|
||||
// Yes - the new descriptor is at the start of the new section.
|
||||
//
|
||||
psDesc =
|
||||
(tDescriptorHeader *)psConfig->psSections[*pui32Sec]->pui8Data;
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
// No - we ran off the end of the descriptor so return NULL.
|
||||
//
|
||||
psDesc = (tDescriptorHeader *)0;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Return the new descriptor pointer.
|
||||
//
|
||||
return(psDesc);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! \internal
|
||||
//!
|
||||
//! Returns a pointer to the n-th interface descriptor in a configuration
|
||||
//! descriptor with the supplied interface number.
|
||||
//!
|
||||
//! \param psConfig points to the header structure for the configuration
|
||||
//! descriptor to search.
|
||||
//! \param ui8InterfaceNumber is the interface number of the descriptor to
|
||||
//! query.
|
||||
//! \param ui32Index is the zero based index of the descriptor.
|
||||
//! \param pui32Section points to storage which is written with the index
|
||||
//! of the section containing the returned descriptor.
|
||||
//!
|
||||
//! This function returns a pointer to the n-th interface descriptor in the
|
||||
//! supplied configuration which has the requested interface number. It may be
|
||||
//! used by a client to retrieve the descriptors for each alternate setting
|
||||
//! of a given interface within the configuration passed.
|
||||
//!
|
||||
//! \return Returns a pointer to the n-th interface descriptor with interface
|
||||
//! number as specified or NULL of this descriptor does not exist.
|
||||
//
|
||||
//*****************************************************************************
|
||||
static tInterfaceDescriptor *
|
||||
ConfigAlternateInterfaceGet(const tConfigHeader *psConfig,
|
||||
uint8_t ui8InterfaceNumber, uint32_t ui32Index,
|
||||
uint32_t *pui32Section)
|
||||
{
|
||||
tDescriptorHeader *psDescCheck;
|
||||
uint32_t ui32Count, ui32Sec;
|
||||
|
||||
//
|
||||
// Set up for our descriptor counting loop.
|
||||
//
|
||||
psDescCheck = (tDescriptorHeader *)psConfig->psSections[0]->pui8Data;
|
||||
ui32Count = 0;
|
||||
ui32Sec = 0;
|
||||
|
||||
//
|
||||
// Keep looking through the supplied data until we reach the end.
|
||||
//
|
||||
while(psDescCheck)
|
||||
{
|
||||
//
|
||||
// Does this descriptor match the type passed (if a specific type
|
||||
// has been specified)?
|
||||
//
|
||||
if((psDescCheck->bDescriptorType == USB_DTYPE_INTERFACE) &&
|
||||
(((tInterfaceDescriptor *)psDescCheck)->bInterfaceNumber ==
|
||||
ui8InterfaceNumber))
|
||||
{
|
||||
//
|
||||
// This is an interface descriptor for interface
|
||||
// ui8InterfaceNumber. Determine if this is the n-th one we have
|
||||
// found and, if so, return its pointer.
|
||||
//
|
||||
if(ui32Count == ui32Index)
|
||||
{
|
||||
//
|
||||
// Found it - return the pointer and section number.
|
||||
//
|
||||
*pui32Section = ui32Sec;
|
||||
return((tInterfaceDescriptor *)psDescCheck);
|
||||
}
|
||||
|
||||
//
|
||||
// Increment our count of matching descriptors found and go back
|
||||
// to look for another since we have not yet reached the n-th
|
||||
// match.
|
||||
//
|
||||
ui32Count++;
|
||||
}
|
||||
|
||||
//
|
||||
// Move on to the next descriptor.
|
||||
//
|
||||
psDescCheck = NextConfigDescGet(psConfig, &ui32Sec, psDescCheck);
|
||||
}
|
||||
|
||||
//
|
||||
// If we drop out the end of the loop, we did not find the requested
|
||||
// descriptor so return NULL.
|
||||
//
|
||||
return((tInterfaceDescriptor *)0);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! \internal
|
||||
//!
|
||||
//! Determines the total length of a configuration descriptor defined in terms
|
||||
//! of a collection of concatenated sections.
|
||||
//!
|
||||
//! \param psConfig points to the header structure for the configuration
|
||||
//! descriptor whose size is to be determined.
|
||||
//!
|
||||
//! \return Returns the number of bytes in the configuration descriptor will
|
||||
//! result from concatenating the required sections.
|
||||
//
|
||||
//*****************************************************************************
|
||||
uint32_t
|
||||
USBDCDConfigDescGetSize(const tConfigHeader *psConfig)
|
||||
{
|
||||
uint32_t ui32Loop, ui32Len;
|
||||
|
||||
ui32Len = 0;
|
||||
|
||||
//
|
||||
// Determine the size of the whole descriptor by adding the sizes of
|
||||
// each section which will be concatenated to produce it.
|
||||
//
|
||||
for(ui32Loop = 0; ui32Loop < psConfig->ui8NumSections; ui32Loop++)
|
||||
{
|
||||
ui32Len += psConfig->psSections[ui32Loop]->ui16Size;
|
||||
}
|
||||
|
||||
return(ui32Len);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! \internal
|
||||
//!
|
||||
//! Determines the number of individual descriptors of a particular type within
|
||||
//! a supplied configuration descriptor.
|
||||
//!
|
||||
//! \param psConfig points to the header structure for the configuration
|
||||
//! descriptor that is to be searched.
|
||||
//! \param ui32Type identifies the type of descriptor that is to be counted.
|
||||
//! If the value is \b USB_DESC_ANY, the function returns the total number of
|
||||
//! descriptors regardless of type.
|
||||
//!
|
||||
//! This function can be used to count the number of descriptors of a
|
||||
//! particular type within a configuration descriptor. The caller can provide
|
||||
//! a specific type value which the function matches against the second byte
|
||||
//! of each descriptor or, alternatively, can specify \b USB_DESC_ANY to have
|
||||
//! the function count all descriptors regardless of their type.
|
||||
//!
|
||||
//! The search performed by this function traverses through the list of
|
||||
//! sections comprising the configuration descriptor. Note that the similar
|
||||
//! top-level function, USBDescGetNum(), searches through a single, contiguous
|
||||
//! block of data to perform the same enumeration.
|
||||
//!
|
||||
//! \return Returns the number of descriptors found in the supplied block of
|
||||
//! data.
|
||||
//
|
||||
//*****************************************************************************
|
||||
uint32_t
|
||||
USBDCDConfigDescGetNum(const tConfigHeader *psConfig, uint32_t ui32Type)
|
||||
{
|
||||
uint32_t ui32Section, ui32NumDescs;
|
||||
|
||||
//
|
||||
// Initialize our counts.
|
||||
//
|
||||
ui32NumDescs = 0;
|
||||
|
||||
//
|
||||
// Determine the number of descriptors of the given type in each of the
|
||||
// sections comprising the configuration descriptor. Note that this
|
||||
// assumes each section contains only whole descriptors!
|
||||
//
|
||||
for(ui32Section = 0; ui32Section < (uint32_t)psConfig->ui8NumSections;
|
||||
ui32Section++)
|
||||
{
|
||||
ui32NumDescs += USBDescGetNum(
|
||||
(tDescriptorHeader *)psConfig->psSections[ui32Section]->pui8Data,
|
||||
psConfig->psSections[ui32Section]->ui16Size, ui32Type);
|
||||
}
|
||||
|
||||
return(ui32NumDescs);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! \internal
|
||||
//!
|
||||
//! Finds the n-th descriptor of a particular type within the supplied
|
||||
//! configuration descriptor.
|
||||
//!
|
||||
//! \param psConfig points to the header structure for the configuration
|
||||
//! descriptor that is to be searched.
|
||||
//! \param ui32Type identifies the type of descriptor that is to be found. If
|
||||
//! the value is \b USB_DESC_ANY, the function returns a pointer to the n-th
|
||||
//! descriptor regardless of type.
|
||||
//! \param ui32Index is the zero based index of the descriptor whose pointer is
|
||||
//! to be returned. For example, passing value 1 in \e ui32Index returns the
|
||||
//! second matching descriptor.
|
||||
//! \param pui32Section points to storage which will receive the section index
|
||||
//! containing the requested descriptor.
|
||||
//!
|
||||
//! Return a pointer to the n-th descriptor of a particular type found in the
|
||||
//! configuration descriptor passed.
|
||||
//!
|
||||
//! The search performed by this function traverses through the list of
|
||||
//! sections comprising the configuration descriptor. Note that the similar
|
||||
//! top-level function, USBDescGet(), searches through a single, contiguous
|
||||
//! block of data to perform the same enumeration.
|
||||
//!
|
||||
//! \return Returns a pointer to the header of the required descriptor if
|
||||
//! found or NULL otherwise.
|
||||
//
|
||||
//*****************************************************************************
|
||||
tDescriptorHeader *
|
||||
USBDCDConfigDescGet(const tConfigHeader *psConfig, uint32_t ui32Type,
|
||||
uint32_t ui32Index, uint32_t *pui32Section)
|
||||
{
|
||||
uint32_t ui32Section, ui32TotalDescs, ui32NumDescs;
|
||||
|
||||
//
|
||||
// Initialize our counts.
|
||||
//
|
||||
ui32TotalDescs = 0;
|
||||
|
||||
//
|
||||
// Determine the number of descriptors of the given type in each of the
|
||||
// sections comprising the configuration descriptor. This allows us to
|
||||
// determine which section contains the descriptor we are being asked for.
|
||||
//
|
||||
for(ui32Section = 0; ui32Section < (uint32_t)psConfig->ui8NumSections;
|
||||
ui32Section++)
|
||||
{
|
||||
//
|
||||
// How many descriptors of the requested type exist in this section?
|
||||
//
|
||||
ui32NumDescs = USBDescGetNum(
|
||||
(tDescriptorHeader *)psConfig->psSections[ui32Section]->pui8Data,
|
||||
psConfig->psSections[ui32Section]->ui16Size, ui32Type);
|
||||
|
||||
//
|
||||
// Does this section contain the descriptor whose index we are looking
|
||||
// for?
|
||||
//
|
||||
if((ui32TotalDescs + ui32NumDescs) > ui32Index)
|
||||
{
|
||||
//
|
||||
// We know the requested descriptor exists in the current
|
||||
// block so write the section number to the caller's storage.
|
||||
//
|
||||
*pui32Section = ui32Section;
|
||||
|
||||
//
|
||||
// Now find the actual descriptor requested and return its pointer.
|
||||
//
|
||||
return(USBDescGet(
|
||||
(tDescriptorHeader *)psConfig->psSections[ui32Section]->pui8Data,
|
||||
psConfig->psSections[ui32Section]->ui16Size,
|
||||
ui32Type, ui32Index - ui32TotalDescs));
|
||||
}
|
||||
|
||||
//
|
||||
// We have not found the required descriptor yet. Update our running
|
||||
// count of the number of type matches found so far then move on to
|
||||
// the next section.
|
||||
//
|
||||
ui32TotalDescs += ui32NumDescs;
|
||||
}
|
||||
|
||||
//
|
||||
// If we drop out of the loop, we can't find the requested descriptor
|
||||
// so return NULL.
|
||||
//
|
||||
return((tDescriptorHeader *)0);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! \internal
|
||||
//!
|
||||
//! Determines the number of different alternate configurations for a given
|
||||
//! interface within a configuration descriptor.
|
||||
//!
|
||||
//! \param psConfig points to the header structure for the configuration
|
||||
//! descriptor that is to be searched.
|
||||
//! \param ui8InterfaceNumber is the interface number for which the number of
|
||||
//! alternate configurations is to be counted.
|
||||
//!
|
||||
//! This function can be used to count the number of alternate settings for a
|
||||
//! specific interface within a configuration.
|
||||
//!
|
||||
//! The search performed by this function traverses through the list of
|
||||
//! sections comprising the configuration descriptor. Note that the similar
|
||||
//! top-level function, USBDescGetNumAlternateInterfaces(), searches through
|
||||
//! a single, contiguous block of data to perform the same enumeration.
|
||||
//!
|
||||
//! \return Returns the number of alternate versions of the specified interface
|
||||
//! or 0 if the interface number supplied cannot be found in the configuration
|
||||
//! descriptor.
|
||||
//
|
||||
//*****************************************************************************
|
||||
uint32_t
|
||||
USBDCDConfigGetNumAlternateInterfaces(const tConfigHeader *psConfig,
|
||||
uint8_t ui8InterfaceNumber)
|
||||
{
|
||||
tDescriptorHeader *psDescCheck;
|
||||
uint32_t ui32Count, ui32Sec;
|
||||
|
||||
//
|
||||
// Set up for our descriptor counting loop.
|
||||
//
|
||||
psDescCheck = (tDescriptorHeader *)psConfig->psSections[0]->pui8Data;
|
||||
ui32Sec = 0;
|
||||
ui32Count = 0;
|
||||
|
||||
//
|
||||
// Keep looking through the supplied data until we reach the end.
|
||||
//
|
||||
while(psDescCheck)
|
||||
{
|
||||
//
|
||||
// Is this an interface descriptor with the required interface number?
|
||||
//
|
||||
if((psDescCheck->bDescriptorType == USB_DTYPE_INTERFACE) &&
|
||||
(((tInterfaceDescriptor *)psDescCheck)->bInterfaceNumber ==
|
||||
ui8InterfaceNumber))
|
||||
{
|
||||
//
|
||||
// Yes - increment our count.
|
||||
//
|
||||
ui32Count++;
|
||||
}
|
||||
|
||||
//
|
||||
// Move on to the next descriptor.
|
||||
//
|
||||
psDescCheck = NextConfigDescGet(psConfig, &ui32Sec, psDescCheck);
|
||||
}
|
||||
|
||||
//
|
||||
// Return the descriptor count to the caller.
|
||||
//
|
||||
return(ui32Count);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! \internal
|
||||
//!
|
||||
//! Returns a pointer to the n-th interface descriptor in a configuration
|
||||
//! descriptor that applies to the supplied alternate setting number.
|
||||
//!
|
||||
//! \param psConfig points to the header structure for the configuration
|
||||
//! descriptor that is to be searched.
|
||||
//! \param ui32Index is the zero based index of the interface that is to be
|
||||
//! found. If \e ui32Alt is set to a value other than \b USB_DESC_ANY, this
|
||||
//! is equivalent to the interface number being searched for.
|
||||
//! \param ui32Alt is the alternate setting number which is to be
|
||||
//! searched for. If this value is \b USB_DESC_ANY, the alternate setting
|
||||
//! is ignored and all interface descriptors are considered in the search.
|
||||
//! \param pui32Section points to storage which will receive the index of the
|
||||
//! config descriptor section which contains the requested interface
|
||||
//! descriptor.
|
||||
//!
|
||||
//! Return a pointer to the n-th interface descriptor found in the supplied
|
||||
//! configuration descriptor. If \e ui32Alt is not \b USB_DESC_ANY, only
|
||||
//! interface descriptors which are part of the supplied alternate setting are
|
||||
//! considered in the search otherwise all interface descriptors are
|
||||
//! considered.
|
||||
//!
|
||||
//! Note that, although alternate settings can be applied on an interface-by-
|
||||
//! interface basis, the number of interfaces offered is fixed for a given
|
||||
//! config descriptor. Hence, this function will correctly find the unique
|
||||
//! interface descriptor for that interface's alternate setting number \e
|
||||
//! ui32Alt if \e ui32Index is set to the required interface number and
|
||||
//! \e ui32Alt is set to a valid alternate setting number for that interface.
|
||||
//!
|
||||
//! The search performed by this function traverses through the list of
|
||||
//! sections comprising the configuration descriptor. Note that the similar
|
||||
//! top-level function, USBDescGetInterface(), searches through a single,
|
||||
//! contiguous block of data to perform the same enumeration.
|
||||
//!
|
||||
//! \return Returns a pointer to the required interface descriptor if
|
||||
//! found or NULL otherwise.
|
||||
//
|
||||
//*****************************************************************************
|
||||
tInterfaceDescriptor *
|
||||
USBDCDConfigGetInterface(const tConfigHeader *psConfig, uint32_t ui32Index,
|
||||
uint32_t ui32Alt, uint32_t *pui32Section)
|
||||
{
|
||||
//
|
||||
// If we are being told to ignore the alternate configuration, this boils
|
||||
// down to a very simple query.
|
||||
//
|
||||
if(ui32Alt == USB_DESC_ANY)
|
||||
{
|
||||
//
|
||||
// Return the ui32Index-th interface descriptor we find in the
|
||||
// configuration descriptor.
|
||||
//
|
||||
return((tInterfaceDescriptor *)USBDCDConfigDescGet(psConfig,
|
||||
USB_DTYPE_INTERFACE,
|
||||
ui32Index,
|
||||
pui32Section));
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
// In this case, a specific alternate setting number is required.
|
||||
// Given that interface numbers are zero based indices, we can
|
||||
// pass the supplied ui32Index parameter directly as the interface
|
||||
// number to USBDescGetAlternateInterface() to retrieve the requested
|
||||
// interface descriptor pointer.
|
||||
//
|
||||
return(ConfigAlternateInterfaceGet(psConfig, ui32Index, ui32Alt,
|
||||
pui32Section));
|
||||
}
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! \internal
|
||||
//!
|
||||
//! Return a pointer to the n-th endpoint descriptor in a particular interface
|
||||
//! within a configuration descriptor.
|
||||
//!
|
||||
//! \param psConfig points to the header structure for the configuration
|
||||
//! descriptor that is to be searched.
|
||||
//! \param ui32InterfaceNumber is the interface number whose endpoint is to be
|
||||
//! found.
|
||||
//! \param ui32AltCfg is the alternate setting number which is to be searched
|
||||
//! for. This must be a valid alternate setting number for the requested
|
||||
//! interface.
|
||||
//! \param ui32Index is the zero based index of the endpoint that is to be
|
||||
//! found within the appropriate alternate setting for the interface.
|
||||
//!
|
||||
//! Return a pointer to the n-th endpoint descriptor found in the supplied
|
||||
//! interface descriptor. If the \e ui32Index parameter is invalid (greater
|
||||
//! than or equal to the bNumEndpoints field of the interface descriptor) or
|
||||
//! the endpoint descriptor cannot be found, the function will return NULL.
|
||||
//!
|
||||
//! The search performed by this function traverses through the list of
|
||||
//! sections comprising the configuration descriptor. Note that the similar
|
||||
//! top-level function, USBDescGetInterfaceEndpoint(), searches through a
|
||||
//! single, contiguous block of data to perform the same enumeration.
|
||||
//!
|
||||
//! \return Returns a pointer to the requested endpoint descriptor if
|
||||
//! found or NULL otherwise.
|
||||
//
|
||||
//*****************************************************************************
|
||||
tEndpointDescriptor *
|
||||
USBDCDConfigGetInterfaceEndpoint(const tConfigHeader *psConfig,
|
||||
uint32_t ui32InterfaceNumber,
|
||||
uint32_t ui32AltCfg, uint32_t ui32Index)
|
||||
{
|
||||
tInterfaceDescriptor *psInterface;
|
||||
tDescriptorHeader *psEndpoint;
|
||||
uint32_t ui32Section, ui32Count;
|
||||
|
||||
//
|
||||
// Find the requested interface descriptor.
|
||||
//
|
||||
psInterface = USBDCDConfigGetInterface(psConfig, ui32InterfaceNumber,
|
||||
ui32AltCfg, &ui32Section);
|
||||
|
||||
//
|
||||
// Did we find the requested interface?
|
||||
//
|
||||
if(psInterface)
|
||||
{
|
||||
//
|
||||
// Is the index passed valid?
|
||||
//
|
||||
if(ui32Index >= psInterface->bNumEndpoints)
|
||||
{
|
||||
//
|
||||
// It's out of bounds so return a NULL.
|
||||
//
|
||||
return((tEndpointDescriptor *)0);
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
// Endpoint index is valid so find the descriptor. We start from
|
||||
// the interface descriptor and look for following endpoint
|
||||
// descriptors.
|
||||
//
|
||||
ui32Count = 0;
|
||||
psEndpoint = (tDescriptorHeader *)psInterface;
|
||||
|
||||
while(psEndpoint)
|
||||
{
|
||||
if(psEndpoint->bDescriptorType == USB_DTYPE_ENDPOINT)
|
||||
{
|
||||
//
|
||||
// We found an endpoint descriptor. Have we reached the
|
||||
// one we want?
|
||||
//
|
||||
if(ui32Count == ui32Index)
|
||||
{
|
||||
//
|
||||
// Yes - return the descriptor pointer to the caller.
|
||||
//
|
||||
return((tEndpointDescriptor *)psEndpoint);
|
||||
}
|
||||
|
||||
//
|
||||
// Move on to look for the next endpoint.
|
||||
//
|
||||
ui32Count++;
|
||||
}
|
||||
|
||||
//
|
||||
// Move to the next descriptor.
|
||||
//
|
||||
psEndpoint = NextConfigDescGet(psConfig, &ui32Section,
|
||||
psEndpoint);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// We could not find the requested interface or we got to the end of the
|
||||
// descriptor without finding the requested endpoint.
|
||||
//
|
||||
return((tEndpointDescriptor *)0);
|
||||
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Close the Doxygen group.
|
||||
//! @}
|
||||
//
|
||||
//*****************************************************************************
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,260 @@
|
|||
//*****************************************************************************
|
||||
//
|
||||
// usbdcomp.h - USB composite device class driver.
|
||||
//
|
||||
// Copyright (c) 2010-2013 Texas Instruments Incorporated. All rights reserved.
|
||||
// Software License Agreement
|
||||
//
|
||||
// Texas Instruments (TI) is supplying this software for use solely and
|
||||
// exclusively on TI's microcontroller products. The software is owned by
|
||||
// TI and/or its suppliers, and is protected under applicable copyright
|
||||
// laws. You may not combine this software with "viral" open-source
|
||||
// software in order to form a larger program.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
|
||||
// NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
|
||||
// NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
|
||||
// CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
|
||||
// DAMAGES, FOR ANY REASON WHATSOEVER.
|
||||
//
|
||||
// This is part of revision 1.1 of the Tiva USB Library.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
#ifndef __USBDCOMP_H__
|
||||
#define __USBDCOMP_H__
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// If building with a C++ compiler, make all of the definitions in this header
|
||||
// have a C binding.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Return to default packing when using the IAR Embedded Workbench compiler.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#ifdef ewarm
|
||||
#pragma pack()
|
||||
#endif
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! \addtogroup composite_device_class_api
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//
|
||||
// Defines a single entry in a table of device types supported by the composite
|
||||
// device.
|
||||
//
|
||||
typedef struct
|
||||
{
|
||||
//
|
||||
// This is set internally by the composite class so it can be left
|
||||
// uninitialized by the application.
|
||||
//
|
||||
const tDeviceInfo *psDeviceInfo;
|
||||
|
||||
//
|
||||
// This should be the header to the configuration header for a class.
|
||||
//
|
||||
const tConfigHeader *psConfigHeader;
|
||||
|
||||
//
|
||||
// The offset to this devices interface, filled in by the composite class.
|
||||
//
|
||||
uint8_t ui8IfaceOffset;
|
||||
}
|
||||
tUSBDCompositeEntry;
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// PRIVATE
|
||||
//
|
||||
// This structure defines the private instance data and state variables for the
|
||||
// composite device class. The memory for this structure is included in
|
||||
// the sPrivateData field in the tUSBDCompositeDevice structure passed on
|
||||
// USBDCompositeInit() and should not be modified by any code outside of the
|
||||
// composite device code.
|
||||
//
|
||||
//*****************************************************************************
|
||||
typedef struct
|
||||
{
|
||||
//
|
||||
// Saves which USB controller is in use.
|
||||
//
|
||||
uint32_t ui32USBBase;
|
||||
|
||||
//
|
||||
// The device information pointer.
|
||||
//
|
||||
tDeviceInfo sDevInfo;
|
||||
|
||||
//
|
||||
// This is the configuration descriptor for this instance.
|
||||
//
|
||||
tConfigDescriptor sConfigDescriptor;
|
||||
|
||||
//
|
||||
// This is the device descriptor for this instance.
|
||||
//
|
||||
tDeviceDescriptor sDeviceDescriptor;
|
||||
|
||||
//
|
||||
// The configuration header for this instance.
|
||||
//
|
||||
tConfigHeader sCompConfigHeader;
|
||||
|
||||
//
|
||||
// These are the configuration sections that will be built from the
|
||||
// Configuration Descriptor header and the descriptors from the devices
|
||||
// that are part of this composite device.
|
||||
//
|
||||
tConfigSection psCompSections[2];
|
||||
tConfigSection *ppsCompSections[2];
|
||||
|
||||
//
|
||||
// The size and pointer to the data used by the instance.
|
||||
//
|
||||
uint32_t ui32DataSize;
|
||||
uint8_t *pui8Data;
|
||||
|
||||
//
|
||||
// The current "owner" of endpoint 0. This is used to track the device
|
||||
// class which is currently transferring data on EP0.
|
||||
//
|
||||
uint32_t ui32EP0Owner;
|
||||
}
|
||||
tCompositeInstance;
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! The structure used by the application to define operating parameters for
|
||||
//! the composite device class.
|
||||
//
|
||||
//*****************************************************************************
|
||||
typedef struct
|
||||
{
|
||||
//
|
||||
//! The vendor ID that this device is to present in the device descriptor.
|
||||
//
|
||||
const uint16_t ui16VID;
|
||||
|
||||
//
|
||||
//! The product ID that this device is to present in the device descriptor.
|
||||
//
|
||||
const uint16_t ui16PID;
|
||||
|
||||
//
|
||||
//! The maximum power consumption of the device, expressed in mA.
|
||||
//
|
||||
const uint16_t ui16MaxPowermA;
|
||||
|
||||
//
|
||||
//! Indicates whether the device is self or bus-powered and whether or not
|
||||
//! it supports remote wake up. Valid values are USB_CONF_ATTR_SELF_PWR or
|
||||
//! USB_CONF_ATTR_BUS_PWR, optionally ORed with USB_CONF_ATTR_RWAKE.
|
||||
//
|
||||
const uint8_t ui8PwrAttributes;
|
||||
|
||||
//
|
||||
//! A pointer to the callback function which will be called to notify
|
||||
//! the application of events relating to the operation of the composite
|
||||
//! device.
|
||||
//
|
||||
const tUSBCallback pfnCallback;
|
||||
|
||||
//
|
||||
//! A pointer to the string descriptor array for this device. This array
|
||||
//! must contain the following string descriptor pointers in this order.
|
||||
//! Language descriptor, Manufacturer name string (language 1), Product
|
||||
//! name string (language 1), Serial number string (language 1), Composite
|
||||
//! device interface description string (language 1), Configuration
|
||||
//! description string (language 1).
|
||||
//!
|
||||
//! If supporting more than 1 language, the descriptor block (except for
|
||||
//! string descriptor 0) must be repeated for each language defined in the
|
||||
//! language descriptor.
|
||||
//!
|
||||
//
|
||||
const uint8_t * const *ppui8StringDescriptors;
|
||||
|
||||
//
|
||||
//! The number of descriptors provided in the ppStringDescriptors
|
||||
//! array. This must be 1 + ((5 + (number of strings)) *
|
||||
//! (number of languages)).
|
||||
//
|
||||
const uint32_t ui32NumStringDescriptors;
|
||||
|
||||
//
|
||||
//! The number of devices in the psDevices array.
|
||||
//
|
||||
const uint32_t ui32NumDevices;
|
||||
|
||||
//
|
||||
//! This application supplied array holds the the top level device class
|
||||
//! information as well as the Instance data for that class.
|
||||
//
|
||||
tCompositeEntry * const psDevices;
|
||||
|
||||
//
|
||||
//! The private data for this device instance. This memory must remain
|
||||
//! accessible for as long as the composite device is in use and must
|
||||
//! not be modified by any code outside the composite class driver.
|
||||
//
|
||||
tCompositeInstance sPrivateData;
|
||||
}
|
||||
tUSBDCompositeDevice;
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Return to default packing when using the IAR Embedded Workbench compiler.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#ifdef ewarm
|
||||
#pragma pack()
|
||||
#endif
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Composite specific device class driver events
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// API Function Prototypes
|
||||
//
|
||||
//*****************************************************************************
|
||||
extern void *USBDCompositeInit(uint32_t ui32Index,
|
||||
tUSBDCompositeDevice *psCompDevice,
|
||||
uint32_t ui32Size, uint8_t *pui8Data);
|
||||
extern void USBDCompositeTerm(void *pvInstance);
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Close the Doxygen group.
|
||||
//! @}
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Mark the end of the C bindings section for C++ compilers.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,562 @@
|
|||
//*****************************************************************************
|
||||
//
|
||||
// usbdconfig.c - High level USB device configuration function.
|
||||
//
|
||||
// Copyright (c) 2008-2013 Texas Instruments Incorporated. All rights reserved.
|
||||
// Software License Agreement
|
||||
//
|
||||
// Texas Instruments (TI) is supplying this software for use solely and
|
||||
// exclusively on TI's microcontroller products. The software is owned by
|
||||
// TI and/or its suppliers, and is protected under applicable copyright
|
||||
// laws. You may not combine this software with "viral" open-source
|
||||
// software in order to form a larger program.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
|
||||
// NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
|
||||
// NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
|
||||
// CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
|
||||
// DAMAGES, FOR ANY REASON WHATSOEVER.
|
||||
//
|
||||
// This is part of revision 1.1 of the Tiva USB Library.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "inc/hw_memmap.h"
|
||||
#include "inc/hw_types.h"
|
||||
#include "driverlib/debug.h"
|
||||
#include "driverlib/usbdrv.h"
|
||||
#include "usblib/usblib.h"
|
||||
#include "usblib/usblibpriv.h"
|
||||
#include "usblib/device/usbdevice.h"
|
||||
#include "usblib/device/usbdevicepriv.h"
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! \addtogroup device_api
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Structure used in compiling FIFO size and endpoint properties from a
|
||||
// configuration descriptor.
|
||||
//
|
||||
//*****************************************************************************
|
||||
typedef struct
|
||||
{
|
||||
uint32_t pui32Size[2];
|
||||
}
|
||||
tUSBEndpointInfo;
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Indices used when accessing the tUSBEndpointInfo structure.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define EP_INFO_IN 0
|
||||
#define EP_INFO_OUT 1
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Given a maximum packet size and the user's FIFO scaling requirements,
|
||||
// determine the flags to use to configure the endpoint FIFO and the number
|
||||
// of bytes of FIFO space occupied.
|
||||
//
|
||||
//*****************************************************************************
|
||||
static uint32_t
|
||||
GetEndpointFIFOSize(uint32_t ui32MaxPktSize, uint32_t *pupBytesUsed)
|
||||
{
|
||||
uint32_t ui32Loop, ui32FIFOSize;
|
||||
|
||||
//
|
||||
// Now we need to find the nearest supported size that accommodates the
|
||||
// requested size. Step through each of the supported sizes until we
|
||||
// find one that will do.
|
||||
//
|
||||
for(ui32Loop = USB_FIFO_SZ_8; ui32Loop <= USB_FIFO_SZ_2048; ui32Loop++)
|
||||
{
|
||||
//
|
||||
// How many bytes does this FIFO value represent?
|
||||
//
|
||||
ui32FIFOSize = USBFIFOSizeToBytes(ui32Loop);
|
||||
|
||||
//
|
||||
// Is this large enough to hold one packet.
|
||||
//
|
||||
if(ui32FIFOSize >= ui32MaxPktSize)
|
||||
{
|
||||
//
|
||||
// Return the FIFO size setting and the USB_FIFO_SZ_ value.
|
||||
//
|
||||
*pupBytesUsed = ui32FIFOSize;
|
||||
|
||||
return(ui32Loop);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// If we drop out, we can't support the FIFO size requested. Signal a
|
||||
// problem by returning 0 in the pBytesUsed
|
||||
//
|
||||
*pupBytesUsed = 0;
|
||||
|
||||
return(USB_FIFO_SZ_8);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Translate a USB endpoint descriptor into the values we need to pass to the
|
||||
// USBDevEndpointConfigSet() API.
|
||||
//
|
||||
//*****************************************************************************
|
||||
static void
|
||||
GetEPDescriptorType(tEndpointDescriptor *psEndpoint, uint32_t *pui32EPIndex,
|
||||
uint32_t *pui32MaxPktSize, uint32_t *pui32Flags)
|
||||
{
|
||||
//
|
||||
// Get the endpoint index.
|
||||
//
|
||||
*pui32EPIndex = psEndpoint->bEndpointAddress & USB_EP_DESC_NUM_M;
|
||||
|
||||
//
|
||||
// Extract the maximum packet size.
|
||||
//
|
||||
*pui32MaxPktSize = psEndpoint->wMaxPacketSize & USB_EP_MAX_PACKET_COUNT_M;
|
||||
|
||||
//
|
||||
// Is this an IN or an OUT endpoint?
|
||||
//
|
||||
*pui32Flags = (psEndpoint->bEndpointAddress & USB_EP_DESC_IN) ?
|
||||
USB_EP_DEV_IN : USB_EP_DEV_OUT;
|
||||
|
||||
//
|
||||
// Set the endpoint mode.
|
||||
//
|
||||
switch(psEndpoint->bmAttributes & USB_EP_ATTR_TYPE_M)
|
||||
{
|
||||
case USB_EP_ATTR_CONTROL:
|
||||
{
|
||||
*pui32Flags |= USB_EP_MODE_CTRL;
|
||||
break;
|
||||
}
|
||||
case USB_EP_ATTR_BULK:
|
||||
{
|
||||
*pui32Flags |= USB_EP_MODE_BULK;
|
||||
break;
|
||||
}
|
||||
case USB_EP_ATTR_INT:
|
||||
{
|
||||
*pui32Flags |= USB_EP_MODE_INT;
|
||||
break;
|
||||
}
|
||||
case USB_EP_ATTR_ISOC:
|
||||
{
|
||||
*pui32Flags |= USB_EP_MODE_ISOC;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! Configure the USB controller appropriately for the device whose
|
||||
//! configuration descriptor is passed.
|
||||
//!
|
||||
//! \param psDevInst is a pointer to the device instance being configured.
|
||||
//! \param psConfig is a pointer to the configuration descriptor that the
|
||||
//! USB controller is to be set up to support.
|
||||
//!
|
||||
//! This function may be used to initialize a USB controller to operate as
|
||||
//! the device whose configuration descriptor is passed. The function
|
||||
//! enables the USB controller, partitions the FIFO appropriately and
|
||||
//! configures each endpoint required by the configuration. If the supplied
|
||||
//! configuration supports multiple alternate settings for any interface,
|
||||
//! the USB FIFO is set up assuming the worst case use (largest packet size
|
||||
//! for a given endpoint in any alternate setting using that endpoint) to
|
||||
//! allow for on-the-fly alternate setting changes later. On return from this
|
||||
//! function, the USB controller is configured for correct operation of
|
||||
//! the default configuration of the device described by the descriptor passed.
|
||||
//!
|
||||
//! USBDCDConfig() is an optional call and applications may chose to make
|
||||
//! direct calls to SysCtlPeripheralEnable(), SysCtlUSBPLLEnable(),
|
||||
//! USBDevEndpointConfigSet() and USBFIFOConfigSet() instead of using this
|
||||
//! function. If this function is used, it must be called prior to
|
||||
//! USBDCDInit() since this call assumes that the low level hardware
|
||||
//! configuration has been completed before it is made.
|
||||
//!
|
||||
//! \return Returns \b true on success or \b false on failure.
|
||||
//
|
||||
//*****************************************************************************
|
||||
bool
|
||||
USBDeviceConfig(tDCDInstance *psDevInst, const tConfigHeader *psConfig)
|
||||
{
|
||||
uint32_t ui32Loop, ui32Count, ui32NumInterfaces, ui32EpIndex, ui32EpType,
|
||||
ui32MaxPkt, ui32NumEndpoints, ui32Flags, ui32BytesUsed,
|
||||
ui32Section;
|
||||
tInterfaceDescriptor *psInterface;
|
||||
tEndpointDescriptor *psEndpoint;
|
||||
tUSBEndpointInfo psEPInfo[NUM_USB_EP - 1];
|
||||
|
||||
//
|
||||
// A valid device instance is required.
|
||||
//
|
||||
ASSERT(psDevInst != 0);
|
||||
|
||||
//
|
||||
// Catch bad pointers in a debug build.
|
||||
//
|
||||
ASSERT(psConfig);
|
||||
|
||||
//
|
||||
// Clear out our endpoint info.
|
||||
//
|
||||
for(ui32Loop = 0; ui32Loop < (NUM_USB_EP - 1); ui32Loop++)
|
||||
{
|
||||
psEPInfo[ui32Loop].pui32Size[EP_INFO_IN] = 0;
|
||||
psEPInfo[ui32Loop].pui32Size[EP_INFO_OUT] = 0;
|
||||
}
|
||||
|
||||
//
|
||||
// How many (total) endpoints does this configuration describe?
|
||||
//
|
||||
ui32NumEndpoints = USBDCDConfigDescGetNum(psConfig,
|
||||
USB_DTYPE_ENDPOINT);
|
||||
|
||||
//
|
||||
// How many interfaces are included?
|
||||
//
|
||||
ui32NumInterfaces = USBDCDConfigDescGetNum(psConfig,
|
||||
USB_DTYPE_INTERFACE);
|
||||
|
||||
//
|
||||
// Look at each endpoint and determine the largest max packet size for
|
||||
// each endpoint. This will determine how we partition the USB FIFO.
|
||||
//
|
||||
for(ui32Loop = 0; ui32Loop < ui32NumEndpoints; ui32Loop++)
|
||||
{
|
||||
//
|
||||
// Get a pointer to the endpoint descriptor.
|
||||
//
|
||||
psEndpoint = (tEndpointDescriptor *)USBDCDConfigDescGet(
|
||||
psConfig, USB_DTYPE_ENDPOINT, ui32Loop,
|
||||
&ui32Section);
|
||||
|
||||
//
|
||||
// Extract the endpoint number and whether it is an IN or OUT
|
||||
// endpoint.
|
||||
//
|
||||
ui32EpIndex = (uint32_t)
|
||||
psEndpoint->bEndpointAddress & USB_EP_DESC_NUM_M;
|
||||
ui32EpType = (psEndpoint->bEndpointAddress & USB_EP_DESC_IN) ?
|
||||
EP_INFO_IN : EP_INFO_OUT;
|
||||
|
||||
//
|
||||
// Make sure the endpoint number is valid for our controller. If not,
|
||||
// return false to indicate an error. Note that 0 is invalid since
|
||||
// you shouldn't reference endpoint 0 in the config descriptor.
|
||||
//
|
||||
if((ui32EpIndex >= NUM_USB_EP) || (ui32EpIndex == 0))
|
||||
{
|
||||
return(false);
|
||||
}
|
||||
|
||||
//
|
||||
// Does this endpoint have a max packet size requirement larger than
|
||||
// any previous use we have seen?
|
||||
//
|
||||
if(psEndpoint->wMaxPacketSize >
|
||||
psEPInfo[ui32EpIndex - 1].pui32Size[ui32EpType])
|
||||
{
|
||||
//
|
||||
// Yes - remember the new maximum packet size.
|
||||
//
|
||||
psEPInfo[ui32EpIndex - 1].pui32Size[ui32EpType] =
|
||||
psEndpoint->wMaxPacketSize;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// At this point, we have determined the maximum packet size required
|
||||
// for each endpoint by any possible alternate setting of any interface
|
||||
// in this configuration. Now determine the endpoint settings required
|
||||
// for the interface setting we are actually going to use.
|
||||
//
|
||||
for(ui32Loop = 0; ui32Loop < ui32NumInterfaces; ui32Loop++)
|
||||
{
|
||||
//
|
||||
// Get the next interface descriptor in the configuration descriptor.
|
||||
//
|
||||
psInterface = USBDCDConfigGetInterface(psConfig, ui32Loop,
|
||||
USB_DESC_ANY, &ui32Section);
|
||||
|
||||
//
|
||||
// Is this the default interface (bAlternateSetting set to 0)?
|
||||
//
|
||||
if(psInterface && (psInterface->bAlternateSetting == 0))
|
||||
{
|
||||
//
|
||||
// This is an interface we are interested in so gather the
|
||||
// information on its endpoints.
|
||||
//
|
||||
ui32NumEndpoints = (uint32_t)psInterface->bNumEndpoints;
|
||||
|
||||
//
|
||||
// Walk through each endpoint in this interface and configure
|
||||
// it appropriately.
|
||||
//
|
||||
for(ui32Count = 0; ui32Count < ui32NumEndpoints; ui32Count++)
|
||||
{
|
||||
//
|
||||
// Get a pointer to the endpoint descriptor.
|
||||
//
|
||||
psEndpoint = USBDCDConfigGetInterfaceEndpoint(psConfig,
|
||||
psInterface->bInterfaceNumber,
|
||||
psInterface->bAlternateSetting,
|
||||
ui32Count);
|
||||
|
||||
//
|
||||
// Make sure we got a good pointer.
|
||||
//
|
||||
if(psEndpoint)
|
||||
{
|
||||
//
|
||||
// Determine maximum packet size and flags from the
|
||||
// endpoint descriptor.
|
||||
//
|
||||
GetEPDescriptorType(psEndpoint, &ui32EpIndex, &ui32MaxPkt,
|
||||
&ui32Flags);
|
||||
|
||||
//
|
||||
// Make sure no-one is trying to configure endpoint 0.
|
||||
//
|
||||
if(!ui32EpIndex)
|
||||
{
|
||||
return(false);
|
||||
}
|
||||
|
||||
//
|
||||
// Set the endpoint configuration.
|
||||
//
|
||||
USBDevEndpointConfigSet(USB0_BASE,
|
||||
IndexToUSBEP(ui32EpIndex),
|
||||
ui32MaxPkt, ui32Flags);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// At this point, we have configured all the endpoints that are to be
|
||||
// used by this configuration's alternate setting 0. Now we go on and
|
||||
// partition the FIFO based on the maximum packet size information we
|
||||
// extracted earlier. Endpoint 0 is automatically configured to use the
|
||||
// first MAX_PACKET_SIZE_EP0 bytes of the FIFO so we start from there.
|
||||
//
|
||||
ui32Count = MAX_PACKET_SIZE_EP0;
|
||||
for(ui32Loop = 1; ui32Loop < NUM_USB_EP; ui32Loop++)
|
||||
{
|
||||
//
|
||||
// Configure the IN endpoint at this index if it is referred to
|
||||
// anywhere.
|
||||
//
|
||||
if(psEPInfo[ui32Loop - 1].pui32Size[EP_INFO_IN])
|
||||
{
|
||||
//
|
||||
// What FIFO size flag do we use for this endpoint?
|
||||
//
|
||||
ui32MaxPkt = GetEndpointFIFOSize(
|
||||
psEPInfo[ui32Loop - 1].pui32Size[EP_INFO_IN],
|
||||
&ui32BytesUsed);
|
||||
|
||||
//
|
||||
// The FIFO space could not be allocated.
|
||||
//
|
||||
if(ui32BytesUsed == 0)
|
||||
{
|
||||
return(false);
|
||||
}
|
||||
|
||||
//
|
||||
// Now actually configure the FIFO for this endpoint.
|
||||
//
|
||||
USBFIFOConfigSet(USB0_BASE, IndexToUSBEP(ui32Loop), ui32Count,
|
||||
ui32MaxPkt, USB_EP_DEV_IN);
|
||||
ui32Count += ui32BytesUsed;
|
||||
}
|
||||
|
||||
//
|
||||
// Configure the OUT endpoint at this index.
|
||||
//
|
||||
if(psEPInfo[ui32Loop - 1].pui32Size[EP_INFO_OUT])
|
||||
{
|
||||
//
|
||||
// What FIFO size flag do we use for this endpoint?
|
||||
//
|
||||
ui32MaxPkt = GetEndpointFIFOSize(
|
||||
psEPInfo[ui32Loop - 1].pui32Size[EP_INFO_OUT],
|
||||
&ui32BytesUsed);
|
||||
|
||||
//
|
||||
// The FIFO space could not be allocated.
|
||||
//
|
||||
if(ui32BytesUsed == 0)
|
||||
{
|
||||
return(false);
|
||||
}
|
||||
|
||||
//
|
||||
// Now actually configure the FIFO for this endpoint.
|
||||
//
|
||||
USBFIFOConfigSet(USB0_BASE, IndexToUSBEP(ui32Loop), ui32Count,
|
||||
ui32MaxPkt, USB_EP_DEV_OUT);
|
||||
ui32Count += ui32BytesUsed;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// If we get to the end, all is well.
|
||||
//
|
||||
return(true);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! Configure the affected USB endpoints appropriately for one alternate
|
||||
//! interface setting.
|
||||
//!
|
||||
//! \param psDevInst is a pointer to the device instance being configured.
|
||||
//! \param psConfig is a pointer to the configuration descriptor that contains
|
||||
//! the interface whose alternate settings is to be configured.
|
||||
//! \param ui8InterfaceNum is the number of the interface whose alternate
|
||||
//! setting is to be configured. This number corresponds to the
|
||||
//! bInterfaceNumber field in the desired interface descriptor.
|
||||
//! \param ui8AlternateSetting is the alternate setting number for the desired
|
||||
//! interface. This number corresponds to the bAlternateSetting field in the
|
||||
//! desired interface descriptor.
|
||||
//!
|
||||
//! This function may be used to reconfigure the endpoints of an interface
|
||||
//! for operation in one of the interface's alternate settings. Note that this
|
||||
//! function assumes that the endpoint FIFO settings will not need to change
|
||||
//! and only the endpoint mode is changed. This assumption is valid if the
|
||||
//! USB controller was initialized using a previous call to USBDCDConfig().
|
||||
//!
|
||||
//! In reconfiguring the interface endpoints, any additional configuration
|
||||
//! bits set in the endpoint configuration other than the direction (\b
|
||||
//! USB_EP_DEV_IN or \b USB_EP_DEV_OUT) and mode (\b USB_EP_MODE_MASK) are
|
||||
//! preserved.
|
||||
//!
|
||||
//! \return Returns \b true on success or \b false on failure.
|
||||
//
|
||||
//*****************************************************************************
|
||||
bool
|
||||
USBDeviceConfigAlternate(tDCDInstance *psDevInst,
|
||||
const tConfigHeader *psConfig,
|
||||
uint8_t ui8InterfaceNum,
|
||||
uint8_t ui8AlternateSetting)
|
||||
{
|
||||
uint32_t ui32NumInterfaces, ui32NumEndpoints, ui32Loop, ui32Count,
|
||||
ui32MaxPkt, ui32Flags, ui32Section, ui32EpIndex;
|
||||
tInterfaceDescriptor *psInterface;
|
||||
tEndpointDescriptor *psEndpoint;
|
||||
|
||||
//
|
||||
// How many interfaces are included in the descriptor?
|
||||
//
|
||||
ui32NumInterfaces = USBDCDConfigDescGetNum(psConfig,
|
||||
USB_DTYPE_INTERFACE);
|
||||
|
||||
//
|
||||
// Find the interface descriptor for the supplied interface and alternate
|
||||
// setting numbers.
|
||||
//
|
||||
|
||||
for(ui32Loop = 0; ui32Loop < ui32NumInterfaces; ui32Loop++)
|
||||
{
|
||||
//
|
||||
// Get the next interface descriptor in the configuration descriptor.
|
||||
//
|
||||
psInterface = USBDCDConfigGetInterface(psConfig, ui32Loop,
|
||||
USB_DESC_ANY, &ui32Section);
|
||||
|
||||
//
|
||||
// Is this the default interface (bAlternateSetting set to 0)?
|
||||
//
|
||||
if(psInterface &&
|
||||
(psInterface->bInterfaceNumber == ui8InterfaceNum) &&
|
||||
(psInterface->bAlternateSetting == ui8AlternateSetting))
|
||||
{
|
||||
//
|
||||
// This is an interface we are interested in and the descriptor
|
||||
// representing the alternate setting we want so go ahead and
|
||||
// reconfigure the endpoints.
|
||||
//
|
||||
|
||||
//
|
||||
// How many endpoints does this interface have?
|
||||
//
|
||||
ui32NumEndpoints = (uint32_t)psInterface->bNumEndpoints;
|
||||
|
||||
//
|
||||
// Walk through each endpoint in turn.
|
||||
//
|
||||
for(ui32Count = 0; ui32Count < ui32NumEndpoints; ui32Count++)
|
||||
{
|
||||
//
|
||||
// Get a pointer to the endpoint descriptor.
|
||||
//
|
||||
psEndpoint = USBDCDConfigGetInterfaceEndpoint(psConfig,
|
||||
psInterface->bInterfaceNumber,
|
||||
psInterface->bAlternateSetting,
|
||||
ui32Count);
|
||||
|
||||
//
|
||||
// Make sure we got a good pointer.
|
||||
//
|
||||
if(psEndpoint)
|
||||
{
|
||||
//
|
||||
// Determine maximum packet size and flags from the
|
||||
// endpoint descriptor.
|
||||
//
|
||||
GetEPDescriptorType(psEndpoint, &ui32EpIndex, &ui32MaxPkt,
|
||||
&ui32Flags);
|
||||
|
||||
//
|
||||
// Make sure no-one is trying to configure endpoint 0.
|
||||
//
|
||||
if(!ui32EpIndex)
|
||||
{
|
||||
return(false);
|
||||
}
|
||||
|
||||
//
|
||||
// Set the endpoint configuration.
|
||||
//
|
||||
USBDevEndpointConfigSet(USB0_BASE,
|
||||
IndexToUSBEP(ui32EpIndex),
|
||||
ui32MaxPkt, ui32Flags);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// At this point, we have reconfigured the desired interface so
|
||||
// return indicating all is well.
|
||||
//
|
||||
return(true);
|
||||
}
|
||||
}
|
||||
|
||||
return(false);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Close the Doxygen group.
|
||||
//! @}
|
||||
//
|
||||
//*****************************************************************************
|
|
@ -0,0 +1,661 @@
|
|||
//*****************************************************************************
|
||||
//
|
||||
// usbddfu-rt.c - USB Device Firmware Update runtime device class driver.
|
||||
//
|
||||
// Copyright (c) 2010-2013 Texas Instruments Incorporated. All rights reserved.
|
||||
// Software License Agreement
|
||||
//
|
||||
// Texas Instruments (TI) is supplying this software for use solely and
|
||||
// exclusively on TI's microcontroller products. The software is owned by
|
||||
// TI and/or its suppliers, and is protected under applicable copyright
|
||||
// laws. You may not combine this software with "viral" open-source
|
||||
// software in order to form a larger program.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
|
||||
// NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
|
||||
// NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
|
||||
// CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
|
||||
// DAMAGES, FOR ANY REASON WHATSOEVER.
|
||||
//
|
||||
// This is part of revision 1.1 of the Tiva USB Library.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "inc/hw_memmap.h"
|
||||
#include "inc/hw_types.h"
|
||||
#include "inc/hw_nvic.h"
|
||||
#include "driverlib/debug.h"
|
||||
#include "driverlib/usbdrv.h"
|
||||
#include "driverlib/sysctl.h"
|
||||
#include "driverlib/systick.h"
|
||||
#include "driverlib/interrupt.h"
|
||||
#include "driverlib/rom.h"
|
||||
#include "driverlib/rom_map.h"
|
||||
#include "usblib/usblib.h"
|
||||
#include "usblib/usblibpriv.h"
|
||||
#include "usblib/usbdfu.h"
|
||||
#include "usblib/usb-ids.h"
|
||||
#include "usblib/device/usbdevice.h"
|
||||
#include "usblib/device/usbddfu-rt.h"
|
||||
#include "usblib/usblibpriv.h"
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! \addtogroup dfu_device_class_api
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// DFU Device Descriptor. This is a dummy structure since runtime DFU must be
|
||||
// a part of a composite device and cannot be instantiated on its own.
|
||||
//
|
||||
//*****************************************************************************
|
||||
const uint8_t g_pui8DFUDeviceDescriptor[] =
|
||||
{
|
||||
18, // Size of this structure.
|
||||
USB_DTYPE_DEVICE, // Type of this structure.
|
||||
USBShort(0x110), // USB version 1.1 (if we say 2.0, hosts
|
||||
// assume
|
||||
// high-speed - see USB 2.0 spec 9.2.6.6)
|
||||
USB_CLASS_VEND_SPECIFIC, // USB Device Class
|
||||
0, // USB Device Sub-class
|
||||
0, // USB Device protocol
|
||||
64, // Maximum packet size for default pipe.
|
||||
USBShort(0), // Vendor ID (VID).
|
||||
USBShort(0), // Product ID (PID).
|
||||
USBShort(0), // Device Release Number BCD.
|
||||
0, // Manufacturer string identifier.
|
||||
0, // Product string identifier.
|
||||
0, // Product serial number.
|
||||
1 // Number of configurations.
|
||||
};
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// DFU device runtime configuration descriptor. This is also a dummy structure
|
||||
// since the primary device class configuration will be used when DFU is added
|
||||
// to the composite device.
|
||||
//
|
||||
//*****************************************************************************
|
||||
uint8_t g_pui8DFUConfigDescriptor[] =
|
||||
{
|
||||
//
|
||||
// Configuration descriptor header.
|
||||
//
|
||||
9, // Size of the configuration descriptor.
|
||||
USB_DTYPE_CONFIGURATION, // Type of this descriptor.
|
||||
USBShort(27), // The total size of this full structure.
|
||||
1, // The number of interfaces in this
|
||||
// configuration.
|
||||
1, // The unique value for this configuration.
|
||||
0, // The string identifier that describes
|
||||
// this configuration.
|
||||
USB_CONF_ATTR_SELF_PWR, // Bus Powered, Self Powered, remote wake
|
||||
// up.
|
||||
250, // The maximum power in 2mA increments.
|
||||
};
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// The DFU runtime interface descriptor.
|
||||
//
|
||||
//*****************************************************************************
|
||||
uint8_t g_pui8DFUInterface[DFUINTERFACE_SIZE] =
|
||||
{
|
||||
//
|
||||
// Interface descriptor for runtime DFU operation.
|
||||
//
|
||||
9, // Length of this descriptor.
|
||||
USB_DTYPE_INTERFACE, // This is an interface descriptor.
|
||||
0, // Interface number .
|
||||
0, // Alternate setting number.
|
||||
0, // Number of endpoints (only endpoint 0
|
||||
// used)
|
||||
USB_CLASS_APP_SPECIFIC, // Application specific interface class
|
||||
USB_DFU_SUBCLASS, // Device Firmware Upgrade subclass
|
||||
USB_DFU_RUNTIME_PROTOCOL, // DFU runtime protocol
|
||||
0, // No string descriptor for this interface.
|
||||
};
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// The DFU functional descriptor.
|
||||
//
|
||||
//*****************************************************************************
|
||||
uint8_t g_pui8DFUFunctionalDesc[DFUFUNCTIONALDESC_SIZE] =
|
||||
{
|
||||
//
|
||||
// Device Firmware Upgrade functional descriptor.
|
||||
//
|
||||
9, // Length of this descriptor.
|
||||
USB_DFU_FUNC_DESCRIPTOR_TYPE, // DFU Functional descriptor type
|
||||
(DFU_ATTR_CAN_DOWNLOAD | // DFU attributes.
|
||||
DFU_ATTR_CAN_UPLOAD |
|
||||
DFU_ATTR_WILL_DETACH |
|
||||
DFU_ATTR_MANIFEST_TOLERANT),
|
||||
USBShort(0xFFFF), // Detach timeout (set to maximum).
|
||||
USBShort(DFU_TRANSFER_SIZE), // Transfer size 1KB.
|
||||
USBShort(0x0110) // DFU Version 1.1
|
||||
};
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// The DFU runtime configuration descriptor is defined as two sections.
|
||||
// These sections are:
|
||||
//
|
||||
// 1. The 9 byte configuration descriptor.
|
||||
// 2. The interface descriptor + DFU functional descriptor.
|
||||
//
|
||||
//*****************************************************************************
|
||||
const tConfigSection g_sDFUConfigSection =
|
||||
{
|
||||
sizeof(g_pui8DFUConfigDescriptor),
|
||||
g_pui8DFUConfigDescriptor
|
||||
};
|
||||
|
||||
const tConfigSection g_sDFUInterfaceSection =
|
||||
{
|
||||
sizeof(g_pui8DFUInterface),
|
||||
g_pui8DFUInterface
|
||||
};
|
||||
|
||||
const tConfigSection g_sDFUFunctionalDescSection =
|
||||
{
|
||||
sizeof(g_pui8DFUFunctionalDesc),
|
||||
g_pui8DFUFunctionalDesc
|
||||
};
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// This array lists all the sections that must be concatenated to make a
|
||||
// single, complete DFU runtime configuration descriptor.
|
||||
//
|
||||
//*****************************************************************************
|
||||
const tConfigSection *g_psDFUSections[] =
|
||||
{
|
||||
&g_sDFUConfigSection,
|
||||
&g_sDFUInterfaceSection,
|
||||
&g_sDFUFunctionalDescSection
|
||||
};
|
||||
|
||||
#define NUM_DFU_SECTIONS (sizeof(g_psDFUSections) / \
|
||||
sizeof(g_psDFUSections[0]))
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// The header for the single configuration we support. This is the root of
|
||||
// the data structure that defines all the bits and pieces that are pulled
|
||||
// together to generate the configuration descriptor.
|
||||
//
|
||||
//*****************************************************************************
|
||||
tConfigHeader g_sDFUConfigHeader =
|
||||
{
|
||||
NUM_DFU_SECTIONS,
|
||||
g_psDFUSections
|
||||
};
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Configuration Descriptor.
|
||||
//
|
||||
//*****************************************************************************
|
||||
const tConfigHeader * const g_ppsDFUConfigDescriptors[] =
|
||||
{
|
||||
&g_sDFUConfigHeader
|
||||
};
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Forward references for device handler callbacks
|
||||
//
|
||||
//*****************************************************************************
|
||||
static void HandleGetDescriptor(void *pvDFUInstance, tUSBRequest *psUSBRequest);
|
||||
static void HandleRequest(void *pvDFUInstance, tUSBRequest *psUSBRequest);
|
||||
static void HandleDevice(void *pvDFUInstance, uint32_t ui32Request,
|
||||
void *pvRequestData);
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// The device information structure for the USB DFU devices.
|
||||
//
|
||||
//*****************************************************************************
|
||||
static const tCustomHandlers g_sDFUHandlers =
|
||||
{
|
||||
//
|
||||
// GetDescriptor
|
||||
//
|
||||
HandleGetDescriptor,
|
||||
|
||||
//
|
||||
// RequestHandler
|
||||
//
|
||||
HandleRequest,
|
||||
|
||||
//
|
||||
// InterfaceChange
|
||||
//
|
||||
0,
|
||||
|
||||
//
|
||||
// ConfigChange
|
||||
//
|
||||
0,
|
||||
|
||||
//
|
||||
// DataReceived
|
||||
//
|
||||
0,
|
||||
|
||||
//
|
||||
// DataSentCallback
|
||||
//
|
||||
0,
|
||||
|
||||
//
|
||||
// ResetHandler
|
||||
//
|
||||
0,
|
||||
|
||||
//
|
||||
// SuspendHandler
|
||||
//
|
||||
0,
|
||||
|
||||
//
|
||||
//
|
||||
|
||||
//
|
||||
// ResumeHandler
|
||||
//
|
||||
0,
|
||||
|
||||
//
|
||||
// DisconnectHandler
|
||||
//
|
||||
0,
|
||||
|
||||
//
|
||||
// EndpointHandler
|
||||
//
|
||||
0,
|
||||
|
||||
//
|
||||
// Device handler.
|
||||
//
|
||||
HandleDevice,
|
||||
};
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Device instance specific handler. This callback received notifications of
|
||||
// events related to handling interface, endpoint and string identifiers when
|
||||
// a device is part of a composite device. In this case, the only resource we
|
||||
// need which may be renumbered is the DFU runtime interface.
|
||||
//
|
||||
//*****************************************************************************
|
||||
static void
|
||||
HandleDevice(void *pvDFUInstance, uint32_t ui32Request, void *pvRequestData)
|
||||
{
|
||||
tDFUInstance *psInst;
|
||||
uint8_t *pui8Data;
|
||||
|
||||
//
|
||||
// Get a pointer to the DFU device instance data pointer
|
||||
//
|
||||
psInst = &((tUSBDDFUDevice *)pvDFUInstance)->sPrivateData;
|
||||
|
||||
//
|
||||
// Get a byte pointer to the data.
|
||||
//
|
||||
pui8Data = (uint8_t *)pvRequestData;
|
||||
|
||||
//
|
||||
// Which request event have we been passed?
|
||||
//
|
||||
switch(ui32Request)
|
||||
{
|
||||
//
|
||||
// This was an interface change event.
|
||||
//
|
||||
case USB_EVENT_COMP_IFACE_CHANGE:
|
||||
{
|
||||
//
|
||||
// Save the change to the interface number.
|
||||
//
|
||||
psInst->ui8Interface = pui8Data[1];
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
// We are not interested in any other event.
|
||||
//
|
||||
default:
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// This function is called by the USB device stack whenever a request for a
|
||||
// non-standard descriptor is received.
|
||||
//
|
||||
// \param pvDFUInstance is the instance data for this request.
|
||||
// \param psUSBRequest points to the request received.
|
||||
//
|
||||
// This call parses the provided request structure and determines which
|
||||
// descriptor is being requested. Assuming the descriptor can be found, it is
|
||||
// scheduled for transmission via endpoint zero. If the descriptor cannot be
|
||||
// found, the endpoint is stalled to indicate an error to the host.
|
||||
//
|
||||
//*****************************************************************************
|
||||
static void
|
||||
HandleGetDescriptor(void *pvDFUInstance, tUSBRequest *psUSBRequest)
|
||||
{
|
||||
uint32_t ui32Size;
|
||||
|
||||
ASSERT(pvDFUInstance != 0);
|
||||
|
||||
//
|
||||
// Which type of class descriptor are we being asked for? We only support
|
||||
// 1 type - the DFU functional descriptor.
|
||||
//
|
||||
if(((psUSBRequest->wValue >> 8) == USB_DFU_FUNC_DESCRIPTOR_TYPE) &&
|
||||
((psUSBRequest->wValue & 0xFF) == 0))
|
||||
{
|
||||
//
|
||||
// If there is more data to send than the host requested then just
|
||||
// send the requested amount of data.
|
||||
//
|
||||
if((uint16_t)g_pui8DFUFunctionalDesc[0] > psUSBRequest->wLength)
|
||||
{
|
||||
ui32Size = (uint32_t)psUSBRequest->wLength;
|
||||
}
|
||||
else
|
||||
{
|
||||
ui32Size = (uint32_t)g_pui8DFUFunctionalDesc[0];
|
||||
}
|
||||
|
||||
//
|
||||
// Send the data via endpoint 0.
|
||||
//
|
||||
USBDCDSendDataEP0(0, g_pui8DFUFunctionalDesc, ui32Size);
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
// This was an unknown or invalid request so stall.
|
||||
//
|
||||
USBDCDStallEP0(0);
|
||||
}
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// This function is called by the USB device stack whenever a non-standard
|
||||
// request is received.
|
||||
//
|
||||
// \param pvDFUInstance is the instance data for this HID device.
|
||||
// \param psUSBRequest points to the request received.
|
||||
//
|
||||
// This call parses the provided request structure. Assuming the request is
|
||||
// understood, it is handled and any required response generated. If the
|
||||
// request cannot be handled by this device class, endpoint zero is stalled to
|
||||
// indicate an error to the host.
|
||||
//
|
||||
//*****************************************************************************
|
||||
static void
|
||||
HandleRequest(void *pvDFUInstance, tUSBRequest *psUSBRequest)
|
||||
{
|
||||
tDFUInstance *psInst;
|
||||
tUSBDDFUDevice *psDevice;
|
||||
|
||||
ASSERT(pvDFUInstance != 0);
|
||||
|
||||
//
|
||||
// Get a pointer to the DFU device structure
|
||||
//
|
||||
psDevice = pvDFUInstance;
|
||||
|
||||
//
|
||||
// Get a pointer to the DFU device instance data pointer
|
||||
//
|
||||
psInst = &psDevice->sPrivateData;
|
||||
|
||||
//
|
||||
// Make sure the request was for this interface.
|
||||
//
|
||||
if(psUSBRequest->wIndex != psInst->ui8Interface)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// Determine the type of request.
|
||||
//
|
||||
switch(psUSBRequest->bRequest)
|
||||
{
|
||||
//
|
||||
// We have been asked to detach. In this case, we call back to the
|
||||
// application telling it to tidy up and re-enter the boot loader. We
|
||||
// rely upon it doing this on our behalf since this must be done from a
|
||||
// non-interrupt context and this call is most likely in interrupt
|
||||
// context.
|
||||
//
|
||||
case USBD_DFU_REQUEST_DETACH:
|
||||
{
|
||||
//
|
||||
// Tell the application it's time to reenter the boot loader.
|
||||
//
|
||||
psDevice->pfnCallback(psDevice->pvCBData, USBD_DFU_EVENT_DETACH,
|
||||
0, (void *)0);
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
// This request was not recognized so stall.
|
||||
//
|
||||
default:
|
||||
{
|
||||
USBDCDStallEP0(0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! Initializes DFU device operation for a given USB controller.
|
||||
//!
|
||||
//! \param ui32Index is the index of the USB controller which is to be
|
||||
//! initialized for DFU runtime device operation.
|
||||
//! \param psDFUDevice points to a structure containing parameters customizing
|
||||
//! the operation of the DFU device.
|
||||
//! \param psCompEntry is the composite device entry to initialize when
|
||||
//! creating a composite device.
|
||||
//!
|
||||
//! The \e psCompEntry should point to the composite device entry to
|
||||
//! initialize. This is part of the array that is passed to the
|
||||
//! USBDCompositeInit() function.
|
||||
//!
|
||||
//! \return Returns zero on failure or a non-zero instance value that should be
|
||||
//! used with the remaining USB DFU APIs.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void *
|
||||
USBDDFUCompositeInit(uint32_t ui32Index, tUSBDDFUDevice *psDFUDevice,
|
||||
tCompositeEntry *psCompEntry)
|
||||
{
|
||||
tDFUInstance *psInst;
|
||||
|
||||
//
|
||||
// Check parameter validity.
|
||||
//
|
||||
ASSERT(ui32Index == 0);
|
||||
ASSERT(psDFUDevice);
|
||||
ASSERT(psCompEntry != 0);
|
||||
|
||||
//
|
||||
// Get a pointer to the DFU device instance data pointer
|
||||
//
|
||||
psInst = &psDFUDevice->sPrivateData;
|
||||
|
||||
//
|
||||
// Initialize the composite entry that is used by the composite device
|
||||
// class.
|
||||
//
|
||||
if(psCompEntry != 0)
|
||||
{
|
||||
psCompEntry->psDevInfo = &psInst->sDevInfo;
|
||||
psCompEntry->pvInstance = (void *)psDFUDevice;
|
||||
}
|
||||
|
||||
//
|
||||
// Initialize the device information structure.
|
||||
//
|
||||
psInst->sDevInfo.psCallbacks = &g_sDFUHandlers;
|
||||
psInst->sDevInfo.pui8DeviceDescriptor = g_pui8DFUDeviceDescriptor;
|
||||
psInst->sDevInfo.ppsConfigDescriptors = g_ppsDFUConfigDescriptors;
|
||||
psInst->sDevInfo.ppui8StringDescriptors = 0;
|
||||
psInst->sDevInfo.ui32NumStringDescriptors = 0;
|
||||
|
||||
psInst->ui32USBBase = USB0_BASE;
|
||||
psInst->bConnected = false;
|
||||
psInst->ui8Interface = 0;
|
||||
|
||||
//
|
||||
// Initialize the device info structure for the DFU device.
|
||||
//
|
||||
USBDCDDeviceInfoInit(0, &psInst->sDevInfo);
|
||||
|
||||
//
|
||||
// Return the pointer to the instance indicating that everything went well.
|
||||
//
|
||||
return((void *)psDFUDevice);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! Shuts down the DFU device.
|
||||
//!
|
||||
//! \param pvDFUInstance is the pointer to the device instance structure as
|
||||
//! returned by USBDDFUCompositeInit().
|
||||
//!
|
||||
//! This function terminates DFU operation for the instance supplied and
|
||||
//! removes the device from the USB bus.
|
||||
//!
|
||||
//! Following this call, the \e pvDFUInstance instance should not me used in
|
||||
//! any other calls.
|
||||
//!
|
||||
//! \return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
USBDDFUCompositeTerm(void *pvDFUInstance)
|
||||
{
|
||||
tDFUInstance *psInst;
|
||||
|
||||
ASSERT(pvDFUInstance);
|
||||
|
||||
//
|
||||
// Get a pointer to our instance data.
|
||||
//
|
||||
psInst = &((tUSBDDFUDevice *)pvDFUInstance)->sPrivateData;
|
||||
|
||||
//
|
||||
// Terminate the requested instance.
|
||||
//
|
||||
USBDCDTerm(0);
|
||||
|
||||
psInst->ui32USBBase = 0;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! Removes the current USB device from the bus and transfers control to the
|
||||
//! DFU boot loader.
|
||||
//!
|
||||
//! This function should be called from the application's main loop (i.e. not
|
||||
//! in interrupt context) following a callback to the USB DFU callback function
|
||||
//! notifying the application of a DETACH request from the host. The function
|
||||
//! will prepare the system to switch to DFU mode and transfer control to the
|
||||
//! boot loader in preparation for a firmware upgrade from the host.
|
||||
//!
|
||||
//! The application must ensure that it has completed all necessary shutdown
|
||||
//! activities (saved any required data, etc.) before making this call since
|
||||
//! the function will not return.
|
||||
//!
|
||||
//! \return This function does not return.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
USBDDFUUpdateBegin(void)
|
||||
{
|
||||
//
|
||||
// Terminate the USB device and take us off the bus.
|
||||
//
|
||||
USBDCDTerm(0);
|
||||
|
||||
//
|
||||
// Disable all interrupts.
|
||||
//
|
||||
MAP_IntMasterDisable();
|
||||
|
||||
//
|
||||
// We must make sure we turn off SysTick and its interrupt
|
||||
// before entering the boot loader!
|
||||
//
|
||||
MAP_SysTickIntDisable();
|
||||
MAP_SysTickDisable();
|
||||
|
||||
//
|
||||
// Disable all processor interrupts. Instead of disabling them
|
||||
// one at a time, a direct write to NVIC is done to disable all
|
||||
// peripheral interrupts.
|
||||
//
|
||||
HWREG(NVIC_DIS0) = 0xffffffff;
|
||||
HWREG(NVIC_DIS1) = 0xffffffff;
|
||||
|
||||
//
|
||||
// Reset the USB peripheral
|
||||
//
|
||||
MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_USB0);
|
||||
MAP_SysCtlPeripheralReset(SYSCTL_PERIPH_USB0);
|
||||
MAP_SysCtlPeripheralDisable(SYSCTL_PERIPH_USB0);
|
||||
|
||||
//
|
||||
// Wait for about a second.
|
||||
//
|
||||
MAP_SysCtlDelay(MAP_SysCtlClockGet() / 3);
|
||||
|
||||
//
|
||||
// Re-enable interrupts at the NVIC level.
|
||||
//
|
||||
MAP_IntMasterEnable();
|
||||
|
||||
//
|
||||
// Return control to the boot loader. This is a call to the SVC
|
||||
// handler in the boot loader.
|
||||
//
|
||||
(*((void (*)(void))(*(uint32_t *)0x2c)))();
|
||||
|
||||
//
|
||||
// Should never get here, but just in case.
|
||||
//
|
||||
while(1)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Close the Doxygen group.
|
||||
//! @}
|
||||
//
|
||||
//*****************************************************************************
|
|
@ -0,0 +1,184 @@
|
|||
//*****************************************************************************
|
||||
//
|
||||
// usbddfu-rt.h - Definitions used by runtime DFU class devices.
|
||||
//
|
||||
// Copyright (c) 2010-2013 Texas Instruments Incorporated. All rights reserved.
|
||||
// Software License Agreement
|
||||
//
|
||||
// Texas Instruments (TI) is supplying this software for use solely and
|
||||
// exclusively on TI's microcontroller products. The software is owned by
|
||||
// TI and/or its suppliers, and is protected under applicable copyright
|
||||
// laws. You may not combine this software with "viral" open-source
|
||||
// software in order to form a larger program.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
|
||||
// NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
|
||||
// NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
|
||||
// CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
|
||||
// DAMAGES, FOR ANY REASON WHATSOEVER.
|
||||
//
|
||||
// This is part of revision 1.1 of the Tiva USB Library.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
#ifndef __USBDDFURT_H__
|
||||
#define __USBDDFURT_H__
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// If building with a C++ compiler, make all of the definitions in this header
|
||||
// have a C binding.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! \addtogroup dfu_device_class_api
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// This is the size of the g_pui8DFUInterface array in bytes.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define DFUINTERFACE_SIZE (9)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// This is the size of the g_pui8DFUFunctionalDesc array in bytes.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define DFUFUNCTIONALDESC_SIZE (9)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! The size of the memory that should be allocated to create a configuration
|
||||
//! descriptor for a single instance of the DFU runtime device. This does not
|
||||
//! include the configuration descriptor which is automatically ignored by the
|
||||
//! composite device class.
|
||||
//!
|
||||
//! This label is used to compute the value which will be passed to the
|
||||
//! USBDCompositeInit function in the ui32Size parameter.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define COMPOSITE_DDFU_SIZE (DFUINTERFACE_SIZE + DFUFUNCTIONALDESC_SIZE)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! This value is passed to the client via the callback function provided in
|
||||
//! the tUSBDDFUDevice structure and indicates that the host has sent a DETACH
|
||||
//! request to the DFU interface. This request indicates that the device detach
|
||||
//! from the USB bus and reattach in DFU mode in preparation for a firmware
|
||||
//! upgrade. Currently, this is the only event that the DFU runtime class
|
||||
//! reports to the client.
|
||||
//!
|
||||
//! When this event is received, the client should call USBDDFUUpdateBegin()
|
||||
//! from a non-interrupt context at its earliest opportunity.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define USBD_DFU_EVENT_DETACH (USBD_DFU_EVENT_BASE + 0)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// PRIVATE
|
||||
//
|
||||
// This structure defines the private instance data and state variables for
|
||||
// DFU devices. The memory for this structure is included in the
|
||||
// sPrivateData field in the tUSBDDFUDevice structure passed in the
|
||||
// USBDDFUCompositeInit() function.
|
||||
//
|
||||
//*****************************************************************************
|
||||
typedef struct
|
||||
{
|
||||
//
|
||||
// Base address for the USB controller.
|
||||
//
|
||||
uint32_t ui32USBBase;
|
||||
|
||||
//
|
||||
// The device info to interact with the lower level DCD code.
|
||||
//
|
||||
tDeviceInfo sDevInfo;
|
||||
|
||||
//
|
||||
// The DFU class interface number, this is modified in composite devices.
|
||||
//
|
||||
uint8_t ui8Interface;
|
||||
|
||||
//
|
||||
// The connection status of the device.
|
||||
//
|
||||
bool bConnected;
|
||||
}
|
||||
tDFUInstance;
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! The structure used by the application to define operating parameters for
|
||||
//! the DFU device. Note that, unlike all other devices, this structure does
|
||||
//! not contain any fields which configure the device descriptor sent back to
|
||||
//! the host. The DFU runtime device class must be used as part of a composite
|
||||
//! device since all it provides is the capability to signal the device to
|
||||
//! switch into DFU mode in preparation for a firmware upgrade. Creating a
|
||||
//! device with nothing but DFU runtime mode capability is rather pointless
|
||||
//! so this is not supported.
|
||||
//
|
||||
//*****************************************************************************
|
||||
typedef struct
|
||||
{
|
||||
//
|
||||
//! A pointer to the callback function which will be called to notify
|
||||
//! the application of DETACH requests.
|
||||
//
|
||||
const tUSBCallback pfnCallback;
|
||||
|
||||
//
|
||||
//! A client-supplied pointer which will be sent as the first
|
||||
//! parameter in all calls made to the pfnCallback function.
|
||||
//
|
||||
void * const pvCBData;
|
||||
|
||||
//
|
||||
//! The private instance data for this device class. This
|
||||
//! memory must remain accessible for as long as the DFU device is in use
|
||||
//! and must not be modified by any code outside the DFU class driver.
|
||||
//
|
||||
tDFUInstance sPrivateData;
|
||||
}
|
||||
tUSBDDFUDevice;
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// API Function Prototypes
|
||||
//
|
||||
//*****************************************************************************
|
||||
extern void *USBDDFUCompositeInit(uint32_t ui32Index,
|
||||
tUSBDDFUDevice *psDFUDevice,
|
||||
tCompositeEntry *psCompEntry);
|
||||
extern void USBDDFUCompositeTerm(void *pvDFUInstance);
|
||||
extern void USBDDFUUpdateBegin(void);
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Close the Doxygen group.
|
||||
//! @}
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Mark the end of the C bindings section for C++ compilers.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // __USBDDFURT_H__
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,206 @@
|
|||
//*****************************************************************************
|
||||
//
|
||||
// usbdevice.h - types and definitions used during USB enumeration.
|
||||
//
|
||||
// Copyright (c) 2008-2013 Texas Instruments Incorporated. All rights reserved.
|
||||
// Software License Agreement
|
||||
//
|
||||
// Texas Instruments (TI) is supplying this software for use solely and
|
||||
// exclusively on TI's microcontroller products. The software is owned by
|
||||
// TI and/or its suppliers, and is protected under applicable copyright
|
||||
// laws. You may not combine this software with "viral" open-source
|
||||
// software in order to form a larger program.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
|
||||
// NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
|
||||
// NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
|
||||
// CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
|
||||
// DAMAGES, FOR ANY REASON WHATSOEVER.
|
||||
//
|
||||
// This is part of revision 1.1 of the Tiva USB Library.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
#ifndef __USBDEVICE_H__
|
||||
#define __USBDEVICE_H__
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// If building with a C++ compiler, make all of the definitions in this header
|
||||
// have a C binding.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! \addtogroup device_api
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! The maximum number of independent interfaces that any single device
|
||||
//! implementation can support. Independent interfaces means interface
|
||||
//! descriptors with different bInterfaceNumber values - several interface
|
||||
//! descriptors offering different alternative settings but the same interface
|
||||
//! number count as a single interface.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define USB_MAX_INTERFACES_PER_DEVICE 8
|
||||
|
||||
#include "usbdevicepriv.h"
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! This structure is passed to the USB library on a call to USBDCDInit and
|
||||
//! provides the library with information about the device that the
|
||||
//! application is implementing. It contains functions pointers for the
|
||||
//! various USB event handlers and pointers to each of the standard device
|
||||
//! descriptors.
|
||||
//
|
||||
//*****************************************************************************
|
||||
struct tDeviceInfo
|
||||
{
|
||||
//
|
||||
//! A pointer to a structure containing pointers to event handler functions
|
||||
//! provided by the client to support the operation of this device.
|
||||
//
|
||||
const tCustomHandlers * psCallbacks;
|
||||
|
||||
//
|
||||
//! A pointer to the device descriptor for this device.
|
||||
//
|
||||
const uint8_t *pui8DeviceDescriptor;
|
||||
|
||||
//
|
||||
//! A pointer to an array of configuration descriptor pointers. Each entry
|
||||
//! in the array corresponds to one configuration that the device may be
|
||||
//! set to use by the USB host. The number of entries in the array must
|
||||
//! match the bNumConfigurations value in the device descriptor
|
||||
//! array, pui8DeviceDescriptor.
|
||||
//
|
||||
const tConfigHeader * const *ppsConfigDescriptors;
|
||||
|
||||
//
|
||||
//! A pointer to the string descriptor array for this device. This array
|
||||
//! must be arranged as follows:
|
||||
//!
|
||||
//! - [0] - Standard descriptor containing supported language codes.
|
||||
//! - [1] - String 1 for the first language listed in descriptor 0.
|
||||
//! - [2] - String 2 for the first language listed in descriptor 0.
|
||||
//! - ...
|
||||
//! - [n] - String n for the first language listed in descriptor 0.
|
||||
//! - [n+1] - String 1 for the second language listed in descriptor 0.
|
||||
//! - ...
|
||||
//! - [2n] - String n for the second language listed in descriptor 0.
|
||||
//! - [2n+1]- String 1 for the third language listed in descriptor 0.
|
||||
//! - ...
|
||||
//! - [3n] - String n for the third language listed in descriptor 0.
|
||||
//!
|
||||
//! and so on.
|
||||
//
|
||||
const uint8_t * const *ppui8StringDescriptors;
|
||||
|
||||
//
|
||||
//! The total number of descriptors provided in the ppStringDescriptors
|
||||
//! array.
|
||||
//
|
||||
uint32_t ui32NumStringDescriptors;
|
||||
};
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! This type is used by an application to describe and instance of a device
|
||||
//! and an instance data pointer for that class. The psDevice pointer should
|
||||
//! be a pointer to a valid device class to include in the composite device.
|
||||
//! The pvInstance pointer should be a pointer to an instance pointer for the
|
||||
//! device in the psDevice pointer.
|
||||
//!
|
||||
//
|
||||
//*****************************************************************************
|
||||
typedef struct
|
||||
{
|
||||
//
|
||||
//! This is the top level device information structure.
|
||||
//
|
||||
const tDeviceInfo *psDevInfo;
|
||||
|
||||
//
|
||||
//! This is the instance data for the device structure.
|
||||
//
|
||||
void *pvInstance;
|
||||
|
||||
//
|
||||
//! A per-device workspace used by the composite device.
|
||||
//
|
||||
uint32_t ui32DeviceWorkspace;
|
||||
}
|
||||
tCompositeEntry;
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Close the Doxygen group.
|
||||
//! @}
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Public APIs offered by the USB library device control driver.
|
||||
//
|
||||
//*****************************************************************************
|
||||
extern void USBDCDInit(uint32_t ui32Index, tDeviceInfo *psDevice,
|
||||
void *pvDCDCBData);
|
||||
extern void USBDCDTerm(uint32_t ui32Index);
|
||||
extern void USBDCDStallEP0(uint32_t ui32Index);
|
||||
extern void USBDCDRequestDataEP0(uint32_t ui32Index, uint8_t *pui8Data,
|
||||
uint32_t ui32Size);
|
||||
extern void USBDCDSendDataEP0(uint32_t ui32Index, uint8_t *pui8Data,
|
||||
uint32_t ui32Size);
|
||||
extern void USBDCDSetDefaultConfiguration(uint32_t ui32Index,
|
||||
uint32_t ui32DefaultConfig);
|
||||
extern uint32_t USBDCDConfigDescGetSize(const tConfigHeader *psConfig);
|
||||
extern uint32_t USBDCDConfigDescGetNum(const tConfigHeader *psConfig,
|
||||
uint32_t ui32Type);
|
||||
extern tDescriptorHeader *USBDCDConfigDescGet(const tConfigHeader *psConfig,
|
||||
uint32_t ui32Type,
|
||||
uint32_t ui32Index,
|
||||
uint32_t *pui32Section);
|
||||
extern uint32_t
|
||||
USBDCDConfigGetNumAlternateInterfaces(const tConfigHeader *psConfig,
|
||||
uint8_t ui8InterfaceNumber);
|
||||
extern tInterfaceDescriptor *
|
||||
USBDCDConfigGetInterface(const tConfigHeader *psConfig,
|
||||
uint32_t ui32Index, uint32_t ui32AltCfg,
|
||||
uint32_t *pui32Section);
|
||||
extern tEndpointDescriptor *
|
||||
USBDCDConfigGetInterfaceEndpoint(const tConfigHeader *psConfig,
|
||||
uint32_t ui32InterfaceNumber,
|
||||
uint32_t ui32AltCfg,
|
||||
uint32_t ui32Index);
|
||||
extern void USBDCDPowerStatusSet(uint32_t ui32Index, uint8_t ui8Power);
|
||||
extern bool USBDCDRemoteWakeupRequest(uint32_t ui32Index);
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Device mode interrupt handler for controller index 0.
|
||||
//
|
||||
//*****************************************************************************
|
||||
extern void USB0DeviceIntHandler(void);
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Mark the end of the C bindings section for C++ compilers.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // __USBENUM_H__
|
|
@ -0,0 +1,238 @@
|
|||
//*****************************************************************************
|
||||
//
|
||||
// usbdevicepriv.h - Private header file used to share internal variables and
|
||||
// function prototypes between the various device-related
|
||||
// modules in the USB library. This header MUST NOT be
|
||||
// used by application code.
|
||||
//
|
||||
// Copyright (c) 2008-2013 Texas Instruments Incorporated. All rights reserved.
|
||||
// Software License Agreement
|
||||
//
|
||||
// Texas Instruments (TI) is supplying this software for use solely and
|
||||
// exclusively on TI's microcontroller products. The software is owned by
|
||||
// TI and/or its suppliers, and is protected under applicable copyright
|
||||
// laws. You may not combine this software with "viral" open-source
|
||||
// software in order to form a larger program.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
|
||||
// NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
|
||||
// NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
|
||||
// CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
|
||||
// DAMAGES, FOR ANY REASON WHATSOEVER.
|
||||
//
|
||||
// This is part of revision 1.1 of the Tiva USB Library.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
#ifndef __USBDEVICEPRIV_H__
|
||||
#define __USBDEVICEPRIV_H__
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// If building with a C++ compiler, make all of the definitions in this header
|
||||
// have a C binding.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// The states for endpoint zero during enumeration.
|
||||
//
|
||||
//*****************************************************************************
|
||||
typedef enum
|
||||
{
|
||||
//
|
||||
// The USB device is waiting on a request from the host controller on
|
||||
// endpoint zero.
|
||||
//
|
||||
eUSBStateIdle,
|
||||
|
||||
//
|
||||
// The USB device is sending data back to the host due to an IN request.
|
||||
//
|
||||
eUSBStateTx,
|
||||
|
||||
//
|
||||
// The USB device is sending the configuration descriptor back to the host
|
||||
// due to an IN request.
|
||||
//
|
||||
eUSBStateTxConfig,
|
||||
|
||||
//
|
||||
// The USB device is receiving data from the host due to an OUT
|
||||
// request from the host.
|
||||
//
|
||||
eUSBStateRx,
|
||||
|
||||
//
|
||||
// The USB device has completed the IN or OUT request and is now waiting
|
||||
// for the host to acknowledge the end of the IN/OUT transaction. This
|
||||
// is the status phase for a USB control transaction.
|
||||
//
|
||||
eUSBStateStatus,
|
||||
|
||||
//
|
||||
// This endpoint has signaled a stall condition and is waiting for the
|
||||
// stall to be acknowledged by the host controller.
|
||||
//
|
||||
eUSBStateStall
|
||||
}
|
||||
tEP0State;
|
||||
|
||||
typedef struct tDeviceInfo tDeviceInfo;
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// The USB controller device information.
|
||||
//
|
||||
//*****************************************************************************
|
||||
typedef struct
|
||||
{
|
||||
//
|
||||
// The current state of endpoint zero.
|
||||
//
|
||||
volatile tEP0State iEP0State;
|
||||
|
||||
//
|
||||
// The devices current address, this also has a change pending bit in the
|
||||
// MSB of this value specified by DEV_ADDR_PENDING.
|
||||
//
|
||||
volatile uint32_t ui32DevAddress;
|
||||
|
||||
//
|
||||
// This holds the current active configuration for this device.
|
||||
//
|
||||
uint32_t ui32Configuration;
|
||||
|
||||
//
|
||||
// This holds the configuration id that will take effect after a reset.
|
||||
//
|
||||
uint32_t ui32DefaultConfiguration;
|
||||
|
||||
//
|
||||
// This holds the current alternate interface for this device.
|
||||
//
|
||||
uint8_t pui8AltSetting[USB_MAX_INTERFACES_PER_DEVICE];
|
||||
|
||||
//
|
||||
// This is the pointer to the current data being sent out or received
|
||||
// on endpoint zero.
|
||||
//
|
||||
uint8_t *pui8EP0Data;
|
||||
|
||||
//
|
||||
// This is the number of bytes that remain to be sent from or received
|
||||
// into the g_sUSBDeviceState.pui8EP0Data data buffer.
|
||||
//
|
||||
volatile uint32_t ui32EP0DataRemain;
|
||||
|
||||
//
|
||||
// The amount of data being sent/received due to a custom request.
|
||||
//
|
||||
uint32_t ui32OUTDataSize;
|
||||
|
||||
//
|
||||
// Holds the current device status.
|
||||
//
|
||||
uint8_t ui8Status;
|
||||
|
||||
//
|
||||
// Holds the endpoint status for the HALT condition. This array is sized
|
||||
// to hold halt status for all IN and OUT endpoints.
|
||||
//
|
||||
uint8_t ppui8Halt[2][USBLIB_NUM_EP - 1];
|
||||
|
||||
//
|
||||
// Holds the configuration descriptor section number currently being sent
|
||||
// to the host.
|
||||
//
|
||||
uint8_t ui8ConfigSection;
|
||||
|
||||
//
|
||||
// Holds the offset within the configuration descriptor section currently
|
||||
// being sent to the host.
|
||||
//
|
||||
uint8_t ui8SectionOffset;
|
||||
|
||||
//
|
||||
// Holds the index of the configuration that we are currently sending back
|
||||
// to the host.
|
||||
//
|
||||
uint8_t ui8ConfigIndex;
|
||||
|
||||
//
|
||||
// This flag is set to true if the client has called USBDPowerStatusSet()
|
||||
// and tells the USB library not to try to determine the current power
|
||||
// status from the configuration descriptor.
|
||||
//
|
||||
bool bPwrSrcSet;
|
||||
|
||||
//
|
||||
// This flag indicates whether or not remote wake up signaling is in
|
||||
// progress.
|
||||
//
|
||||
bool bRemoteWakeup;
|
||||
|
||||
//
|
||||
// During remote wake up signaling, this counter is used to track the
|
||||
// number of milliseconds since the signaling was initiated.
|
||||
//
|
||||
uint8_t ui8RemoteWakeupCount;
|
||||
|
||||
//
|
||||
// The DMA instance information for this USB controller.
|
||||
//
|
||||
tUSBDMAInstance *psDMAInstance;
|
||||
|
||||
//
|
||||
// The interrupt number for this instance.
|
||||
//
|
||||
uint32_t ui32IntNum;
|
||||
|
||||
//
|
||||
// Pointer to the device supplied call back data.
|
||||
//
|
||||
void *pvCBData;
|
||||
}
|
||||
tDCDInstance;
|
||||
|
||||
extern tDCDInstance g_psDCDInst[];
|
||||
extern tDeviceInfo *g_ppsDevInfo[];
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Device enumeration functions provided by device/usbenum.c and called from
|
||||
// the interrupt handler in device/usbhandler.c
|
||||
//
|
||||
//*****************************************************************************
|
||||
extern bool USBDeviceConfig(tDCDInstance *psDevInst,
|
||||
const tConfigHeader *psConfig);
|
||||
extern bool USBDeviceConfigAlternate(tDCDInstance *psDevInst,
|
||||
const tConfigHeader *psConfig,
|
||||
uint8_t ui8InterfaceNum,
|
||||
uint8_t ui8AlternateSetting);
|
||||
|
||||
extern void USBDCDDeviceInfoInit(uint32_t ui32Index, tDeviceInfo *psDevice);
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Macro access function to device information.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define DCDGetDMAInstance(psDevInfo) (&(psDevInfo->psDCDInst->sDMAInstance))
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Mark the end of the C bindings section for C++ compilers.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // __USBDEVICEPRIV_H__
|
|
@ -0,0 +1,85 @@
|
|||
//*****************************************************************************
|
||||
//
|
||||
// usbhandler.c - General USB handling routines.
|
||||
//
|
||||
// Copyright (c) 2007-2013 Texas Instruments Incorporated. All rights reserved.
|
||||
// Software License Agreement
|
||||
//
|
||||
// Texas Instruments (TI) is supplying this software for use solely and
|
||||
// exclusively on TI's microcontroller products. The software is owned by
|
||||
// TI and/or its suppliers, and is protected under applicable copyright
|
||||
// laws. You may not combine this software with "viral" open-source
|
||||
// software in order to form a larger program.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
|
||||
// NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
|
||||
// NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
|
||||
// CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
|
||||
// DAMAGES, FOR ANY REASON WHATSOEVER.
|
||||
//
|
||||
// This is part of revision 1.1 of the Tiva USB Library.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "inc/hw_memmap.h"
|
||||
#include "inc/hw_types.h"
|
||||
#include "driverlib/rom.h"
|
||||
#include "driverlib/rom_map.h"
|
||||
#include "driverlib/usbdrv.h"
|
||||
#include "usblib/usblib.h"
|
||||
#include "usblib/usblibpriv.h"
|
||||
#include "usblib/device/usbdevice.h"
|
||||
#include "usblib/device/usbdevicepriv.h"
|
||||
#include "usblib/usblibpriv.h"
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! \addtogroup device_api
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! The USB device interrupt handler.
|
||||
//!
|
||||
//! This the main USB interrupt handler entry point for use in USB device
|
||||
//! applications. This top-level handler will branch the interrupt off to the
|
||||
//! appropriate application or stack handlers depending on the current status
|
||||
//! of the USB controller.
|
||||
//!
|
||||
//! Applications which operate purely as USB devices (rather than dual mode
|
||||
//! applications which can operate in either device or host mode at different
|
||||
//! times) must ensure that a pointer to this function is installed in the
|
||||
//! interrupt vector table entry for the USB0 interrupt. For dual mode
|
||||
//! operation, the vector should be set to point to \e USB0DualModeIntHandler()
|
||||
//! instead.
|
||||
//!
|
||||
//! \return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
USB0DeviceIntHandler(void)
|
||||
{
|
||||
uint32_t ui32Status;
|
||||
|
||||
//
|
||||
// Get the controller interrupt status.
|
||||
//
|
||||
ui32Status = MAP_USBIntStatusControl(USB0_BASE);
|
||||
|
||||
//
|
||||
// Call the internal handler.
|
||||
//
|
||||
USBDeviceIntHandlerInternal(0, ui32Status);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Close the Doxygen group.
|
||||
//! @}
|
||||
//
|
||||
//*****************************************************************************
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,364 @@
|
|||
//*****************************************************************************
|
||||
//
|
||||
// usbdhidkeyb.h - Definitions used by HID keyboard class devices.
|
||||
//
|
||||
// Copyright (c) 2008-2013 Texas Instruments Incorporated. All rights reserved.
|
||||
// Software License Agreement
|
||||
//
|
||||
// Texas Instruments (TI) is supplying this software for use solely and
|
||||
// exclusively on TI's microcontroller products. The software is owned by
|
||||
// TI and/or its suppliers, and is protected under applicable copyright
|
||||
// laws. You may not combine this software with "viral" open-source
|
||||
// software in order to form a larger program.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
|
||||
// NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
|
||||
// NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
|
||||
// CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
|
||||
// DAMAGES, FOR ANY REASON WHATSOEVER.
|
||||
//
|
||||
// This is part of revision 1.1 of the Tiva USB Library.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
#ifndef __USBDHIDKEYB_H__
|
||||
#define __USBDHIDKEYB_H__
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// If building with a C++ compiler, make all of the definitions in this header
|
||||
// have a C binding.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! \addtogroup hid_keyboard_device_class_api
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! The maximum number of simultaneously-pressed, non-modifier keys that the
|
||||
//! HID BIOS keyboard protocol can send at once. Attempts to send more pressed
|
||||
//! keys than this will result in a rollover error being reported to the host
|
||||
//! and KEYB_ERR_TOO_MANY_KEYS being returned from
|
||||
//! USBDHIDKeyboardKeyStateChange.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define KEYB_MAX_CHARS_PER_REPORT \
|
||||
6
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// PRIVATE
|
||||
//
|
||||
// The first few sections of this header are private defines that are used by
|
||||
// the USB HID keyboard code and are here only to help with the application
|
||||
// allocating the correct amount of memory for the USB HID Keyboard device
|
||||
// code.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// PRIVATE
|
||||
//
|
||||
// This enumeration holds the various states that the keyboard can be in during
|
||||
// normal operation.
|
||||
//
|
||||
//*****************************************************************************
|
||||
typedef enum
|
||||
{
|
||||
//
|
||||
// Unconfigured.
|
||||
//
|
||||
HID_KEYBOARD_STATE_UNCONFIGURED,
|
||||
|
||||
//
|
||||
// No keys to send and not waiting on data.
|
||||
//
|
||||
HID_KEYBOARD_STATE_IDLE,
|
||||
|
||||
//
|
||||
// Waiting on report data from the host.
|
||||
//
|
||||
HID_KEYBOARD_STATE_WAIT_DATA,
|
||||
|
||||
//
|
||||
// Waiting on data to be sent out.
|
||||
//
|
||||
HID_KEYBOARD_STATE_SEND
|
||||
}
|
||||
tKeyboardState;
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// PRIVATE
|
||||
//
|
||||
// The size of the keyboard input and output reports.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define KEYB_IN_REPORT_SIZE 8
|
||||
#define KEYB_OUT_REPORT_SIZE 1
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// PRIVATE
|
||||
//
|
||||
// This structure defines the private instance data structure for the USB HID
|
||||
// keyboard device. This structure forms the RAM workspace used by each
|
||||
// instance of the keyboard.
|
||||
//
|
||||
//*****************************************************************************
|
||||
typedef struct
|
||||
{
|
||||
//
|
||||
// The USB configuration number set by the host or 0 of the device is
|
||||
// currently unconfigured.
|
||||
//
|
||||
uint8_t ui8USBConfigured;
|
||||
|
||||
//
|
||||
// The protocol requested by the host, USB_HID_PROTOCOL_BOOT or
|
||||
// USB_HID_PROTOCOL_REPORT.
|
||||
//
|
||||
uint8_t ui8Protocol;
|
||||
|
||||
//
|
||||
// The current states that the keyboard LEDs are to be set to.
|
||||
//
|
||||
volatile uint8_t ui8LEDStates;
|
||||
|
||||
//
|
||||
// The total number of keys currently pressed. This indicates the number
|
||||
// of key press entries in the pui8KeysPressed array.
|
||||
//
|
||||
uint8_t ui8KeyCount;
|
||||
|
||||
//
|
||||
// The current state of the keyboard interrupt IN endpoint.
|
||||
//
|
||||
volatile tKeyboardState eKeyboardState;
|
||||
|
||||
//
|
||||
// A flag to indicate that the application pressed or released a key
|
||||
// but that we couldn't send the report immediately.
|
||||
//
|
||||
volatile bool bChangeMade;
|
||||
|
||||
//
|
||||
// A buffer used to receive output reports from the host.
|
||||
//
|
||||
uint8_t pui8DataBuffer[KEYB_OUT_REPORT_SIZE];
|
||||
|
||||
//
|
||||
// A buffer used to hold the last input report sent to the host.
|
||||
//
|
||||
uint8_t pui8Report[KEYB_IN_REPORT_SIZE];
|
||||
|
||||
//
|
||||
// A buffer containing the usage codes of all non-modifier keys currently
|
||||
// in the pressed state.
|
||||
//
|
||||
uint8_t pui8KeysPressed[KEYB_MAX_CHARS_PER_REPORT];
|
||||
|
||||
//
|
||||
// The idle timeout control structure for our input report. This is
|
||||
// required by the lower level HID driver.
|
||||
//
|
||||
tHIDReportIdle sReportIdle;
|
||||
|
||||
//
|
||||
// This is needed for the lower level HID driver.
|
||||
//
|
||||
tUSBDHIDDevice sHIDDevice;
|
||||
}
|
||||
tHIDKeyboardInstance;
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! This structure is used by the application to define operating parameters
|
||||
//! for the HID keyboard device.
|
||||
//
|
||||
//*****************************************************************************
|
||||
typedef struct
|
||||
{
|
||||
//
|
||||
//! The vendor ID that this device is to present in the device descriptor.
|
||||
//
|
||||
const uint16_t ui16VID;
|
||||
|
||||
//
|
||||
//! The product ID that this device is to present in the device descriptor.
|
||||
//
|
||||
const uint16_t ui16PID;
|
||||
|
||||
//
|
||||
//! The maximum power consumption of the device, expressed in milliamps.
|
||||
//
|
||||
const uint16_t ui16MaxPowermA;
|
||||
|
||||
//
|
||||
//! Indicates whether the device is self- or bus-powered and whether or not
|
||||
//! it supports remote wakeup. Valid values are USB_CONF_ATTR_SELF_PWR or
|
||||
//! USB_CONF_ATTR_BUS_PWR, optionally ORed with USB_CONF_ATTR_RWAKE.
|
||||
//
|
||||
const uint8_t ui8PwrAttributes;
|
||||
|
||||
//! A pointer to the callback function which will be called to notify
|
||||
//! the application of general events and those related to reception of
|
||||
//! Output and Feature reports via the (optional) interrupt OUT endpoint.
|
||||
//
|
||||
const tUSBCallback pfnCallback;
|
||||
|
||||
//
|
||||
//! A client-supplied pointer which will be sent as the first
|
||||
//! parameter in all calls made to the keyboard callback,
|
||||
//! pfnCallback.
|
||||
//
|
||||
void *pvCBData;
|
||||
|
||||
//
|
||||
//! A pointer to the string descriptor array for this device. This array
|
||||
//! must contain the following string descriptor pointers in this order.
|
||||
//! Language descriptor, Manufacturer name string (language 1), Product
|
||||
//! name string (language 1), Serial number string (language 1),HID
|
||||
//! Interface description string (language 1), Configuration description
|
||||
//! string (language 1).
|
||||
//!
|
||||
//! If supporting more than 1 language, the descriptor block (except for
|
||||
//! string descriptor 0) must be repeated for each language defined in the
|
||||
//! language descriptor.
|
||||
//
|
||||
const uint8_t * const *ppui8StringDescriptors;
|
||||
|
||||
//
|
||||
//! The number of descriptors provided in the ppStringDescriptors
|
||||
//! array. This must be (1 + (5 * (num languages))).
|
||||
//
|
||||
const uint32_t ui32NumStringDescriptors;
|
||||
|
||||
//
|
||||
//! The private instance data for this device. This memory must
|
||||
//! remain accessible for as long as the keyboard device is in use and
|
||||
//! must not be modified by any code outside the HID keyboard driver.
|
||||
//
|
||||
tHIDKeyboardInstance sPrivateData;
|
||||
}
|
||||
tUSBDHIDKeyboardDevice;
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Keyboard-specific device class driver events
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! This event indicates that the keyboard LED states are to be set. The
|
||||
//! ui32MsgValue parameter contains the requested state for each of the LEDs
|
||||
//! defined as a collection of ORed bits where a 1 indicates that the LED is
|
||||
//! to be turned on and a 0 indicates that it should be turned off. The
|
||||
//! individual LED bits are defined using labels HID_KEYB_NUM_LOCK,
|
||||
//! HID_KEYB_CAPS_LOCK, HID_KEYB_SCROLL_LOCK, HID_KEYB_COMPOSE and
|
||||
//! HID_KEYB_KANA.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define USBD_HID_KEYB_EVENT_SET_LEDS \
|
||||
USBD_HID_KEYB_EVENT_BASE
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! This return code from USBDHIDKeyboardKeyStateChange indicates success.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define KEYB_SUCCESS 0
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! This return code from USBDHIDKeyboardKeyStateChange indicates that an
|
||||
//! attempt has been made to record more than 6 simultaneously pressed,
|
||||
//! non-modifier keys. The USB HID BIOS keyboard protocol allows no more than
|
||||
//! 6 pressed keys to be reported at one time. Until at least one key is
|
||||
//! released, the device will report a roll over error to the host each time it
|
||||
//! is asked for the keyboard input report.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define KEYB_ERR_TOO_MANY_KEYS 1
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! This return code from USBDHIDKeyboardKeyStateChange indicates that an
|
||||
//! error was reported while attempting to send a report to the host. A client
|
||||
//! should assume that the host has disconnected if this return code is seen.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define KEYB_ERR_TX_ERROR 2
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! USBDHIDKeyboardKeyStateChange returns this value if it is called with the
|
||||
//! bPress parameter set to false but with a ui8UsageCode parameter which does
|
||||
//! does not indicate a key that is currently recorded as being pressed. This
|
||||
//! may occur if an attempt was previously made to report more than 6 pressed
|
||||
//! keys and the earlier pressed keys are released before the later ones. This
|
||||
//! condition is benign and should not be used to indicate a host disconnection
|
||||
//! or serious error.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define KEYB_ERR_NOT_FOUND 3
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! USBDHIDKeyboardKeyStateChange returns this value if it is called before the
|
||||
//! USB host has connected and configured the device. Any key usage code
|
||||
//! passed will be stored and passed to the host once configuration completes.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define KEYB_ERR_NOT_CONFIGURED 4
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// API Function Prototypes
|
||||
//
|
||||
//*****************************************************************************
|
||||
extern void *USBDHIDKeyboardInit(uint32_t ui32Index,
|
||||
tUSBDHIDKeyboardDevice *psHIDKbDevice);
|
||||
extern void *USBDHIDKeyboardCompositeInit(uint32_t ui32Index,
|
||||
tUSBDHIDKeyboardDevice *psHIDKbDevice,
|
||||
tCompositeEntry *psCompEntry);
|
||||
extern void USBDHIDKeyboardTerm(void *pvKeyboardInstance);
|
||||
extern void *USBDHIDKeyboardSetCBData(void *pvKeyboardInstance,
|
||||
void *pvCBData);
|
||||
extern uint32_t USBDHIDKeyboardKeyStateChange(void *pvKeyboardInstance,
|
||||
uint8_t ui8Modifiers,
|
||||
uint8_t ui8UsageCode,
|
||||
bool bPressed);
|
||||
extern void USBDHIDKeyboardPowerStatusSet(void *pvKeyboardInstance,
|
||||
uint8_t ui8Power);
|
||||
extern bool USBDHIDKeyboardRemoteWakeupRequest(void *pvKeyboardInstance);
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Close the Doxygen group.
|
||||
//! @}
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Mark the end of the C bindings section for C++ compilers.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // __USBDHIDKEYB_H__
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,299 @@
|
|||
//*****************************************************************************
|
||||
//
|
||||
// usbdhidmouse.h - Public header file for the USB HID Mouse device class
|
||||
// driver
|
||||
//
|
||||
// Copyright (c) 2008-2013 Texas Instruments Incorporated. All rights reserved.
|
||||
// Software License Agreement
|
||||
//
|
||||
// Texas Instruments (TI) is supplying this software for use solely and
|
||||
// exclusively on TI's microcontroller products. The software is owned by
|
||||
// TI and/or its suppliers, and is protected under applicable copyright
|
||||
// laws. You may not combine this software with "viral" open-source
|
||||
// software in order to form a larger program.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
|
||||
// NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
|
||||
// NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
|
||||
// CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
|
||||
// DAMAGES, FOR ANY REASON WHATSOEVER.
|
||||
//
|
||||
// This is part of revision 1.1 of the Tiva USB Library.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
#ifndef __USBDHIDMOUSE_H__
|
||||
#define __USBDHIDMOUSE_H__
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// If building with a C++ compiler, make all of the definitions in this header
|
||||
// have a C binding.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! \addtogroup hid_mouse_device_class_api
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// PRIVATE
|
||||
//
|
||||
// The first few sections of this header are private defines that are used by
|
||||
// the USB HID mouse code and are here only to help with the application
|
||||
// allocating the correct amount of memory for the HID mouse device code.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// PRIVATE
|
||||
//
|
||||
// The size of the mouse input report sent to the host.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define MOUSE_REPORT_SIZE 3
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// PRIVATE
|
||||
//
|
||||
// This enumeration holds the various states that the mouse can be in during
|
||||
// normal operation.
|
||||
//
|
||||
//*****************************************************************************
|
||||
typedef enum
|
||||
{
|
||||
//
|
||||
// Unconfigured.
|
||||
//
|
||||
eHIDMouseStateUnconfigured,
|
||||
|
||||
//
|
||||
// No keys to send and not waiting on data.
|
||||
//
|
||||
eHIDMouseStateIdle,
|
||||
|
||||
//
|
||||
// Waiting on report data from the host.
|
||||
//
|
||||
eHIDMouseStateWaitData,
|
||||
|
||||
//
|
||||
// Waiting on data to be sent out.
|
||||
//
|
||||
eHIDMouseStateSend
|
||||
}
|
||||
tMouseState;
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// PRIVATE
|
||||
//
|
||||
// This structure provides the private instance data structure for the USB
|
||||
// HID Mouse device. This structure forms the RAM workspace used by each
|
||||
// instance of the mouse.
|
||||
//
|
||||
//*****************************************************************************
|
||||
typedef struct
|
||||
{
|
||||
//
|
||||
// The USB configuration number set by the host or 0 of the device is
|
||||
// currently unconfigured.
|
||||
//
|
||||
uint8_t ui8USBConfigured;
|
||||
|
||||
//
|
||||
// The protocol requested by the host, USB_HID_PROTOCOL_BOOT or
|
||||
// USB_HID_PROTOCOL_REPORT.
|
||||
//
|
||||
uint8_t ui8Protocol;
|
||||
|
||||
//
|
||||
// A buffer used to hold the last input report sent to the host.
|
||||
//
|
||||
uint8_t pui8Report[MOUSE_REPORT_SIZE];
|
||||
|
||||
//
|
||||
// The current state of the mouse interrupt IN endpoint.
|
||||
//
|
||||
volatile tMouseState iMouseState;
|
||||
|
||||
//
|
||||
// The idle timeout control structure for our input report. This is
|
||||
// required by the lower level HID driver.
|
||||
//
|
||||
tHIDReportIdle sReportIdle;
|
||||
|
||||
//
|
||||
// This is needed for the lower level HID driver.
|
||||
//
|
||||
tUSBDHIDDevice sHIDDevice;
|
||||
}
|
||||
tHIDMouseInstance;
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! This structure is used by the application to define operating parameters
|
||||
//! for the HID mouse device.
|
||||
//
|
||||
//*****************************************************************************
|
||||
typedef struct
|
||||
{
|
||||
//
|
||||
//! The vendor ID that this device is to present in the device descriptor.
|
||||
//
|
||||
const uint16_t ui16VID;
|
||||
|
||||
//
|
||||
//! The product ID that this device is to present in the device descriptor.
|
||||
//
|
||||
const uint16_t ui16PID;
|
||||
|
||||
//
|
||||
//! The maximum power consumption of the device, expressed in milliamps.
|
||||
//
|
||||
const uint16_t ui16MaxPowermA;
|
||||
|
||||
//
|
||||
//! Indicates whether the device is self- or bus-powered and whether or not
|
||||
//! it supports remote wakeup. Valid values are USB_CONF_ATTR_SELF_PWR or
|
||||
//! USB_CONF_ATTR_BUS_PWR, optionally ORed with USB_CONF_ATTR_RWAKE.
|
||||
//
|
||||
const uint8_t ui8PwrAttributes;
|
||||
|
||||
//
|
||||
//! A pointer to the callback function which will be called to notify
|
||||
//! the application of events relating to the operation of the mouse.
|
||||
//
|
||||
const tUSBCallback pfnCallback;
|
||||
|
||||
//
|
||||
//! A client-supplied pointer which will be sent as the first
|
||||
//! parameter in all calls made to the mouse callback, pfnCallback.
|
||||
//
|
||||
void *pvCBData;
|
||||
|
||||
//
|
||||
//! A pointer to the string descriptor array for this device. This array
|
||||
//! must contain the following string descriptor pointers in this order.
|
||||
//! Language descriptor, Manufacturer name string (language 1), Product
|
||||
//! name string (language 1), Serial number string (language 1),HID
|
||||
//! Interface description string (language 1), Configuration description
|
||||
//! string (language 1).
|
||||
//!
|
||||
//! If supporting more than 1 language, the descriptor block (except for
|
||||
//! string descriptor 0) must be repeated for each language defined in the
|
||||
//! language descriptor.
|
||||
//
|
||||
const uint8_t * const *ppui8StringDescriptors;
|
||||
|
||||
//
|
||||
//! The number of descriptors provided in the ppStringDescriptors
|
||||
//! array. This must be (1 + (5 * (num languages))).
|
||||
//
|
||||
const uint32_t ui32NumStringDescriptors;
|
||||
|
||||
//
|
||||
//! The private instance data for this device. This memory must
|
||||
//! remain accessible for as long as the mouse device is in use and must
|
||||
//! not be modified by any code outside the HID mouse driver.
|
||||
//
|
||||
tHIDMouseInstance sPrivateData;
|
||||
}
|
||||
tUSBDHIDMouseDevice;
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! This return code from USBDHIDMouseStateChange indicates success.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define MOUSE_SUCCESS 0
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! This return code from USBDHIDMouseStateChange indicates that an error was
|
||||
//! reported while attempting to send a report to the host. A client should
|
||||
//! assume that the host has disconnected if this return code is seen.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define MOUSE_ERR_TX_ERROR 2
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! USBDHIDMouseStateChange returns this value if it is called before the
|
||||
//! USB host has connected and configured the device. All mouse state
|
||||
//! information passed on the call will have been ignored.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define MOUSE_ERR_NOT_CONFIGURED \
|
||||
4
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! Setting this bit in the ui8Buttons parameter to USBDHIDMouseStateChange
|
||||
//! indicates to the USB host that button 1 on the mouse is pressed.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define MOUSE_REPORT_BUTTON_1 0x01
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! Setting this bit in the ui8Buttons parameter to USBDHIDMouseStateChange
|
||||
//! indicates to the USB host that button 2 on the mouse is pressed.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define MOUSE_REPORT_BUTTON_2 0x02
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! Setting this bit in the ui8Buttons parameter to USBDHIDMouseStateChange
|
||||
//! indicates to the USB host that button 3 on the mouse is pressed.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define MOUSE_REPORT_BUTTON_3 0x04
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// API Function Prototypes
|
||||
//
|
||||
//*****************************************************************************
|
||||
extern void *USBDHIDMouseInit(uint32_t ui32Index,
|
||||
tUSBDHIDMouseDevice *psMouseDevice);
|
||||
extern void *USBDHIDMouseCompositeInit(uint32_t ui32Index,
|
||||
tUSBDHIDMouseDevice *psMouseDevice,
|
||||
tCompositeEntry *psCompEntry);
|
||||
extern void USBDHIDMouseTerm(void *pvMouseDevice);
|
||||
extern void *USBDHIDMouseSetCBData(void *pvMouseDevice, void *pvCBData);
|
||||
extern uint32_t USBDHIDMouseStateChange(void *pvMouseDevice, int8_t i8DeltaX,
|
||||
int8_t i8DeltaY, uint8_t ui8Buttons);
|
||||
extern void USBDHIDMousePowerStatusSet(void *pvMouseDevice,
|
||||
uint8_t ui8Power);
|
||||
extern bool USBDHIDMouseRemoteWakeupRequest(void *pvMouseDevice);
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Close the Doxygen group.
|
||||
//! @}
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Mark the end of the C bindings section for C++ compilers.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // __USBDHIDMOUSE_H__
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,429 @@
|
|||
//*****************************************************************************
|
||||
//
|
||||
// usbdmsc.h - USB mass storage device class driver.
|
||||
//
|
||||
// Copyright (c) 2009-2013 Texas Instruments Incorporated. All rights reserved.
|
||||
// Software License Agreement
|
||||
//
|
||||
// Texas Instruments (TI) is supplying this software for use solely and
|
||||
// exclusively on TI's microcontroller products. The software is owned by
|
||||
// TI and/or its suppliers, and is protected under applicable copyright
|
||||
// laws. You may not combine this software with "viral" open-source
|
||||
// software in order to form a larger program.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
|
||||
// NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
|
||||
// NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
|
||||
// CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
|
||||
// DAMAGES, FOR ANY REASON WHATSOEVER.
|
||||
//
|
||||
// This is part of revision 1.1 of the Tiva USB Library.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
#ifndef __USBDMSC_H__
|
||||
#define __USBDMSC_H__
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// If building with a C++ compiler, make all of the definitions in this header
|
||||
// have a C binding.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! \addtogroup msc_device_class_api
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! Media Access functions.
|
||||
//
|
||||
//*****************************************************************************
|
||||
typedef struct
|
||||
{
|
||||
//
|
||||
//! This function is used to initialize and open the physical drive number
|
||||
//! associated with the parameter ui32Drive. The function will return zero
|
||||
//! if the drive could not be opened for some reason. In the case of
|
||||
//! removable device like an SD card this function should return zero if
|
||||
//! the SD card is not present.
|
||||
//! The function returns a pointer to data that should be passed to other
|
||||
//! APIs or it will return 0 if no drive was found.
|
||||
//
|
||||
void *(*pfnOpen)(uint32_t ui32Drive);
|
||||
|
||||
//*************************************************************************
|
||||
//
|
||||
// This function close the drive number in use by the mass storage class
|
||||
// device.
|
||||
//
|
||||
// /param pvDrive is the pointer that was returned from a call to
|
||||
// USBDMSCStorageOpen().
|
||||
//
|
||||
// This function is used to close the physical drive number associated with
|
||||
// the parameter \e pvDrive. This function will return 0 if the drive was
|
||||
// closed successfully and any other value will indicate a failure.
|
||||
//
|
||||
// /return Returns 0 if the drive was successfully closed or non-zero for a
|
||||
// failure.
|
||||
//
|
||||
//*************************************************************************
|
||||
void (*pfnClose)(void *pvDrive);
|
||||
|
||||
//*************************************************************************
|
||||
//
|
||||
// This function will read a block from a device opened by the
|
||||
// USBDMSCStorageOpen() call.
|
||||
//
|
||||
// /param pvDrive is the pointer that was returned from a call to
|
||||
// USBDMSCStorageOpen().
|
||||
// /param pui8Data is the buffer that data will be written into.
|
||||
// /param ui32Sector is the block address to read.
|
||||
// /param ui32NumBlocks is the number of blocks to read.
|
||||
//
|
||||
// This function is use to read blocks from a physical device and return
|
||||
// them in the \e pui8Data buffer. The data area pointed to by \e pui8Data
|
||||
// should be at least \e ui32NumBlocks * Block Size bytes to prevent
|
||||
// overwriting data.
|
||||
//
|
||||
// /return Returns the number of bytes that were read from the device.
|
||||
//
|
||||
//*************************************************************************
|
||||
uint32_t (*pfnBlockRead)(void *pvDrive, uint8_t *pui8Data,
|
||||
uint32_t ui32Sector, uint32_t ui32NumBlocks);
|
||||
|
||||
//*************************************************************************
|
||||
//
|
||||
// This function will write a block to a device opened by the
|
||||
// USBDMSCStorageOpen() call.
|
||||
//
|
||||
// /param pvDrive is the pointer that was returned from a call to
|
||||
// USBDMSCStorageOpen().
|
||||
// /param pui8Data is the buffer that data will be used for writing.
|
||||
// /param ui32NumBlocks is the number of blocks to write.
|
||||
//
|
||||
// This function is use to write blocks to a physical device from the
|
||||
// buffer pointed to by the \e pui8Data buffer. If the number of blocks is
|
||||
// greater than one then the block address will increment and write to the
|
||||
// next block until \e ui32NumBlocks * Block Size bytes have been written.
|
||||
//
|
||||
// /return Returns the number of bytes that were written to the device.
|
||||
//
|
||||
//*************************************************************************
|
||||
uint32_t (*pfnBlockWrite)(void *pvDrive, uint8_t *pui8Data,
|
||||
uint32_t ui32Sector, uint32_t ui32NumBlocks);
|
||||
|
||||
//*************************************************************************
|
||||
//
|
||||
// This function will return the number of blocks present on a device.
|
||||
//
|
||||
// /param pvDrive is the pointer that was returned from a call to
|
||||
// USBDMSCStorageOpen().
|
||||
//
|
||||
// This function is used to return the total number of blocks on a physical
|
||||
// device based on the \e pvDrive parameter.
|
||||
//
|
||||
// /return Returns the number of blocks that are present in a device.
|
||||
//
|
||||
//*************************************************************************
|
||||
uint32_t (*pfnNumBlocks)(void *pvDrive);
|
||||
}
|
||||
tMSCDMedia;
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// These defines control the sizes of USB transfers for data and commands.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define DEVICE_BLOCK_SIZE 512
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// USBDMSCMediaChange() tUSBDMSCMediaStatus values.
|
||||
//
|
||||
//*****************************************************************************
|
||||
typedef enum
|
||||
{
|
||||
eUSBDMSCMediaPresent,
|
||||
eUSBDMSCMediaNotPresent,
|
||||
eUSBDMSCMediaUnknown
|
||||
}
|
||||
tUSBDMSCMediaStatus;
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// PRIVATE
|
||||
//
|
||||
// This structure defines the private instance data and state variables for the
|
||||
// mass storage class. The memory for this structure is in the the
|
||||
// sPrivateData field in the tUSBDMSCDevice structure passed on
|
||||
// USBDMSCInit() and should not be modified by any code outside of the mass
|
||||
// storage device code.
|
||||
//
|
||||
//*****************************************************************************
|
||||
typedef struct
|
||||
{
|
||||
//
|
||||
// Base address for the USB controller.
|
||||
//
|
||||
uint32_t ui32USBBase;
|
||||
|
||||
//
|
||||
// The device info to interact with the lower level DCD code.
|
||||
//
|
||||
tDeviceInfo sDevInfo;
|
||||
|
||||
//
|
||||
// These three values are used to return the current sense data for an
|
||||
// instance of the mass storage class.
|
||||
//
|
||||
uint8_t ui8ErrorCode;
|
||||
uint8_t ui8SenseKey;
|
||||
uint16_t ui16AddSenseCode;
|
||||
|
||||
//
|
||||
// The pointer to the instance returned from the Open call to the media.
|
||||
//
|
||||
void *pvMedia;
|
||||
|
||||
//
|
||||
// The connection status of the device.
|
||||
//
|
||||
volatile bool bConnected;
|
||||
|
||||
//
|
||||
// Holds the flag settings for this instance.
|
||||
//
|
||||
uint32_t ui32Flags;
|
||||
|
||||
//
|
||||
// Holds the current media status.
|
||||
//
|
||||
tUSBDMSCMediaStatus iMediaStatus;
|
||||
|
||||
//
|
||||
// MSC block buffer.
|
||||
//
|
||||
uint32_t pui32Buffer[DEVICE_BLOCK_SIZE>>2];
|
||||
|
||||
//
|
||||
// Current number of bytes to transfer.
|
||||
//
|
||||
uint32_t ui32BytesToTransfer;
|
||||
|
||||
//
|
||||
// The LBA for the current transfer.
|
||||
//
|
||||
uint32_t ui32CurrentLBA;
|
||||
|
||||
//
|
||||
// The IN endpoint number, this is modified in composite devices.
|
||||
//
|
||||
uint8_t ui8INEndpoint;
|
||||
|
||||
//
|
||||
// The IN DMA channel.
|
||||
//
|
||||
uint8_t ui8INDMA;
|
||||
|
||||
//
|
||||
// The OUT endpoint number, this is modified in composite devices.
|
||||
//
|
||||
uint8_t ui8OUTEndpoint;
|
||||
|
||||
//
|
||||
// The OUT DMA channel.
|
||||
//
|
||||
uint8_t ui8OUTDMA;
|
||||
|
||||
//
|
||||
// The bulk class interface number, this is modified in composite devices.
|
||||
//
|
||||
uint8_t ui8Interface;
|
||||
|
||||
//
|
||||
// Active SCSI state.
|
||||
//
|
||||
uint8_t ui8SCSIState;
|
||||
|
||||
//
|
||||
// A copy of the DMA instance data used with calls to USBLibDMA functions.
|
||||
//
|
||||
tUSBDMAInstance *psDMAInstance;
|
||||
}
|
||||
tMSCInstance;
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// This is the size of the g_pui8MSCInterface array in bytes.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define MSCINTERFACE_SIZE (23)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! The size of the memory that should be allocated to create a configuration
|
||||
//! descriptor for a single instance of the USB Audio Device.
|
||||
//! This does not include the configuration descriptor which is automatically
|
||||
//! ignored by the composite device class.
|
||||
//
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define COMPOSITE_DMSC_SIZE (MSCINTERFACE_SIZE)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! The structure used by the application to define operating parameters for
|
||||
//! the mass storage device.
|
||||
//
|
||||
//*****************************************************************************
|
||||
typedef struct
|
||||
{
|
||||
//
|
||||
//! The vendor ID that this device is to present in the device descriptor.
|
||||
//
|
||||
const uint16_t ui16VID;
|
||||
|
||||
//
|
||||
//! The product ID that this device is to present in the device descriptor.
|
||||
//
|
||||
const uint16_t ui16PID;
|
||||
|
||||
//
|
||||
//! 8 byte vendor string.
|
||||
//
|
||||
const uint8_t pui8Vendor[8];
|
||||
|
||||
//
|
||||
//! 16 byte vendor string.
|
||||
//
|
||||
const uint8_t pui8Product[16];
|
||||
|
||||
//
|
||||
//! 4 byte vendor string.
|
||||
//
|
||||
const uint8_t pui8Version[4];
|
||||
|
||||
//
|
||||
//! The maximum power consumption of the device, expressed in milliamps.
|
||||
//
|
||||
const uint16_t ui16MaxPowermA;
|
||||
|
||||
//
|
||||
//! Indicates whether the device is self or bus-powered and whether or not
|
||||
//! it supports remote wakeup. Valid values are USB_CONF_ATTR_SELF_PWR or
|
||||
//! USB_CONF_ATTR_BUS_PWR, optionally ORed with USB_CONF_ATTR_RWAKE.
|
||||
//
|
||||
const uint8_t ui8PwrAttributes;
|
||||
|
||||
//
|
||||
//! A pointer to the string descriptor array for this device. This array
|
||||
//! must contain the following string descriptor pointers in this order.
|
||||
//! Language descriptor, Manufacturer name string (language 1), Product
|
||||
//! name string (language 1), Serial number string (language 1), MSC
|
||||
//! Interface description string (language 1), Configuration description
|
||||
//! string (language 1).
|
||||
//!
|
||||
//! If supporting more than 1 language, the descriptor block (except for
|
||||
//! string descriptor 0) must be repeated for each language defined in the
|
||||
//! language descriptor.
|
||||
//!
|
||||
//
|
||||
const uint8_t * const *ppui8StringDescriptors;
|
||||
|
||||
//
|
||||
//! The number of descriptors provided in the ppStringDescriptors
|
||||
//! array. This must be 1 + ((5 + (num HID strings)) * (num languages)).
|
||||
//
|
||||
const uint32_t ui32NumStringDescriptors;
|
||||
|
||||
//
|
||||
//! This structure holds the access functions for the media used by this
|
||||
//! instance of the mass storage class device. All of the functions in
|
||||
//! this structure are required to be filled out with valid functions.
|
||||
//
|
||||
const tMSCDMedia sMediaFunctions;
|
||||
|
||||
//
|
||||
//! This is the callback function for various events that occur during
|
||||
//! mass storage class operation.
|
||||
//
|
||||
const tUSBCallback pfnEventCallback;
|
||||
|
||||
//
|
||||
//! The private instance data for this device. This memory
|
||||
//! must remain accessible for as long as the MSC device is in use and
|
||||
//! must not be modified by any code outside the MSC class driver.
|
||||
//
|
||||
tMSCInstance sPrivateData;
|
||||
}
|
||||
tUSBDMSCDevice;
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// MSC-specific device class driver events
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! This event indicates that the host has completed other operations and is
|
||||
//! no longer accessing the device.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define USBD_MSC_EVENT_IDLE (USBD_MSC_EVENT_BASE + 0)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! This event indicates that the host is reading the storage media.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define USBD_MSC_EVENT_READING (USBD_MSC_EVENT_BASE + 1)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! This event indicates that the host is writing to the storage media.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define USBD_MSC_EVENT_WRITING (USBD_MSC_EVENT_BASE + 2)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// API Function Prototypes
|
||||
//
|
||||
//*****************************************************************************
|
||||
extern void *USBDMSCInit(uint32_t ui32Index,
|
||||
tUSBDMSCDevice *psMSCDevice);
|
||||
extern void *USBDMSCCompositeInit(uint32_t ui32Index,
|
||||
tUSBDMSCDevice *psMSCDevice,
|
||||
tCompositeEntry *psCompEntry);
|
||||
extern void USBDMSCTerm(void *pvInstance);
|
||||
extern void USBDMSCMediaChange(void *pvInstance,
|
||||
tUSBDMSCMediaStatus eMediaStatus);
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Close the Doxygen group.
|
||||
//! @}
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Mark the end of the C bindings section for C++ compilers.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,161 @@
|
|||
//*****************************************************************************
|
||||
//
|
||||
// usbhaudio.h - USB host audio class driver.
|
||||
//
|
||||
// Copyright (c) 2010-2013 Texas Instruments Incorporated. All rights reserved.
|
||||
// Software License Agreement
|
||||
//
|
||||
// Texas Instruments (TI) is supplying this software for use solely and
|
||||
// exclusively on TI's microcontroller products. The software is owned by
|
||||
// TI and/or its suppliers, and is protected under applicable copyright
|
||||
// laws. You may not combine this software with "viral" open-source
|
||||
// software in order to form a larger program.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
|
||||
// NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
|
||||
// NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
|
||||
// CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
|
||||
// DAMAGES, FOR ANY REASON WHATSOEVER.
|
||||
//
|
||||
// This is part of revision 1.1 of the Tiva USB Library.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
#ifndef __USBHAUDIO_H__
|
||||
#define __USBHAUDIO_H__
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// If building with a C++ compiler, make all of the definitions in this header
|
||||
// have a C binding.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! \addtogroup usblib_host_class
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// USB host audio specific events
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! This USB host audio event indicates that the device is connected and
|
||||
//! ready to send or receive buffers. The \e pvBuffer and \e ui32Param
|
||||
//! values are not used in this event.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define USBH_AUDIO_EVENT_OPEN (USBH_AUDIO_EVENT_BASE + 0)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! This USB host audio event indicates that the previously connected device
|
||||
//! has been disconnected. The \e pvBuffer and \e ui32Param values are not used
|
||||
//! in this event.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define USBH_AUDIO_EVENT_CLOSE (USBH_AUDIO_EVENT_BASE + 1)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// This definition is used with the USBHostAudioFormatGet() and
|
||||
// USBHostAudioFormatSet() API's to determine if the audio input is being
|
||||
// accesses(USBH_AUDIO_FORMAT_IN set) or audio output(USBH_AUDIO_FORMAT clear).
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define USBH_AUDIO_FORMAT_IN 0x00000001
|
||||
#define USBH_AUDIO_FORMAT_OUT 0x00000000
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t ui8Channels;
|
||||
uint8_t ui8Bits;
|
||||
uint32_t ui32SampleRate;
|
||||
}
|
||||
tUSBAudioFormat;
|
||||
|
||||
typedef struct tUSBHostAudioInstance tUSBHostAudioInstance;
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// The prototype for the host USB Audio driver callback function.
|
||||
//
|
||||
//*****************************************************************************
|
||||
typedef void (*tUSBHostAudioCallback)(tUSBHostAudioInstance *psAudioInstance,
|
||||
uint32_t ui32Event,
|
||||
uint32_t ui32MsgParam,
|
||||
void *pvMsgData);
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// API Function Prototypes
|
||||
//
|
||||
//*****************************************************************************
|
||||
extern tUSBHostAudioInstance * USBHostAudioOpen(uint32_t ui32Index,
|
||||
tUSBHostAudioCallback pfnCallback);
|
||||
extern void USBHostAudioClose(tUSBHostAudioInstance *psAudioInstance);
|
||||
extern int32_t USBHostAudioPlay(tUSBHostAudioInstance *psAudioInstance,
|
||||
void *pvBuffer, uint32_t ui32Size,
|
||||
tUSBHostAudioCallback pfnCallback);
|
||||
|
||||
extern uint32_t USBHostAudioFormatGet(tUSBHostAudioInstance *psAudioInstance,
|
||||
uint32_t ui32SampleRate,
|
||||
uint32_t ui32Bits, uint32_t ui32Channels,
|
||||
uint32_t ui32Flags);
|
||||
extern uint32_t USBHostAudioFormatSet(tUSBHostAudioInstance *psAudioInstance,
|
||||
uint32_t ui32SampleRate,
|
||||
uint32_t ui32Bits, uint32_t ui32Channels,
|
||||
uint32_t ui32Flags);
|
||||
|
||||
extern int32_t USBHostAudioRecord(tUSBHostAudioInstance *psAudioInstance,
|
||||
void *pvBuffer, uint32_t ui32Size,
|
||||
tUSBHostAudioCallback pfnAudioCallback);
|
||||
|
||||
extern uint32_t USBHostAudioVolumeGet(tUSBHostAudioInstance *psAudioInstance,
|
||||
uint32_t ui32Interface,
|
||||
uint32_t ui32Channel);
|
||||
|
||||
extern void USBHostAudioVolumeSet(tUSBHostAudioInstance *psAudioInstance,
|
||||
uint32_t ui32Interface, uint32_t ui32Channel,
|
||||
uint32_t ui32Value);
|
||||
|
||||
extern uint32_t USBHostAudioVolumeMaxGet(tUSBHostAudioInstance *psAudioInstance,
|
||||
uint32_t ui32Interface,
|
||||
uint32_t ui32Channel);
|
||||
|
||||
extern uint32_t USBHostAudioVolumeMinGet(tUSBHostAudioInstance *psAudioInstance,
|
||||
uint32_t ui32Interface,
|
||||
uint32_t ui32Channel);
|
||||
|
||||
extern uint32_t USBHostAudioVolumeResGet(tUSBHostAudioInstance *psAudioInstance,
|
||||
uint32_t ui32Interface,
|
||||
uint32_t ui32Channel);
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @}
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Mark the end of the C bindings section for C++ compilers.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,687 @@
|
|||
//*****************************************************************************
|
||||
//
|
||||
// usbhhid.c - This file contains the host HID driver.
|
||||
//
|
||||
// Copyright (c) 2008-2013 Texas Instruments Incorporated. All rights reserved.
|
||||
// Software License Agreement
|
||||
//
|
||||
// Texas Instruments (TI) is supplying this software for use solely and
|
||||
// exclusively on TI's microcontroller products. The software is owned by
|
||||
// TI and/or its suppliers, and is protected under applicable copyright
|
||||
// laws. You may not combine this software with "viral" open-source
|
||||
// software in order to form a larger program.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
|
||||
// NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
|
||||
// NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
|
||||
// CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
|
||||
// DAMAGES, FOR ANY REASON WHATSOEVER.
|
||||
//
|
||||
// This is part of revision 1.1 of the Tiva USB Library.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "inc/hw_types.h"
|
||||
#include "driverlib/usbdrv.h"
|
||||
#include "usblib/usblib.h"
|
||||
#include "usblib/usblibpriv.h"
|
||||
#include "usblib/usbhid.h"
|
||||
#include "usblib/host/usbhost.h"
|
||||
#include "usblib/host/usbhostpriv.h"
|
||||
#include "usblib/host/usbhhid.h"
|
||||
|
||||
static void * HIDDriverOpen(tUSBHostDevice *psDevice);
|
||||
static void HIDDriverClose(void *pvInstance);
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! \addtogroup usblib_host_class
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// If the user has not explicitly stated the maximum number of HID devices to
|
||||
// support, we assume that we need to support up to the maximum number of USB
|
||||
// devices that the build is configured for.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#ifndef MAX_HID_DEVICES
|
||||
#define MAX_HID_DEVICES MAX_USB_DEVICES
|
||||
#endif
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// This is the structure that holds all of the data for a given instance of
|
||||
// a HID device.
|
||||
//
|
||||
//*****************************************************************************
|
||||
struct tHIDInstance
|
||||
{
|
||||
//
|
||||
// Save the device instance.
|
||||
//
|
||||
tUSBHostDevice *psDevice;
|
||||
|
||||
//
|
||||
// Used to save the callback.
|
||||
//
|
||||
tUSBCallback pfnCallback;
|
||||
|
||||
//
|
||||
// Callback data provided by caller.
|
||||
//
|
||||
void *pvCBData;
|
||||
|
||||
//
|
||||
// Used to remember what type of device was registered.
|
||||
//
|
||||
tHIDSubClassProtocol iDeviceType;
|
||||
|
||||
//
|
||||
// Interrupt IN pipe.
|
||||
//
|
||||
uint32_t ui32IntInPipe;
|
||||
};
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// The instance data storage for attached hid devices.
|
||||
//
|
||||
//*****************************************************************************
|
||||
static tHIDInstance g_psHIDDevice[MAX_HID_DEVICES];
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! This constant global structure defines the HID Class Driver that is
|
||||
//! provided with the USB library.
|
||||
//
|
||||
//*****************************************************************************
|
||||
const tUSBHostClassDriver g_sUSBHIDClassDriver =
|
||||
{
|
||||
USB_CLASS_HID,
|
||||
HIDDriverOpen,
|
||||
HIDDriverClose,
|
||||
0
|
||||
};
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! This function is used to open an instance of a HID device.
|
||||
//!
|
||||
//! \param iDeviceType is the type of device that should be loaded for this
|
||||
//! instance of the HID device.
|
||||
//! \param pfnCallback is the function that will be called whenever changes
|
||||
//! are detected for this device.
|
||||
//! \param pvCBData is the data that will be returned in when the
|
||||
//! \e pfnCallback function is called.
|
||||
//!
|
||||
//! This function creates an instance of an specific type of HID device. The
|
||||
//! \e iDeviceType parameter is one subclass/protocol values of the types
|
||||
//! specified in enumerated types tHIDSubClassProtocol. Only devices that
|
||||
//! enumerate with this type will be called back via the \e pfnCallback
|
||||
//! function. The \e pfnCallback parameter is the callback function for any
|
||||
//! events that occur for this device type. The \e pfnCallback function must
|
||||
//! point to a valid function of type \e tUSBCallback for this call to complete
|
||||
//! successfully. To release this device instance the caller of USBHHIDOpen()
|
||||
//! should call USBHHIDClose() and pass in the value returned from the
|
||||
//! USBHHIDOpen() call.
|
||||
//!
|
||||
//! \return This function returns and instance value that should be used with
|
||||
//! any other APIs that require an instance value. If a value of 0 is returned
|
||||
//! then the device instance could not be created.
|
||||
//
|
||||
//*****************************************************************************
|
||||
tHIDInstance *
|
||||
USBHHIDOpen(tHIDSubClassProtocol iDeviceType, tUSBCallback pfnCallback,
|
||||
void *pvCBData)
|
||||
{
|
||||
uint32_t ui32Loop;
|
||||
|
||||
//
|
||||
// Find a free device instance structure.
|
||||
//
|
||||
for(ui32Loop = 0; ui32Loop < MAX_HID_DEVICES; ui32Loop++)
|
||||
{
|
||||
if(g_psHIDDevice[ui32Loop].iDeviceType == eUSBHHIDClassNone)
|
||||
{
|
||||
//
|
||||
// Save the instance data for this device.
|
||||
//
|
||||
g_psHIDDevice[ui32Loop].pfnCallback = pfnCallback;
|
||||
g_psHIDDevice[ui32Loop].iDeviceType = iDeviceType;
|
||||
g_psHIDDevice[ui32Loop].pvCBData = pvCBData;
|
||||
|
||||
//
|
||||
// Return the device instance pointer.
|
||||
//
|
||||
return(&g_psHIDDevice[ui32Loop]);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// If we get here, there are no space device slots so return NULL to
|
||||
// indicate a problem.
|
||||
//
|
||||
return(0);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! This function is used to release an instance of a HID device.
|
||||
//!
|
||||
//! \param psHIDInstance is the instance value for a HID device to release.
|
||||
//!
|
||||
//! This function releases an instance of a HID device that was created by a
|
||||
//! call to USBHHIDOpen(). This call is required to allow other HID devices
|
||||
//! to be enumerated after another HID device has been disconnected. The
|
||||
//! \e psHIDInstance parameter should hold the value that was returned from
|
||||
//! the previous call to USBHHIDOpen().
|
||||
//!
|
||||
//! \return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
USBHHIDClose(tHIDInstance *psHIDInstance)
|
||||
{
|
||||
//
|
||||
// Disable any more notifications from the HID layer.
|
||||
//
|
||||
psHIDInstance->pfnCallback = 0;
|
||||
|
||||
//
|
||||
// Mark this device slot as free.
|
||||
//
|
||||
psHIDInstance->iDeviceType = eUSBHHIDClassNone;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// This function handles callbacks for the interrupt IN endpoint.
|
||||
//
|
||||
//*****************************************************************************
|
||||
static void
|
||||
HIDIntINCallback(uint32_t ui32Pipe, uint32_t ui32Event)
|
||||
{
|
||||
int32_t i32Dev;
|
||||
|
||||
switch (ui32Event)
|
||||
{
|
||||
//
|
||||
// Handles a request to schedule a new request on the interrupt IN
|
||||
// pipe.
|
||||
//
|
||||
case USB_EVENT_SCHEDULER:
|
||||
{
|
||||
USBHCDPipeSchedule(ui32Pipe, 0, 1);
|
||||
break;
|
||||
}
|
||||
//
|
||||
// Called when new data is available on the interrupt IN pipe.
|
||||
//
|
||||
case USB_EVENT_RX_AVAILABLE:
|
||||
{
|
||||
//
|
||||
// Determine which device this notification is intended for.
|
||||
//
|
||||
for(i32Dev = 0; i32Dev < MAX_HID_DEVICES; i32Dev++)
|
||||
{
|
||||
//
|
||||
// Does this device own the pipe we have been passed?
|
||||
//
|
||||
if(g_psHIDDevice[i32Dev].ui32IntInPipe == ui32Pipe)
|
||||
{
|
||||
//
|
||||
// Yes - send the report data to the USB host HID device
|
||||
// class driver.
|
||||
//
|
||||
g_psHIDDevice[i32Dev].pfnCallback(
|
||||
g_psHIDDevice[i32Dev].pvCBData,
|
||||
USB_EVENT_RX_AVAILABLE, ui32Pipe, 0);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! This function is used to open an instance of the HID driver.
|
||||
//!
|
||||
//! \param psDevice is a pointer to the device information structure.
|
||||
//!
|
||||
//! This function will attempt to open an instance of the HID driver based on
|
||||
//! the information contained in the psDevice structure. This call can fail if
|
||||
//! there are not sufficient resources to open the device. The function will
|
||||
//! return a value that should be passed back into USBHIDClose() when the
|
||||
//! driver is no longer needed.
|
||||
//!
|
||||
//! \return The function will return a pointer to a HID driver instance.
|
||||
//
|
||||
//*****************************************************************************
|
||||
static void *
|
||||
HIDDriverOpen(tUSBHostDevice *psDevice)
|
||||
{
|
||||
int32_t i32Idx, i32Dev;
|
||||
tEndpointDescriptor *psEndpointDescriptor;
|
||||
tInterfaceDescriptor *psInterface;
|
||||
|
||||
//
|
||||
// Get the interface descriptor.
|
||||
//
|
||||
psInterface = USBDescGetInterface(psDevice->psConfigDescriptor, 0, 0);
|
||||
|
||||
//
|
||||
// Search the currently open instances for one that supports the protocol
|
||||
// of this device.
|
||||
//
|
||||
for(i32Dev = 0; i32Dev < MAX_HID_DEVICES; i32Dev++)
|
||||
{
|
||||
if(g_psHIDDevice[i32Dev].iDeviceType ==
|
||||
psInterface->bInterfaceProtocol)
|
||||
{
|
||||
//
|
||||
// Save the device pointer.
|
||||
//
|
||||
g_psHIDDevice[i32Dev].psDevice = psDevice;
|
||||
|
||||
for(i32Idx = 0; i32Idx < 3; i32Idx++)
|
||||
{
|
||||
//
|
||||
// Get the first endpoint descriptor.
|
||||
//
|
||||
psEndpointDescriptor = USBDescGetInterfaceEndpoint(psInterface,
|
||||
i32Idx,
|
||||
256);
|
||||
|
||||
//
|
||||
// If no more endpoints then break out.
|
||||
//
|
||||
if(psEndpointDescriptor == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
// Interrupt
|
||||
//
|
||||
if((psEndpointDescriptor->bmAttributes & USB_EP_ATTR_TYPE_M) ==
|
||||
USB_EP_ATTR_INT)
|
||||
{
|
||||
//
|
||||
// Interrupt IN.
|
||||
//
|
||||
if(psEndpointDescriptor->bEndpointAddress & USB_EP_DESC_IN)
|
||||
{
|
||||
g_psHIDDevice[i32Dev].ui32IntInPipe =
|
||||
USBHCDPipeAlloc(0, USBHCD_PIPE_INTR_IN,
|
||||
psDevice, HIDIntINCallback);
|
||||
USBHCDPipeConfig(g_psHIDDevice[i32Dev].ui32IntInPipe,
|
||||
psEndpointDescriptor->wMaxPacketSize,
|
||||
psEndpointDescriptor->bInterval,
|
||||
(psEndpointDescriptor->bEndpointAddress &
|
||||
USB_EP_DESC_NUM_M));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// If there is a callback function call it to inform the application that
|
||||
// the device has been enumerated.
|
||||
//
|
||||
if(g_psHIDDevice[i32Dev].pfnCallback != 0)
|
||||
{
|
||||
g_psHIDDevice[i32Dev].pfnCallback(
|
||||
g_psHIDDevice[i32Dev].pvCBData,
|
||||
USB_EVENT_CONNECTED,
|
||||
(uint32_t)&g_psHIDDevice[i32Dev], 0);
|
||||
}
|
||||
|
||||
//
|
||||
// Save the device pointer.
|
||||
//
|
||||
g_psHIDDevice[i32Dev].psDevice = psDevice;
|
||||
|
||||
return (&g_psHIDDevice[i32Dev]);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// If we get here, no user has registered an interest in this particular
|
||||
// HID device so we return an error.
|
||||
//
|
||||
return(0);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! This function is used to release an instance of the HID driver.
|
||||
//!
|
||||
//! \param pvInstance is an instance pointer that needs to be released.
|
||||
//!
|
||||
//! This function will free up any resources in use by the HID driver instance
|
||||
//! that is passed in. The \e pvInstance pointer should be a valid value that
|
||||
//! was returned from a call to USBHIDOpen().
|
||||
//!
|
||||
//! \return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
static void
|
||||
HIDDriverClose(void *pvInstance)
|
||||
{
|
||||
tHIDInstance *psInst;
|
||||
|
||||
//
|
||||
// Get our instance pointer.
|
||||
//
|
||||
psInst = (tHIDInstance *)pvInstance;
|
||||
|
||||
//
|
||||
// Reset the device pointer.
|
||||
//
|
||||
psInst->psDevice = 0;
|
||||
|
||||
//
|
||||
// Free the Interrupt IN pipe.
|
||||
//
|
||||
if(psInst->ui32IntInPipe != 0)
|
||||
{
|
||||
USBHCDPipeFree(psInst->ui32IntInPipe);
|
||||
}
|
||||
|
||||
//
|
||||
// If the callback exists, call it with a DISCONNECTED event.
|
||||
//
|
||||
if(psInst->pfnCallback != 0)
|
||||
{
|
||||
psInst->pfnCallback(psInst->pvCBData, USB_EVENT_DISCONNECTED,
|
||||
(uint32_t)pvInstance, 0);
|
||||
}
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! This function is used to set the idle timeout for a HID device.
|
||||
//!
|
||||
//! \param psHIDInstance is the value that was returned from the call to
|
||||
//! USBHHIDOpen().
|
||||
//! \param ui8Duration is the duration of the timeout in milliseconds.
|
||||
//! \param ui8ReportID is the report identifier to set the timeout on.
|
||||
//!
|
||||
//! This function will send the Set Idle command to a HID device to set the
|
||||
//! idle timeout for a given report. The length of the timeout is specified
|
||||
//! by the \e ui8Duration parameter and the report the timeout for is in the
|
||||
//! \e ui8ReportID value.
|
||||
//!
|
||||
//! \return Always returns 0.
|
||||
//
|
||||
//*****************************************************************************
|
||||
uint32_t
|
||||
USBHHIDSetIdle(tHIDInstance *psHIDInstance, uint8_t ui8Duration,
|
||||
uint8_t ui8ReportID)
|
||||
{
|
||||
tUSBRequest sSetupPacket;
|
||||
|
||||
//
|
||||
// This is a Class specific interface OUT request.
|
||||
//
|
||||
sSetupPacket.bmRequestType = USB_RTYPE_DIR_OUT | USB_RTYPE_CLASS |
|
||||
USB_RTYPE_INTERFACE;
|
||||
|
||||
//
|
||||
// Request a Device Descriptor.
|
||||
//
|
||||
sSetupPacket.bRequest = USBREQ_SET_IDLE;
|
||||
sSetupPacket.wValue = (ui8Duration << 8) | ui8ReportID;
|
||||
|
||||
//
|
||||
// Set this on interface 1.
|
||||
//
|
||||
sSetupPacket.wIndex = 0;
|
||||
|
||||
//
|
||||
// This is always 0 for this request.
|
||||
//
|
||||
sSetupPacket.wLength = 0;
|
||||
|
||||
//
|
||||
// Put the setup packet in the buffer.
|
||||
//
|
||||
return(USBHCDControlTransfer(0, &sSetupPacket, psHIDInstance->psDevice,
|
||||
0, 0, MAX_PACKET_SIZE_EP0));
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! This function can be used to retrieve the report descriptor for a given
|
||||
//! device instance.
|
||||
//!
|
||||
//! \param psHIDInstance is the value that was returned from the call to
|
||||
//! USBHHIDOpen().
|
||||
//! \param pui8Buffer is the memory buffer to use to store the report
|
||||
//! descriptor.
|
||||
//! \param ui32Size is the size in bytes of the buffer pointed to by
|
||||
//! \e pui8Buffer.
|
||||
//!
|
||||
//! This function is used to return a report descriptor from a HID device
|
||||
//! instance so that it can determine how to interpret reports that are
|
||||
//! returned from the device indicated by the \e psHIDInstance parameter.
|
||||
//! This call is blocking and will return the number of bytes read into the
|
||||
//! \e pui8Buffer.
|
||||
//!
|
||||
//! \return Returns the number of bytes read into the \e pui8Buffer.
|
||||
//
|
||||
//*****************************************************************************
|
||||
uint32_t
|
||||
USBHHIDGetReportDescriptor(tHIDInstance *psHIDInstance, uint8_t *pui8Buffer,
|
||||
uint32_t ui32Size)
|
||||
{
|
||||
tUSBRequest sSetupPacket;
|
||||
uint32_t ui32Bytes;
|
||||
|
||||
//
|
||||
// This is a Standard Device IN request.
|
||||
//
|
||||
sSetupPacket.bmRequestType = USB_RTYPE_DIR_IN | USB_RTYPE_STANDARD |
|
||||
USB_RTYPE_INTERFACE;
|
||||
|
||||
//
|
||||
// Request a Report Descriptor.
|
||||
//
|
||||
sSetupPacket.bRequest = USBREQ_GET_DESCRIPTOR;
|
||||
sSetupPacket.wValue = USB_HID_DTYPE_REPORT << 8;
|
||||
|
||||
//
|
||||
// Index is always 0 for device requests.
|
||||
//
|
||||
sSetupPacket.wIndex = 0;
|
||||
|
||||
//
|
||||
// All devices must have at least an 8 byte max packet size so just ask
|
||||
// for 8 bytes to start with.
|
||||
//
|
||||
sSetupPacket.wLength = ui32Size;
|
||||
|
||||
//
|
||||
// Now get the full descriptor now that the actual maximum packet size
|
||||
// is known.
|
||||
//
|
||||
ui32Bytes = USBHCDControlTransfer(0, &sSetupPacket,
|
||||
psHIDInstance->psDevice, pui8Buffer, ui32Size,
|
||||
psHIDInstance->psDevice->sDeviceDescriptor.bMaxPacketSize0);
|
||||
|
||||
return(ui32Bytes);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! This function is used to set or clear the boot protocol state of a device.
|
||||
//!
|
||||
//! \param psHIDInstance is the value that was returned from the call to
|
||||
//! USBHHIDOpen().
|
||||
//! \param ui32BootProtocol is either zero or non-zero to indicate which
|
||||
//! protocol to use for the device.
|
||||
//!
|
||||
//! A USB host device can use this function to set the protocol for a connected
|
||||
//! HID device. This is commonly used to set keyboards and mice into their
|
||||
//! simplified boot protocol modes to fix the report structure to a know
|
||||
//! state.
|
||||
//!
|
||||
//! \return This function returns 0.
|
||||
//
|
||||
//*****************************************************************************
|
||||
uint32_t
|
||||
USBHHIDSetProtocol(tHIDInstance *psHIDInstance, uint32_t ui32BootProtocol)
|
||||
{
|
||||
tUSBRequest sSetupPacket;
|
||||
|
||||
//
|
||||
// This is a Standard Device IN request.
|
||||
//
|
||||
sSetupPacket.bmRequestType = USB_RTYPE_DIR_OUT | USB_RTYPE_CLASS |
|
||||
USB_RTYPE_INTERFACE;
|
||||
|
||||
//
|
||||
// Request a Report Descriptor.
|
||||
//
|
||||
sSetupPacket.bRequest = USBREQ_SET_PROTOCOL;
|
||||
|
||||
if(ui32BootProtocol)
|
||||
{
|
||||
//
|
||||
// Boot Protocol.
|
||||
//
|
||||
sSetupPacket.wValue = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
// Report Protocol.
|
||||
//
|
||||
sSetupPacket.wValue = 1;
|
||||
}
|
||||
|
||||
//
|
||||
// Index is always 0 for device requests.
|
||||
//
|
||||
sSetupPacket.wIndex = 0;
|
||||
|
||||
//
|
||||
// Always 0.
|
||||
//
|
||||
sSetupPacket.wLength = 0;
|
||||
|
||||
//
|
||||
// Now get the full descriptor now that the actual maximum packet size
|
||||
// is known.
|
||||
//
|
||||
USBHCDControlTransfer(0, &sSetupPacket, psHIDInstance->psDevice, 0, 0,
|
||||
psHIDInstance->psDevice->sDeviceDescriptor.bMaxPacketSize0);
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! This function is used to retrieve a report from a HID device.
|
||||
//!
|
||||
//! \param psHIDInstance is the value that was returned from the call to
|
||||
//! USBHHIDOpen().
|
||||
//! \param ui32Interface is the interface to retrieve the report from.
|
||||
//! \param pui8Data is the memory buffer to use to store the report.
|
||||
//! \param ui32Size is the size in bytes of the buffer pointed to by
|
||||
//! \e pui8Buffer.
|
||||
//!
|
||||
//! This function is used to retrieve a report from a USB pipe. It is usually
|
||||
//! called when the USB HID layer has detected a new data available in a USB
|
||||
//! pipe. The USB HID host device code will receive a
|
||||
//! \b USB_EVENT_RX_AVAILABLE event when data is available, allowing the
|
||||
//! callback function to retrieve the data.
|
||||
//!
|
||||
//! \return Returns the number of bytes read from report.
|
||||
//
|
||||
//*****************************************************************************
|
||||
uint32_t
|
||||
USBHHIDGetReport(tHIDInstance *psHIDInstance, uint32_t ui32Interface,
|
||||
uint8_t *pui8Data, uint32_t ui32Size)
|
||||
{
|
||||
//
|
||||
// Read the Data out.
|
||||
//
|
||||
ui32Size = USBHCDPipeReadNonBlocking(psHIDInstance->ui32IntInPipe,
|
||||
pui8Data, ui32Size);
|
||||
|
||||
//
|
||||
// Return the number of bytes read from the interrupt in pipe.
|
||||
//
|
||||
return(ui32Size);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! This function is used to send a report to a HID device.
|
||||
//!
|
||||
//! \param psHIDInstance is the value that was returned from the call to
|
||||
//! USBHHIDOpen().
|
||||
//! \param ui32Interface is the interface to send the report to.
|
||||
//! \param pui8Data is the memory buffer to use to store the report.
|
||||
//! \param ui32Size is the size in bytes of the buffer pointed to by
|
||||
//! \e pui8Buffer.
|
||||
//!
|
||||
//! This function is used to send a report to a USB HID device. It can be
|
||||
//! only be called from outside the callback context as this function will not
|
||||
//! return from the call until the data has been sent successfully.
|
||||
//!
|
||||
//! \return Returns the number of bytes sent to the device.
|
||||
//
|
||||
//*****************************************************************************
|
||||
uint32_t
|
||||
USBHHIDSetReport(tHIDInstance *psHIDInstance, uint32_t ui32Interface,
|
||||
uint8_t *pui8Data, uint32_t ui32Size)
|
||||
{
|
||||
tUSBRequest sSetupPacket;
|
||||
|
||||
//
|
||||
// This is a class specific OUT request.
|
||||
//
|
||||
sSetupPacket.bmRequestType = USB_RTYPE_DIR_OUT | USB_RTYPE_CLASS |
|
||||
USB_RTYPE_INTERFACE;
|
||||
|
||||
//
|
||||
// Request a Report Descriptor.
|
||||
//
|
||||
sSetupPacket.bRequest = USBREQ_SET_REPORT;
|
||||
sSetupPacket.wValue = USB_HID_REPORT_OUTPUT << 8;
|
||||
|
||||
//
|
||||
// Index is always 0 for device requests.
|
||||
//
|
||||
sSetupPacket.wIndex = (uint16_t)ui32Interface;
|
||||
|
||||
//
|
||||
// Always 0.
|
||||
//
|
||||
sSetupPacket.wLength = ui32Size;
|
||||
|
||||
//
|
||||
// Now get the full descriptor now that the actual maximum packet size
|
||||
// is known.
|
||||
//
|
||||
USBHCDControlTransfer(0, &sSetupPacket, psHIDInstance->psDevice,
|
||||
pui8Data, ui32Size,
|
||||
psHIDInstance->psDevice->sDeviceDescriptor.bMaxPacketSize0);
|
||||
|
||||
return(ui32Size);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @}
|
||||
//
|
||||
//*****************************************************************************
|
|
@ -0,0 +1,164 @@
|
|||
//*****************************************************************************
|
||||
//
|
||||
// usbhhid.h - This hold the host driver for hid class.
|
||||
//
|
||||
// Copyright (c) 2008-2013 Texas Instruments Incorporated. All rights reserved.
|
||||
// Software License Agreement
|
||||
//
|
||||
// Texas Instruments (TI) is supplying this software for use solely and
|
||||
// exclusively on TI's microcontroller products. The software is owned by
|
||||
// TI and/or its suppliers, and is protected under applicable copyright
|
||||
// laws. You may not combine this software with "viral" open-source
|
||||
// software in order to form a larger program.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
|
||||
// NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
|
||||
// NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
|
||||
// CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
|
||||
// DAMAGES, FOR ANY REASON WHATSOEVER.
|
||||
//
|
||||
// This is part of revision 1.1 of the Tiva USB Library.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
#ifndef __USBHHID_H__
|
||||
#define __USBHHID_H__
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// If building with a C++ compiler, make all of the definitions in this header
|
||||
// have a C binding.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! \addtogroup usblib_host_class
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
typedef struct tHIDInstance tHIDInstance;
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// These defines are the the events that will be passed in the ui32Event
|
||||
// parameter of the callback from the driver.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define USBH_EVENT_HID_SETRPT USBH_HID_EVENT_BASE + 0
|
||||
#define USBH_EVENT_HID_REPORT USBH_HID_EVENT_BASE + 1
|
||||
|
||||
//
|
||||
//! The HID keyboard detected a key being pressed.
|
||||
//
|
||||
#define USBH_EVENT_HID_KB_PRESS USBH_HID_EVENT_BASE + 16
|
||||
|
||||
//
|
||||
//! The HID keyboard detected a key being released.
|
||||
//
|
||||
#define USBH_EVENT_HID_KB_REL USBH_HID_EVENT_BASE + 17
|
||||
|
||||
//
|
||||
//! The HID keyboard detected one of the keyboard modifiers being pressed.
|
||||
//
|
||||
#define USBH_EVENT_HID_KB_MOD USBH_HID_EVENT_BASE + 18
|
||||
|
||||
//
|
||||
//! A button was pressed on a HID mouse.
|
||||
//
|
||||
#define USBH_EVENT_HID_MS_PRESS USBH_HID_EVENT_BASE + 32
|
||||
|
||||
//
|
||||
//! A button was released on a HID mouse.
|
||||
//
|
||||
#define USBH_EVENT_HID_MS_REL USBH_HID_EVENT_BASE + 33
|
||||
|
||||
//
|
||||
//! The HID mouse detected movement in the X direction.
|
||||
//
|
||||
#define USBH_EVENT_HID_MS_X USBH_HID_EVENT_BASE + 34
|
||||
|
||||
//
|
||||
//! The HID mouse detected movement in the Y direction.
|
||||
//
|
||||
#define USBH_EVENT_HID_MS_Y USBH_HID_EVENT_BASE + 35
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! The following values are used to register callbacks to the USB HOST HID
|
||||
//! device class layer.
|
||||
//
|
||||
//*****************************************************************************
|
||||
typedef enum
|
||||
{
|
||||
//
|
||||
//! No device should be used. This value should not be used by
|
||||
//! applications.
|
||||
//
|
||||
eUSBHHIDClassNone = 0,
|
||||
|
||||
//
|
||||
//! This is a keyboard device.
|
||||
//
|
||||
eUSBHHIDClassKeyboard,
|
||||
|
||||
//
|
||||
//! This is a mouse device.
|
||||
//
|
||||
eUSBHHIDClassMouse,
|
||||
|
||||
//
|
||||
//! This is a vendor specific device.
|
||||
//
|
||||
eUSBHHIDClassVendor
|
||||
}
|
||||
tHIDSubClassProtocol;
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Close the Doxygen group.
|
||||
//! @}
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Prototypes.
|
||||
//
|
||||
//*****************************************************************************
|
||||
extern tHIDInstance * USBHHIDOpen(tHIDSubClassProtocol iDeviceType,
|
||||
tUSBCallback pfnCallback,
|
||||
void *pvCBData);
|
||||
extern void USBHHIDClose(tHIDInstance *psHIDInstance);
|
||||
extern uint32_t USBHHIDGetReportDescriptor(tHIDInstance *psHIDInstance,
|
||||
uint8_t *pui8Buffer,
|
||||
uint32_t ui32Size);
|
||||
extern uint32_t USBHHIDSetIdle(tHIDInstance *psHIDInstance, uint8_t ui8Duration,
|
||||
uint8_t ui8ReportID);
|
||||
extern uint32_t USBHHIDSetProtocol(tHIDInstance *psHIDInstance,
|
||||
uint32_t ui32BootProtocol);
|
||||
extern uint32_t USBHHIDSetReport(tHIDInstance *psHIDInstance,
|
||||
uint32_t ui32Interface, uint8_t *pui8Data,
|
||||
uint32_t ui32Size);
|
||||
extern uint32_t USBHHIDGetReport(tHIDInstance *psHIDInstance,
|
||||
uint32_t ui32Interface, uint8_t *pui8Data,
|
||||
uint32_t ui32Size);
|
||||
|
||||
extern const tUSBHostClassDriver g_sUSBHIDClassDriver;
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Mark the end of the C bindings section for C++ compilers.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // __USBHHID_H__
|
|
@ -0,0 +1,682 @@
|
|||
//*****************************************************************************
|
||||
//
|
||||
// usbhhidkeyboard.c - This file holds the application interfaces for USB
|
||||
// keyboard devices.
|
||||
//
|
||||
// Copyright (c) 2008-2013 Texas Instruments Incorporated. All rights reserved.
|
||||
// Software License Agreement
|
||||
//
|
||||
// Texas Instruments (TI) is supplying this software for use solely and
|
||||
// exclusively on TI's microcontroller products. The software is owned by
|
||||
// TI and/or its suppliers, and is protected under applicable copyright
|
||||
// laws. You may not combine this software with "viral" open-source
|
||||
// software in order to form a larger program.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
|
||||
// NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
|
||||
// NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
|
||||
// CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
|
||||
// DAMAGES, FOR ANY REASON WHATSOEVER.
|
||||
//
|
||||
// This is part of revision 1.1 of the Tiva USB Library.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "inc/hw_types.h"
|
||||
#include "usblib/usblib.h"
|
||||
#include "usblib/host/usbhost.h"
|
||||
#include "usblib/usbhid.h"
|
||||
#include "usblib/host/usbhhid.h"
|
||||
#include "usblib/host/usbhhidkeyboard.h"
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! \addtogroup usblib_host_device
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Prototypes for local functions.
|
||||
//
|
||||
//*****************************************************************************
|
||||
static uint32_t USBHKeyboardCallback(void *pvKeyboard, uint32_t ui32Event,
|
||||
uint32_t ui32MsgParam, void *pvMsgData);
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// The size of a USB keyboard report.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define USBHKEYB_REPORT_SIZE 8
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// These are the flags for the tUSBHKeyboard.ui32HIDFlags member variable.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define USBHKEYB_DEVICE_PRESENT 0x00000001
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// This is the structure definition for a keyboard device instance.
|
||||
//
|
||||
//*****************************************************************************
|
||||
struct tUSBHKeyboard
|
||||
{
|
||||
//
|
||||
// Global flags for an instance of a keyboard.
|
||||
//
|
||||
uint32_t ui32HIDFlags;
|
||||
|
||||
//
|
||||
// The applications registered callback.
|
||||
//
|
||||
tUSBHIDKeyboardCallback pfnCallback;
|
||||
|
||||
//
|
||||
// The HID instance pointer for this keyboard instance.
|
||||
//
|
||||
tHIDInstance *psHIDInstance;
|
||||
|
||||
//
|
||||
// NUM_LOCK, CAPS_LOCK, SCROLL_LOCK, COMPOSE or KANA keys.
|
||||
//
|
||||
uint8_t ui8KeyModSticky;
|
||||
|
||||
//
|
||||
// This is the current state of the keyboard modifier keys.
|
||||
//
|
||||
uint8_t ui8KeyModState;
|
||||
|
||||
//
|
||||
// This holds the keyboard usage codes for keys that are being held down.
|
||||
//
|
||||
uint8_t pui8KeyState[6];
|
||||
|
||||
//
|
||||
// This is a local buffer to hold the current HID report that comes up
|
||||
// from the HID driver layer.
|
||||
//
|
||||
uint8_t pui8Buffer[USBHKEYB_REPORT_SIZE];
|
||||
};
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// This is the per instance information for a keyboard device.
|
||||
//
|
||||
//*****************************************************************************
|
||||
static tUSBHKeyboard g_sUSBHKeyboard =
|
||||
{
|
||||
0
|
||||
};
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! This function is used open an instance of a keyboard.
|
||||
//!
|
||||
//! \param pfnCallback is the callback function to call when new events occur
|
||||
//! with the keyboard returned.
|
||||
//! \param pui8Buffer is the memory used by the keyboard to interact with the
|
||||
//! USB keyboard.
|
||||
//! \param ui32Size is the size of the buffer provided by \e pui8Buffer.
|
||||
//!
|
||||
//! This function is used to open an instance of the keyboard. The value
|
||||
//! returned from this function should be used as the instance identifier for
|
||||
//! all other USBHKeyboard calls. The \e pui8Buffer memory buffer is used to
|
||||
//! access the keyboard. The buffer size required is at least enough to hold
|
||||
//! a normal report descriptor for the device. If there is not enough space
|
||||
//! only a partial report descriptor will be read out.
|
||||
//!
|
||||
//! \return Returns the instance identifier for the keyboard that is attached.
|
||||
//! If there is no keyboard present this will return 0.
|
||||
//
|
||||
//*****************************************************************************
|
||||
tUSBHKeyboard *
|
||||
USBHKeyboardOpen(tUSBHIDKeyboardCallback pfnCallback, uint8_t *pui8Buffer,
|
||||
uint32_t ui32Size)
|
||||
{
|
||||
//
|
||||
// Save the callback and data pointers.
|
||||
//
|
||||
g_sUSBHKeyboard.pfnCallback = pfnCallback;
|
||||
|
||||
//
|
||||
// Save the instance pointer for the HID device that was opened.
|
||||
//
|
||||
g_sUSBHKeyboard.psHIDInstance =
|
||||
USBHHIDOpen(eUSBHHIDClassKeyboard, USBHKeyboardCallback,
|
||||
(void *)&g_sUSBHKeyboard);
|
||||
|
||||
return(&g_sUSBHKeyboard);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! This function is used close an instance of a keyboard.
|
||||
//!
|
||||
//! \param psKbInstance is the instance value for this keyboard.
|
||||
//!
|
||||
//! This function is used to close an instance of the keyboard that was opened
|
||||
//! with a call to USBHKeyboardOpen(). The \e psKbInstance value is the
|
||||
//! value that was returned when the application called USBHKeyboardOpen().
|
||||
//!
|
||||
//! \return This function returns 0 to indicate success any non-zero value
|
||||
//! indicates an error condition.
|
||||
//
|
||||
//*****************************************************************************
|
||||
uint32_t
|
||||
USBHKeyboardClose(tUSBHKeyboard *psKbInstance)
|
||||
{
|
||||
//
|
||||
// Reset the callback to null.
|
||||
//
|
||||
psKbInstance->pfnCallback = 0;
|
||||
|
||||
//
|
||||
// Call the HID driver layer to close out this instance.
|
||||
//
|
||||
USBHHIDClose(psKbInstance->psHIDInstance);
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! This function is used to map a USB usage ID to a printable character.
|
||||
//!
|
||||
//! \param psKbInstance is the instance value for this keyboard.
|
||||
//! \param psTable is the table to use to map the usage ID to characters.
|
||||
//! \param ui8UsageID is the USB usage ID to map to a character.
|
||||
//!
|
||||
//! This function is used to map a USB usage ID to a character. The provided
|
||||
//! \e psTable is used to perform the mapping and is described by the
|
||||
//! tHIDKeyboardUsageTable type defined structure. See the documentation on
|
||||
//! the tHIDKeyboardUsageTable structure for more details on the internals of
|
||||
//! this structure. This function uses the current state of the shift keys
|
||||
//! and the Caps Lock key to modify the data returned by this function. The
|
||||
//! psTable structure has values indicating which keys are modified by Caps
|
||||
//! and alternate values for shifted cases. The number of bytes returned from
|
||||
//! Lock this function depends on the \e psTable structure passed in as it
|
||||
//! holds the number of bytes per character in the table.
|
||||
//!
|
||||
//! \return Returns the character value for the given usage id.
|
||||
//
|
||||
//*****************************************************************************
|
||||
uint32_t
|
||||
USBHKeyboardUsageToChar(tUSBHKeyboard *psKbInstance,
|
||||
const tHIDKeyboardUsageTable *psTable,
|
||||
uint8_t ui8UsageID)
|
||||
{
|
||||
uint32_t ui32Value, ui32Offset, ui32Shift;
|
||||
const uint8_t *pui8KeyBoardMap;
|
||||
const uint16_t *pui16KeyBoardMap;
|
||||
|
||||
//
|
||||
// The added offset for the shifted character value.
|
||||
//
|
||||
ui32Shift = 0;
|
||||
|
||||
//
|
||||
// Offset in the table for the character.
|
||||
//
|
||||
ui32Offset = (ui8UsageID * psTable->ui8BytesPerChar * 2);
|
||||
|
||||
//
|
||||
// Handle the case where CAPS lock has been set.
|
||||
//
|
||||
if(psKbInstance->ui8KeyModSticky &= HID_KEYB_CAPS_LOCK)
|
||||
{
|
||||
//
|
||||
// See if this usage ID is modified by Caps Lock by checking the packed
|
||||
// bit array in the pui32ShiftState member of the psTable array.
|
||||
//
|
||||
if((psTable->pui32CapsLock[ui8UsageID >> 5]) >>
|
||||
(ui8UsageID & 0x1f) & 1)
|
||||
{
|
||||
ui32Shift = psTable->ui8BytesPerChar;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Now handle if a shift key is being held.
|
||||
//
|
||||
if((psKbInstance->ui8KeyModState & 0x22) != 0)
|
||||
{
|
||||
//
|
||||
// Not shifted yet so we need to shift.
|
||||
//
|
||||
if(ui32Shift == 0)
|
||||
{
|
||||
ui32Shift = psTable->ui8BytesPerChar;
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
// Unshift because CAPS LOCK and shift were pressed.
|
||||
//
|
||||
ui32Shift = 0;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// One byte per character.
|
||||
//
|
||||
if(psTable->ui8BytesPerChar == 1)
|
||||
{
|
||||
//
|
||||
// Get the base address of the table.
|
||||
//
|
||||
pui8KeyBoardMap = psTable->pvCharMapping;
|
||||
|
||||
ui32Value = pui8KeyBoardMap[ui32Offset + ui32Shift];
|
||||
}
|
||||
//
|
||||
// Two bytes per character.
|
||||
//
|
||||
else if(psTable->ui8BytesPerChar == 2)
|
||||
{
|
||||
//
|
||||
// Get the base address of the table.
|
||||
//
|
||||
pui16KeyBoardMap = (uint16_t *)psTable->pvCharMapping;
|
||||
|
||||
ui32Value = pui16KeyBoardMap[ui32Offset + ui32Shift];
|
||||
}
|
||||
//
|
||||
// All other sizes are unsupported for now.
|
||||
//
|
||||
else
|
||||
{
|
||||
ui32Value = 0;
|
||||
}
|
||||
|
||||
return(ui32Value);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! This function is used to set one of the fixed modifier keys on a keyboard.
|
||||
//!
|
||||
//! \param psKbInstance is the instance value for this keyboard.
|
||||
//! \param ui32Modifiers is a bit mask of the modifiers to set on the keyboard.
|
||||
//!
|
||||
//! This function is used to set the modifier key states on a keyboard. The
|
||||
//! \e ui32Modifiers value is a bitmask of the following set of values:
|
||||
//! - HID_KEYB_NUM_LOCK
|
||||
//! - HID_KEYB_CAPS_LOCK
|
||||
//! - HID_KEYB_SCROLL_LOCK
|
||||
//! - HID_KEYB_COMPOSE
|
||||
//! - HID_KEYB_KANA
|
||||
//!
|
||||
//! Not all of these will be supported on all keyboards however setting values
|
||||
//! on a keyboard that does not have them should have no effect. The
|
||||
//! \e psKbInstance value is the value that was returned when the application
|
||||
//! called USBHKeyboardOpen(). If the value \b HID_KEYB_CAPS_LOCK is used it
|
||||
//! will modify the values returned from the USBHKeyboardUsageToChar()
|
||||
//! function.
|
||||
//!
|
||||
//! \return This function returns 0 to indicate success any non-zero value
|
||||
//! indicates an error condition.
|
||||
//
|
||||
//*****************************************************************************
|
||||
uint32_t
|
||||
USBHKeyboardModifierSet(tUSBHKeyboard *psKbInstance, uint32_t ui32Modifiers)
|
||||
{
|
||||
//
|
||||
// Remember the fact that this is set.
|
||||
//
|
||||
psKbInstance->ui8KeyModSticky = (uint8_t)ui32Modifiers;
|
||||
|
||||
//
|
||||
// Set the LEDs on the keyboard.
|
||||
//
|
||||
USBHHIDSetReport(psKbInstance->psHIDInstance, 0,
|
||||
(uint8_t *)&ui32Modifiers, 1);
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! This function is used to initialize a keyboard interface after a keyboard
|
||||
//! has been detected.
|
||||
//!
|
||||
//! \param psKbInstance is the instance value for this keyboard.
|
||||
//!
|
||||
//! This function should be called after receiving a \b USB_EVENT_CONNECTED
|
||||
//! event in the callback function provided by USBHKeyboardOpen(), however this
|
||||
//! function should only be called outside the callback function. This will
|
||||
//! initialize the keyboard interface and determine the keyboard's
|
||||
//! layout and how it reports keys to the USB host controller. The
|
||||
//! \e psKbInstance value is the value that was returned when the application
|
||||
//! called USBHKeyboardOpen(). This function only needs to be called once
|
||||
//! per connection event but it should be called every time a
|
||||
//! \b USB_EVENT_CONNECTED event occurs.
|
||||
//!
|
||||
//! \return This function returns 0 to indicate success any non-zero value
|
||||
//! indicates an error condition.
|
||||
//
|
||||
//*****************************************************************************
|
||||
uint32_t
|
||||
USBHKeyboardInit(tUSBHKeyboard *psKbInstance)
|
||||
{
|
||||
uint8_t ui8ModData;
|
||||
|
||||
//
|
||||
// Set the initial rate to only update on keyboard state changes.
|
||||
//
|
||||
USBHHIDSetIdle(psKbInstance->psHIDInstance, 0, 0);
|
||||
|
||||
//
|
||||
// Read out the Report Descriptor from the keyboard and parse it for
|
||||
// the format of the reports coming back from the keyboard.
|
||||
//
|
||||
USBHHIDGetReportDescriptor(psKbInstance->psHIDInstance,
|
||||
psKbInstance->pui8Buffer,
|
||||
USBHKEYB_REPORT_SIZE);
|
||||
|
||||
//
|
||||
// Set the keyboard to boot protocol.
|
||||
//
|
||||
USBHHIDSetProtocol(psKbInstance->psHIDInstance, 1);
|
||||
|
||||
//
|
||||
// Used to clear the initial state of all on keyboard modifiers.
|
||||
//
|
||||
ui8ModData = 0;
|
||||
|
||||
//
|
||||
// Update the keyboard LED state.
|
||||
//
|
||||
USBHHIDSetReport(psKbInstance->psHIDInstance, 0, &ui8ModData, 1);
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! This function is used to set the automatic poll rate of the keyboard.
|
||||
//!
|
||||
//! \param psKbInstance is the instance value for this keyboard.
|
||||
//! \param ui32PollRate is the rate in ms to cause the keyboard to update the
|
||||
//! host regardless of no change in key state.
|
||||
//!
|
||||
//! This function will allow an application to tell the keyboard how often it
|
||||
//! should send updates to the USB host controller regardless of any changes
|
||||
//! in keyboard state. The \e psKbInstance value is the value that was
|
||||
//! returned when the application called USBHKeyboardOpen(). The
|
||||
//! \e ui32PollRate is the new value in ms for the update rate on the keyboard.
|
||||
//! This value is initially set to 0 which indicates that the keyboard should
|
||||
//! only to update when the keyboard state changes. Any value other than 0 can
|
||||
//! be used to force the keyboard to generate auto-repeat sequences for the
|
||||
//! application.
|
||||
//!
|
||||
//! \return This function returns 0 to indicate success any non-zero value
|
||||
//! indicates an error condition.
|
||||
//
|
||||
//*****************************************************************************
|
||||
uint32_t
|
||||
USBHKeyboardPollRateSet(tUSBHKeyboard *psKbInstance, uint32_t ui32PollRate)
|
||||
{
|
||||
//
|
||||
// Send the Set Idle command to the USB keyboard.
|
||||
//
|
||||
USBHHIDSetIdle(psKbInstance->psHIDInstance, ui32PollRate, 0);
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// This is an internal function used to modify the current keyboard state.
|
||||
//
|
||||
// This function checks for changes in the keyboard state due to a new report
|
||||
// being received from the device. It first checks if this is a "roll-over"
|
||||
// case by seeing if 0x01 is in the first position of the new keyboard report.
|
||||
// This indicates that too many keys were pressed to handle and to ignore this
|
||||
// report. Next the keyboard modifier state is stored and if any changes are
|
||||
// detected a \b USBH_EVENT_HID_KB_MOD event is sent back to the application.
|
||||
// Then this function will check for any keys that have been released and send
|
||||
// a \b USBH_EVENT_HID_KB_REL even for each of these keys. The last check is
|
||||
// for any new keys that are pressed and a \b USBH_EVENT_HID_KB_PRESS event
|
||||
// will be sent for each new key pressed.
|
||||
//
|
||||
// \return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
static void
|
||||
UpdateKeyboardState(tUSBHKeyboard *psKbInstance)
|
||||
{
|
||||
int32_t i32NewKey, i32OldKey;
|
||||
|
||||
//
|
||||
// rollover code so ignore this buffer.
|
||||
//
|
||||
if(psKbInstance->pui8Buffer[2] == 0x01)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// Handle the keyboard modifier states.
|
||||
//
|
||||
if(psKbInstance->ui8KeyModState != psKbInstance->pui8Buffer[0])
|
||||
{
|
||||
//
|
||||
// Notify the application of the event.
|
||||
//
|
||||
psKbInstance->pfnCallback(0, USBH_EVENT_HID_KB_MOD,
|
||||
psKbInstance->pui8Buffer[0], 0);
|
||||
|
||||
//
|
||||
// Save the new state of the modifier keys.
|
||||
//
|
||||
psKbInstance->ui8KeyModState = psKbInstance->pui8Buffer[0];
|
||||
}
|
||||
|
||||
//
|
||||
// This loop checks for keys that have been released to make room for new
|
||||
// ones that may have been pressed.
|
||||
//
|
||||
for(i32OldKey = 2; i32OldKey < 8; i32OldKey++)
|
||||
{
|
||||
//
|
||||
// If there is no old key pressed in this entry go to the next one.
|
||||
//
|
||||
if(psKbInstance->pui8KeyState[i32OldKey] == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
// Check if this old key is still in the list of currently pressed
|
||||
// keys.
|
||||
//
|
||||
for(i32NewKey = 2; i32NewKey < 8; i32NewKey++)
|
||||
{
|
||||
//
|
||||
// Break out if the key is still present.
|
||||
//
|
||||
if(psKbInstance->pui8Buffer[i32NewKey] ==
|
||||
psKbInstance->pui8KeyState[i32OldKey])
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
//
|
||||
// If the old key was no longer in the list of pressed keys then
|
||||
// notify the application of the key release.
|
||||
//
|
||||
if(i32NewKey == 8)
|
||||
{
|
||||
//
|
||||
// Send the key release notification to the application.
|
||||
//
|
||||
psKbInstance->pfnCallback(0, USBH_EVENT_HID_KB_REL,
|
||||
psKbInstance->pui8KeyState[i32OldKey],
|
||||
0);
|
||||
//
|
||||
// Remove the old key from the currently held key list.
|
||||
//
|
||||
psKbInstance->pui8KeyState[i32OldKey] = 0;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// This loop checks for new keys that have been pressed.
|
||||
//
|
||||
for(i32NewKey = 2; i32NewKey < 8; i32NewKey++)
|
||||
{
|
||||
//
|
||||
// The new list is empty so no new keys are pressed.
|
||||
//
|
||||
if(psKbInstance->pui8Buffer[i32NewKey] == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
// This loop checks if the current key was already pressed.
|
||||
//
|
||||
for(i32OldKey = 2; i32OldKey < 8; i32OldKey++)
|
||||
{
|
||||
//
|
||||
// If it is in both lists then it was already pressed so ignore it.
|
||||
//
|
||||
if(psKbInstance->pui8Buffer[i32NewKey] ==
|
||||
psKbInstance->pui8KeyState[i32OldKey])
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
//
|
||||
// The key in the new list was not found so it is new.
|
||||
//
|
||||
if(i32OldKey == 8)
|
||||
{
|
||||
//
|
||||
// Look for a free location to store this key usage code.
|
||||
//
|
||||
for(i32OldKey = 2; i32OldKey < 8; i32OldKey++)
|
||||
{
|
||||
//
|
||||
// If an empty location is found, store it and notify the
|
||||
// application.
|
||||
//
|
||||
if(psKbInstance->pui8KeyState[i32OldKey] == 0)
|
||||
{
|
||||
//
|
||||
// Save the newly pressed key.
|
||||
//
|
||||
psKbInstance->pui8KeyState[i32OldKey] =
|
||||
psKbInstance->pui8Buffer[i32NewKey];
|
||||
|
||||
//
|
||||
// Notify the application of the new key that has been
|
||||
// pressed.
|
||||
//
|
||||
psKbInstance->pfnCallback( 0, USBH_EVENT_HID_KB_PRESS,
|
||||
psKbInstance->pui8Buffer[i32NewKey],
|
||||
0);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! This function handles event callbacks from the USB HID driver layer.
|
||||
//!
|
||||
//! \param pvKeyboard is the pointer that was passed in to the USBHHIDOpen()
|
||||
//! call.
|
||||
//! \param ui32Event is the event that has been passed up from the HID driver.
|
||||
//! \param ui32MsgParam has meaning related to the \e ui32Event that occurred.
|
||||
//! \param pvMsgData has meaning related to the \e ui32Event that occurred.
|
||||
//!
|
||||
//! This function will receive all event updates from the HID driver layer.
|
||||
//! The keyboard driver itself will mostly be concerned with report callbacks
|
||||
//! from the HID driver layer and parsing them into keystrokes for the
|
||||
//! application that has registered for callbacks with the USBHKeyboardOpen()
|
||||
//! call.
|
||||
//!
|
||||
//! \return Non-zero values should be assumed to indicate an error condition.
|
||||
//
|
||||
//*****************************************************************************
|
||||
static uint32_t
|
||||
USBHKeyboardCallback(void *pvKeyboard, uint32_t ui32Event,
|
||||
uint32_t ui32MsgParam, void *pvMsgData)
|
||||
{
|
||||
tUSBHKeyboard *psKbInstance;
|
||||
|
||||
//
|
||||
// Recover the pointer to the instance data.
|
||||
//
|
||||
psKbInstance = (tUSBHKeyboard *)pvKeyboard;
|
||||
|
||||
switch (ui32Event)
|
||||
{
|
||||
//
|
||||
// New keyboard has been connected so notify the application.
|
||||
//
|
||||
case USB_EVENT_CONNECTED:
|
||||
{
|
||||
//
|
||||
// Remember that a keyboard is present.
|
||||
//
|
||||
psKbInstance->ui32HIDFlags |= USBHKEYB_DEVICE_PRESENT;
|
||||
|
||||
//
|
||||
// Notify the application that a new keyboard was connected.
|
||||
//
|
||||
psKbInstance->pfnCallback(0, ui32Event, ui32MsgParam, pvMsgData);
|
||||
|
||||
break;
|
||||
}
|
||||
case USB_EVENT_DISCONNECTED:
|
||||
{
|
||||
//
|
||||
// No keyboard is present.
|
||||
//
|
||||
psKbInstance->ui32HIDFlags &= ~USBHKEYB_DEVICE_PRESENT;
|
||||
|
||||
//
|
||||
// Notify the application that the keyboard was disconnected.
|
||||
//
|
||||
psKbInstance->pfnCallback(0, ui32Event, ui32MsgParam, pvMsgData);
|
||||
|
||||
break;
|
||||
}
|
||||
case USB_EVENT_RX_AVAILABLE:
|
||||
{
|
||||
//
|
||||
// New keyboard report structure was received.
|
||||
//
|
||||
USBHHIDGetReport(psKbInstance->psHIDInstance, 0,
|
||||
psKbInstance->pui8Buffer,
|
||||
USBHKEYB_REPORT_SIZE);
|
||||
|
||||
//
|
||||
// Update the application on the changes in the keyboard state.
|
||||
//
|
||||
UpdateKeyboardState(psKbInstance);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @}
|
||||
//
|
||||
//*****************************************************************************
|
|
@ -0,0 +1,87 @@
|
|||
//*****************************************************************************
|
||||
//
|
||||
// usbhhidkeyboard.h - This file holds the application interfaces for USB
|
||||
// keyboard devices.
|
||||
//
|
||||
// Copyright (c) 2008-2013 Texas Instruments Incorporated. All rights reserved.
|
||||
// Software License Agreement
|
||||
//
|
||||
// Texas Instruments (TI) is supplying this software for use solely and
|
||||
// exclusively on TI's microcontroller products. The software is owned by
|
||||
// TI and/or its suppliers, and is protected under applicable copyright
|
||||
// laws. You may not combine this software with "viral" open-source
|
||||
// software in order to form a larger program.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
|
||||
// NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
|
||||
// NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
|
||||
// CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
|
||||
// DAMAGES, FOR ANY REASON WHATSOEVER.
|
||||
//
|
||||
// This is part of revision 1.1 of the Tiva USB Library.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
#ifndef __USBHHIDKEYBOARD_H__
|
||||
#define __USBHHIDKEYBOARD_H__
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// If building with a C++ compiler, make all of the definitions in this header
|
||||
// have a C binding.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! \addtogroup usblib_host_device
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
typedef struct tUSBHKeyboard tUSBHKeyboard;
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// The prototype for the host USB Keyboard driver callback function.
|
||||
//
|
||||
//*****************************************************************************
|
||||
typedef void (*tUSBHIDKeyboardCallback)(tUSBHKeyboard *psKbInstance,
|
||||
uint32_t ui32Event,
|
||||
uint32_t ui32MsgParam,
|
||||
void *pvMsgData);
|
||||
|
||||
extern tUSBHKeyboard * USBHKeyboardOpen(tUSBHIDKeyboardCallback pfnCallback,
|
||||
uint8_t *pui8Buffer,
|
||||
uint32_t ui32BufferSize);
|
||||
extern uint32_t USBHKeyboardClose(tUSBHKeyboard *psKbInstance);
|
||||
extern uint32_t USBHKeyboardInit(tUSBHKeyboard *psKbInstance);
|
||||
extern uint32_t USBHKeyboardModifierSet(tUSBHKeyboard *psKbInstance,
|
||||
uint32_t ui32Modifiers);
|
||||
extern uint32_t USBHKeyboardPollRateSet(tUSBHKeyboard *psKbInstance,
|
||||
uint32_t ui32PollRate);
|
||||
extern uint32_t USBHKeyboardUsageToChar(tUSBHKeyboard *psKbInstance,
|
||||
const tHIDKeyboardUsageTable *psTable,
|
||||
uint8_t ui8UsageID);
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @}
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Mark the end of the C bindings section for C++ compilers.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -0,0 +1,393 @@
|
|||
//*****************************************************************************
|
||||
//
|
||||
// usbhhidmouse.c - This file holds the application interfaces for USB
|
||||
// mouse devices.
|
||||
//
|
||||
// Copyright (c) 2008-2013 Texas Instruments Incorporated. All rights reserved.
|
||||
// Software License Agreement
|
||||
//
|
||||
// Texas Instruments (TI) is supplying this software for use solely and
|
||||
// exclusively on TI's microcontroller products. The software is owned by
|
||||
// TI and/or its suppliers, and is protected under applicable copyright
|
||||
// laws. You may not combine this software with "viral" open-source
|
||||
// software in order to form a larger program.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
|
||||
// NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
|
||||
// NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
|
||||
// CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
|
||||
// DAMAGES, FOR ANY REASON WHATSOEVER.
|
||||
//
|
||||
// This is part of revision 1.1 of the Tiva USB Library.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "inc/hw_types.h"
|
||||
#include "usblib/usblib.h"
|
||||
#include "usblib/host/usbhost.h"
|
||||
#include "usblib/usbhid.h"
|
||||
#include "usblib/host/usbhhid.h"
|
||||
#include "usblib/host/usbhhidmouse.h"
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! \addtogroup usblib_host_device
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Prototypes for local functions.
|
||||
//
|
||||
//*****************************************************************************
|
||||
static uint32_t USBHMouseCallback(void *pvMouse, uint32_t ui32Event,
|
||||
uint32_t ui32MsgParam, void *pvMsgData);
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// The size of a USB mouse report.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define USBHMS_REPORT_SIZE 4
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// These are the flags for the tUSBHMouse.ui32HIDFlags member variable.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define USBHMS_DEVICE_PRESENT 0x00000001
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// This is the structure definition for a mouse device instance.
|
||||
//
|
||||
//*****************************************************************************
|
||||
struct tUSBHMouse
|
||||
{
|
||||
//
|
||||
// Global flags for an instance of a mouse.
|
||||
//
|
||||
uint32_t ui32HIDFlags;
|
||||
|
||||
//
|
||||
// The applications registered callback.
|
||||
//
|
||||
tUSBHIDMouseCallback pfnCallback;
|
||||
|
||||
//
|
||||
// The current state of the buttons.
|
||||
//
|
||||
uint8_t ui8Buttons;
|
||||
|
||||
//
|
||||
// This is a local buffer to hold the current HID report that comes up
|
||||
// from the HID driver layer.
|
||||
//
|
||||
uint8_t pui8Buffer[USBHMS_REPORT_SIZE];
|
||||
|
||||
//
|
||||
// Heap data for the mouse currently used to read the HID Report
|
||||
// Descriptor.
|
||||
//
|
||||
uint8_t *pui8Heap;
|
||||
|
||||
//
|
||||
// Size of the heap in bytes.
|
||||
//
|
||||
uint32_t ui32HeapSize;
|
||||
|
||||
//
|
||||
// This is the instance value for the HID device that will be used for the
|
||||
// mouse.
|
||||
//
|
||||
tHIDInstance *psHIDInstance;
|
||||
};
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// This is the per instance information for a mouse device.
|
||||
//
|
||||
//*****************************************************************************
|
||||
static tUSBHMouse g_sUSBHMouse =
|
||||
{
|
||||
0
|
||||
};
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! This function is used open an instance of a mouse.
|
||||
//!
|
||||
//! \param pfnCallback is the callback function to call when new events occur
|
||||
//! with the mouse returned.
|
||||
//! \param pui8Buffer is the memory used by the driver to interact with the
|
||||
//! USB mouse.
|
||||
//! \param ui32Size is the size of the buffer provided by \e pui8Buffer.
|
||||
//!
|
||||
//! This function is used to open an instance of the mouse. The value
|
||||
//! returned from this function should be used as the instance identifier for
|
||||
//! all other USBHMouse calls. The \e pui8Buffer memory buffer is used to
|
||||
//! access the mouse. The buffer size required is at least enough to hold
|
||||
//! a normal report descriptor for the device.
|
||||
//!
|
||||
//! \return Returns the instance identifier for the mouse that is attached.
|
||||
//! If there is no mouse present this will return 0.
|
||||
//
|
||||
//*****************************************************************************
|
||||
tUSBHMouse *
|
||||
USBHMouseOpen(tUSBHIDMouseCallback pfnCallback, uint8_t *pui8Buffer,
|
||||
uint32_t ui32Size)
|
||||
{
|
||||
//
|
||||
// Save the callback and data pointers.
|
||||
//
|
||||
g_sUSBHMouse.pfnCallback = pfnCallback;
|
||||
|
||||
//
|
||||
// Save the instance pointer for the HID device that was opened.
|
||||
//
|
||||
g_sUSBHMouse.psHIDInstance = USBHHIDOpen(eUSBHHIDClassMouse,
|
||||
USBHMouseCallback,
|
||||
(void *)&g_sUSBHMouse);
|
||||
|
||||
//
|
||||
// Save the heap buffer and size.
|
||||
//
|
||||
g_sUSBHMouse.pui8Heap = pui8Buffer;
|
||||
g_sUSBHMouse.ui32HeapSize = ui32Size;
|
||||
|
||||
return(&g_sUSBHMouse);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! This function is used close an instance of a mouse.
|
||||
//!
|
||||
//! \param psMsInstance is the instance value for this mouse.
|
||||
//!
|
||||
//! This function is used to close an instance of the mouse that was opened
|
||||
//! with a call to USBHMouseOpen(). The \e psMsInstance value is the value
|
||||
//! that was returned when the application called USBHMouseOpen().
|
||||
//!
|
||||
//! \return Returns 0.
|
||||
//
|
||||
//*****************************************************************************
|
||||
uint32_t
|
||||
USBHMouseClose(tUSBHMouse *psMsInstance)
|
||||
{
|
||||
//
|
||||
// Reset the callback to null.
|
||||
//
|
||||
psMsInstance->pfnCallback = 0;
|
||||
|
||||
//
|
||||
// Call the HID driver layer to close out this instance.
|
||||
//
|
||||
USBHHIDClose(psMsInstance->psHIDInstance);
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! This function is used to initialize a mouse interface after a mouse has
|
||||
//! been detected.
|
||||
//!
|
||||
//! \param psMsInstance is the instance value for this mouse.
|
||||
//!
|
||||
//! This function should be called after receiving a \b USB_EVENT_CONNECTED
|
||||
//! event in the callback function provided by USBHMouseOpen(), however it
|
||||
//! should only be called outside of the callback function. This will
|
||||
//! initialize the mouse interface and determine how it reports events to the
|
||||
//! USB host controller. The \e psMsInstance value is the value that was
|
||||
//! returned when the application called USBHMouseOpen(). This function only
|
||||
//! needs to be called once per connection event but it should be called every
|
||||
//! time a \b USB_EVENT_CONNECTED event occurs.
|
||||
//!
|
||||
//! \return Non-zero values should be assumed to indicate an error condition.
|
||||
//
|
||||
//*****************************************************************************
|
||||
uint32_t
|
||||
USBHMouseInit(tUSBHMouse *psMsInstance)
|
||||
{
|
||||
//
|
||||
// Set the initial rate to only update on mouse state changes.
|
||||
//
|
||||
USBHHIDSetIdle(psMsInstance->psHIDInstance, 0, 0);
|
||||
|
||||
//
|
||||
// Read out the Report Descriptor from the mouse and parse it for
|
||||
// the format of the reports coming back from the mouse.
|
||||
//
|
||||
USBHHIDGetReportDescriptor(psMsInstance->psHIDInstance,
|
||||
psMsInstance->pui8Heap,
|
||||
psMsInstance->ui32HeapSize);
|
||||
|
||||
//
|
||||
// Set the mouse to boot protocol.
|
||||
//
|
||||
USBHHIDSetProtocol(psMsInstance->psHIDInstance, 1);
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// This function handles updating the state of the mouse buttons and axis.
|
||||
//
|
||||
// \param psMsInstance is the pointer to an instance of the mouse data.
|
||||
//
|
||||
// This function will check for updates to buttons or X/Y movements and send
|
||||
// callbacks to the mouse callback function.
|
||||
//
|
||||
// \return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
static void
|
||||
UpdateMouseState(tUSBHMouse *psMsInstance)
|
||||
{
|
||||
uint32_t ui32Button;
|
||||
|
||||
if(psMsInstance->pui8Buffer[0] != psMsInstance->ui8Buttons)
|
||||
{
|
||||
for(ui32Button = 1; ui32Button <= 0x4; ui32Button <<= 1)
|
||||
{
|
||||
if(((psMsInstance->pui8Buffer[0] & ui32Button) != 0) &&
|
||||
((psMsInstance->ui8Buttons & ui32Button) == 0))
|
||||
{
|
||||
//
|
||||
// Send the mouse button press notification to the application.
|
||||
//
|
||||
psMsInstance->pfnCallback(0, USBH_EVENT_HID_MS_PRESS,
|
||||
ui32Button, 0);
|
||||
}
|
||||
if(((psMsInstance->pui8Buffer[0] & ui32Button) == 0) &&
|
||||
((psMsInstance->ui8Buttons & ui32Button) != 0))
|
||||
{
|
||||
//
|
||||
// Send the mouse button release notification to the
|
||||
// application.
|
||||
//
|
||||
psMsInstance->pfnCallback(0, USBH_EVENT_HID_MS_REL,
|
||||
ui32Button, 0);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Save the new state.
|
||||
//
|
||||
psMsInstance->ui8Buttons = psMsInstance->pui8Buffer[0];
|
||||
}
|
||||
|
||||
if(psMsInstance->pui8Buffer[1] != 0)
|
||||
{
|
||||
//
|
||||
// Send the mouse button release notification to the
|
||||
// application.
|
||||
//
|
||||
psMsInstance->pfnCallback(0, USBH_EVENT_HID_MS_X,
|
||||
(uint32_t)psMsInstance->pui8Buffer[1], 0);
|
||||
}
|
||||
|
||||
if(psMsInstance->pui8Buffer[2] != 0)
|
||||
{
|
||||
//
|
||||
// Send the mouse button release notification to the
|
||||
// application.
|
||||
//
|
||||
psMsInstance->pfnCallback(0, USBH_EVENT_HID_MS_Y,
|
||||
(uint32_t)psMsInstance->pui8Buffer[2], 0);
|
||||
}
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! This function handles event callbacks from the USB HID driver layer.
|
||||
//!
|
||||
//! \param pvMouse is the pointer that was passed in to the USBHHIDOpen()
|
||||
//! call.
|
||||
//! \param ui32Event is the event that has been passed up from the HID driver.
|
||||
//! \param ui32MsgParam has meaning related to the \e ui32Event that occurred.
|
||||
//! \param pvMsgData has meaning related to the \e ui32Event that occurred.
|
||||
//!
|
||||
//! This function will receive all event updates from the HID driver layer.
|
||||
//! The mouse driver itself will mostly be concerned with report callbacks
|
||||
//! from the HID driver layer and parsing them into keystrokes for the
|
||||
//! application that has registered for callbacks with the USBHMouseOpen()
|
||||
//! call.
|
||||
//!
|
||||
//! \return Non-zero values should be assumed to indicate an error condition.
|
||||
//
|
||||
//*****************************************************************************
|
||||
uint32_t
|
||||
USBHMouseCallback(void *pvMouse, uint32_t ui32Event,
|
||||
uint32_t ui32MsgParam, void *pvMsgData)
|
||||
{
|
||||
tUSBHMouse *psMsInstance;
|
||||
|
||||
//
|
||||
// Recover the pointer to the instance data.
|
||||
//
|
||||
psMsInstance = (tUSBHMouse *)pvMouse;
|
||||
|
||||
switch(ui32Event)
|
||||
{
|
||||
//
|
||||
// New mouse has been connected so notify the application.
|
||||
//
|
||||
case USB_EVENT_CONNECTED:
|
||||
{
|
||||
//
|
||||
// Remember that a mouse is present.
|
||||
//
|
||||
psMsInstance->ui32HIDFlags |= USBHMS_DEVICE_PRESENT;
|
||||
|
||||
//
|
||||
// Notify the application that a new mouse was connected.
|
||||
//
|
||||
psMsInstance->pfnCallback(0, ui32Event, ui32MsgParam, pvMsgData);
|
||||
|
||||
break;
|
||||
}
|
||||
case USB_EVENT_DISCONNECTED:
|
||||
{
|
||||
//
|
||||
// No mouse is present.
|
||||
//
|
||||
psMsInstance->ui32HIDFlags &= ~USBHMS_DEVICE_PRESENT;
|
||||
|
||||
//
|
||||
// Notify the application that the mouse was disconnected.
|
||||
//
|
||||
psMsInstance->pfnCallback(0, ui32Event, ui32MsgParam, pvMsgData);
|
||||
|
||||
break;
|
||||
}
|
||||
case USB_EVENT_RX_AVAILABLE:
|
||||
{
|
||||
//
|
||||
// New mouse report structure was received.
|
||||
//
|
||||
USBHHIDGetReport(psMsInstance->psHIDInstance, 0,
|
||||
psMsInstance->pui8Buffer, USBHMS_REPORT_SIZE);
|
||||
|
||||
//
|
||||
// Update the current state of the mouse and notify the application
|
||||
// of any changes.
|
||||
//
|
||||
UpdateMouseState(psMsInstance);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @}
|
||||
//
|
||||
//*****************************************************************************
|
|
@ -0,0 +1,79 @@
|
|||
//*****************************************************************************
|
||||
//
|
||||
// usbhhidmouse.h - This file holds the application interfaces for USB
|
||||
// mouse devices.
|
||||
//
|
||||
// Copyright (c) 2008-2013 Texas Instruments Incorporated. All rights reserved.
|
||||
// Software License Agreement
|
||||
//
|
||||
// Texas Instruments (TI) is supplying this software for use solely and
|
||||
// exclusively on TI's microcontroller products. The software is owned by
|
||||
// TI and/or its suppliers, and is protected under applicable copyright
|
||||
// laws. You may not combine this software with "viral" open-source
|
||||
// software in order to form a larger program.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
|
||||
// NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
|
||||
// NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
|
||||
// CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
|
||||
// DAMAGES, FOR ANY REASON WHATSOEVER.
|
||||
//
|
||||
// This is part of revision 1.1 of the Tiva USB Library.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
#ifndef __USBHHIDMOUSE_H__
|
||||
#define __USBHHIDMOUSE_H__
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// If building with a C++ compiler, make all of the definitions in this header
|
||||
// have a C binding.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! \addtogroup usblib_host_device
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
typedef struct tUSBHMouse tUSBHMouse;
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// The prototype for the host USB mouse driver callback function.
|
||||
//
|
||||
//*****************************************************************************
|
||||
typedef void (*tUSBHIDMouseCallback)(tUSBHMouse *psMsInstance,
|
||||
uint32_t ui32Event,
|
||||
uint32_t ui32MsgParam,
|
||||
void *pvMsgData);
|
||||
|
||||
extern tUSBHMouse * USBHMouseOpen(tUSBHIDMouseCallback pfnCallback,
|
||||
uint8_t *pui8Buffer, uint32_t ui32Size);
|
||||
extern uint32_t USBHMouseClose(tUSBHMouse *psMsInstance);
|
||||
extern uint32_t USBHMouseInit(tUSBHMouse *psMsInstance);
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @}
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Mark the end of the C bindings section for C++ compilers.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,172 @@
|
|||
//*****************************************************************************
|
||||
//
|
||||
// usbhhub.h - This hold the host driver for hid class.
|
||||
//
|
||||
// Copyright (c) 2011-2013 Texas Instruments Incorporated. All rights reserved.
|
||||
// Software License Agreement
|
||||
//
|
||||
// Texas Instruments (TI) is supplying this software for use solely and
|
||||
// exclusively on TI's microcontroller products. The software is owned by
|
||||
// TI and/or its suppliers, and is protected under applicable copyright
|
||||
// laws. You may not combine this software with "viral" open-source
|
||||
// software in order to form a larger program.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
|
||||
// NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
|
||||
// NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
|
||||
// CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
|
||||
// DAMAGES, FOR ANY REASON WHATSOEVER.
|
||||
//
|
||||
// This is part of revision 1.1 of the Tiva USB Library.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
#ifndef __USBHHUB_H__
|
||||
#define __USBHHUB_H__
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// If building with a C++ compiler, make all of the definitions in this header
|
||||
// have a C binding.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
typedef struct tHubInstance tHubInstance;
|
||||
|
||||
extern const tUSBHostClassDriver g_sUSBHubClassDriver;
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// The USB standard allows for up to 127 downstream ports on a single hub.
|
||||
// This would require rather more memory than we would like to set aside so the
|
||||
// default configuration of the hub driver supports hubs with up to 7
|
||||
// downstream-facing ports. In practice, this should be more than enough
|
||||
// since this covers the vast majority of consumer hubs. Note that, by
|
||||
// default, we will only support 4 devices so you can't fully populate a 7 port
|
||||
// hub and have everything work.
|
||||
//
|
||||
// Feel free to change this but bad things will happen if you increase it above
|
||||
// 31 since we assume the reports will always fit inside a 4 byte buffer.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define ROOT_HUB_MAX_PORTS 7
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Values used as the ui16Feature parameter to USBHHubClearHubFeature().
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define HUB_FEATURE_C_HUB_LOCAL_POWER \
|
||||
0
|
||||
#define HUB_FEATURE_C_HUB_OVER_CURRENT \
|
||||
1
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Values used as the ui16Feature parameter to USBHHubSetPortFeature() and
|
||||
// USBHHubClearPortFeature().
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define HUB_FEATURE_PORT_CONNECTION \
|
||||
0
|
||||
#define HUB_FEATURE_PORT_ENABLE 1
|
||||
#define HUB_FEATURE_PORT_SUSPEND \
|
||||
2
|
||||
#define HUB_FEATURE_PORT_OVER_CURRENT \
|
||||
3
|
||||
#define HUB_FEATURE_PORT_RESET 4
|
||||
#define HUB_FEATURE_PORT_POWER 8
|
||||
#define HUB_FEATURE_PORT_LOW_SPEED \
|
||||
9
|
||||
#define HUB_FEATURE_C_PORT_CONNECTION \
|
||||
16
|
||||
#define HUB_FEATURE_C_PORT_ENABLE \
|
||||
17
|
||||
#define HUB_FEATURE_C_PORT_SUSPEND \
|
||||
18
|
||||
#define HUB_FEATURE_C_PORT_OVER_CURRENT \
|
||||
19
|
||||
#define HUB_FEATURE_C_PORT_RESET \
|
||||
20
|
||||
#define HUB_FEATURE_PORT_TEST 21
|
||||
#define HUB_FEATURE_PORT_INDICATOR \
|
||||
22
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Values returned via the *pui16HubStatus and *pui16HubChange parameters
|
||||
// passed to USBHHubGetHubStatus(). These may be ORed together into the
|
||||
// returned status value.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define HUB_STATUS_PWR_LOST 1
|
||||
#define HUB_STATUS_OVER_CURRENT 2
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Values returned via the *pui16PortStatus parameter passed to
|
||||
// USBHHubGetPortStatus(). These may be ORed together into the returned status
|
||||
// value.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define HUB_PORT_STATUS_DEVICE_PRESENT \
|
||||
0x0001
|
||||
#define HUB_PORT_STATUS_ENABLED 0x0002
|
||||
#define HUB_PORT_STATUS_SUSPENDED \
|
||||
0x0004
|
||||
#define HUB_PORT_STATUS_OVER_CURRENT \
|
||||
0x0008
|
||||
#define HUB_PORT_STATUS_RESET 0x0010
|
||||
#define HUB_PORT_STATUS_POWERED 0x0100
|
||||
#define HUB_PORT_STATUS_LOW_SPEED \
|
||||
0x0200
|
||||
#define HUB_PORT_STATUS_HIGH_SPEED \
|
||||
0x0400
|
||||
#define HUB_PORT_STATUS_TEST_MODE \
|
||||
0x0800
|
||||
#define HUB_PORT_STATUS_INDICATOR_CONTROL \
|
||||
0x1000
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Values returned via the *pui16PortChange parameter passed to
|
||||
// USBHHubGetPortStatus(). These may be ORed together into the returned status
|
||||
// value.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define HUB_PORT_CHANGE_DEVICE_PRESENT \
|
||||
0x0001
|
||||
#define HUB_PORT_CHANGE_ENABLED 0x0002
|
||||
#define HUB_PORT_CHANGE_SUSPENDED \
|
||||
0x0004
|
||||
#define HUB_PORT_CHANGE_OVER_CURRENT \
|
||||
0x0008
|
||||
#define HUB_PORT_CHANGE_RESET 0x0010
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// The prototype for the USB Hub host driver callback function.
|
||||
//
|
||||
//*****************************************************************************
|
||||
typedef void (*tUSBHHubCallback)(tHubInstance *psHubInstance,
|
||||
uint32_t ui32Event, uint32_t ui32MsgParam,
|
||||
void *pvMsgData);
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Public function prototypes for the HUB class driver.
|
||||
//
|
||||
//*****************************************************************************
|
||||
extern tHubInstance * USBHHubOpen(tUSBHHubCallback pfnCallback);
|
||||
extern void USBHHubClose(tHubInstance *psHubInstance);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // __USBHHUB_H__
|
|
@ -0,0 +1,697 @@
|
|||
//*****************************************************************************
|
||||
//
|
||||
// usbhmsc.c - USB MSC host driver.
|
||||
//
|
||||
// Copyright (c) 2008-2013 Texas Instruments Incorporated. All rights reserved.
|
||||
// Software License Agreement
|
||||
//
|
||||
// Texas Instruments (TI) is supplying this software for use solely and
|
||||
// exclusively on TI's microcontroller products. The software is owned by
|
||||
// TI and/or its suppliers, and is protected under applicable copyright
|
||||
// laws. You may not combine this software with "viral" open-source
|
||||
// software in order to form a larger program.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
|
||||
// NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
|
||||
// NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
|
||||
// CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
|
||||
// DAMAGES, FOR ANY REASON WHATSOEVER.
|
||||
//
|
||||
// This is part of revision 1.1 of the Tiva USB Library.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "inc/hw_types.h"
|
||||
#include "driverlib/usbdrv.h"
|
||||
#include "usblib/usblib.h"
|
||||
#include "usblib/usblibpriv.h"
|
||||
#include "usblib/usbmsc.h"
|
||||
#include "usblib/host/usbhost.h"
|
||||
#include "usblib/host/usbhostpriv.h"
|
||||
#include "usblib/host/usbhmsc.h"
|
||||
#include "usblib/host/usbhscsi.h"
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! \addtogroup usblib_host_class
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Forward declarations for the driver open and close calls.
|
||||
//
|
||||
//*****************************************************************************
|
||||
static void *USBHMSCOpen(tUSBHostDevice *psDevice);
|
||||
static void USBHMSCClose(void *pvInstance);
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// This is the structure for an instance of a USB MSC host driver.
|
||||
//
|
||||
//*****************************************************************************
|
||||
struct tUSBHMSCInstance
|
||||
{
|
||||
//
|
||||
// Save the device instance.
|
||||
//
|
||||
tUSBHostDevice *psDevice;
|
||||
|
||||
//
|
||||
// Used to save the callback.
|
||||
//
|
||||
tUSBHMSCCallback pfnCallback;
|
||||
|
||||
//
|
||||
// The Maximum LUNs
|
||||
//
|
||||
uint32_t ui32MaxLUN;
|
||||
|
||||
//
|
||||
// The total number of blocks associated with this device.
|
||||
//
|
||||
uint32_t ui32NumBlocks;
|
||||
|
||||
//
|
||||
// The size of the blocks associated with this device.
|
||||
//
|
||||
uint32_t ui32BlockSize;
|
||||
|
||||
//
|
||||
// Bulk IN pipe.
|
||||
//
|
||||
uint32_t ui32BulkInPipe;
|
||||
|
||||
//
|
||||
// Bulk OUT pipe.
|
||||
//
|
||||
uint32_t ui32BulkOutPipe;
|
||||
};
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// The array of USB MSC host drivers.
|
||||
//
|
||||
//*****************************************************************************
|
||||
static tUSBHMSCInstance g_sUSBHMSCDevice =
|
||||
{
|
||||
0
|
||||
};
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! This constant global structure defines the Mass Storage Class Driver that
|
||||
//! is provided with the USB library.
|
||||
//
|
||||
//*****************************************************************************
|
||||
const tUSBHostClassDriver g_sUSBHostMSCClassDriver =
|
||||
{
|
||||
USB_CLASS_MASS_STORAGE,
|
||||
USBHMSCOpen,
|
||||
USBHMSCClose,
|
||||
0
|
||||
};
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! This function is used to open an instance of the MSC driver.
|
||||
//!
|
||||
//! \param psDevice is a pointer to the device information structure.
|
||||
//!
|
||||
//! This function will attempt to open an instance of the MSC driver based on
|
||||
//! the information contained in the \e psDevice structure. This call can fail
|
||||
//! if there are not sufficient resources to open the device. The function
|
||||
//! returns a value that should be passed back into USBMSCClose() when the
|
||||
//! driver is no longer needed.
|
||||
//!
|
||||
//! \return The function will return a pointer to a MSC driver instance.
|
||||
//
|
||||
//*****************************************************************************
|
||||
static void *
|
||||
USBHMSCOpen(tUSBHostDevice *psDevice)
|
||||
{
|
||||
int32_t i32Idx;
|
||||
tEndpointDescriptor *psEndpointDescriptor;
|
||||
tInterfaceDescriptor *psInterface;
|
||||
|
||||
//
|
||||
// Don't allow the device to be opened without closing first.
|
||||
//
|
||||
if(g_sUSBHMSCDevice.psDevice)
|
||||
{
|
||||
return(0);
|
||||
}
|
||||
|
||||
//
|
||||
// Save the device pointer.
|
||||
//
|
||||
g_sUSBHMSCDevice.psDevice = psDevice;
|
||||
|
||||
//
|
||||
// Get the interface descriptor.
|
||||
//
|
||||
psInterface = USBDescGetInterface(psDevice->psConfigDescriptor, 0, 0);
|
||||
|
||||
//
|
||||
// Loop through the endpoints of the device.
|
||||
//
|
||||
for(i32Idx = 0; i32Idx < 3; i32Idx++)
|
||||
{
|
||||
//
|
||||
// Get the first endpoint descriptor.
|
||||
//
|
||||
psEndpointDescriptor =
|
||||
USBDescGetInterfaceEndpoint(psInterface, i32Idx,
|
||||
psDevice->ui32ConfigDescriptorSize);
|
||||
|
||||
//
|
||||
// If no more endpoints then break out.
|
||||
//
|
||||
if(psEndpointDescriptor == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
// See if this is a bulk endpoint.
|
||||
//
|
||||
if((psEndpointDescriptor->bmAttributes & USB_EP_ATTR_TYPE_M) ==
|
||||
USB_EP_ATTR_BULK)
|
||||
{
|
||||
//
|
||||
// See if this is bulk IN or bulk OUT.
|
||||
//
|
||||
if(psEndpointDescriptor->bEndpointAddress & USB_EP_DESC_IN)
|
||||
{
|
||||
//
|
||||
// Allocate the USB Pipe for this Bulk IN endpoint.
|
||||
//
|
||||
g_sUSBHMSCDevice.ui32BulkInPipe =
|
||||
USBHCDPipeAllocSize(0, USBHCD_PIPE_BULK_IN_DMA,
|
||||
psDevice,
|
||||
psEndpointDescriptor->wMaxPacketSize,
|
||||
0);
|
||||
//
|
||||
// Configure the USB pipe as a Bulk IN endpoint.
|
||||
//
|
||||
USBHCDPipeConfig(g_sUSBHMSCDevice.ui32BulkInPipe,
|
||||
psEndpointDescriptor->wMaxPacketSize,
|
||||
0,
|
||||
(psEndpointDescriptor->bEndpointAddress &
|
||||
USB_EP_DESC_NUM_M));
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
// Allocate the USB Pipe for this Bulk OUT endpoint.
|
||||
//
|
||||
g_sUSBHMSCDevice.ui32BulkOutPipe =
|
||||
USBHCDPipeAllocSize(0, USBHCD_PIPE_BULK_OUT_DMA,
|
||||
psDevice,
|
||||
psEndpointDescriptor->wMaxPacketSize,
|
||||
0);
|
||||
//
|
||||
// Configure the USB pipe as a Bulk OUT endpoint.
|
||||
//
|
||||
USBHCDPipeConfig(g_sUSBHMSCDevice.ui32BulkOutPipe,
|
||||
psEndpointDescriptor->wMaxPacketSize,
|
||||
0,
|
||||
(psEndpointDescriptor->bEndpointAddress &
|
||||
USB_EP_DESC_NUM_M));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// If the callback exists, call it with an Open event.
|
||||
//
|
||||
if(g_sUSBHMSCDevice.pfnCallback != 0)
|
||||
{
|
||||
g_sUSBHMSCDevice.pfnCallback(&g_sUSBHMSCDevice, MSC_EVENT_OPEN, 0);
|
||||
}
|
||||
|
||||
|
||||
g_sUSBHMSCDevice.ui32MaxLUN = 0xffffffff;
|
||||
|
||||
//
|
||||
// Return the only instance of this device.
|
||||
//
|
||||
return(&g_sUSBHMSCDevice);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! This function is used to release an instance of the MSC driver.
|
||||
//!
|
||||
//! \param pvInstance is an instance pointer that needs to be released.
|
||||
//!
|
||||
//! This function will free up any resources in use by the MSC driver instance
|
||||
//! that is passed in. The \e pvInstance pointer should be a valid value that
|
||||
//! was returned from a call to USBMSCOpen().
|
||||
//!
|
||||
//! \return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
static void
|
||||
USBHMSCClose(void *pvInstance)
|
||||
{
|
||||
//
|
||||
// Do nothing if there is not a driver open.
|
||||
//
|
||||
if(g_sUSBHMSCDevice.psDevice == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// Reset the device pointer.
|
||||
//
|
||||
g_sUSBHMSCDevice.psDevice = 0;
|
||||
|
||||
//
|
||||
// Free the Bulk IN pipe.
|
||||
//
|
||||
if(g_sUSBHMSCDevice.ui32BulkInPipe != 0)
|
||||
{
|
||||
USBHCDPipeFree(g_sUSBHMSCDevice.ui32BulkInPipe);
|
||||
}
|
||||
|
||||
//
|
||||
// Free the Bulk OUT pipe.
|
||||
//
|
||||
if(g_sUSBHMSCDevice.ui32BulkOutPipe != 0)
|
||||
{
|
||||
USBHCDPipeFree(g_sUSBHMSCDevice.ui32BulkOutPipe);
|
||||
}
|
||||
|
||||
//
|
||||
// If the callback exists then call it.
|
||||
//
|
||||
if(g_sUSBHMSCDevice.pfnCallback != 0)
|
||||
{
|
||||
g_sUSBHMSCDevice.pfnCallback(&g_sUSBHMSCDevice, MSC_EVENT_CLOSE, 0);
|
||||
}
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! This function retrieves the maximum number of the logical units on a
|
||||
//! mass storage device.
|
||||
//!
|
||||
//! \param psDevice is the device instance pointer for this request.
|
||||
//! \param ui32Interface is the interface number on the device specified by the
|
||||
//! \e ui32Address parameter.
|
||||
//! \param pui8MaxLUN is the byte value returned from the device for the
|
||||
//! device's maximum logical unit.
|
||||
//!
|
||||
//! The device will return one byte of data that contains the maximum LUN
|
||||
//! supported by the device. For example, if the device supports four LUNs
|
||||
//! then the LUNs would be numbered from 0 to 3 and the return value would be
|
||||
//! 3. If no LUN is associated with the device, the value returned shall be 0.
|
||||
//!
|
||||
//! \return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
static void
|
||||
USBHMSCGetMaxLUN(tUSBHostDevice *psDevice, uint32_t ui32Interface,
|
||||
uint8_t *pui8MaxLUN)
|
||||
{
|
||||
tUSBRequest sSetupPacket;
|
||||
|
||||
//
|
||||
// This is a Class specific interface IN request.
|
||||
//
|
||||
sSetupPacket.bmRequestType =
|
||||
USB_RTYPE_DIR_IN | USB_RTYPE_CLASS | USB_RTYPE_INTERFACE;
|
||||
|
||||
//
|
||||
// Request a the Max LUN for this interface.
|
||||
//
|
||||
sSetupPacket.bRequest = USBREQ_GET_MAX_LUN;
|
||||
sSetupPacket.wValue = 0;
|
||||
|
||||
//
|
||||
// Indicate the interface to use.
|
||||
//
|
||||
sSetupPacket.wIndex = (uint16_t)ui32Interface;
|
||||
|
||||
//
|
||||
// Only request a single byte of data.
|
||||
//
|
||||
sSetupPacket.wLength = 1;
|
||||
|
||||
//
|
||||
// Put the setup packet in the buffer and send the command.
|
||||
//
|
||||
if(USBHCDControlTransfer(0, &sSetupPacket, psDevice, pui8MaxLUN, 1,
|
||||
MAX_PACKET_SIZE_EP0) != 1)
|
||||
{
|
||||
*pui8MaxLUN = 0;
|
||||
}
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! This function checks if a drive is ready to be accessed.
|
||||
//!
|
||||
//! \param psMSCInstance is the device instance to use for this read.
|
||||
//!
|
||||
//! This function checks if the current device is ready to be accessed.
|
||||
//! It uses the \e psMSCInstance parameter to determine which device to check
|
||||
//! and returns zero when the device is ready. Any non-zero return code
|
||||
//! indicates that the device was not ready.
|
||||
//!
|
||||
//! \return This function returns zero if the device is ready and it
|
||||
//! returns a other value if the device is not ready or if an error occurred.
|
||||
//
|
||||
//*****************************************************************************
|
||||
int32_t
|
||||
USBHMSCDriveReady(tUSBHMSCInstance *psMSCInstance)
|
||||
{
|
||||
uint8_t ui8MaxLUN, pui8Buffer[SCSI_INQUIRY_DATA_SZ];
|
||||
uint32_t ui32Size;
|
||||
|
||||
//
|
||||
// If there is no device present then return an error.
|
||||
//
|
||||
if(psMSCInstance->psDevice == 0)
|
||||
{
|
||||
return(-1);
|
||||
}
|
||||
|
||||
//
|
||||
// Only request the maximum number of LUNs once.
|
||||
//
|
||||
if(g_sUSBHMSCDevice.ui32MaxLUN == 0xffffffff)
|
||||
{
|
||||
//
|
||||
// Get the Maximum LUNs on this device.
|
||||
//
|
||||
USBHMSCGetMaxLUN(g_sUSBHMSCDevice.psDevice,
|
||||
g_sUSBHMSCDevice.psDevice->ui32Interface, &ui8MaxLUN);
|
||||
|
||||
//
|
||||
// Save the Maximum number of LUNs on this device.
|
||||
//
|
||||
g_sUSBHMSCDevice.ui32MaxLUN = ui8MaxLUN;
|
||||
}
|
||||
|
||||
//
|
||||
// Just return if the device is returning not present.
|
||||
//
|
||||
ui32Size = SCSI_REQUEST_SENSE_SZ;
|
||||
if(USBHSCSIRequestSense(psMSCInstance->ui32BulkInPipe,
|
||||
psMSCInstance->ui32BulkOutPipe, pui8Buffer,
|
||||
&ui32Size) != SCSI_CMD_STATUS_PASS)
|
||||
{
|
||||
return(-1);
|
||||
}
|
||||
|
||||
if((pui8Buffer[SCSI_RS_SKEY] == SCSI_RS_KEY_UNIT_ATTN) &&
|
||||
(pui8Buffer[SCSI_RS_SKEY_AD_SKEY] == SCSI_RS_KEY_NOTPRSNT))
|
||||
{
|
||||
return(-1);
|
||||
}
|
||||
|
||||
//
|
||||
// Issue a SCSI Inquiry to get basic information on the device
|
||||
//
|
||||
ui32Size = SCSI_INQUIRY_DATA_SZ;
|
||||
if((USBHSCSIInquiry(psMSCInstance->ui32BulkInPipe,
|
||||
psMSCInstance->ui32BulkOutPipe, pui8Buffer,
|
||||
&ui32Size) != SCSI_CMD_STATUS_PASS))
|
||||
{
|
||||
return(-1);
|
||||
}
|
||||
|
||||
//
|
||||
// Get the size of the drive.
|
||||
//
|
||||
ui32Size = SCSI_INQUIRY_DATA_SZ;
|
||||
if(USBHSCSIReadCapacity(psMSCInstance->ui32BulkInPipe,
|
||||
psMSCInstance->ui32BulkOutPipe, pui8Buffer,
|
||||
&ui32Size) != SCSI_CMD_STATUS_PASS)
|
||||
{
|
||||
//
|
||||
// Get the current sense data from the device to see why it failed
|
||||
// the Read Capacity command.
|
||||
//
|
||||
ui32Size = SCSI_REQUEST_SENSE_SZ;
|
||||
USBHSCSIRequestSense(psMSCInstance->ui32BulkInPipe,
|
||||
psMSCInstance->ui32BulkOutPipe, pui8Buffer,
|
||||
&ui32Size);
|
||||
|
||||
//
|
||||
// If the read capacity failed then check if the drive is ready.
|
||||
//
|
||||
if(USBHSCSITestUnitReady(psMSCInstance->ui32BulkInPipe,
|
||||
psMSCInstance->ui32BulkOutPipe) !=
|
||||
SCSI_CMD_STATUS_PASS)
|
||||
{
|
||||
//
|
||||
// Get the current sense data from the device to see why it failed
|
||||
// the Test Unit Ready command.
|
||||
//
|
||||
ui32Size = SCSI_REQUEST_SENSE_SZ;
|
||||
USBHSCSIRequestSense(psMSCInstance->ui32BulkInPipe,
|
||||
psMSCInstance->ui32BulkOutPipe, pui8Buffer,
|
||||
&ui32Size);
|
||||
}
|
||||
|
||||
return(-1);
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
// Read the block size out, value is stored big endian.
|
||||
//
|
||||
psMSCInstance->ui32BlockSize =
|
||||
(pui8Buffer[7] | (pui8Buffer[6] << 8) | pui8Buffer[5] << 16 |
|
||||
(pui8Buffer[4] << 24));
|
||||
|
||||
//
|
||||
// Read the block size out.
|
||||
//
|
||||
psMSCInstance->ui32NumBlocks =
|
||||
(pui8Buffer[3] | (pui8Buffer[2] << 8) | pui8Buffer[1] << 16 |
|
||||
(pui8Buffer[0] << 24));
|
||||
}
|
||||
|
||||
//
|
||||
// See if the drive is ready to use.
|
||||
//
|
||||
if(USBHSCSITestUnitReady(psMSCInstance->ui32BulkInPipe,
|
||||
psMSCInstance->ui32BulkOutPipe) !=
|
||||
SCSI_CMD_STATUS_PASS)
|
||||
{
|
||||
//
|
||||
// Get the current sense data from the device to see why it failed
|
||||
// the Test Unit Ready command.
|
||||
//
|
||||
ui32Size = SCSI_REQUEST_SENSE_SZ;
|
||||
USBHSCSIRequestSense(psMSCInstance->ui32BulkInPipe,
|
||||
psMSCInstance->ui32BulkOutPipe, pui8Buffer,
|
||||
&ui32Size);
|
||||
|
||||
return(-1);
|
||||
}
|
||||
|
||||
//
|
||||
// Success.
|
||||
//
|
||||
return(0);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! This function should be called before any devices are present to enable
|
||||
//! the mass storage device class driver.
|
||||
//!
|
||||
//! \param ui32Drive is the drive number to open.
|
||||
//! \param pfnCallback is the driver callback for any mass storage events.
|
||||
//!
|
||||
//! This function is called to open an instance of a mass storage device. It
|
||||
//! should be called before any devices are connected to allow for proper
|
||||
//! notification of drive connection and disconnection. The \e ui32Drive
|
||||
//! parameter is a zero based index of the drives present in the system.
|
||||
//! There are a constant number of drives, and this number should only
|
||||
//! be greater than 0 if there is a USB hub present in the system. The
|
||||
//! application should also provide the \e pfnCallback to be notified of mass
|
||||
//! storage related events like device enumeration and device removal.
|
||||
//!
|
||||
//! \return This function will return the driver instance to use for the other
|
||||
//! mass storage functions. If there is no driver available at the time of
|
||||
//! this call, this function will return zero.
|
||||
//
|
||||
//*****************************************************************************
|
||||
tUSBHMSCInstance *
|
||||
USBHMSCDriveOpen(uint32_t ui32Drive, tUSBHMSCCallback pfnCallback)
|
||||
{
|
||||
//
|
||||
// Only the first drive is supported and only one callback is supported.
|
||||
//
|
||||
if((ui32Drive != 0) || (g_sUSBHMSCDevice.pfnCallback))
|
||||
{
|
||||
return(0);
|
||||
}
|
||||
|
||||
//
|
||||
// Save the callback.
|
||||
//
|
||||
g_sUSBHMSCDevice.pfnCallback = pfnCallback;
|
||||
|
||||
//
|
||||
// Return the requested device instance.
|
||||
//
|
||||
return(&g_sUSBHMSCDevice);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! This function should be called to release a drive instance.
|
||||
//!
|
||||
//! \param psMSCInstance is the device instance that is to be released.
|
||||
//!
|
||||
//! This function is called when an MSC drive is to be released in preparation
|
||||
//! for shutdown or a switch to USB device mode, for example. Following this
|
||||
//! call, the drive is available for other clients who may open it again using
|
||||
//! a call to USBHMSCDriveOpen().
|
||||
//!
|
||||
//! \return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
USBHMSCDriveClose(tUSBHMSCInstance *psMSCInstance)
|
||||
{
|
||||
//
|
||||
// Close the drive (if it is already open)
|
||||
//
|
||||
USBHMSCClose((void *)psMSCInstance);
|
||||
|
||||
//
|
||||
// Clear the callback indicating that the device is now closed.
|
||||
//
|
||||
psMSCInstance->pfnCallback = 0;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! This function performs a block read to an MSC device.
|
||||
//!
|
||||
//! \param psMSCInstance is the device instance to use for this read.
|
||||
//! \param ui32LBA is the logical block address to read on the device.
|
||||
//! \param pui8Data is a pointer to the returned data buffer.
|
||||
//! \param ui32NumBlocks is the number of blocks to read from the device.
|
||||
//!
|
||||
//! This function will perform a block sized read from the device associated
|
||||
//! with the \e psMSCInstance parameter. The \e ui32LBA parameter specifies
|
||||
//! the logical block address to read on the device. This function will only
|
||||
//! perform \e ui32NumBlocks block sized reads. In most cases this is a read
|
||||
//! of 512 bytes of data. The \e *pui8Data buffer should be at least
|
||||
//! \e ui32NumBlocks * 512 bytes in size.
|
||||
//!
|
||||
//! \return The function returns zero for success and any negative value
|
||||
//! indicates a failure.
|
||||
//
|
||||
//*****************************************************************************
|
||||
int32_t
|
||||
USBHMSCBlockRead(tUSBHMSCInstance *psMSCInstance, uint32_t ui32LBA,
|
||||
uint8_t *pui8Data, uint32_t ui32NumBlocks)
|
||||
{
|
||||
uint32_t ui32Size;
|
||||
|
||||
//
|
||||
// If there is no device present then return an error.
|
||||
//
|
||||
if(psMSCInstance->psDevice == 0)
|
||||
{
|
||||
return(-1);
|
||||
}
|
||||
|
||||
//
|
||||
// Calculate the actual byte size of the read.
|
||||
//
|
||||
ui32Size = psMSCInstance->ui32BlockSize * ui32NumBlocks;
|
||||
|
||||
//
|
||||
// Perform the SCSI read command.
|
||||
//
|
||||
if(USBHSCSIRead10(psMSCInstance->ui32BulkInPipe,
|
||||
psMSCInstance->ui32BulkOutPipe, ui32LBA, pui8Data,
|
||||
&ui32Size, ui32NumBlocks) != SCSI_CMD_STATUS_PASS)
|
||||
{
|
||||
return(-1);
|
||||
}
|
||||
|
||||
//
|
||||
// Success.
|
||||
//
|
||||
return(0);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! This function performs a block write to an MSC device.
|
||||
//!
|
||||
//! \param psMSCInstance is the device instance to use for this write.
|
||||
//! \param ui32LBA is the logical block address to write on the device.
|
||||
//! \param pui8Data is a pointer to the data to write out.
|
||||
//! \param ui32NumBlocks is the number of blocks to write to the device.
|
||||
//!
|
||||
//! This function will perform a block sized write to the device associated
|
||||
//! with the \e psMSCInstance parameter. The \e ui32LBA parameter specifies
|
||||
//! the logical block address to write on the device. This function will only
|
||||
//! perform \e ui32NumBlocks block sized writes. In most cases this is a write
|
||||
//! of 512 bytes of data. The \e *pui8Data buffer should contain at least
|
||||
//! \e ui32NumBlocks * 512 bytes in size to prevent unwanted data being written
|
||||
//! to the device.
|
||||
//!
|
||||
//! \return The function returns zero for success and any negative value
|
||||
//! indicates a failure.
|
||||
//
|
||||
//*****************************************************************************
|
||||
int32_t
|
||||
USBHMSCBlockWrite(tUSBHMSCInstance *psMSCInstance, uint32_t ui32LBA,
|
||||
uint8_t *pui8Data, uint32_t ui32NumBlocks)
|
||||
{
|
||||
uint32_t ui32Size;
|
||||
|
||||
//
|
||||
// If there is no device present then return an error.
|
||||
//
|
||||
if(psMSCInstance->psDevice == 0)
|
||||
{
|
||||
return(-1);
|
||||
}
|
||||
|
||||
//
|
||||
// Calculate the actual byte size of the write.
|
||||
//
|
||||
ui32Size = psMSCInstance->ui32BlockSize * ui32NumBlocks;
|
||||
|
||||
//
|
||||
// Perform the SCSI write command.
|
||||
//
|
||||
if(USBHSCSIWrite10(psMSCInstance->ui32BulkInPipe,
|
||||
psMSCInstance->ui32BulkOutPipe, ui32LBA, pui8Data,
|
||||
&ui32Size, ui32NumBlocks) != SCSI_CMD_STATUS_PASS)
|
||||
{
|
||||
return(-1);
|
||||
}
|
||||
|
||||
//
|
||||
// Success.
|
||||
//
|
||||
return(0);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Close the Doxygen group.
|
||||
//! @}
|
||||
//
|
||||
//*****************************************************************************
|
|
@ -0,0 +1,97 @@
|
|||
//*****************************************************************************
|
||||
//
|
||||
// usbhmsc.h - Definitions for the USB MSC host driver.
|
||||
//
|
||||
// Copyright (c) 2008-2013 Texas Instruments Incorporated. All rights reserved.
|
||||
// Software License Agreement
|
||||
//
|
||||
// Texas Instruments (TI) is supplying this software for use solely and
|
||||
// exclusively on TI's microcontroller products. The software is owned by
|
||||
// TI and/or its suppliers, and is protected under applicable copyright
|
||||
// laws. You may not combine this software with "viral" open-source
|
||||
// software in order to form a larger program.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
|
||||
// NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
|
||||
// NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
|
||||
// CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
|
||||
// DAMAGES, FOR ANY REASON WHATSOEVER.
|
||||
//
|
||||
// This is part of revision 1.1 of the Tiva USB Library.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
#ifndef __USBHMSC_H__
|
||||
#define __USBHMSC_H__
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// If building with a C++ compiler, make all of the definitions in this header
|
||||
// have a C binding.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! \addtogroup usblib_host_class
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
typedef struct tUSBHMSCInstance tUSBHMSCInstance;
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// These defines are the the events that will be passed in the \e ui32Event
|
||||
// parameter of the callback from the driver.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define MSC_EVENT_OPEN 1
|
||||
#define MSC_EVENT_CLOSE 2
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// The prototype for the USB MSC host driver callback function.
|
||||
//
|
||||
//*****************************************************************************
|
||||
typedef void (*tUSBHMSCCallback)(tUSBHMSCInstance *psMSCInstance,
|
||||
uint32_t ui32Event,
|
||||
void *pvEventData);
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Prototypes for the USB MSC host driver APIs.
|
||||
//
|
||||
//*****************************************************************************
|
||||
extern tUSBHMSCInstance * USBHMSCDriveOpen(uint32_t ui32Drive,
|
||||
tUSBHMSCCallback pfnCallback);
|
||||
extern void USBHMSCDriveClose(tUSBHMSCInstance *psMSCInstance);
|
||||
extern int32_t USBHMSCDriveReady(tUSBHMSCInstance *psMSCInstance);
|
||||
extern int32_t USBHMSCBlockRead(tUSBHMSCInstance *psMSCInstance,
|
||||
uint32_t ui32LBA, uint8_t *pui8Data,
|
||||
uint32_t ui32NumBlocks);
|
||||
extern int32_t USBHMSCBlockWrite(tUSBHMSCInstance *psMSCInstance,
|
||||
uint32_t ui32LBA, uint8_t *pui8Data,
|
||||
uint32_t ui32NumBlocks);
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @}
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Mark the end of the C bindings section for C++ compilers.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // __USBHMSC_H__
|
|
@ -0,0 +1,274 @@
|
|||
//*****************************************************************************
|
||||
//
|
||||
// usbhost.h - Host specific definitions for the USB host library.
|
||||
//
|
||||
// Copyright (c) 2008-2013 Texas Instruments Incorporated. All rights reserved.
|
||||
// Software License Agreement
|
||||
//
|
||||
// Texas Instruments (TI) is supplying this software for use solely and
|
||||
// exclusively on TI's microcontroller products. The software is owned by
|
||||
// TI and/or its suppliers, and is protected under applicable copyright
|
||||
// laws. You may not combine this software with "viral" open-source
|
||||
// software in order to form a larger program.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
|
||||
// NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
|
||||
// NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
|
||||
// CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
|
||||
// DAMAGES, FOR ANY REASON WHATSOEVER.
|
||||
//
|
||||
// This is part of revision 1.1 of the Tiva USB Library.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
#ifndef __USBHOST_H__
|
||||
#define __USBHOST_H__
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// If building with a C++ compiler, make all of the definitions in this header
|
||||
// have a C binding.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! \addtogroup usblib_hcd
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// This is the type used to identify what the pipe is currently in use for.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define USBHCD_PIPE_UNUSED 0x00100000
|
||||
#define USBHCD_PIPE_CONTROL 0x00130000
|
||||
#define USBHCD_PIPE_BULK_OUT 0x00210000
|
||||
#define USBHCD_PIPE_BULK_IN 0x00220000
|
||||
#define USBHCD_PIPE_INTR_OUT 0x00410000
|
||||
#define USBHCD_PIPE_INTR_IN 0x00420000
|
||||
#define USBHCD_PIPE_ISOC_OUT 0x00810000
|
||||
#define USBHCD_PIPE_ISOC_IN 0x00820000
|
||||
#define USBHCD_PIPE_ISOC_OUT_DMA 0x01810000
|
||||
#define USBHCD_PIPE_ISOC_IN_DMA 0x01820000
|
||||
#define USBHCD_PIPE_BULK_OUT_DMA 0x01210000
|
||||
#define USBHCD_PIPE_BULK_IN_DMA 0x01220000
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// These are the defines that are used with USBHCDPowerConfigInit().
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define USBHCD_FAULT_LOW 0x00000010
|
||||
#define USBHCD_FAULT_HIGH 0x00000030
|
||||
#define USBHCD_FAULT_VBUS_NONE 0x00000000
|
||||
#define USBHCD_FAULT_VBUS_TRI 0x00000140
|
||||
#define USBHCD_FAULT_VBUS_DIS 0x00000400
|
||||
#define USBHCD_VBUS_MANUAL 0x00000004
|
||||
#define USBHCD_VBUS_AUTO_LOW 0x00000002
|
||||
#define USBHCD_VBUS_AUTO_HIGH 0x00000003
|
||||
#define USBHCD_VBUS_FILTER 0x00010000
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! This macro is used to declare an instance of an Event driver for the USB
|
||||
//! library.
|
||||
//!
|
||||
//! \param VarName is the name of the variable.
|
||||
//! \param pfnOpen is the callback for the Open call to this driver. This
|
||||
//! value is currently reserved and should be set to 0.
|
||||
//! \param pfnClose is the callback for the Close call to this driver. This
|
||||
//! value is currently reserved and should be set to 0.
|
||||
//! \param pfnEvent is the callback that will be called for various USB events.
|
||||
//!
|
||||
//! The first parameter is the actual name of the variable that will
|
||||
//! be declared by this macro. The second and third parameter are reserved
|
||||
//! for future functionality and are unused and should be set to zero. The
|
||||
//! last parameter is the actual callback function and is specified as
|
||||
//! a function pointer of the type:
|
||||
//!
|
||||
//! void (*pfnEvent)(void *pvData);
|
||||
//!
|
||||
//! When the \e pfnEvent function is called the void pointer that is passed in
|
||||
//! as a parameter should be cast to a pointer to a structure of type
|
||||
//! tEventInfo. This will contain the event that caused the pfnEvent function
|
||||
//! to be called.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define DECLARE_EVENT_DRIVER(VarName, pfnOpen, pfnClose, pfnEvent) \
|
||||
void IntFn(void *pvData); \
|
||||
const tUSBHostClassDriver VarName = \
|
||||
{ \
|
||||
USB_CLASS_EVENTS, \
|
||||
0, \
|
||||
0, \
|
||||
pfnEvent \
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// This is the type definition a callback for events on USB Pipes allocated
|
||||
// by USBHCDPipeAlloc().
|
||||
//
|
||||
// \param ui32Pipe is well the pipe
|
||||
// \param ui32Event is well the event
|
||||
//
|
||||
// This prototype is used by any Pipe callbacks that are used in the host
|
||||
// class drivers. These functions typically handle data events like
|
||||
// USB_EVENT_RX_AVAILABLE or USB_EVENT_TX_COMPLETE but can be sent other events
|
||||
// depending on the USB host class in use. See the documentation for the
|
||||
// individual classes for the valid events for that class.
|
||||
//
|
||||
// \return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
typedef void (* tHCDPipeCallback)(uint32_t ui32Pipe, uint32_t ui32Event);
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Predeclare the private tUSBHostDevice structure.
|
||||
//
|
||||
//*****************************************************************************
|
||||
typedef struct tUSBHostDevice tUSBHostDevice;
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! This structure defines a USB host class driver interface, it is parsed to
|
||||
//! find a USB class driver once a USB device is enumerated.
|
||||
//
|
||||
//*****************************************************************************
|
||||
typedef struct
|
||||
{
|
||||
//
|
||||
//! The interface class that this device class driver supports.
|
||||
//
|
||||
uint32_t ui32InterfaceClass;
|
||||
|
||||
//
|
||||
//! The function is called when this class of device has been detected.
|
||||
//
|
||||
void *(*pfnOpen)(tUSBHostDevice *psDevice);
|
||||
|
||||
//
|
||||
//! The function is called when the device, originally opened with a call
|
||||
//! to the pfnOpen function, is disconnected.
|
||||
//
|
||||
void (*pfnClose)(void *pvInstance);
|
||||
|
||||
//
|
||||
//! This is the optional interrupt handler that will be called when an
|
||||
//! endpoint associated with this device instance generates an interrupt.
|
||||
//
|
||||
void (*pfnIntHandler)(void *pvInstance);
|
||||
}
|
||||
tUSBHostClassDriver;
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Close the Doxygen group.
|
||||
//! @}
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// If the g_USBEventDriver is included in the host controller driver list then
|
||||
// this function must be provided by the application.
|
||||
//
|
||||
//*****************************************************************************
|
||||
extern void USBHCDEvents(void *pvData);
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Prototypes for the USB Host controller APIs.
|
||||
//
|
||||
//*****************************************************************************
|
||||
extern void USBHCDMain(void);
|
||||
extern int32_t USBHCDEventEnable(uint32_t ui32Index, void *pvEventDriver,
|
||||
uint32_t ui32Event);
|
||||
extern int32_t USBHCDEventDisable(uint32_t ui32Index, void *pvEventDriver,
|
||||
uint32_t ui32Event);
|
||||
extern void USBHCDInit(uint32_t ui32Index, void *pvData,
|
||||
uint32_t ui32Size);
|
||||
extern void USBHCDPowerConfigInit(uint32_t ui32Index,
|
||||
uint32_t ui32Flags);
|
||||
extern uint32_t USBHCDPowerConfigGet(uint32_t ui32Index);
|
||||
extern uint32_t USBHCDPowerConfigSet(uint32_t ui32Index,
|
||||
uint32_t ui32Config);
|
||||
extern uint32_t USBHCDPowerAutomatic(uint32_t ui32Index);
|
||||
extern void USBHCDRegisterDrivers(uint32_t ui32Index,
|
||||
const tUSBHostClassDriver * const *ppsHClassDrvrs,
|
||||
uint32_t ui32NumDrivers);
|
||||
extern void USBHCDTerm(uint32_t ui32Index);
|
||||
extern void USBHCDSetConfig(uint32_t ui32Index, uint32_t ui32Device,
|
||||
uint32_t ui32Configuration);
|
||||
extern void USBHCDSetInterface(uint32_t ui32Index, uint32_t ui32Device,
|
||||
uint32_t ui32Interface,
|
||||
uint32_t ui32AltSetting);
|
||||
extern void USBHCDSuspend(uint32_t ui32Index);
|
||||
extern void USBHCDResume(uint32_t ui32Index);
|
||||
extern void USBHCDReset(uint32_t ui32Index);
|
||||
extern void USBHCDPipeFree(uint32_t ui32Pipe);
|
||||
extern uint32_t USBHCDPipeAlloc(uint32_t ui32Index,
|
||||
uint32_t ui32EndpointType,
|
||||
tUSBHostDevice *psDevice,
|
||||
tHCDPipeCallback pfnCallback);
|
||||
extern uint32_t USBHCDPipeAllocSize(uint32_t ui32Index,
|
||||
uint32_t ui32EndpointType,
|
||||
tUSBHostDevice *psDevice,
|
||||
uint32_t ui32FIFOSize,
|
||||
tHCDPipeCallback pfnCallback);
|
||||
extern uint32_t USBHCDPipeConfig(uint32_t ui32Pipe, uint32_t ui32MaxPayload,
|
||||
uint32_t ui32Interval,
|
||||
uint32_t ui32TargetEndpoint);
|
||||
extern uint32_t USBHCDPipeStatus(uint32_t ui32Pipe);
|
||||
extern uint32_t USBHCDPipeWrite(uint32_t ui32Pipe, uint8_t *pui8Data,
|
||||
uint32_t ui32Size);
|
||||
extern uint32_t USBHCDPipeRead(uint32_t ui32Pipe, uint8_t *pui8Data,
|
||||
uint32_t ui32Size);
|
||||
extern uint32_t USBHCDPipeSchedule(uint32_t ui32Pipe, uint8_t *pui8Data,
|
||||
uint32_t ui32Size);
|
||||
extern void USBHCDPipeDataAck(uint32_t ui32Pipe);
|
||||
extern uint32_t USBHCDPipeReadNonBlocking(uint32_t ui32Pipe, uint8_t *pui8Data,
|
||||
uint32_t ui32Size);
|
||||
extern uint32_t USBHCDControlTransfer(uint32_t ui32Index,
|
||||
tUSBRequest *psSetupPacket,
|
||||
tUSBHostDevice *psDevice,
|
||||
uint8_t *pui8Data, uint32_t ui32Size,
|
||||
uint32_t ui32MaxPacketSize);
|
||||
extern void USB0HostIntHandler(void);
|
||||
|
||||
extern uint8_t USBHCDDevHubPort(uint32_t ui32Instance);
|
||||
extern uint8_t USBHCDDevAddress(uint32_t ui32Instance);
|
||||
extern uint8_t USBHCDDevClass(uint32_t ui32Instance, uint32_t ui32Interface);
|
||||
extern uint8_t USBHCDDevSubClass(uint32_t ui32Instance,
|
||||
uint32_t ui32Interface);
|
||||
extern uint8_t USBHCDDevProtocol(uint32_t ui32Instance,
|
||||
uint32_t ui32Interface);
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// The host class drivers supported by the USB library.
|
||||
//
|
||||
//*****************************************************************************
|
||||
extern const tUSBHostClassDriver g_sUSBHostMSCClassDriver;
|
||||
extern const tUSBHostClassDriver g_sUSBHIDClassDriver;
|
||||
extern const tUSBHostClassDriver g_sUSBHostAudioClassDriver;
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Mark the end of the C bindings section for C++ compilers.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // __USBHOST_H__
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,195 @@
|
|||
//*****************************************************************************
|
||||
//
|
||||
// usbhostpriv.h - Internal header file for USB host functions.
|
||||
//
|
||||
// Copyright (c) 2011-2013 Texas Instruments Incorporated. All rights reserved.
|
||||
// Software License Agreement
|
||||
//
|
||||
// Texas Instruments (TI) is supplying this software for use solely and
|
||||
// exclusively on TI's microcontroller products. The software is owned by
|
||||
// TI and/or its suppliers, and is protected under applicable copyright
|
||||
// laws. You may not combine this software with "viral" open-source
|
||||
// software in order to form a larger program.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
|
||||
// NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
|
||||
// NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
|
||||
// CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
|
||||
// DAMAGES, FOR ANY REASON WHATSOEVER.
|
||||
//
|
||||
// This is part of revision 1.1 of the Tiva USB Library.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
#ifndef __USBHOSTPRIV_H__
|
||||
#define __USBHOSTPRIV_H__
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// If building with a C++ compiler, make all of the definitions in this header
|
||||
// have a C binding.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// The states a hub port can be in during device connection.
|
||||
//
|
||||
//*****************************************************************************
|
||||
typedef enum
|
||||
{
|
||||
//
|
||||
// The port has no device connected.
|
||||
//
|
||||
ePortIdle,
|
||||
|
||||
//
|
||||
// The port has a device present and is waiting for the enumeration
|
||||
// sequence to begin.
|
||||
//
|
||||
ePortConnected,
|
||||
|
||||
//
|
||||
// A device connection notification has been received and we have initiated
|
||||
// a reset to the port. We are waiting for the reset to complete.
|
||||
//
|
||||
ePortResetActive,
|
||||
|
||||
//
|
||||
// The Port reset has completed but now the hub is waiting the required
|
||||
// 10ms before accessing the device.
|
||||
//
|
||||
ePortResetWait,
|
||||
|
||||
//
|
||||
// A device is connected and the port has been reset. Control has been
|
||||
// passed to the main host handling portion of USBLib to enumerate the
|
||||
// device.
|
||||
//
|
||||
ePortActive,
|
||||
|
||||
//
|
||||
// A device has completed enumeration.
|
||||
//
|
||||
ePortEnumerated,
|
||||
|
||||
//
|
||||
// A device is attached to the port but enumeration failed.
|
||||
//
|
||||
ePortError
|
||||
}
|
||||
tHubPortState;
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// The list of valid event flags in the g_sUSBHCD.ui32EventEnables member
|
||||
// variable.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define USBHCD_EVFLAG_SOF 0x00000001
|
||||
#define USBHCD_EVFLAG_CONNECT 0x00000002
|
||||
#define USBHCD_EVFLAG_UNKCNCT 0x00000004
|
||||
#define USBHCD_EVFLAG_DISCNCT 0x00000008
|
||||
#define USBHCD_EVFLAG_PWRFAULT 0x00000010
|
||||
#define USBHCD_EVFLAG_PWRDIS 0x00000020
|
||||
#define USBHCD_EVFLAG_PWREN 0x00000040
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! This is the structure that holds all of the information for devices
|
||||
//! that are enumerated in the system. It is passed in to Open function of
|
||||
//! USB host class drivers so that they can allocate any endpoints and parse
|
||||
//! out other information that the device class needs to complete enumeration.
|
||||
//
|
||||
//*****************************************************************************
|
||||
struct tUSBHostDevice
|
||||
{
|
||||
//
|
||||
//! The current device address for this device.
|
||||
//
|
||||
uint32_t ui32Address;
|
||||
|
||||
//
|
||||
//! The current interface for this device.
|
||||
//
|
||||
uint32_t ui32Interface;
|
||||
|
||||
//
|
||||
//! A flag used to record whether this is a low-speed or a full-speed
|
||||
//! device.
|
||||
//
|
||||
bool bLowSpeed;
|
||||
|
||||
//
|
||||
//! A flag indicating whether or not we have read the device's
|
||||
//! configuration descriptor yet.
|
||||
//
|
||||
bool bConfigRead;
|
||||
|
||||
//
|
||||
//! The hub number to which this device is attached.
|
||||
//
|
||||
uint8_t ui8Hub;
|
||||
|
||||
//
|
||||
//! The hub port number to which the device is attached.
|
||||
//
|
||||
uint8_t ui8HubPort;
|
||||
|
||||
//
|
||||
//! The device descriptor for this device.
|
||||
//
|
||||
tDeviceDescriptor sDeviceDescriptor;
|
||||
|
||||
//
|
||||
//! A pointer to the configuration descriptor for this device.
|
||||
//
|
||||
tConfigDescriptor *psConfigDescriptor;
|
||||
|
||||
//
|
||||
//! The size of the buffer allocated to psConfigDescriptor.
|
||||
//
|
||||
uint32_t ui32ConfigDescriptorSize;
|
||||
|
||||
//
|
||||
//! Internal flags used by the host controller driver.
|
||||
//
|
||||
uint32_t ui32Flags;
|
||||
};
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Functions within the host controller that are called by the hub class driver
|
||||
//
|
||||
//*****************************************************************************
|
||||
extern uint32_t USBHCDHubDeviceConnected(uint32_t ui32Index, uint8_t ui8Hub,
|
||||
uint8_t ui8Port,
|
||||
bool bLowSpeed);
|
||||
extern void USBHCDHubDeviceDisconnected(uint32_t ui32Index,
|
||||
uint32_t ui32DevIndex);
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Functions in the hub class driver that are called by the host controller.
|
||||
//
|
||||
//*****************************************************************************
|
||||
extern void USBHHubMain(void);
|
||||
extern void USBHHubInit(void);
|
||||
extern void USBHHubEnumerationComplete(uint8_t ui8Hub, uint8_t ui8Port);
|
||||
extern void USBHHubEnumerationError(uint8_t ui8Hub, uint8_t ui8Port);
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Mark the end of the C bindings section for C++ compilers.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // __USBHOSTPRIV_H__
|
|
@ -0,0 +1,780 @@
|
|||
//*****************************************************************************
|
||||
//
|
||||
// usbhscsi.c - USB host SCSI layer used by the USB host MSC driver.
|
||||
//
|
||||
// Copyright (c) 2008-2013 Texas Instruments Incorporated. All rights reserved.
|
||||
// Software License Agreement
|
||||
//
|
||||
// Texas Instruments (TI) is supplying this software for use solely and
|
||||
// exclusively on TI's microcontroller products. The software is owned by
|
||||
// TI and/or its suppliers, and is protected under applicable copyright
|
||||
// laws. You may not combine this software with "viral" open-source
|
||||
// software in order to form a larger program.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
|
||||
// NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
|
||||
// NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
|
||||
// CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
|
||||
// DAMAGES, FOR ANY REASON WHATSOEVER.
|
||||
//
|
||||
// This is part of revision 1.1 of the Tiva USB Library.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "inc/hw_types.h"
|
||||
#include "usblib/usblib.h"
|
||||
#include "usblib/usbmsc.h"
|
||||
#include "usblib/host/usbhost.h"
|
||||
#include "usblib/host/usbhmsc.h"
|
||||
#include "usblib/host/usbhscsi.h"
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! \addtogroup usblib_host_class
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// This is the data verify tag passed between requests.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define CBW_TAG_VALUE 0x54231990
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! This function is used to issue SCSI commands via USB.
|
||||
//!
|
||||
//! \param ui32InPipe is the USB IN pipe to use for this command.
|
||||
//! \param ui32OutPipe is the USB OUT pipe to use for this command.
|
||||
//! \param psSCSICmd is the SCSI command structure to send.
|
||||
//! \param pui8Data is pointer to the command data to be sent.
|
||||
//! \param pui32Size is the number of bytes is the number of bytes expected or
|
||||
//! sent by the command.
|
||||
//!
|
||||
//! This internal function is used to handle SCSI commands sent by other
|
||||
//! functions. It serves as a layer between the SCSI command and the USB
|
||||
//! interface being used to send the command. The \e pSCSI parameter contains
|
||||
//! the SCSI command to send. For commands that expect data back, the
|
||||
//! \e pui8Data is the buffer to store the data into and \e pui32Size is used
|
||||
//! to store the amount of data to request as well as used to indicate how many
|
||||
//! bytes were filled into the \e pui8Data buffer on return. For commands that
|
||||
//! are sending data, \e pui8Data is the data to be sent and \e pui32Size is
|
||||
//! the number of bytes to send.
|
||||
//!
|
||||
//! \return This function returns the SCSI status from the command. The value
|
||||
//! will be either \b SCSI_CMD_STATUS_PASS or \b SCSI_CMD_STATUS_FAIL.
|
||||
//
|
||||
//*****************************************************************************
|
||||
static uint32_t
|
||||
USBHSCSISendCommand(uint32_t ui32InPipe, uint32_t ui32OutPipe,
|
||||
tMSCCBW *psSCSICmd, uint8_t *pui8Data, uint32_t *pui32Size)
|
||||
{
|
||||
tMSCCSW sCmdStatus;
|
||||
uint32_t ui32Bytes;
|
||||
|
||||
//
|
||||
// Initialize the command status.
|
||||
//
|
||||
sCmdStatus.dCSWSignature = 0;
|
||||
sCmdStatus.dCSWTag = 0;
|
||||
sCmdStatus.bCSWStatus = SCSI_CMD_STATUS_FAIL;
|
||||
|
||||
//
|
||||
// Set the CBW signature and tag.
|
||||
//
|
||||
psSCSICmd->dCBWSignature = CBW_SIGNATURE;
|
||||
psSCSICmd->dCBWTag = CBW_TAG_VALUE;
|
||||
|
||||
//
|
||||
// Set the size of the data to be returned by the device.
|
||||
//
|
||||
psSCSICmd->dCBWDataTransferLength = *pui32Size;
|
||||
|
||||
//
|
||||
// Send the command.
|
||||
//
|
||||
ui32Bytes = USBHCDPipeWrite(ui32OutPipe, (uint8_t*)psSCSICmd,
|
||||
sizeof(tMSCCBW));
|
||||
|
||||
//
|
||||
// If no bytes went out then the command failed.
|
||||
//
|
||||
if(ui32Bytes == 0)
|
||||
{
|
||||
return(SCSI_CMD_STATUS_FAIL);
|
||||
}
|
||||
|
||||
//
|
||||
// Only request data if there is data to request.
|
||||
//
|
||||
if(psSCSICmd->dCBWDataTransferLength != 0)
|
||||
{
|
||||
//
|
||||
// See if this is a read or a write.
|
||||
//
|
||||
if(psSCSICmd->bmCBWFlags & CBWFLAGS_DIR_IN)
|
||||
{
|
||||
//
|
||||
// Read the data back.
|
||||
//
|
||||
*pui32Size = USBHCDPipeRead(ui32InPipe, pui8Data, *pui32Size);
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
// Write the data out.
|
||||
//
|
||||
*pui32Size = USBHCDPipeWrite(ui32OutPipe, pui8Data, *pui32Size);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Get the status of the command.
|
||||
//
|
||||
ui32Bytes = USBHCDPipeRead(ui32InPipe, (uint8_t *)&sCmdStatus,
|
||||
sizeof(tMSCCSW));
|
||||
|
||||
|
||||
//
|
||||
// If the status was invalid or did not have the correct signature then
|
||||
// indicate a failure.
|
||||
//
|
||||
if((ui32Bytes == 0) || (sCmdStatus.dCSWSignature != CSW_SIGNATURE) ||
|
||||
(sCmdStatus.dCSWTag != CBW_TAG_VALUE))
|
||||
{
|
||||
return(SCSI_CMD_STATUS_FAIL);
|
||||
}
|
||||
|
||||
//
|
||||
// Return the status.
|
||||
//
|
||||
return((uint32_t)sCmdStatus.bCSWStatus);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! This will issue the SCSI inquiry command to a device.
|
||||
//!
|
||||
//! \param ui32InPipe is the USB IN pipe to use for this command.
|
||||
//! \param ui32OutPipe is the USB OUT pipe to use for this command.
|
||||
//! \param pui8Data is the data buffer to return the results into.
|
||||
//! \param pui32Size is the size of buffer that was passed in on entry and the
|
||||
//! number of bytes returned.
|
||||
//!
|
||||
//! This function should be used to issue a SCSI Inquiry command to a mass
|
||||
//! storage device. To allow for multiple devices, the \e ui32InPipe and
|
||||
//! \e ui32OutPipe parameters indicate which USB pipes to use for this call.
|
||||
//!
|
||||
//! \note The \e pui8Data buffer pointer should have at least
|
||||
//! \b SCSI_INQUIRY_DATA_SZ bytes of data or this function will overflow the
|
||||
//! buffer.
|
||||
//!
|
||||
//! \return This function returns the SCSI status from the command. The value
|
||||
//! will be either \b SCSI_CMD_STATUS_PASS or \b SCSI_CMD_STATUS_FAIL.
|
||||
//
|
||||
//*****************************************************************************
|
||||
uint32_t
|
||||
USBHSCSIInquiry(uint32_t ui32InPipe, uint32_t ui32OutPipe,
|
||||
uint8_t *pui8Data, uint32_t *pui32Size)
|
||||
{
|
||||
tMSCCBW sSCSICmd;
|
||||
uint32_t *pui32Data;
|
||||
|
||||
//
|
||||
// Create a local 32-bit pointer to the command.
|
||||
//
|
||||
pui32Data = (uint32_t *)sSCSICmd.CBWCB;
|
||||
|
||||
//
|
||||
// The number of bytes of data that the host expects to transfer on the
|
||||
// Bulk-In or Bulk-Out endpoint (as indicated by the Direction bit) during
|
||||
// the execution of this command. If this field is zero, the device and
|
||||
// the host shall transfer no data between the CBW and the associated CSW,
|
||||
// and the device shall ignore the value of the Direction bit in
|
||||
// bmCBWFlags.
|
||||
//
|
||||
*pui32Size = SCSI_INQUIRY_DATA_SZ;
|
||||
|
||||
//
|
||||
// This is an IN request.
|
||||
//
|
||||
sSCSICmd.bmCBWFlags = CBWFLAGS_DIR_IN;
|
||||
|
||||
//
|
||||
// Only handle LUN 0.
|
||||
//
|
||||
sSCSICmd.bCBWLUN = 0;
|
||||
|
||||
//
|
||||
// This is the length of the command itself.
|
||||
//
|
||||
sSCSICmd.bCBWCBLength = 6;
|
||||
|
||||
//
|
||||
// Send Inquiry command with no request for vital product data.
|
||||
//
|
||||
pui32Data[0] = SCSI_INQUIRY_CMD;
|
||||
|
||||
//
|
||||
// Allocation length.
|
||||
//
|
||||
pui32Data[1] = SCSI_INQUIRY_DATA_SZ;
|
||||
pui32Data[2] = 0;
|
||||
pui32Data[3] = 0;
|
||||
|
||||
//
|
||||
// Send the command and get the results.
|
||||
//
|
||||
return(USBHSCSISendCommand(ui32InPipe, ui32OutPipe, &sSCSICmd, pui8Data,
|
||||
pui32Size));
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! This will issue the SCSI read capacity command to a device.
|
||||
//!
|
||||
//! \param ui32InPipe is the USB IN pipe to use for this command.
|
||||
//! \param ui32OutPipe is the USB OUT pipe to use for this command.
|
||||
//! \param pui8Data is the data buffer to return the results into.
|
||||
//! \param pui32Size is the size of buffer that was passed in on entry and the
|
||||
//! number of bytes returned.
|
||||
//!
|
||||
//! This function should be used to issue a SCSI Read Capacity command
|
||||
//! to a mass storage device that is connected. To allow for multiple devices,
|
||||
//! the \e ui32InPipe and \e ui32OutPipe parameters indicate which USB pipes to
|
||||
//! use for this call.
|
||||
//!
|
||||
//! \note The \e pui8Data buffer pointer should have at least
|
||||
//! \b SCSI_READ_CAPACITY_SZ bytes of data or this function will overflow the
|
||||
//! buffer.
|
||||
//!
|
||||
//! \return This function returns the SCSI status from the command. The value
|
||||
//! will be either \b SCSI_CMD_STATUS_PASS or \b SCSI_CMD_STATUS_FAIL.
|
||||
//
|
||||
//*****************************************************************************
|
||||
uint32_t
|
||||
USBHSCSIReadCapacity(uint32_t ui32InPipe, uint32_t ui32OutPipe,
|
||||
uint8_t *pui8Data, uint32_t *pui32Size)
|
||||
{
|
||||
tMSCCBW sSCSICmd;
|
||||
uint32_t *pui32Data;
|
||||
|
||||
//
|
||||
// Create a local 32-bit pointer to the command.
|
||||
//
|
||||
pui32Data = (uint32_t *)sSCSICmd.CBWCB;
|
||||
|
||||
//
|
||||
// Set the size of the command data.
|
||||
//
|
||||
*pui32Size = SCSI_READ_CAPACITY_SZ;
|
||||
|
||||
//
|
||||
// This is an IN request.
|
||||
//
|
||||
sSCSICmd.bmCBWFlags = CBWFLAGS_DIR_IN;
|
||||
|
||||
//
|
||||
// Only handle LUN 0.
|
||||
//
|
||||
sSCSICmd.bCBWLUN = 0;
|
||||
|
||||
//
|
||||
// Set the length of the command itself.
|
||||
//
|
||||
sSCSICmd.bCBWCBLength = 12;
|
||||
|
||||
//
|
||||
// Only use the first byte and set it to the Read Capacity command. The
|
||||
// rest are set to 0.
|
||||
//
|
||||
pui32Data[0] = SCSI_READ_CAPACITY;
|
||||
pui32Data[1] = 0;
|
||||
pui32Data[2] = 0;
|
||||
pui32Data[3] = 0;
|
||||
|
||||
//
|
||||
// Send the command and get the results.
|
||||
//
|
||||
return(USBHSCSISendCommand(ui32InPipe, ui32OutPipe, &sSCSICmd, pui8Data,
|
||||
pui32Size));
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! This will issue the SCSI read capacities command to a device.
|
||||
//!
|
||||
//! \param ui32InPipe is the USB IN pipe to use for this command.
|
||||
//! \param ui32OutPipe is the USB OUT pipe to use for this command.
|
||||
//! \param pui8Data is the data buffer to return the results into.
|
||||
//! \param pui32Size is the size of buffer that was passed in on entry and the
|
||||
//! number of bytes returned.
|
||||
//!
|
||||
//! This function should be used to issue a SCSI Read Capacities command
|
||||
//! to a mass storage device that is connected. To allow for multiple devices,
|
||||
//! the \e ui32InPipe and \e ui32OutPipe parameters indicate which USB pipes to
|
||||
//! use for this call.
|
||||
//!
|
||||
//! \return This function returns the SCSI status from the command. The value
|
||||
//! will be either \b SCSI_CMD_STATUS_PASS or \b SCSI_CMD_STATUS_FAIL.
|
||||
//
|
||||
//*****************************************************************************
|
||||
uint32_t
|
||||
USBHSCSIReadCapacities(uint32_t ui32InPipe, uint32_t ui32OutPipe,
|
||||
uint8_t *pui8Data, uint32_t *pui32Size)
|
||||
{
|
||||
tMSCCBW sSCSICmd;
|
||||
uint32_t *pui32Data;
|
||||
|
||||
//
|
||||
// Create a local 32-bit pointer to the command.
|
||||
//
|
||||
pui32Data = (uint32_t *)sSCSICmd.CBWCB;
|
||||
|
||||
//
|
||||
// This is an IN request.
|
||||
//
|
||||
sSCSICmd.bmCBWFlags = CBWFLAGS_DIR_IN;
|
||||
|
||||
//
|
||||
// Only handle LUN 0.
|
||||
//
|
||||
sSCSICmd.bCBWLUN = 0;
|
||||
|
||||
//
|
||||
// Set the length of the command itself.
|
||||
//
|
||||
sSCSICmd.bCBWCBLength = 12;
|
||||
|
||||
//
|
||||
// Only use the first byte and set it to the Read Capacity command. The
|
||||
// rest are set to 0.
|
||||
//
|
||||
pui32Data[0] = SCSI_READ_CAPACITIES;
|
||||
pui32Data[1] = 0;
|
||||
pui32Data[2] = 0;
|
||||
pui32Data[3] = 0;
|
||||
|
||||
//
|
||||
// Send the command and get the results.
|
||||
//
|
||||
return(USBHSCSISendCommand(ui32InPipe, ui32OutPipe, &sSCSICmd, pui8Data,
|
||||
pui32Size));
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! This will issue the SCSI Mode Sense(6) command to a device.
|
||||
//!
|
||||
//! \param ui32InPipe is the USB IN pipe to use for this command.
|
||||
//! \param ui32OutPipe is the USB OUT pipe to use for this command.
|
||||
//! \param ui32Flags is a combination of flags defining the exact query that is
|
||||
//! to be made.
|
||||
//! \param pui8Data is the data buffer to return the results into.
|
||||
//! \param pui32Size is the size of the buffer on entry and number of bytes
|
||||
//! read on exit.
|
||||
//!
|
||||
//! This function should be used to issue a SCSI Mode Sense(6) command
|
||||
//! to a mass storage device. To allow for multiple devices,the \e ui32InPipe
|
||||
//! and \e ui32OutPipe parameters indicate which USB pipes to use for this
|
||||
//! call. The call will return at most the number of bytes in the \e pui32Size
|
||||
//! parameter, however it can return less and change the \e pui32Size parameter
|
||||
//! to the number of valid bytes in the \e *pui32Size buffer.
|
||||
//!
|
||||
//! The \e ui32Flags parameter is a combination of the following three sets of
|
||||
//! definitions:
|
||||
//!
|
||||
//! One of the following values must be specified:
|
||||
//!
|
||||
//! - \b SCSI_MS_PC_CURRENT request for current settings.
|
||||
//! - \b SCSI_MS_PC_CHANGEABLE request for changeable settings.
|
||||
//! - \b SCSI_MS_PC_DEFAULT request for default settings.
|
||||
//! - \b SCSI_MS_PC_SAVED request for the saved values.
|
||||
//!
|
||||
//! One of these following values must also be specified to determine the page
|
||||
//! code for the request:
|
||||
//!
|
||||
//! - \b SCSI_MS_PC_VENDOR is the vendor specific page code.
|
||||
//! - \b SCSI_MS_PC_DISCO is the disconnect/reconnect page code.
|
||||
//! - \b SCSI_MS_PC_CONTROL is the control page code.
|
||||
//! - \b SCSI_MS_PC_LUN is the protocol specific LUN page code.
|
||||
//! - \b SCSI_MS_PC_PORT is the protocol specific port page code.
|
||||
//! - \b SCSI_MS_PC_POWER is the power condition page code.
|
||||
//! - \b SCSI_MS_PC_INFORM is the informational exceptions page code.
|
||||
//! - \b SCSI_MS_PC_ALL will request all pages codes supported by the device.
|
||||
//!
|
||||
//! The last value is optional and supports the following global flag:
|
||||
//! - \b SCSI_MS_DBD disables returning block descriptors.
|
||||
//!
|
||||
//! Example: Request for all current settings.
|
||||
//!
|
||||
//! \verbatim
|
||||
//! SCSIModeSense6(ui32InPipe, ui32OutPipe,
|
||||
//! SCSI_MS_PC_CURRENT | SCSI_MS_PC_ALL,
|
||||
//! pui8Data, pui32Size);
|
||||
//! \endverbatim
|
||||
//!
|
||||
//! \return This function returns the SCSI status from the command. The value
|
||||
//! will be either \b SCSI_CMD_STATUS_PASS or \b SCSI_CMD_STATUS_FAIL.
|
||||
//
|
||||
//*****************************************************************************
|
||||
uint32_t
|
||||
USBHSCSIModeSense6(uint32_t ui32InPipe, uint32_t ui32OutPipe,
|
||||
uint32_t ui32Flags, uint8_t *pui8Data,
|
||||
uint32_t *pui32Size)
|
||||
{
|
||||
tMSCCBW sSCSICmd;
|
||||
uint32_t *pui32Data;
|
||||
|
||||
//
|
||||
// Create a local 32-bit pointer to the command.
|
||||
//
|
||||
pui32Data = (uint32_t *)sSCSICmd.CBWCB;
|
||||
|
||||
//
|
||||
// This is an IN request.
|
||||
//
|
||||
sSCSICmd.bmCBWFlags = CBWFLAGS_DIR_IN;
|
||||
|
||||
//
|
||||
// Only handle LUN 0.
|
||||
//
|
||||
sSCSICmd.bCBWLUN = 0;
|
||||
|
||||
//
|
||||
// Set the size of the command data.
|
||||
//
|
||||
sSCSICmd.bCBWCBLength = 6;
|
||||
|
||||
//
|
||||
// Set the options for the Mode Sense Command (6).
|
||||
//
|
||||
pui32Data[0] = (SCSI_MODE_SENSE_6 | ui32Flags);
|
||||
pui32Data[1] = (uint8_t)*pui32Size;
|
||||
pui32Data[2] = 0;
|
||||
pui32Data[3] = 0;
|
||||
|
||||
//
|
||||
// Send the command and get the results.
|
||||
//
|
||||
return(USBHSCSISendCommand(ui32InPipe, ui32OutPipe, &sSCSICmd, pui8Data,
|
||||
pui32Size));
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! This function issues a SCSI Test Unit Ready command to a device.
|
||||
//!
|
||||
//! \param ui32InPipe is the USB IN pipe to use for this command.
|
||||
//! \param ui32OutPipe is the USB OUT pipe to use for this command.
|
||||
//!
|
||||
//! This function is used to issue a SCSI Test Unit Ready command to a device.
|
||||
//! This call will simply return the results of issuing this command.
|
||||
//!
|
||||
//! \return This function returns the results of the SCSI Test Unit Ready
|
||||
//! command. The value will be either \b SCSI_CMD_STATUS_PASS or
|
||||
//! \b SCSI_CMD_STATUS_FAIL.
|
||||
//
|
||||
//*****************************************************************************
|
||||
uint32_t
|
||||
USBHSCSITestUnitReady(uint32_t ui32InPipe, uint32_t ui32OutPipe)
|
||||
{
|
||||
tMSCCBW sSCSICmd;
|
||||
uint32_t ui32Size;
|
||||
uint32_t *pui32Data;
|
||||
|
||||
//
|
||||
// Create a local 32-bit pointer to the command.
|
||||
//
|
||||
pui32Data = (uint32_t *)sSCSICmd.CBWCB;
|
||||
|
||||
//
|
||||
// No data in this command.
|
||||
//
|
||||
ui32Size = 0;
|
||||
|
||||
//
|
||||
// This is an IN request.
|
||||
//
|
||||
sSCSICmd.bmCBWFlags = CBWFLAGS_DIR_IN;
|
||||
|
||||
//
|
||||
// Only handle LUN 0.
|
||||
//
|
||||
sSCSICmd.bCBWLUN = 0;
|
||||
|
||||
//
|
||||
// Set the size of the command data.
|
||||
//
|
||||
sSCSICmd.bCBWCBLength = 6;
|
||||
|
||||
//
|
||||
// Set the parameter options.
|
||||
//
|
||||
pui32Data[0] = SCSI_TEST_UNIT_READY;
|
||||
pui32Data[1] = 0;
|
||||
pui32Data[2] = 0;
|
||||
pui32Data[3] = 0;
|
||||
|
||||
//
|
||||
// Send the command and get the results.
|
||||
//
|
||||
return(USBHSCSISendCommand(ui32InPipe, ui32OutPipe, &sSCSICmd, 0,
|
||||
&ui32Size));
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! This function issues a SCSI Request Sense command to a device.
|
||||
//!
|
||||
//! \param ui32InPipe is the USB IN pipe to use for this command.
|
||||
//! \param ui32OutPipe is the USB OUT pipe to use for this command.
|
||||
//! \param pui8Data is the data buffer to return the results into.
|
||||
//! \param pui32Size is the size of the buffer on entry and number of bytes
|
||||
//! read on exit.
|
||||
//!
|
||||
//! This function is used to issue a SCSI Request Sense command to a device.
|
||||
//! It will return the data in the buffer pointed to by \e pui8Data. The
|
||||
//! parameter \e pui32Size should have the allocation size in bytes of the
|
||||
//! buffer pointed to by \e pui8Data.
|
||||
//!
|
||||
//! \return This function returns the results of the SCSI Request Sense
|
||||
//! command. The value will be either \b SCSI_CMD_STATUS_PASS or
|
||||
//! \b SCSI_CMD_STATUS_FAIL.
|
||||
//
|
||||
//*****************************************************************************
|
||||
uint32_t
|
||||
USBHSCSIRequestSense(uint32_t ui32InPipe, uint32_t ui32OutPipe,
|
||||
uint8_t *pui8Data, uint32_t *pui32Size)
|
||||
{
|
||||
tMSCCBW sSCSICmd;
|
||||
uint32_t *pui32Data;
|
||||
|
||||
//
|
||||
// Create a local 32-bit pointer to the command.
|
||||
//
|
||||
pui32Data = (uint32_t *)sSCSICmd.CBWCB;
|
||||
|
||||
//
|
||||
// This is an IN request.
|
||||
//
|
||||
sSCSICmd.bmCBWFlags = CBWFLAGS_DIR_IN;
|
||||
|
||||
//
|
||||
// Only handle LUN 0.
|
||||
//
|
||||
sSCSICmd.bCBWLUN = 0;
|
||||
|
||||
//
|
||||
// Set the size of the command data.
|
||||
//
|
||||
sSCSICmd.bCBWCBLength = 12;
|
||||
|
||||
//
|
||||
// Set the parameter options.
|
||||
//
|
||||
pui32Data[0] = SCSI_REQUEST_SENSE;
|
||||
pui32Data[1] = 18;
|
||||
pui32Data[2] = 0;
|
||||
pui32Data[3] = 0;
|
||||
|
||||
//
|
||||
// Send the command and get the results.
|
||||
//
|
||||
return(USBHSCSISendCommand(ui32InPipe, ui32OutPipe, &sSCSICmd, pui8Data,
|
||||
pui32Size));
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! This function issues a SCSI Read(10) command to a device.
|
||||
//!
|
||||
//! \param ui32InPipe is the USB IN pipe to use for this command.
|
||||
//! \param ui32OutPipe is the USB OUT pipe to use for this command.
|
||||
//! \param ui32LBA is the logical block address to read.
|
||||
//! \param pui8Data is the data buffer to return the data.
|
||||
//! \param pui32Size is the size of the buffer on entry and number of bytes
|
||||
//! read on exit.
|
||||
//! \param ui32NumBlocks is the number of contiguous blocks to read from the
|
||||
//! device.
|
||||
//!
|
||||
//! This function is used to issue a SCSI Read(10) command to a device. The
|
||||
//! \e ui32LBA parameter specifies the logical block address to read from the
|
||||
//! device. The data from this block will be returned in the buffer pointed to
|
||||
//! by \e pui8Data. The parameter \e pui32Size should indicate enough space to
|
||||
//! hold a full block size, or only the first \e pui32Size bytes of the LBA are
|
||||
//! returned.
|
||||
//!
|
||||
//! \return This function returns the results of the SCSI Read(10) command.
|
||||
//! The value will be either \b SCSI_CMD_STATUS_PASS or
|
||||
//! \b SCSI_CMD_STATUS_FAIL.
|
||||
//
|
||||
//*****************************************************************************
|
||||
uint32_t
|
||||
USBHSCSIRead10(uint32_t ui32InPipe, uint32_t ui32OutPipe,
|
||||
uint32_t ui32LBA, uint8_t *pui8Data,
|
||||
uint32_t *pui32Size, uint32_t ui32NumBlocks)
|
||||
{
|
||||
tMSCCBW sSCSICmd;
|
||||
|
||||
//
|
||||
// This is an IN request.
|
||||
//
|
||||
sSCSICmd.bmCBWFlags = CBWFLAGS_DIR_IN;
|
||||
|
||||
//
|
||||
// Only handle LUN 0.
|
||||
//
|
||||
sSCSICmd.bCBWLUN = 0;
|
||||
|
||||
//
|
||||
// Set the size of the command data.
|
||||
//
|
||||
sSCSICmd.bCBWCBLength = 10;
|
||||
|
||||
//
|
||||
// Set the parameter options.
|
||||
//
|
||||
sSCSICmd.CBWCB[0] = SCSI_READ_10;
|
||||
|
||||
//
|
||||
// Clear the reserved field.
|
||||
//
|
||||
sSCSICmd.CBWCB[1] = 0;
|
||||
|
||||
//
|
||||
// LBA starts at offset 2.
|
||||
//
|
||||
sSCSICmd.CBWCB[2] = (uint8_t)(ui32LBA >> 24);
|
||||
sSCSICmd.CBWCB[3] = (uint8_t)(ui32LBA >> 16);
|
||||
sSCSICmd.CBWCB[4] = (uint8_t)(ui32LBA >> 8);
|
||||
sSCSICmd.CBWCB[5] = (uint8_t)ui32LBA;
|
||||
|
||||
//
|
||||
// Clear the reserved field.
|
||||
//
|
||||
sSCSICmd.CBWCB[6] = 0;
|
||||
|
||||
//
|
||||
// Transfer length in blocks starts at offset 2.
|
||||
// This also sets the Control value to 0 at offset 9.
|
||||
//
|
||||
sSCSICmd.CBWCB[7] = (ui32NumBlocks & 0xFF00) >> 8;
|
||||
*((uint32_t *)&sSCSICmd.CBWCB[8]) = (ui32NumBlocks & 0xFF);
|
||||
*((uint32_t *)&sSCSICmd.CBWCB[12]) = 0;
|
||||
|
||||
//
|
||||
// Send the command and get the results.
|
||||
//
|
||||
return(USBHSCSISendCommand(ui32InPipe, ui32OutPipe, &sSCSICmd, pui8Data,
|
||||
pui32Size));
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! This function issues a SCSI Write(10) command to a device.
|
||||
//!
|
||||
//! This function is used to issue a SCSI Write(10) command to a device. The
|
||||
//! \e ui32LBA parameter specifies the logical block address on the device.
|
||||
//! The data to write to this block should be in the buffer pointed to by
|
||||
//! \e pui8Data parameter. The parameter \e pui32Size should indicate the
|
||||
//! amount of data to write to the specified LBA.
|
||||
//!
|
||||
//! \param ui32InPipe is the USB IN pipe to use for this command.
|
||||
//! \param ui32OutPipe is the USB OUT pipe to use for this command.
|
||||
//! \param ui32LBA is the logical block address to read.
|
||||
//! \param pui8Data is the data buffer to write out.
|
||||
//! \param pui32Size is the size of the buffer.
|
||||
//! \param ui32NumBlocks is the number of contiguous blocks to write to the
|
||||
//! device.
|
||||
//!
|
||||
//! \return This function returns the results of the SCSI Write(10) command.
|
||||
//! The value will be either \b SCSI_CMD_STATUS_PASS or
|
||||
//! \b SCSI_CMD_STATUS_FAIL.
|
||||
//
|
||||
//*****************************************************************************
|
||||
uint32_t
|
||||
USBHSCSIWrite10(uint32_t ui32InPipe, uint32_t ui32OutPipe,
|
||||
uint32_t ui32LBA, uint8_t *pui8Data,
|
||||
uint32_t *pui32Size, uint32_t ui32NumBlocks)
|
||||
{
|
||||
tMSCCBW sSCSICmd;
|
||||
uint32_t *pui32Data;
|
||||
|
||||
//
|
||||
// Create a local 32-bit pointer to the command.
|
||||
//
|
||||
pui32Data = (uint32_t *)sSCSICmd.CBWCB;
|
||||
|
||||
//
|
||||
// This is an IN request.
|
||||
//
|
||||
sSCSICmd.bmCBWFlags = CBWFLAGS_DIR_OUT;
|
||||
|
||||
//
|
||||
// Only handle LUN 0.
|
||||
//
|
||||
sSCSICmd.bCBWLUN = 0;
|
||||
|
||||
//
|
||||
// Set the size of the command data.
|
||||
//
|
||||
sSCSICmd.bCBWCBLength = 10;
|
||||
|
||||
//
|
||||
// Set the parameter options.
|
||||
//
|
||||
sSCSICmd.CBWCB[0] = SCSI_WRITE_10;
|
||||
|
||||
//
|
||||
// Clear the reserved field.
|
||||
//
|
||||
sSCSICmd.CBWCB[1] = 0;
|
||||
|
||||
//
|
||||
// LBA starts at offset 2.
|
||||
//
|
||||
sSCSICmd.CBWCB[2] = (uint8_t)(ui32LBA >> 24);
|
||||
sSCSICmd.CBWCB[3] = (uint8_t)(ui32LBA >> 16);
|
||||
sSCSICmd.CBWCB[4] = (uint8_t)(ui32LBA >> 8);
|
||||
sSCSICmd.CBWCB[5] = (uint8_t)ui32LBA;
|
||||
|
||||
//
|
||||
// Clear the reserved field.
|
||||
//
|
||||
sSCSICmd.CBWCB[6] = 0;
|
||||
|
||||
//
|
||||
// Set the transfer length in blocks.
|
||||
// This also sets the Control value to 0 at offset 9.
|
||||
//
|
||||
sSCSICmd.CBWCB[7] = (ui32NumBlocks & 0xFF00) >> 8;
|
||||
|
||||
//
|
||||
// The blocks go into is byte offset 8 or word address 2.
|
||||
//
|
||||
pui32Data[2] = (ui32NumBlocks & 0xFF);
|
||||
|
||||
//
|
||||
// The blocks go into is byte offset 12 or word address 3.
|
||||
//
|
||||
pui32Data[3] = 0;
|
||||
|
||||
//
|
||||
// Send the command and get the results.
|
||||
//
|
||||
return(USBHSCSISendCommand(ui32InPipe, ui32OutPipe, &sSCSICmd, pui8Data,
|
||||
pui32Size));
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Close the Doxygen group.
|
||||
//! @}
|
||||
//
|
||||
//*****************************************************************************
|
|
@ -0,0 +1,87 @@
|
|||
//*****************************************************************************
|
||||
//
|
||||
// usbhscsi.h - Definitions for the USB host SCSI layer.
|
||||
//
|
||||
// Copyright (c) 2008-2013 Texas Instruments Incorporated. All rights reserved.
|
||||
// Software License Agreement
|
||||
//
|
||||
// Texas Instruments (TI) is supplying this software for use solely and
|
||||
// exclusively on TI's microcontroller products. The software is owned by
|
||||
// TI and/or its suppliers, and is protected under applicable copyright
|
||||
// laws. You may not combine this software with "viral" open-source
|
||||
// software in order to form a larger program.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
|
||||
// NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
|
||||
// NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
|
||||
// CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
|
||||
// DAMAGES, FOR ANY REASON WHATSOEVER.
|
||||
//
|
||||
// This is part of revision 1.1 of the Tiva USB Library.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
#ifndef __USBHSCSI_H__
|
||||
#define __USBHSCSI_H__
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// If building with a C++ compiler, make all of the definitions in this header
|
||||
// have a C binding.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! \addtogroup usblib_host_class
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Prototypes for the APIs exported by the USB SCSI layer.
|
||||
//
|
||||
//*****************************************************************************
|
||||
extern uint32_t USBHSCSIInquiry(uint32_t ui32InPipe, uint32_t ui32OutPipe,
|
||||
uint8_t *pui8Buffer, uint32_t *pui32Size);
|
||||
extern uint32_t USBHSCSIReadCapacity(uint32_t ui32InPipe, uint32_t ui32OutPipe,
|
||||
uint8_t *pui8Data, uint32_t *pui32Size);
|
||||
extern uint32_t USBHSCSIReadCapacities(uint32_t ui32InPipe,
|
||||
uint32_t ui32OutPipe, uint8_t *pui8Data,
|
||||
uint32_t *pui32Size);
|
||||
extern uint32_t USBHSCSIModeSense6(uint32_t ui32InPipe, uint32_t ui32OutPipe,
|
||||
uint32_t ui32Flags, uint8_t *pui8Data,
|
||||
uint32_t *pui32Size);
|
||||
extern uint32_t USBHSCSITestUnitReady(uint32_t ui32InPipe,
|
||||
uint32_t ui32OutPipe);
|
||||
extern uint32_t USBHSCSIRequestSense(uint32_t ui32InPipe, uint32_t ui32OutPipe,
|
||||
uint8_t *pui8Data, uint32_t *pui32Size);
|
||||
extern uint32_t USBHSCSIRead10(uint32_t ui32InPipe, uint32_t ui32OutPipe,
|
||||
uint32_t ui32LBA, uint8_t *pui8Data,
|
||||
uint32_t *pui32Size, uint32_t ui32NumBlocks);
|
||||
extern uint32_t USBHSCSIWrite10(uint32_t ui32InPipe, uint32_t ui32OutPipe,
|
||||
uint32_t ui32LBA, uint8_t *pui8Data,
|
||||
uint32_t *pui32Size, uint32_t ui32NumBlocks);
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! @}
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Mark the end of the C bindings section for C++ compilers.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // __USBHSCSI_H__
|
|
@ -0,0 +1,21 @@
|
|||
This project will build the Tiva USB Library.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2008-2013 Texas Instruments Incorporated. All rights reserved.
|
||||
Software License Agreement
|
||||
|
||||
Texas Instruments (TI) is supplying this software for use solely and
|
||||
exclusively on TI's microcontroller products. The software is owned by
|
||||
TI and/or its suppliers, and is protected under applicable copyright
|
||||
laws. You may not combine this software with "viral" open-source
|
||||
software in order to form a larger program.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
|
||||
NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
|
||||
NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
|
||||
CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
|
||||
DAMAGES, FOR ANY REASON WHATSOEVER.
|
||||
|
||||
This is part of revision 1.1 of the Tiva USB Library.
|
|
@ -0,0 +1,55 @@
|
|||
//*****************************************************************************
|
||||
//
|
||||
// usb-ids.h - Definitions of VIDs and PIDs used by USB library.
|
||||
//
|
||||
// Copyright (c) 2008-2013 Texas Instruments Incorporated. All rights reserved.
|
||||
// Software License Agreement
|
||||
//
|
||||
// Texas Instruments (TI) is supplying this software for use solely and
|
||||
// exclusively on TI's microcontroller products. The software is owned by
|
||||
// TI and/or its suppliers, and is protected under applicable copyright
|
||||
// laws. You may not combine this software with "viral" open-source
|
||||
// software in order to form a larger program.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
|
||||
// NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
|
||||
// NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
|
||||
// CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
|
||||
// DAMAGES, FOR ANY REASON WHATSOEVER.
|
||||
//
|
||||
// This is part of revision 1.1 of the Tiva USB Library.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
#ifndef __USBIDS_H__
|
||||
#define __USBIDS_H__
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// TI Vendor ID for devices that use VID as 0x1CBE.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define USB_VID_TI_1CBE 0x1cbe
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Product IDs.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define USB_PID_MOUSE 0x0000
|
||||
#define USB_PID_KEYBOARD 0x0001
|
||||
#define USB_PID_SERIAL 0x0002
|
||||
#define USB_PID_BULK 0x0003
|
||||
#define USB_PID_SCOPE 0x0004
|
||||
#define USB_PID_MSC 0x0005
|
||||
#define USB_PID_AUDIO 0x0006
|
||||
#define USB_PID_COMP_SERIAL 0x0007
|
||||
#define USB_PID_COMP_AUDIO_HID 0x0008
|
||||
#define USB_PID_COMP_HID_SER 0x0009
|
||||
#define USB_PID_COMP_HID_DFU 0x000A
|
||||
#define USB_PID_DATA_LOGGER 0x000B
|
||||
#define USB_PID_COMP_HID_HID 0x000D
|
||||
#define USB_PID_DFU 0x00FF
|
||||
|
||||
#endif /* __USBIDS_H__ */
|
|
@ -0,0 +1,718 @@
|
|||
//*****************************************************************************
|
||||
//
|
||||
// usbaudio.h - Definitions used by Audio Class devices.
|
||||
//
|
||||
// Copyright (c) 2009-2013 Texas Instruments Incorporated. All rights reserved.
|
||||
// Software License Agreement
|
||||
//
|
||||
// Texas Instruments (TI) is supplying this software for use solely and
|
||||
// exclusively on TI's microcontroller products. The software is owned by
|
||||
// TI and/or its suppliers, and is protected under applicable copyright
|
||||
// laws. You may not combine this software with "viral" open-source
|
||||
// software in order to form a larger program.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
|
||||
// NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
|
||||
// NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
|
||||
// CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
|
||||
// DAMAGES, FOR ANY REASON WHATSOEVER.
|
||||
//
|
||||
// This is part of revision 1.1 of the Tiva USB Library.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
#ifndef __USBAUDIO_H__
|
||||
#define __USBAUDIO_H__
|
||||
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Standard Audio descriptor sub types.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define USB_AI_UNDEFINED 0
|
||||
#define USB_AI_HEADER 1
|
||||
#define USB_AI_INPUT_TERMINAL 2
|
||||
#define USB_AI_OUTPUT_TERMINAL 3
|
||||
#define USB_AI_MIXER_UNIT 4
|
||||
#define USB_AI_SELECTOR_UNIT 5
|
||||
#define USB_AI_FEATURE_UNIT 6
|
||||
#define USB_AI_PROCESSING_UNIT 7
|
||||
#define USB_AI_EXTENSION_UNIT 8
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Standard Audio Streaming Interface descriptor types.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define USB_AS_UNDEFINED 0
|
||||
#define USB_AS_GENERAL 1
|
||||
#define USB_AS_FORMAT_TYPE 2
|
||||
#define USB_AS_FORMAT_SPECIFIC 3
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Standard USB terminal types used with audio terminal descriptors. These
|
||||
// are defined in the "Universal Serial Bus Device Class Definition for
|
||||
// Terminal Types" version 1.0 released March 18, 1998.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define USB_TTYPE_UNDEFINED 0x0100
|
||||
#define USB_TTYPE_STREAMING 0x0101
|
||||
#define USB_TTYPE_VENDOR 0x01ff
|
||||
|
||||
#define USB_TTYPE_OUT_UNDEF 0x0300
|
||||
#define USB_TTYPE_OUT_SPEAKER 0x0301
|
||||
#define USB_TTYPE_OUT_HEADPHONE 0x0302
|
||||
#define USB_TTYPE_OUT_DESK_SPKR 0x0304
|
||||
#define USB_TTYPE_OUT_ROOM_SPKR 0x0305
|
||||
#define USB_TTYPE_OUT_COMM_SPKR 0x0306
|
||||
#define USB_TTYPE_OUT_LFE 0x0307
|
||||
|
||||
#define USB_TTYPE_EXT_UNDEF 0x0600
|
||||
#define USB_TTYPE_EXT_ANALOG 0x0601
|
||||
#define USB_TTYPE_EXT_DIGITAL 0x0602
|
||||
#define USB_TTYPE_EXT_LINE 0x0603
|
||||
#define USB_TTYPE_EXT_LEGACY 0x0604
|
||||
#define USB_TTYPE_EXT_SPDIF 0x0605
|
||||
#define USB_TTYPE_EXT_1394_DA 0x0606
|
||||
#define USB_TTYPE_EXT_1394_DV 0x0607
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Audio Interface Subclass Codes
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define USB_ASC_UNDEFINED 0x00
|
||||
#define USB_ASC_AUDIO_CONTROL 0x01
|
||||
#define USB_ASC_AUDIO_STREAMING 0x02
|
||||
#define USB_ASC_MIDI_STREAMING 0x03
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Audio Class-Specific Descriptor Types
|
||||
// (Table A-4)
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define USB_ACSDT_UNDEFINED 0x20
|
||||
#define USB_ACSDT_DEVICE 0x21
|
||||
#define USB_ACSDT_CONFIGURATION 0x22
|
||||
#define USB_ACSDT_STRING 0x23
|
||||
#define USB_ACSDT_INTERFACE 0x24
|
||||
#define USB_ACSDT_ENDPOINT 0x25
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Audio Class-Specific AC Interface Descriptor Subtypes
|
||||
// (Table A-5)
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define USB_ACDSTYPE_UNDEFINED 0x00
|
||||
#define USB_ACDSTYPE_HEADER 0x01
|
||||
#define USB_ACDSTYPE_IN_TERMINAL 0x02
|
||||
#define USB_ACDSTYPE_OUT_TERMINAL 0x03
|
||||
#define USB_ACDSTYPE_MIXER_UNIT 0x04
|
||||
#define USB_ACDSTYPE_SELECTOR_UNIT 0x05
|
||||
#define USB_ACDSTYPE_FEATURE_UNIT 0x06
|
||||
#define USB_ACDSTYPE_PROCESSING_UNIT 0x07
|
||||
#define USB_ACDSTYPE_EXTENSION_UNIT 0x08
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Audio Class-Specific AS Interface Descriptor Subtypes
|
||||
// (Table A-6)
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define USB_ASDSTYPE_UNDEFINED 0x00
|
||||
#define USB_ASDSTYPE_GENERAL 0x01
|
||||
#define USB_ASDSTYPE_FORMAT_TYPE 0x02
|
||||
#define USB_ASDSTYPE_FORMAT_SPECIFIC 0x03
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Audio Data Format Type I Codes.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define USB_ADF_UNDEFINED 0x0000
|
||||
#define USB_ADF_PCM 0x0001
|
||||
#define USB_ADF_PCM8 0x0002
|
||||
#define USB_ADF_IEEE_FLOAT 0x0003
|
||||
#define USB_ADF_ALAW 0x0004
|
||||
#define USB_ADF_MULAW 0x0005
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Audio Format Type Codes
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define USB_AF_TYPE_UNDEFINED 0x00
|
||||
#define USB_AF_TYPE_TYPE_I 0x01
|
||||
#define USB_AF_TYPE_TYPE_II 0x02
|
||||
#define USB_AF_TYPE_TYPE_III 0x03
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Audio Class-Specific controls used with bmaControls values.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define USB_ACONTROL_MUTE 0x0001 // Mute
|
||||
#define USB_ACONTROL_VOLUME 0x0002 // Volume
|
||||
#define USB_ACONTROL_BASS 0x0004 // Bass
|
||||
#define USB_ACONTROL_MID 0x0008 // Mid
|
||||
#define USB_ACONTROL_TREBLE 0x0010 // Treble
|
||||
#define USB_ACONTROL_EQ 0x0020 // Graphic Equalizer
|
||||
#define USB_ACONTROL_AGC 0x0040 // Automatic Gain
|
||||
#define USB_ACONTROL_DELAY 0x0080 // Delay
|
||||
#define USB_ACONTROL_BASS_BOOST 0x0100 // Bass Boost
|
||||
#define USB_ACONTROL_LOUD 0x0200 // Loudness
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Audio Class-Specific Output terminal types.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define USB_ATTYPE_UNDEFINED 0x0300 // Output Terminal, undefined Type.
|
||||
#define USB_ATTYPE_SPEAKER 0x0301 // A generic speaker.
|
||||
#define USB_ATTYPE_HEADPHONES 0x0302 // A head-mounted audio output device.
|
||||
#define USB_ATTYPE_HMD 0x0303 // The audio part of a VR head mounted
|
||||
// display.
|
||||
#define USB_ATTYPE_SPEAKER_DT 0x0304 // Desktop or Monitor speaker(s).
|
||||
#define USB_ATTYPE_SPEAKER_RM 0x0305 // Larger room speaker(s).
|
||||
#define USB_ATTYPE_SPEAKER_COM 0x0306 // Communications Speaker (phone).
|
||||
#define USB_ATTYPE_SPEAKER_LFE 0x0307 // Speaker designed for low
|
||||
// frequencies.
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// USB Audio channel configuration bits for wChannelConfig values.
|
||||
// wChannelConfig: a bit field that indicates which spatial locations are
|
||||
// present in the cluster. The bit allocations are as follows:
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define USB_CHANNEL_L 0x0001 // Left Front (L)
|
||||
#define USB_CHANNEL_R 0x0002 // Right Front (R)
|
||||
#define USB_CHANNEL_C 0x0004 // Center Front (C)
|
||||
#define USB_CHANNEL_LFE 0x0008 // Low Frequency Enhancement (LFE)
|
||||
#define USB_CHANNEL_LS 0x0010 // Left Surround (LS)
|
||||
#define USB_CHANNEL_RS 0x0020 // Right Surround (RS)
|
||||
#define USB_CHANNEL_LC 0x0040 // Left of Center (LC)
|
||||
#define USB_CHANNEL_RC 0x0080 // Right of Center (RC)
|
||||
#define USB_CHANNEL_S 0x0100 // Surround (S)
|
||||
#define USB_CHANNEL_SL 0x0200 // Side Left (SL)
|
||||
#define USB_CHANNEL_SR 0x0400 // Side Right (SR)
|
||||
#define USB_CHANNEL_T 0x0800 // Top (T)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Endpoint attributes for Audio Class General type.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define USB_EP_ATTR_ACG_SAMPLING 0x01 // Sampling Frequency
|
||||
#define USB_EP_ATTR_ACG_PITCH 0x02 // Pitch
|
||||
#define USB_EP_ATTR_ACG_MAXPACKET 0x80 // MaxPacketsOnly
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Indicates the units used for the wLockDelay field for Audio Class General
|
||||
// type.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define USB_EP_LOCKDELAY_UNDEF 0x00 // Undefined
|
||||
#define USB_EP_LOCKDELAY_MS 0x01 // Milliseconds
|
||||
#define USB_EP_LOCKDELAY_PCM 0x02 // Decoded PCM samples
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Audio Class-Specific Request Codes
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define USB_AC_SET_CUR 0x01
|
||||
#define USB_AC_SET_MIN 0x02
|
||||
#define USB_AC_SET_MAX 0x03
|
||||
#define USB_AC_SET_RES 0x04
|
||||
#define USB_AC_SET_MEM 0x05
|
||||
#define USB_AC_GET_CUR 0x81
|
||||
#define USB_AC_GET_MIN 0x82
|
||||
#define USB_AC_GET_MAX 0x83
|
||||
#define USB_AC_GET_RES 0x84
|
||||
#define USB_AC_GET_MEM 0x85
|
||||
#define USB_AC_GET_STAT 0xff
|
||||
|
||||
#define USB_CS_CONTROL_M 0xff00
|
||||
#define USB_CS_CHANNEL_M 0x00ff
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Endpoint Control Selectors
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define EP_CONTROL_UNDEFINED 0x0000
|
||||
#define SAMPLING_FREQ_CONTROL 0x0100
|
||||
#define PITCH_CONTROL 0x0200
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Feature Unit Control Selectors
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define FU_CONTROL_UNDEFINED 0x0000
|
||||
#define MUTE_CONTROL 0x0100
|
||||
#define VOLUME_CONTROL 0x0200
|
||||
#define BASS_CONTROL 0x0300
|
||||
#define MID_CONTROL 0x0400
|
||||
#define TREBLE_CONTROL 0x0500
|
||||
#define EQUALIZER_CONTROL 0x0600
|
||||
#define AUTOMATIC_GAIN_CONTROL 0x0700
|
||||
#define DELAY_CONTROL 0x0800
|
||||
#define BASS_BOOST_CONTROL 0x0900
|
||||
#define LOUDNESS_CONTROL 0x0A00
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// All structures defined in this section of the header require byte packing of
|
||||
// fields. This is usually accomplished using the PACKED macro but, for IAR
|
||||
// Embedded Workbench, this requires a pragma.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#ifdef ewarm
|
||||
#pragma pack(1)
|
||||
#endif
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! This structure describes the Class-Specific Audio Class Interface Header
|
||||
//! Descriptor as defined in Universal Serial Bus Device Class Definition
|
||||
//! for Audio Devices Release 1.0.
|
||||
//
|
||||
//*****************************************************************************
|
||||
typedef struct
|
||||
{
|
||||
//
|
||||
//! The length of this descriptor in bytes.
|
||||
//
|
||||
uint8_t bLength;
|
||||
|
||||
//
|
||||
//! The type of the descriptor. For an interface descriptor, this will
|
||||
//! be USB_DTYPE_CS_INTERFACE (36).
|
||||
//
|
||||
uint8_t bDescriptorType;
|
||||
|
||||
//
|
||||
//! This will be USB_DSUBTYPE_HEADER for the header.
|
||||
//
|
||||
uint8_t bDescriptorSubtype;
|
||||
|
||||
//
|
||||
//! Audio Device Class Specification Release Number in Binary-Coded
|
||||
//! Decimal.
|
||||
//
|
||||
uint16_t bcdADC;
|
||||
|
||||
//
|
||||
//! Total number of bytes returned for the class-specific AudioControl
|
||||
//! interface descriptor. Includes the combined length of this descriptor
|
||||
//! header and all Unit and Terminal descriptors.
|
||||
//
|
||||
uint16_t wTotai32Length;
|
||||
|
||||
//
|
||||
//! The number of AudioStreaming and MIDIStreaming interfaces in the Audio
|
||||
//! Interface Collection to which this AudioControl interface belongs.
|
||||
//
|
||||
uint8_t bInCollection;
|
||||
|
||||
//
|
||||
//! Interface number of the first AudioStreaming or MIDIStreaming interface
|
||||
//! in the Collection.
|
||||
//
|
||||
uint8_t baInterfaceNr;
|
||||
}
|
||||
PACKED tACHeader;
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// These are the possible bits set in the tACInputTerminal.wChannelConfig
|
||||
// value.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define USB_AC_CC_LEFT 0x0001
|
||||
#define USB_AC_CC_RIGHT 0x0002
|
||||
#define USB_AC_CC_CENTER 0x0004
|
||||
#define USB_AC_CC_LFE 0x0008
|
||||
#define USB_AC_CC_LEFTSURROUND 0x0010
|
||||
#define USB_AC_CC_RIGHTSURROUND 0x0020
|
||||
#define USB_AC_CC_LEFT_CENTER 0x0040
|
||||
#define USB_AC_CC_RIGHT_CENTER 0x0080
|
||||
#define USB_AC_CC_SURROUND 0x0100
|
||||
#define USB_AC_CC_SIDE_LEFT 0x0200
|
||||
#define USB_AC_CC_SIDE_RIGHT 0x0400
|
||||
#define USB_AC_CC_TOP 0x0800
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! This structure describes the Feature Unit Descriptor as defined in
|
||||
//! Universal Serial Bus Device Class Definition for Audio Devices Release 1.0.
|
||||
//
|
||||
//*****************************************************************************
|
||||
typedef struct
|
||||
{
|
||||
//
|
||||
//! The length of this descriptor in bytes.
|
||||
//
|
||||
uint8_t bLength;
|
||||
|
||||
//
|
||||
//! The type of the descriptor. For an interface descriptor, this will
|
||||
//! be USB_DTYPE_CS_INTERFACE (36).
|
||||
//
|
||||
uint8_t bDescriptorType;
|
||||
|
||||
//
|
||||
//! This will be USB_DSUBTYPE_IN_TERM for the header.
|
||||
//
|
||||
uint8_t bDescriptorSubtype;
|
||||
|
||||
//
|
||||
//! Constant uniquely identifying the Unit within the audio function. This
|
||||
//! value is used in all requests to address this Unit.
|
||||
//
|
||||
uint8_t bUnitID;
|
||||
|
||||
//
|
||||
//! ID of the Unit or Terminal to which this Feature Unit is connected.
|
||||
//
|
||||
uint8_t bSourceID;
|
||||
|
||||
//
|
||||
//! ID of the Output Terminal to which this Input Terminal is associated.
|
||||
//
|
||||
uint8_t bControlSize;
|
||||
|
||||
//
|
||||
//! A bit set to 1 indicates that the mentioned Control is supported for
|
||||
//! a given channel. See the USB_FU_* defines for the bit definitions.
|
||||
//! This actually an array of elements of size bControlSize so be
|
||||
//! careful when using this value directly.
|
||||
//
|
||||
uint16_t bmaControls;
|
||||
}
|
||||
PACKED tACFeatureUnit;
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! This structure describes the Output Terminal Descriptor as defined in
|
||||
//! Universal Serial Bus Device Class Definition for Audio Devices Release 1.0.
|
||||
//
|
||||
//*****************************************************************************
|
||||
typedef struct
|
||||
{
|
||||
//
|
||||
//! The length of this descriptor in bytes.
|
||||
//
|
||||
uint8_t bLength;
|
||||
|
||||
//
|
||||
//! The type of the descriptor. For an interface descriptor, this will
|
||||
//! be USB_DTYPE_CS_INTERFACE (36).
|
||||
//
|
||||
uint8_t bDescriptorType;
|
||||
|
||||
//
|
||||
//! This will be USB_DSUBTYPE_OUT_TERM for the header.
|
||||
//
|
||||
uint8_t bDescriptorSubtype;
|
||||
|
||||
//
|
||||
//! Constant uniquely identifying the Terminal within the audio function.
|
||||
//! This value is used in all requests to address this Terminal.
|
||||
//
|
||||
uint8_t bTerminalID;
|
||||
|
||||
//
|
||||
//! Constant characterizing the type of Terminal. See USB Audio Terminal
|
||||
//! Types.
|
||||
//
|
||||
uint16_t wTerminalType;
|
||||
|
||||
//
|
||||
//! Constant, identifying the Input Terminal to which this Output Terminal
|
||||
//! is associated.
|
||||
//
|
||||
uint8_t bAssocTerminal;
|
||||
|
||||
//
|
||||
//! ID of the Unit or Terminal to which this Terminal is connected.
|
||||
//
|
||||
uint8_t bSourceID;
|
||||
|
||||
//
|
||||
//! Index of a string descriptor, describing the Output Terminal.
|
||||
//
|
||||
uint8_t iTerminal;
|
||||
}
|
||||
PACKED tACOutputTerminal;
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! This structure describes the Input Terminal Descriptor as defined in
|
||||
//! Universal Serial Bus Device Class Definition for Audio Devices Release 1.0.
|
||||
//
|
||||
//*****************************************************************************
|
||||
typedef struct
|
||||
{
|
||||
//
|
||||
//! The length of this descriptor in bytes.
|
||||
//
|
||||
uint8_t bLength;
|
||||
|
||||
//
|
||||
//! The type of the descriptor. For an interface descriptor, this will
|
||||
//! be USB_DTYPE_CS_INTERFACE (36).
|
||||
//
|
||||
uint8_t bDescriptorType;
|
||||
|
||||
//
|
||||
//! This will be USB_DSUBTYPE_OUT_TERM for the header.
|
||||
//
|
||||
uint8_t bDescriptorSubtype;
|
||||
|
||||
//
|
||||
//! Constant uniquely identifying the Terminal within the audio function.
|
||||
//! This value is used in all requests to address this Terminal.
|
||||
//
|
||||
uint8_t bTerminalID;
|
||||
|
||||
//
|
||||
//! Constant characterizing the type of Terminal. See USB Audio Terminal
|
||||
//! Types.
|
||||
//
|
||||
uint16_t wTerminalType;
|
||||
|
||||
//
|
||||
//! Constant, identifying the Input Terminal to which this Output Terminal
|
||||
//! is associated.
|
||||
//
|
||||
uint8_t bAssocTerminal;
|
||||
|
||||
//
|
||||
//! Number of logical output channels in the Terminal's output audio
|
||||
//! channel cluster.
|
||||
//
|
||||
uint8_t bNrChannels;
|
||||
|
||||
//
|
||||
//! Describes the spatial location of the logical channels.
|
||||
//
|
||||
uint16_t wChannelConfig;
|
||||
|
||||
//
|
||||
//! Index of a string descriptor, describing the name of the first logical
|
||||
//! channel.
|
||||
//
|
||||
uint8_t iChannelNames;
|
||||
|
||||
//
|
||||
//! Index of a string descriptor, describing the Output Terminal.
|
||||
//
|
||||
uint8_t iTerminal;
|
||||
}
|
||||
PACKED tACInputTerminal;
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! This structure describes the Mixer Descriptor as defined in Universal
|
||||
//! Serial Bus Device Class Definition for Audio Devices Release 1.0.
|
||||
//
|
||||
//*****************************************************************************
|
||||
typedef struct
|
||||
{
|
||||
//
|
||||
//! The length of this descriptor in bytes.
|
||||
//
|
||||
uint8_t bLength;
|
||||
|
||||
//
|
||||
//! The type of the descriptor. For an interface descriptor, this will
|
||||
//! be USB_DTYPE_CS_INTERFACE (36).
|
||||
//
|
||||
uint8_t bDescriptorType;
|
||||
|
||||
//
|
||||
//! This will be USB_AI_MIXER_UNIT for the header.
|
||||
//
|
||||
uint8_t bDescriptorSubtype;
|
||||
|
||||
//
|
||||
//! Constant uniquely identifying the Unit within the audio function. This
|
||||
//! value is used in all requests to address this Unit.
|
||||
//
|
||||
uint8_t bUnitID;
|
||||
|
||||
//
|
||||
//! Number of Input Pins of this Unit.
|
||||
//
|
||||
uint8_t bNrInPins;
|
||||
|
||||
//
|
||||
//! ID of the Unit or Terminal to which the first Input Pin of this Mixer
|
||||
//! Unit is connected.
|
||||
//
|
||||
uint8_t baSourceID;
|
||||
}
|
||||
PACKED tACMixer;
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! This structure describes the Selector Descriptor as defined in Universal
|
||||
//! Serial Bus Device Class Definition for Audio Devices Release 1.0.
|
||||
//
|
||||
//*****************************************************************************
|
||||
typedef struct
|
||||
{
|
||||
//
|
||||
//! The length of this descriptor in bytes.
|
||||
//
|
||||
uint8_t bLength;
|
||||
|
||||
//
|
||||
//! The type of the descriptor. For an interface descriptor, this will
|
||||
//! be USB_DTYPE_CS_INTERFACE (36).
|
||||
//
|
||||
uint8_t bDescriptorType;
|
||||
|
||||
//
|
||||
//! This will be USB_AI_MIXER_UNIT for the header.
|
||||
//
|
||||
uint8_t bDescriptorSubtype;
|
||||
|
||||
//
|
||||
//! Constant uniquely identifying the Unit within the audio function. This
|
||||
//! value is used in all requests to address this Unit.
|
||||
//
|
||||
uint8_t bUnitID;
|
||||
|
||||
//
|
||||
//! Number of Input Pins of this Unit.
|
||||
//
|
||||
uint8_t bNrInPins;
|
||||
|
||||
//
|
||||
//! ID of the Unit or Terminal to which the first Input Pin of this Mixer
|
||||
//! Unit is connected.
|
||||
//
|
||||
uint8_t baSourceID;
|
||||
}
|
||||
PACKED tACSelector;
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! This structure describes the Output Terminal Descriptor as defined in
|
||||
//! Universal Serial Bus Device Class Definition for Audio Devices Release 1.0.
|
||||
//
|
||||
//*****************************************************************************
|
||||
typedef struct
|
||||
{
|
||||
//
|
||||
//! The length of this descriptor in bytes.
|
||||
//
|
||||
uint8_t bLength;
|
||||
|
||||
//
|
||||
//! The type of the descriptor. For an interface descriptor, this will
|
||||
//! be USB_DTYPE_CS_INTERFACE (36).
|
||||
//
|
||||
uint8_t bDescriptorType;
|
||||
|
||||
//
|
||||
//! This will be USB_DSUBTYPE_GENERAL for the header.
|
||||
//
|
||||
uint8_t bDescriptorSubtype;
|
||||
|
||||
//
|
||||
//! The Terminal ID of the Terminal to which the endpoint of this
|
||||
//! interface is connected.
|
||||
//
|
||||
uint8_t bTerminalLink;
|
||||
|
||||
//
|
||||
//! Delay introduced by the data path. Expressed in number of frames.
|
||||
//
|
||||
uint8_t bDelay;
|
||||
|
||||
//
|
||||
//! The Audio Data Format that has to be used to communicate with this
|
||||
//! interface.
|
||||
//
|
||||
uint16_t wFormatTag;
|
||||
}
|
||||
PACKED tACGeneral;
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! This structure describes the Type I Audio format descriptors defined in
|
||||
//! USB Audio Devices Release 1.0.
|
||||
//
|
||||
//*****************************************************************************
|
||||
typedef struct
|
||||
{
|
||||
//
|
||||
//! The length of this descriptor in bytes.
|
||||
//
|
||||
uint8_t bLength;
|
||||
|
||||
//
|
||||
//! The type of the descriptor. For an interface descriptor, this will
|
||||
//! be USB_DTYPE_CS_INTERFACE (36).
|
||||
//
|
||||
uint8_t bDescriptorType;
|
||||
|
||||
//
|
||||
//! This will be USB_AS_FORMAT_TYPE.
|
||||
//
|
||||
uint8_t bDescriptorSubtype;
|
||||
|
||||
//
|
||||
//! This will be USB_AS_FORMAT_TYPE_I.
|
||||
//
|
||||
uint8_t bFormatType;
|
||||
|
||||
//
|
||||
//! Number of channels on this streaming interface.
|
||||
//
|
||||
uint8_t bNrChannels;
|
||||
|
||||
//
|
||||
//! Number of bytes per audio sub-frame or channel.
|
||||
//
|
||||
uint8_t bSubFrameSize;
|
||||
|
||||
//
|
||||
//! Number of bits per sample.
|
||||
//
|
||||
uint8_t bBitResolution;
|
||||
|
||||
//
|
||||
//! Number of sample rates that are supported.
|
||||
//
|
||||
uint8_t bSamFreqType;
|
||||
|
||||
//
|
||||
//! Number of bits per sample.
|
||||
//
|
||||
uint8_t tSamFreq;
|
||||
}
|
||||
PACKED tASFormat;
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Return to default packing when using the IAR Embedded Workbench compiler.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#ifdef ewarm
|
||||
#pragma pack()
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,947 @@
|
|||
//*****************************************************************************
|
||||
//
|
||||
// usbhid.h - Definitions used by Communication Device Class devices.
|
||||
//
|
||||
// Copyright (c) 2007-2013 Texas Instruments Incorporated. All rights reserved.
|
||||
// Software License Agreement
|
||||
//
|
||||
// Texas Instruments (TI) is supplying this software for use solely and
|
||||
// exclusively on TI's microcontroller products. The software is owned by
|
||||
// TI and/or its suppliers, and is protected under applicable copyright
|
||||
// laws. You may not combine this software with "viral" open-source
|
||||
// software in order to form a larger program.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
|
||||
// NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
|
||||
// NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
|
||||
// CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
|
||||
// DAMAGES, FOR ANY REASON WHATSOEVER.
|
||||
//
|
||||
// This is part of revision 1.1 of the Tiva USB Library.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Note: This header contains definitions related to the USB Communication
|
||||
// Device Class specification. The header is complete for ACM model
|
||||
// devices but request and notification definitions specific to other
|
||||
// modem types, ISDN, ATM and Ethernet are currently incomplete or
|
||||
// omitted.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
#ifndef __USBCDC_H__
|
||||
#define __USBCDC_H__
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// If building with a C++ compiler, make all of the definitions in this header
|
||||
// have a C binding.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! \addtogroup cdc_device_class_api
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Generic macros to read an 8-bit, 16-bit or 32-bit value from a character
|
||||
// pointer.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define BYTE(pui8Data) (*(uint8_t *)(pui8Data))
|
||||
#define SHORT(pui8Data) (*(uint16_t *)(pui8Data))
|
||||
#define LONG(pui8Data) (*(uint32_t *)(pui8Data))
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// USB CDC subclass codes. Used in interface descriptor, bInterfaceClass
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define USB_CDC_SUBCLASS_DIRECT_LINE_MODEL \
|
||||
0x01
|
||||
#define USB_CDC_SUBCLASS_ABSTRACT_MODEL \
|
||||
0x02
|
||||
#define USB_CDC_SUBCLASS_TELEPHONE_MODEL \
|
||||
0x03
|
||||
#define USB_CDC_SUBCLASS_MULTI_CHANNEL_MODEL \
|
||||
0x04
|
||||
#define USB_CDC_SUBCLASS_CAPI_MODEL \
|
||||
0x05
|
||||
#define USB_CDC_SUBCLASS_ETHERNET_MODEL \
|
||||
0x06
|
||||
#define USB_CDC_SUBCLASS_ATM_MODEL \
|
||||
0x07
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// USB CDC control interface protocols. Used in control interface descriptor,
|
||||
// bInterfaceProtocol
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define USB_CDC_PROTOCOL_NONE 0x00
|
||||
#define USB_CDC_PROTOCOL_V25TER 0x01
|
||||
#define USB_CDC_PROTOCOL_VENDOR 0xFF
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// USB CDC data interface protocols. Used in data interface descriptor,
|
||||
// bInterfaceProtocol
|
||||
//
|
||||
//*****************************************************************************
|
||||
// USB_CDC_PROTOCOL_NONE 0x00
|
||||
#define USB_CDC_PROTOCOL_I420 0x30
|
||||
#define USB_CDC_PROTOCOL_TRANSPARENT \
|
||||
0x32
|
||||
#define USB_CDC_PROTOCOL_Q921M 0x50
|
||||
#define USB_CDC_PROTOCOL_Q921 0x51
|
||||
#define USB_CDC_PROTOCOL_Q921TM 0x52
|
||||
#define USB_CDC_PROTOCOL_V42BIS 0x90
|
||||
#define USB_CDC_PROTOCOL_Q921EURO \
|
||||
0x91
|
||||
#define USB_CDC_PROTOCOL_V120 0x92
|
||||
#define USB_CDC_PROTOCOL_CAPI20 0x93
|
||||
#define USB_CDC_PROTOCOL_HOST_DRIVER \
|
||||
0xFD
|
||||
#define USB_CDC_PROTOCOL_CDC_SPEC \
|
||||
0xFE
|
||||
// USB_CDC_PROTOCOL_VENDOR 0xFF
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Functional descriptor definitions
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Functional descriptor types
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define USB_CDC_CS_INTERFACE 0x24
|
||||
#define USB_CDC_CS_ENDPOINT 0x25
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Functional descriptor subtypes
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define USB_CDC_FD_SUBTYPE_HEADER \
|
||||
0x00
|
||||
#define USB_CDC_FD_SUBTYPE_CALL_MGMT \
|
||||
0x01
|
||||
#define USB_CDC_FD_SUBTYPE_ABSTRACT_CTL_MGMT \
|
||||
0x02
|
||||
#define USB_CDC_FD_SUBTYPE_DIRECT_LINE_MGMT \
|
||||
0x03
|
||||
#define USB_CDC_FD_SUBTYPE_TELEPHONE_RINGER \
|
||||
0x04
|
||||
#define USB_CDC_FD_SUBTYPE_LINE_STATE_CAPS \
|
||||
0x05
|
||||
#define USB_CDC_FD_SUBTYPE_UNION \
|
||||
0x06
|
||||
#define USB_CDC_FD_SUBTYPE_COUNTRY \
|
||||
0x07
|
||||
#define USB_CDC_FD_SUBTYPE_TELEPHONE_MODES \
|
||||
0x08
|
||||
#define USB_CDC_FD_SUBTYPE_USB_TERMINAL \
|
||||
0x09
|
||||
#define USB_CDC_FD_SUBTYPE_NETWORK_TERMINAL \
|
||||
0x0A
|
||||
#define USB_CDC_FD_SUBTYPE_PROTOCOL_UNIT \
|
||||
0x0B
|
||||
#define USB_CDC_FD_SUBTYPE_EXTENSION_UNIT \
|
||||
0x0C
|
||||
#define USB_CDC_FD_SUBTYPE_MULTI_CHANNEL_MGMT \
|
||||
0x0D
|
||||
#define USB_CDC_FD_SUBTYPE_CAPI_MGMT \
|
||||
0x0E
|
||||
#define USB_CDC_FD_SUBTYPE_ETHERNET \
|
||||
0x0F
|
||||
#define USB_CDC_FD_SUBTYPE_ATM 0x10
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// USB_CDC_FD_SUBTYPE_CALL_MGMT, Header functional descriptor, bmCapabilities
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define USB_CDC_CALL_MGMT_VIA_DATA \
|
||||
0x02
|
||||
#define USB_CDC_CALL_MGMT_HANDLED \
|
||||
0x01
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// USB_CDC_FD_SUBTYPE_ABSTRACT_CTL_MGMT, Abstract Control Management functional
|
||||
// descriptor, bmCapabilities
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define USB_CDC_ACM_SUPPORTS_NETWORK_CONNECTION \
|
||||
0x08
|
||||
#define USB_CDC_ACM_SUPPORTS_SEND_BREAK \
|
||||
0x04
|
||||
#define USB_CDC_ACM_SUPPORTS_LINE_PARAMS \
|
||||
0x02
|
||||
#define USB_CDC_ACM_SUPPORTS_COMM_FEATURE \
|
||||
0x01
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// USB_CDC_FD_SUBTYPE_DIRECT_LINE_MGMT, Direct Line Management functional
|
||||
// descriptor, bmCapabilities
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define USB_CDC_DLM_NEEDS_EXTRA_PULSE_SETUP \
|
||||
0x04
|
||||
#define USB_CDC_DLM_SUPPORTS_AUX \
|
||||
0x02
|
||||
#define USB_CDC_DLM_SUPPORTS_PULSE \
|
||||
0x01
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// USB_CDC_FD_SUBTYPE_TELEPHONE_MODES, Telephone Operational Modes functional
|
||||
// descriptor, bmCapabilities
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define USB_CDC_TELEPHONE_SUPPORTS_COMPUTER \
|
||||
0x04
|
||||
#define USB_CDC_TELEPHONE_SUPPORTS_STANDALONE \
|
||||
0x02
|
||||
#define USB_CDC_TELEPHONE_SUPPORTS_SIMPLE \
|
||||
0x01
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// USB_CDC_FD_SUBTYPE_LINE_STATE_CAPS, Telephone Call and Line State Reporting
|
||||
// Capabilities descriptor
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define USB_CDC_LINE_STATE_CHANGES_NOTIFIED \
|
||||
0x20
|
||||
#define USB_CDC_LINE_STATE_REPORTS_DTMF \
|
||||
0x10
|
||||
#define USB_CDC_LINE_STATE_REPORTS_DIST_RING \
|
||||
0x08
|
||||
#define USB_CDC_LINE_STATE_REPORTS_CALLERID \
|
||||
0x04
|
||||
#define USB_CDC_LINE_STATE_REPORTS_BUSY \
|
||||
0x02
|
||||
#define USB_CDC_LINE_STATE_REPORTS_INT_DIALTONE \
|
||||
0x01
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// USB_CDC_FD_SUBTYPE_USB_TERMINAL, USB Terminal functional descriptor,
|
||||
// bmOptions
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define USB_CDC_TERMINAL_NO_WRAPPER_USED \
|
||||
0x00
|
||||
#define USB_CDC_TERMINAL_WRAPPER_USED \
|
||||
0x01
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// USB_CDC_FD_SUBTYPE_MULTI_CHANNEL_MGMT, Multi-Channel Management functional
|
||||
// descriptor, bmCapabilities
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define USB_CDC_MCM_SUPPORTS_SET_UNIT_PARAM \
|
||||
0x04
|
||||
#define USB_CDC_MCM_SUPPORTS_CLEAR_UNIT_PARAM \
|
||||
0x02
|
||||
#define USB_CDC_MCM_UNIT_PARAMS_NON_VOLATILE \
|
||||
0x01
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// USB_CDC_FD_SUBTYPE_CAPI_MGMT, CAPI Control Management functional descriptor,
|
||||
// bmCapabilities
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define USB_CDC_CAPI_INTELLIGENT \
|
||||
0x01
|
||||
#define USB_CDC_CAPI_SIMPLE 0x00
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// USB_CDC_FD_SUBTYPE_ETHERNET, Ethernet Networking functional descriptor,
|
||||
// bmEthernetStatistics
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define USB_CDC_ETHERNET_XMIT_OK \
|
||||
0x01000000
|
||||
#define USB_CDC_ETHERNET_RCV_OK 0x02000000
|
||||
#define USB_CDC_ETHERNET_XMIT_ERROR \
|
||||
0x04000000
|
||||
#define USB_CDC_ETHERNET_RCV_ERROR \
|
||||
0x08000000
|
||||
#define USB_CDC_ETHERNET_RCV_NO_BUFFER \
|
||||
0x10000000
|
||||
#define USB_CDC_ETHERNET_DIRECTED_BYTES_XMIT \
|
||||
0x20000000
|
||||
#define USB_CDC_ETHERNET_DIRECTED_FRAMES_XMIT \
|
||||
0x40000000
|
||||
#define USB_CDC_ETHERNET_MULTICAST_BYTES_XMIT \
|
||||
0x80000000
|
||||
#define USB_CDC_ETHERNET_MULTICAST_FRAMES_XMIT \
|
||||
0x00010000
|
||||
#define USB_CDC_ETHERNET_BROADCAST_BYTES_XMIT \
|
||||
0x00020000
|
||||
#define USB_CDC_ETHERNET_BROADCAST_FRAMES_XMIT \
|
||||
0x00040000
|
||||
#define USB_CDC_ETHERNET_DIRECTED_BYTES_RCV \
|
||||
0x00080000
|
||||
#define USB_CDC_ETHERNET_DIRECTED_FRAMES_RCV \
|
||||
0x00100000
|
||||
#define USB_CDC_ETHERNET_MULTICAST_BYTES_RCV \
|
||||
0x00200000
|
||||
#define USB_CDC_ETHERNET_MULTICAST_FRAMES_RCV \
|
||||
0x00400000
|
||||
#define USB_CDC_ETHERNET_BROADCAST_BYTES_RCV \
|
||||
0x00800000
|
||||
#define USB_CDC_ETHERNET_BROADCAST_FRAMES_RCV \
|
||||
0x00000100
|
||||
#define USB_CDC_ETHERNET_RCV_CRC_ERROR \
|
||||
0x00000200
|
||||
#define USB_CDC_ETHERNET_TRANSMIT_QUEUE_LENGTH \
|
||||
0x00000400
|
||||
#define USB_CDC_ETHERNET_RCV_ERROR_ALIGNMENT \
|
||||
0x00000800
|
||||
#define USB_CDC_ETHERNET_XMIT_ONE_COLLISION \
|
||||
0x00001000
|
||||
#define USB_CDC_ETHERNET_XMIT_MORE_COLLISIONS \
|
||||
0x00002000
|
||||
#define USB_CDC_ETHERNET_XMIT_DEFERRED \
|
||||
0x00004000
|
||||
#define USB_CDC_ETHERNET_XMIT_MAX_COLLISIONS \
|
||||
0x00008000
|
||||
#define USB_CDC_ETHERNET_RCV_OVERRUN \
|
||||
0x00000001
|
||||
#define USB_CDC_ETHERNET_XMIT_UNDERRUN \
|
||||
0x00000002
|
||||
#define USB_CDC_ETHERNET_XMIT_HEARTBEAT_FAILURE \
|
||||
0x00000004
|
||||
#define USB_CDC_ETHERNET_XMIT_TIMES_CRS_LOST \
|
||||
0x00000010
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// USB_CDC_FD_SUBTYPE_ATM, ATM Networking functional descriptor,
|
||||
// bmDataCapabilities
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define USB_CDC_ATM_TYPE_3 0x08
|
||||
#define USB_CDC_ATM_TYPE_2 0x04
|
||||
#define USB_CDC_ATM_TYPE_1 0x02
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// bmATMDeviceStatistics
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define USB_CDC_ATM_VC_US_CELLS_SENT \
|
||||
0x10
|
||||
#define USB_CDC_ATM_VC_US_CELLS_RECEIVED \
|
||||
0x08
|
||||
#define USB_CDC_ATM_DS_CELLS_HEC_ERR_CORRECTED \
|
||||
0x04
|
||||
#define USB_CDC_ATM_US_CELLS_SENT \
|
||||
0x02
|
||||
#define USB_CDC_ATM_US_CELLS_RECEIVED \
|
||||
0x01
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Management Element Requests (provided in tUSBRequest.bRequest)
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define USB_CDC_SEND_ENCAPSULATED_COMMAND \
|
||||
0x00
|
||||
#define USB_CDC_GET_ENCAPSULATED_RESPONSE \
|
||||
0x01
|
||||
#define USB_CDC_SET_COMM_FEATURE \
|
||||
0x02
|
||||
#define USB_CDC_GET_COMM_FEATURE \
|
||||
0x03
|
||||
#define USB_CDC_CLEAR_COMM_FEATURE \
|
||||
0x04
|
||||
#define USB_CDC_SET_AUX_LINE_STATE \
|
||||
0x10
|
||||
#define USB_CDC_SET_HOOK_STATE 0x11
|
||||
#define USB_CDC_PULSE_SETUP 0x12
|
||||
#define USB_CDC_SEND_PULSE 0x13
|
||||
#define USB_CDC_SET_PULSE_TIME 0x14
|
||||
#define USB_CDC_RING_AUX_JACK 0x15
|
||||
#define USB_CDC_SET_LINE_CODING 0x20
|
||||
#define USB_CDC_GET_LINE_CODING 0x21
|
||||
#define USB_CDC_SET_CONTROL_LINE_STATE \
|
||||
0x22
|
||||
#define USB_CDC_SEND_BREAK 0x23
|
||||
#define USB_CDC_SET_RINGER_PARMS \
|
||||
0x30
|
||||
#define USB_CDC_GET_RINGER_PARMS \
|
||||
0x31
|
||||
#define USB_CDC_SET_OPERATION_PARMS \
|
||||
0x32
|
||||
#define USB_CDC_GET_OPERATION_PARMS \
|
||||
0x33
|
||||
#define USB_CDC_SET_LINE_PARMS 0x34
|
||||
#define USB_CDC_GET_LINE_PARMS 0x35
|
||||
#define USB_CDC_DIAL_DIGITS 0x36
|
||||
#define USB_CDC_SET_UNIT_PARAMETER \
|
||||
0x37
|
||||
#define USB_CDC_GET_UNIT_PARAMETER \
|
||||
0x38
|
||||
#define USB_CDC_CLEAR_UNIT_PARAMETER \
|
||||
0x39
|
||||
#define USB_CDC_GET_PROFILE 0x3A
|
||||
#define USB_CDC_SET_ETHERNET_MULTICAST_FILTERS \
|
||||
0x40
|
||||
#define USB_CDC_SET_ETHERNET_POWER_MANAGEMENT_PATTERN_FILTER \
|
||||
0x41
|
||||
#define USB_CDC_GET_ETHERNET_POWER_MANAGEMENT_PATTERN_FILTER \
|
||||
0x42
|
||||
#define USB_CDC_SET_ETHERNET_PACKET_FILTER \
|
||||
0x43
|
||||
#define USB_CDC_GET_ETHERNET_STATISTIC \
|
||||
0x44
|
||||
#define USB_CDC_SET_ATM_DATA_FORMAT \
|
||||
0x50
|
||||
#define USB_CDC_GET_ATM_DEVICE_STATISTICS \
|
||||
0x51
|
||||
#define USB_CDC_SET_ATM_DEFAULT_VC \
|
||||
0x52
|
||||
#define USB_CDC_GET_ATM_VC_STATISTICS \
|
||||
0x53
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// In cases where a request defined above results in the return of a fixed size
|
||||
// data block, the following group of labels define the size of that block. In
|
||||
// each of these cases, an access macro is also provided to write the response
|
||||
// data into an appropriately-sized array of 8-bit characters.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define USB_CDC_SIZE_COMM_FEATURE \
|
||||
2
|
||||
#define USB_CDC_SIZE_LINE_CODING \
|
||||
7
|
||||
#define USB_CDC_SIZE_RINGER_PARMS \
|
||||
4
|
||||
#define USB_CDC_SIZE_OPERATION_PARMS \
|
||||
2
|
||||
#define USB_CDC_SIZE_UNIT_PARAMETER \
|
||||
2
|
||||
#define USB_CDC_SIZE_PROFILE 64
|
||||
#define USB_CDC_SIZE_ETHERNET_POWER_MANAGEMENT_PATTERN_FILTER \
|
||||
2
|
||||
#define USB_CDC_SIZE_ETHERNET_STATISTIC \
|
||||
4
|
||||
#define USB_CDC_SIZE_ATM_DEVICE_STATISTICS \
|
||||
4
|
||||
#define USB_CDC_SIZE_ATM_VC_STATISTICS \
|
||||
4
|
||||
#define USB_CDC_SIZE_LINE_PARMS \
|
||||
10
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// NB: USB_CDC_SIZE_LINE_PARAMS assumes only a single call. For multiple
|
||||
// calls, add 4 bytes per additional call.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// USB_CDC_GET_COMM_FEATURE & USB_CDC_SET_COMM_FEATURE
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// wValue (Feature Selector)
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define USB_CDC_ABSTRACT_STATE 0x0001
|
||||
#define USB_CDC_COUNTRY_SETTING 0x0002
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Data when feature selector is USB_DCD_ABSTRACT_STATE
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define USB_CDC_ABSTRACT_CALL_DATA_MULTIPLEXED \
|
||||
0x0002
|
||||
#define USB_CDC_ABSTRACT_ENDPOINTS_IDLE \
|
||||
0x0001
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Macros to populate the response data buffer (whose size in bytes is defined
|
||||
// by USB_CDC_SIZE_COMM_FEATURE).
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define SetResponseCommFeature(pi8Buf, ui16Data) \
|
||||
do \
|
||||
{ \
|
||||
(*(uint16_t *)(pi8Buf)) = ui16Data; \
|
||||
} \
|
||||
while(0)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// USB_CDC_SET_AUX_LINE_STATE, wValue
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define USB_CDC_AUX_DISCONNECT 0x0000
|
||||
#define USB_CDC_AUX_CONNECT 0x0001
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// USB_CDC_SET_HOOK_STATE, wValue
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define USB_CDC_ON_HOOK 0x0000
|
||||
#define USB_CDC_OFF_HOOK 0x0001
|
||||
#define USB_CDC_SNOOPING 0x0002
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// USB_CDC_GET_LINE_CODING
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define USB_CDC_STOP_BITS_1 0x00
|
||||
#define USB_CDC_STOP_BITS_1_5 0x01
|
||||
#define USB_CDC_STOP_BITS_2 0x02
|
||||
|
||||
#define USB_CDC_PARITY_NONE 0x00
|
||||
#define USB_CDC_PARITY_ODD 0x01
|
||||
#define USB_CDC_PARITY_EVEN 0x02
|
||||
#define USB_CDC_PARITY_MARK 0x03
|
||||
#define USB_CDC_PARITY_SPACE 0x04
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Macro to populate the response data buffer (whose size in bytes is defined
|
||||
// by USB_CDC_SIZE_LINE_CODING).
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define SetResponseLineCoding(pi8Buf, ui8Rate, ui8Stop, ui8Parity, \
|
||||
ui8Databits) \
|
||||
do \
|
||||
{ \
|
||||
(*(uint32_t *)(pi8Buf)) = ui8Rate; \
|
||||
(*((uint8_t *)(pi8Buf) + 4)) = ui8Stop; \
|
||||
(*((uint8_t *)(pi8Buf) + 5)) = ui8Parity; \
|
||||
(*((uint8_t *)(pi8Buf) + 6)) = ui8Databits; \
|
||||
} \
|
||||
while(0)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// USB_CDC_SET_CONTROL_LINE_STATE, wValue
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define USB_CDC_DEACTIVATE_CARRIER \
|
||||
0x00
|
||||
#define USB_CDC_ACTIVATE_CARRIER \
|
||||
0x02
|
||||
#define USB_CDC_DTE_NOT_PRESENT 0x00
|
||||
#define USB_CDC_DTE_PRESENT 0x01
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// USB_CDC_SET_RINGER_PARMS, USB_CDC_GET_RINGER_PARMS and
|
||||
// USB_CDC_GET_LINE_PARMS (ui32RingerBmp)
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define USB_CDC_RINGER_EXISTS 0x80000000
|
||||
#define USB_CDC_RINGER_DOES_NOT_EXIST \
|
||||
0x00000000
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Macro to populate the response data buffer to USB_CDC_GET_RINGER_PARMS.
|
||||
// Parameter buf points to a buffer of size USB_CDC_SIZE_RINGER_PARMS bytes.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define SetResponseRingerParms(pi8Buf, ui8Pattern, ui8Volume, ui32Exists) \
|
||||
do \
|
||||
{ \
|
||||
*(uint32_t *)(pi8Buf) = ((ui8Pattern) + \
|
||||
((ui8Volume & 0xFF) << 8) + \
|
||||
(ui32Exists & USB_CDC_RINGER_EXISTS)); \
|
||||
} \
|
||||
while(0)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Macros to extract fields from the USB_CDC_SET_RINGER_PARMS data
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define GetRingerVolume(pi8Data) \
|
||||
(BYTE((pi8Data) + 1))
|
||||
#define GetRingerPattern(pi8Data) \
|
||||
(BYTE(pi8Data))
|
||||
#define GetRingerExists(pi8Data) \
|
||||
((LONG(pi8Data)) & USB_CDC_RINGER_EXISTS)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// USB_CDC_SET_OPERATION_PARMS, wValue
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define USB_CDC_SIMPLE_MODE 0x0000
|
||||
#define USB_CDC_STANDALONE_MODE 0x0001
|
||||
#define USB_CDC_HOST_CENTRIC_MODE \
|
||||
0x0002
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Macro to populate the response data buffer to USB_CDC_GET_OPERATION_PARMS.
|
||||
// Parameter buf points to a buffer of size USB_CDC_SIZE_OPERATION_PARMS
|
||||
// bytes.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define SetResponseOperationParms(pi8Bbuf, ui16Data) \
|
||||
do \
|
||||
{ \
|
||||
WORD(pi8Buf) = ui16Data; \
|
||||
} \
|
||||
while(0)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// USB_CDC_SET_LINE_PARMS, wParam - Line State Change
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define USB_CDC_DROP_ACTIVE_CALL \
|
||||
0x0000
|
||||
#define USB_CDC_START_NEW_CALL 0x0001
|
||||
#define USB_CDC_APPLY_RINGING 0x0002
|
||||
#define USB_CDC_REMOVE_RINGING 0x0003
|
||||
#define USB_CDC_SWITCH_CALL 0x0004
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Line state bitmap in USB_CDC_GET_LINE_PARMS response
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define USB_CDC_LINE_IS_ACTIVE 0x80000000
|
||||
#define USB_CDC_LINE_IS_IDLE 0x00000000
|
||||
#define USB_CDC_LINE_NO_ACTIVE_CALL \
|
||||
0x000000FF
|
||||
|
||||
#define USB_CDC_CALL_ACTIVE 0x80000000
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Call state value definitions
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define USB_CDC_CALL_IDLE 0x00000000
|
||||
#define USB_CDC_CALL_TYPICAL_DIALTONE \
|
||||
0x00000001
|
||||
#define USB_CDC_CALL_INTERRUPTED_DIALTONE \
|
||||
0x00000002
|
||||
#define USB_CDC_CALL_DIALING 0x00000003
|
||||
#define USB_CDC_CALL_RINGBACK 0x00000004
|
||||
#define USB_CDC_CALL_CONNECTED 0x00000005
|
||||
#define USB_CDC_CALL_INCOMING 0x00000006
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Call state change value definitions
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define USB_CDC_CALL_STATE_IDLE 0x01
|
||||
#define USB_CDC_CALL_STATE_DIALING \
|
||||
0x02
|
||||
#define USB_CDC_CALL_STATE_RINGBACK \
|
||||
0x03
|
||||
#define USB_CDC_CALL_STATE_CONNECTED \
|
||||
0x04
|
||||
#define USB_CDC_CALL_STATE_INCOMING \
|
||||
0x05
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Extra byte of data describing the connection type for
|
||||
// USB_CDC_CALL_STATE_CONNECTED.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define USB_CDC_VOICE 0x00
|
||||
#define USB_CDC_ANSWERING_MACHINE \
|
||||
0x01
|
||||
#define USB_CDC_FAX 0x02
|
||||
#define USB_CDC_MODEM 0x03
|
||||
#define USB_CDC_UNKNOWN 0xFF
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Macro to extract call index from request in cases where wParam is
|
||||
// USB_CDC_SWITCH_CALL.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define GetCallIndex(pi8Data) (BYTE(pi8Data))
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Macro to populate the CallState entries in response to request
|
||||
// USB_CDC_GET_LINE_PARMS. The ui8Index parameter is a zero based index
|
||||
// indicating which call entry in the pi8Buf response buffer to fill in. Note
|
||||
// that pi8Buf points to the first byte of the buffer (the wLength field).
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define SetResponseCallState(pi8Buf, ui8Index, ui32Active, ui8StateChange, \
|
||||
ui8State) \
|
||||
do \
|
||||
{ \
|
||||
(LONG((uint8_t *)(pi8Buf) + (10 + (4 * (ui8Index))))) = \
|
||||
(((ui32Active) & USB_CDC_CALL_IS_ACTIVE) + \
|
||||
(((ui8StateChange) & 0xFF) << 8) + \
|
||||
((ui8State) & 0xFF)); \
|
||||
} \
|
||||
while(0)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Macro to populate the response data buffer (whose size in bytes is defined
|
||||
// by USB_CDC_SIZE_LINE_PARMS). Note that this macro only populates fields for
|
||||
// a single call. If multiple calls are being managed, additional 4 byte
|
||||
// fields must be appended to provide call state for each call after the first.
|
||||
// This may be done using the SetResponseCallState macro with the appropriate
|
||||
// call index supplied.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define SetResponseLineParms(pi8Buf, ui16Length, \
|
||||
ui8RingPattern, ui8RingVolume, ui32RingExists, \
|
||||
ui32LineActive, ui8LineCallIndex, \
|
||||
ui32CallActive, ui8CallStateChange, \
|
||||
ui8CallState) \
|
||||
do \
|
||||
{ \
|
||||
(WORD(pi8Buf)) = ui16Length; \
|
||||
SetResponseRingerParams(((uint8_t *)(pi8Buf) + 2), \
|
||||
ui8RingPattern, ui8RingVolume, \
|
||||
ui32RingExists); \
|
||||
(LONG((uint8_t *)(pi8Buf) + 6)) = \
|
||||
(((ui32LineActive) & USB_CDC_LINE_IS_ACTIVE) + \
|
||||
((ui8LineCallIndex) & 0xFF)) ; \
|
||||
SetResponseCallState(pi8Buf, 0, ui32CallActive, \
|
||||
ui8CallStateChange, ui8CallState); \
|
||||
} \
|
||||
while(0)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Notification Element definitions
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define USB_CDC_NOTIFY_NETWORK_CONNECTION \
|
||||
0x00
|
||||
#define USB_CDC_NOTIFY_RESPONSE_AVAILABLE \
|
||||
0x01
|
||||
#define USB_CDC_NOTIFY_AUX_JACK_HOOK_STATE \
|
||||
0x08
|
||||
#define USB_CDC_NOTIFY_RING_DETECT \
|
||||
0x09
|
||||
#define USB_CDC_NOTIFY_SERIAL_STATE \
|
||||
0x20
|
||||
#define USB_CDC_NOTIFY_CALL_STATE_CHANGE \
|
||||
0x28
|
||||
#define USB_CDC_NOTIFY_LINE_STATE_CHANGE \
|
||||
0x29
|
||||
#define USB_CDC_NOTIFY_CONNECTION_SPEED_CHANGE \
|
||||
0x2A
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// USB_CDC_NOTIFY_NETWORK_CONNECTION, wValue
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define USB_CDC_NETWORK_DISCONNECTED \
|
||||
0x0000
|
||||
#define USB_CDC_NETWORK_CONNECTED \
|
||||
0x0001
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// USB_CDC_NOTIFY_AUX_JACK_HOOK_STATE, wValue
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define USB_CDC_AUX_JACK_ON_HOOK \
|
||||
0x0000
|
||||
#define USB_CDC_AUX_JACK_OFF_HOOK \
|
||||
0x0001
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// USB_CDC_NOTIFY_SERIAL_STATE, Data
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Number of bytes of data returned alongside this notification.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define USB_CDC_NOTIFY_SERIAL_STATE_SIZE \
|
||||
2
|
||||
|
||||
#define USB_CDC_SERIAL_STATE_OVERRUN \
|
||||
0x0040
|
||||
#define USB_CDC_SERIAL_STATE_PARITY \
|
||||
0x0020
|
||||
#define USB_CDC_SERIAL_STATE_FRAMING \
|
||||
0x0010
|
||||
#define USB_CDC_SERIAL_STATE_RING_SIGNAL \
|
||||
0x0008
|
||||
#define USB_CDC_SERIAL_STATE_BREAK \
|
||||
0x0004
|
||||
#define USB_CDC_SERIAL_STATE_TXCARRIER \
|
||||
0x0002
|
||||
#define USB_CDC_SERIAL_STATE_RXCARRIER \
|
||||
0x0001
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// USB_CDC_NOTIFY_CALL_STATE_CHANGE, wValue
|
||||
//
|
||||
// Call state values are defined above in the group beginning
|
||||
// USB_CDC_CALL_STATE_IDLE. Note that the data returned alongside this
|
||||
// notification are heavily dependent upon the call state being reported so no
|
||||
// specific lengths or access macros are provided here.
|
||||
//
|
||||
// Macro to construct the correct wValue for this notification given a state
|
||||
// and call index.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define SetNotifyCallStatewValue(pi16Result, ui8CallState, ui8Index) \
|
||||
do \
|
||||
{ \
|
||||
(WORD(pi16Result)) = (((ui8CallState) & 0xFF) + \
|
||||
(((ui8Index) & 0xFF) << 8)); \
|
||||
} \
|
||||
while(0)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// USB_CDC_NOTIFY_LINE_STATE_CHANGE, wValue
|
||||
//
|
||||
// Note that the data returned alongside this notification are heavily
|
||||
// dependent upon the call state being reported so no specific lengths or
|
||||
// access macros are provided here.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define USB_CDC_LINE_STATE_IDLE 0x0000
|
||||
#define USB_CDC_LINE_STATE_HOLD 0x0001
|
||||
#define USB_CDC_LINE_STATE_OFF_HOOK \
|
||||
0x0002
|
||||
#define USB_CDC_LINE_STATE_ON_HOOK \
|
||||
0x0003
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// USB_CDC_NOTIFY_CONNECTION_SPEED_CHANGE, Data
|
||||
//
|
||||
// Macro to populate the 8 byte data structure returned alongside this
|
||||
// notification.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define SetNotifyConnectionSpeedChange(pi8Buf, ui32USBitRate, ui32DSBitRate) \
|
||||
do \
|
||||
{ \
|
||||
LONG(pi8Buf) = ui32USBitRate; \
|
||||
LONG((uint8_t *)(pi8Buf) + 4) = ui32DSBitRate; \
|
||||
} \
|
||||
while(0)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Packed structure definitions for request/response data blocks
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// All structures defined in this section of the header require byte packing of
|
||||
// fields. This is usually accomplished using the PACKED macro but, for IAR
|
||||
// Embedded Workbench, this requires a pragma.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#ifdef ewarm
|
||||
#pragma pack(1)
|
||||
#endif
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! USB_CDC_GET/SET_LINE_CODING request-specific data.
|
||||
//
|
||||
//*****************************************************************************
|
||||
typedef struct
|
||||
{
|
||||
//
|
||||
//! The data terminal rate in bits per second.
|
||||
//
|
||||
uint32_t ui32Rate;
|
||||
|
||||
//
|
||||
//! The number of stop bits. Valid values are USB_CDC_STOP_BITS_1,
|
||||
//! USB_CDC_STOP_BITS_1_5 or USB_CDC_STOP_BITS_2
|
||||
//
|
||||
uint8_t ui8Stop;
|
||||
|
||||
//
|
||||
//! The parity setting. Valid values are USB_CDC_PARITY_NONE,
|
||||
//! USB_CDC_PARITY_ODD, USB_CDC_PARITY_EVEN, USB_CDC_PARITY_MARK and
|
||||
//! USB_CDC_PARITY_SPACE.
|
||||
//
|
||||
uint8_t ui8Parity;
|
||||
|
||||
//
|
||||
//! The number of data bits per character. Valid values are 5, 6, 7 and 8
|
||||
//! in this implementation.
|
||||
//
|
||||
uint8_t ui8Databits;
|
||||
}
|
||||
PACKED tLineCoding;
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Return to default packing when using the IAR Embedded Workbench compiler.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#ifdef ewarm
|
||||
#pragma pack()
|
||||
#endif
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Close the Doxygen group.
|
||||
//! @}
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Mark the end of the C bindings section for C++ compilers.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // __USBCDC_H__
|
|
@ -0,0 +1,480 @@
|
|||
//*****************************************************************************
|
||||
//
|
||||
// usbdesc.c - USB descriptor parsing functions.
|
||||
//
|
||||
// Copyright (c) 2008-2013 Texas Instruments Incorporated. All rights reserved.
|
||||
// Software License Agreement
|
||||
//
|
||||
// Texas Instruments (TI) is supplying this software for use solely and
|
||||
// exclusively on TI's microcontroller products. The software is owned by
|
||||
// TI and/or its suppliers, and is protected under applicable copyright
|
||||
// laws. You may not combine this software with "viral" open-source
|
||||
// software in order to form a larger program.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
|
||||
// NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
|
||||
// NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
|
||||
// CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
|
||||
// DAMAGES, FOR ANY REASON WHATSOEVER.
|
||||
//
|
||||
// This is part of revision 1.1 of the Tiva USB Library.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "inc/hw_types.h"
|
||||
#include "usblib/usblib.h"
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Assumptions:
|
||||
// ------------
|
||||
//
|
||||
// The following assumptions are made in this module. From reading chapter 9
|
||||
// of the USB 2.0 specification, these appear to be perfectly valid.
|
||||
//
|
||||
// 1. The interface number, bInterfaceNumber in the interface descriptor, is
|
||||
// a zero based index and takes values between 0 and
|
||||
// (pConfigDescriptor->bNumInterfaces - 1) inclusive.
|
||||
// 2. Similarly, the alternate setting number, bAlternateSetting in the
|
||||
// interface descriptor, is a zero based index.
|
||||
// 3. Interface descriptors are ordered by interface number in the
|
||||
// configuration descriptor.
|
||||
// 4. If alternate settings are available for an interface, the interface
|
||||
// descriptors are ordered by alternate setting value bAlternateSetting.
|
||||
// 5. Although the endpoints associated with a given interface must follow
|
||||
// their associated interface descriptor, it is possible for other,
|
||||
// device specific descriptors to be found between an interface descriptor
|
||||
// and its endpoints or between endpoint descriptors for the same
|
||||
// interface.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! \addtogroup general_usblib_api
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! Determines the number of individual descriptors of a particular type within
|
||||
//! a supplied buffer.
|
||||
//!
|
||||
//! \param psDesc points to the first byte of a block of standard USB
|
||||
//! descriptors.
|
||||
//! \param ui32Size is the number of bytes of descriptor data found at pointer
|
||||
//! \e psDesc.
|
||||
//! \param ui32Type identifies the type of descriptor that is to be counted.
|
||||
//! If the value is \b USB_DESC_ANY, the function returns the total number of
|
||||
//! descriptors regardless of type.
|
||||
//!
|
||||
//! This function can be used to count the number of descriptors of a
|
||||
//! particular type within a block of descriptors. The caller can provide a
|
||||
//! specific type value which the function matches against the second byte of
|
||||
//! each descriptor or, alternatively, can specify \b USB_DESC_ANY to have the
|
||||
//! function count all descriptors regardless of their type.
|
||||
//!
|
||||
//! \return Returns the number of descriptors found in the supplied block of
|
||||
//! data.
|
||||
//
|
||||
//*****************************************************************************
|
||||
uint32_t
|
||||
USBDescGetNum(tDescriptorHeader *psDesc, uint32_t ui32Size,
|
||||
uint32_t ui32Type)
|
||||
{
|
||||
tDescriptorHeader *psDescCheck;
|
||||
uint32_t ui32TotLength;
|
||||
uint32_t ui32Count;
|
||||
|
||||
//
|
||||
// Set up for our descriptor counting loop.
|
||||
//
|
||||
psDescCheck = psDesc;
|
||||
ui32TotLength = 0;
|
||||
ui32Count = 0;
|
||||
|
||||
//
|
||||
// Keep looking through the supplied data until we reach the end.
|
||||
//
|
||||
while(ui32TotLength < ui32Size)
|
||||
{
|
||||
//
|
||||
// Does this descriptor match the type passed (if a specific type
|
||||
// has been specified)?
|
||||
//
|
||||
if((ui32Type == USB_DESC_ANY) ||
|
||||
(psDescCheck->bDescriptorType == (uint8_t)(ui32Type & 0xFF)))
|
||||
{
|
||||
ui32Count++;
|
||||
}
|
||||
|
||||
//
|
||||
// Move on to the next descriptor.
|
||||
//
|
||||
ui32TotLength += (uint32_t)psDescCheck->bLength;
|
||||
psDescCheck = NEXT_USB_DESCRIPTOR(psDescCheck);
|
||||
}
|
||||
|
||||
//
|
||||
// Return the descriptor count to the caller.
|
||||
//
|
||||
return(ui32Count);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! Determines the number of individual descriptors of a particular type within
|
||||
//! a supplied buffer.
|
||||
//!
|
||||
//! \param psDesc points to the first byte of a block of standard USB
|
||||
//! descriptors.
|
||||
//! \param ui32Size is the number of bytes of descriptor data found at pointer
|
||||
//! \e psDesc.
|
||||
//! \param ui32Type identifies the type of descriptor that is to be found. If
|
||||
//! the value is \b USB_DESC_ANY, the function returns a pointer to the n-th
|
||||
//! descriptor regardless of type.
|
||||
//! \param ui32Index is the zero based index of the descriptor whose pointer is
|
||||
//! to be returned. For example, passing value 1 in \e ui32Index returns the
|
||||
//! second matching descriptor.
|
||||
//!
|
||||
//! Return a pointer to the n-th descriptor of a particular type found in the
|
||||
//! block of \e ui32Size bytes starting at \e psDesc.
|
||||
//!
|
||||
//! \return Returns a pointer to the header of the required descriptor if
|
||||
//! found or NULL otherwise.
|
||||
//
|
||||
//*****************************************************************************
|
||||
tDescriptorHeader *
|
||||
USBDescGet(tDescriptorHeader *psDesc, uint32_t ui32Size,
|
||||
uint32_t ui32Type, uint32_t ui32Index)
|
||||
{
|
||||
tDescriptorHeader *psDescCheck;
|
||||
uint32_t ui32TotLength;
|
||||
uint32_t ui32Count;
|
||||
|
||||
//
|
||||
// Set up for our descriptor counting loop.
|
||||
//
|
||||
psDescCheck = psDesc;
|
||||
ui32TotLength = 0;
|
||||
ui32Count = 0;
|
||||
|
||||
//
|
||||
// Keep looking through the supplied data until we reach the end.
|
||||
//
|
||||
while(ui32TotLength < ui32Size)
|
||||
{
|
||||
//
|
||||
// Does this descriptor match the type passed (if a specific type
|
||||
// has been specified)?
|
||||
//
|
||||
if((ui32Type == USB_DESC_ANY) ||
|
||||
(psDescCheck->bDescriptorType == (uint8_t)(ui32Type & 0xFF)))
|
||||
{
|
||||
//
|
||||
// We found a matching descriptor. If our count matches the
|
||||
// supplied index, we are done so return the pointer.
|
||||
//
|
||||
if(ui32Count == ui32Index)
|
||||
{
|
||||
return(psDescCheck);
|
||||
}
|
||||
|
||||
//
|
||||
// We have not found enough descriptors yet to satisfy the supplied
|
||||
// index so increment our count and continue.
|
||||
//
|
||||
ui32Count++;
|
||||
}
|
||||
|
||||
//
|
||||
// Move on to the next descriptor.
|
||||
//
|
||||
ui32TotLength += (uint32_t)psDescCheck->bLength;
|
||||
psDescCheck = NEXT_USB_DESCRIPTOR(psDescCheck);
|
||||
}
|
||||
|
||||
//
|
||||
// If we get here, we reached the end of the data without finding the
|
||||
// required descriptor. Return NULL.
|
||||
//
|
||||
return((tDescriptorHeader *)0);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! Determines the number of different alternate configurations for a given
|
||||
//! interface within a configuration descriptor.
|
||||
//!
|
||||
//! \param psConfig points to the first byte of a standard USB configuration
|
||||
//! descriptor.
|
||||
//! \param ui8InterfaceNumber is the interface number for which the number of
|
||||
//! alternate configurations is to be counted.
|
||||
//!
|
||||
//! This function can be used to count the number of alternate settings for a
|
||||
//! specific interface within a configuration.
|
||||
//!
|
||||
//! \return Returns the number of alternate versions of the specified interface
|
||||
//! or 0 if the interface number supplied cannot be found in the config
|
||||
//! descriptor.
|
||||
//
|
||||
//*****************************************************************************
|
||||
uint32_t
|
||||
USBDescGetNumAlternateInterfaces(tConfigDescriptor *psConfig,
|
||||
uint8_t ui8InterfaceNumber)
|
||||
{
|
||||
tDescriptorHeader *psDescCheck;
|
||||
uint32_t ui32TotLength;
|
||||
uint32_t ui32Count;
|
||||
|
||||
//
|
||||
// Set up for our descriptor counting loop.
|
||||
//
|
||||
psDescCheck = (tDescriptorHeader *)psConfig;
|
||||
ui32TotLength = 0;
|
||||
ui32Count = 0;
|
||||
|
||||
//
|
||||
// Keep looking through the supplied data until we reach the end.
|
||||
//
|
||||
while(ui32TotLength < (uint32_t)psConfig->wTotalLength)
|
||||
{
|
||||
//
|
||||
// Is this an interface descriptor with the required interface number?
|
||||
//
|
||||
if((psDescCheck->bDescriptorType == USB_DTYPE_INTERFACE) &&
|
||||
(((tInterfaceDescriptor *)psDescCheck)->bInterfaceNumber ==
|
||||
ui8InterfaceNumber))
|
||||
{
|
||||
//
|
||||
// Yes - increment our count.
|
||||
//
|
||||
ui32Count++;
|
||||
}
|
||||
|
||||
//
|
||||
// Move on to the next descriptor.
|
||||
//
|
||||
ui32TotLength += (uint32_t)psDescCheck->bLength;
|
||||
psDescCheck = NEXT_USB_DESCRIPTOR(psDescCheck);
|
||||
}
|
||||
|
||||
//
|
||||
// Return the descriptor count to the caller.
|
||||
//
|
||||
return(ui32Count);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! Returns a pointer to the n-th interface descriptor in a config descriptor
|
||||
//! with the supplied interface number.
|
||||
//!
|
||||
//! \param psConfig points to the first byte of a standard USB configuration
|
||||
//! descriptor.
|
||||
//! \param ui8InterfaceNumber is the interface number of the descriptor that is
|
||||
//! being queried.
|
||||
//! \param ui32Index is the zero based index of the descriptor to return.
|
||||
//!
|
||||
//! This function returns a pointer to the n-th interface descriptor in the
|
||||
//! supplied configuration which has the requested interface number. It may be
|
||||
//! used by a client to retrieve the descriptors for each alternate setting
|
||||
//! of a given interface within the configuration passed.
|
||||
//!
|
||||
//! \return Returns a pointer to the n-th interface descriptor with interface
|
||||
//! number as specified or NULL of this descriptor does not exist.
|
||||
//
|
||||
//*****************************************************************************
|
||||
static tInterfaceDescriptor *
|
||||
USBDescGetAlternateInterface(tConfigDescriptor *psConfig,
|
||||
uint8_t ui8InterfaceNumber,
|
||||
uint32_t ui32Index)
|
||||
{
|
||||
tDescriptorHeader *psDescCheck;
|
||||
uint32_t ui32TotLength;
|
||||
uint32_t ui32Count;
|
||||
|
||||
//
|
||||
// Set up for our descriptor counting loop.
|
||||
//
|
||||
psDescCheck = (tDescriptorHeader *)psConfig;
|
||||
ui32TotLength = 0;
|
||||
ui32Count = 0;
|
||||
|
||||
//
|
||||
// Keep looking through the supplied data until we reach the end.
|
||||
//
|
||||
while(ui32TotLength < (uint32_t)psConfig->wTotalLength)
|
||||
{
|
||||
//
|
||||
// Does this descriptor match the type passed (if a specific type
|
||||
// has been specified)?
|
||||
//
|
||||
if((psDescCheck->bDescriptorType == USB_DTYPE_INTERFACE) &&
|
||||
(((tInterfaceDescriptor *)psDescCheck)->bInterfaceNumber ==
|
||||
ui8InterfaceNumber))
|
||||
{
|
||||
//
|
||||
// This is an interface descriptor for interface
|
||||
// ui8InterfaceNumber. Determine if this is the n-th one we have
|
||||
// found and, if so, return its pointer.
|
||||
//
|
||||
if(ui32Count == ui32Index)
|
||||
{
|
||||
//
|
||||
// Found it - return the pointer.
|
||||
//
|
||||
return((tInterfaceDescriptor *)psDescCheck);
|
||||
}
|
||||
|
||||
//
|
||||
// Increment our count of matching descriptors found and go back
|
||||
// to look for another since we have not yet reached the n-th
|
||||
// match.
|
||||
//
|
||||
ui32Count++;
|
||||
}
|
||||
|
||||
//
|
||||
// Move on to the next descriptor.
|
||||
//
|
||||
ui32TotLength += (uint32_t)psDescCheck->bLength;
|
||||
psDescCheck = NEXT_USB_DESCRIPTOR(psDescCheck);
|
||||
}
|
||||
|
||||
//
|
||||
// If we drop out the end of the loop, we did not find the requested
|
||||
// descriptor so return NULL.
|
||||
//
|
||||
return((tInterfaceDescriptor *)0);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! Returns a pointer to the n-th interface descriptor in a configuration
|
||||
//! descriptor that applies to the supplied alternate setting number.
|
||||
//!
|
||||
//! \param psConfig points to the first byte of a standard USB configuration
|
||||
//! descriptor.
|
||||
//! \param ui32Index is the zero based index of the interface that is to be
|
||||
//! found. If \e ui32Alt is set to a value other than \b USB_DESC_ANY, this
|
||||
//! will be equivalent to the interface number being searched for.
|
||||
//! \param ui32Alt is the alternate setting number which is to be
|
||||
//! searched for. If this value is \b USB_DESC_ANY, the alternate setting
|
||||
//! is ignored and all interface descriptors are considered in the search.
|
||||
//!
|
||||
//! Return a pointer to the n-th interface descriptor found in the supplied
|
||||
//! configuration descriptor. If \e ui32Alt is not \b USB_DESC_ANY, only
|
||||
//! interface descriptors which are part of the supplied alternate setting are
|
||||
//! considered in the search otherwise all interface descriptors are
|
||||
//! considered.
|
||||
//!
|
||||
//! Note that, although alternate settings can be applied on an interface-by-
|
||||
//! interface basis, the number of interfaces offered is fixed for a given
|
||||
//! config descriptor. Hence, this function will correctly find the unique
|
||||
//! interface descriptor for that interface's alternate setting number
|
||||
//! \e ui32Alt if \e ui32Index is set to the required interface number and
|
||||
//! \e ui32Alt is set to a valid alternate setting number for that interface.
|
||||
//!
|
||||
//! \return Returns a pointer to the required interface descriptor if
|
||||
//! found or NULL otherwise.
|
||||
//
|
||||
//*****************************************************************************
|
||||
tInterfaceDescriptor *
|
||||
USBDescGetInterface(tConfigDescriptor *psConfig, uint32_t ui32Index,
|
||||
uint32_t ui32Alt)
|
||||
{
|
||||
//
|
||||
// If we are being told to ignore the alternate configuration, this boils
|
||||
// down to a very simple query.
|
||||
//
|
||||
if(ui32Alt == USB_DESC_ANY)
|
||||
{
|
||||
//
|
||||
// Return the ui32Index-th interface descriptor we find in the
|
||||
// configuration descriptor.
|
||||
//
|
||||
return((tInterfaceDescriptor *)USBDescGet(
|
||||
(tDescriptorHeader *)psConfig,
|
||||
(uint32_t)psConfig->wTotalLength,
|
||||
USB_DTYPE_INTERFACE, ui32Index));
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
// In this case, a specific alternate setting number is required.
|
||||
// Given that interface numbers are zero based indices, we can
|
||||
// pass the supplied ui32Index parameter directly as the interface
|
||||
// number to USBDescGetAlternateInterface to retrieve the requested
|
||||
// interface descriptor pointer.
|
||||
//
|
||||
return(USBDescGetAlternateInterface(psConfig, ui32Index, ui32Alt));
|
||||
}
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! Return a pointer to the n-th endpoint descriptor in the supplied
|
||||
//! interface descriptor.
|
||||
//!
|
||||
//! \param psInterface points to the first byte of a standard USB interface
|
||||
//! descriptor.
|
||||
//! \param ui32Index is the zero based index of the endpoint that is to be
|
||||
//! found.
|
||||
//! \param ui32Size contains the maximum number of bytes that the function may
|
||||
//! search beyond \e psInterface while looking for the requested endpoint
|
||||
//! descriptor.
|
||||
//!
|
||||
//! Return a pointer to the n-th endpoint descriptor found in the supplied
|
||||
//! interface descriptor. If the \e ui32Index parameter is invalid (greater
|
||||
//! than or equal to the bNumEndpoints field of the interface descriptor) or
|
||||
//! the endpoint cannot be found within \e ui32Size bytes of the interface
|
||||
//! descriptor pointer, the function will return NULL.
|
||||
//!
|
||||
//! Note that, although the USB 2.0 specification states that endpoint
|
||||
//! descriptors must follow the interface descriptor that they relate to, it
|
||||
//! also states that device specific descriptors should follow any standard
|
||||
//! descriptor that they relate to. As a result, we cannot assume that each
|
||||
//! interface descriptor will be followed by nothing but an ordered list of
|
||||
//! its own endpoints and, hence, the function needs to be provided \e ui32Size
|
||||
//! to limit the search range.
|
||||
//!
|
||||
//! \return Returns a pointer to the requested endpoint descriptor if
|
||||
//! found or NULL otherwise.
|
||||
//
|
||||
//*****************************************************************************
|
||||
tEndpointDescriptor *
|
||||
USBDescGetInterfaceEndpoint(tInterfaceDescriptor *psInterface,
|
||||
uint32_t ui32Index, uint32_t ui32Size)
|
||||
{
|
||||
//
|
||||
// Is the index passed valid?
|
||||
//
|
||||
if(ui32Index >= psInterface->bNumEndpoints)
|
||||
{
|
||||
//
|
||||
// It's out of bounds so return a NULL.
|
||||
//
|
||||
return((tEndpointDescriptor *)0);
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
// Endpoint index is valid so find the descriptor.
|
||||
//
|
||||
return((tEndpointDescriptor *)USBDescGet(
|
||||
(tDescriptorHeader *)psInterface,
|
||||
ui32Size, USB_DTYPE_ENDPOINT, ui32Index));
|
||||
}
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Close the Doxygen group.
|
||||
//! @}
|
||||
//
|
||||
//*****************************************************************************
|
|
@ -0,0 +1,504 @@
|
|||
//*****************************************************************************
|
||||
//
|
||||
// usbdfu.h - Definitions related to the USB Device Firmware Upgrade class.
|
||||
//
|
||||
// Copyright (c) 2008-2013 Texas Instruments Incorporated. All rights reserved.
|
||||
// Software License Agreement
|
||||
//
|
||||
// Texas Instruments (TI) is supplying this software for use solely and
|
||||
// exclusively on TI's microcontroller products. The software is owned by
|
||||
// TI and/or its suppliers, and is protected under applicable copyright
|
||||
// laws. You may not combine this software with "viral" open-source
|
||||
// software in order to form a larger program.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
|
||||
// NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
|
||||
// NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
|
||||
// CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
|
||||
// DAMAGES, FOR ANY REASON WHATSOEVER.
|
||||
//
|
||||
// This is part of revision 1.1 of the Tiva USB Library.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
#ifndef __USBDFU_H__
|
||||
#define __USBDFU_H__
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// DFU attributes as published in the functional descriptor.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define DFU_ATTR_WILL_DETACH 0x08
|
||||
#define DFU_ATTR_MANIFEST_TOLERANT \
|
||||
0x04
|
||||
#define DFU_ATTR_CAN_UPLOAD 0x02
|
||||
#define DFU_ATTR_CAN_DOWNLOAD 0x01
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// The states that the DFU device can be in. These values are reported to
|
||||
// the host in response to a USBD_DFU_REQUEST_GETSTATE request.
|
||||
//
|
||||
//*****************************************************************************
|
||||
typedef enum
|
||||
{
|
||||
eDFUStateAppIdle = 0,
|
||||
eDFUStateAppDetach,
|
||||
eDFUStateIdle,
|
||||
eDFUStateDnloadSync,
|
||||
eDFUStateDnBusy,
|
||||
eDFUStateDnloadIdle,
|
||||
eDFUStateManifestSync,
|
||||
eDFUStateManifest,
|
||||
eDFUStateManifestWaitReset,
|
||||
eDFUStateUploadIdle,
|
||||
eDFUStateError
|
||||
}
|
||||
tDFUState;
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// The current error status of the DFU device. These values are reported to
|
||||
// the host in response to a USBD_DFU_REQUEST_GETSTATUS request.
|
||||
//
|
||||
//*****************************************************************************
|
||||
typedef enum
|
||||
{
|
||||
eDFUStatusOk = 0,
|
||||
eDFUStatusErrTarget,
|
||||
eDFUStatusErrFile,
|
||||
eDFUStatusErrWrite,
|
||||
eDFUStatusErrErase,
|
||||
eDFUStatusErrCheckErased,
|
||||
eDFUStatusErrProg,
|
||||
eDFUStatusErrVerify,
|
||||
eDFUStatusErrAddress,
|
||||
eDFUStatusErrNotDone,
|
||||
eDFUStatusErrFirmware,
|
||||
eDFUStatusErrVendor,
|
||||
eDFUStatusErrUSBR,
|
||||
eDFUStatusErrPOR,
|
||||
eDFUStatusErrUnknown,
|
||||
eDFUStatusErrStalledPkt
|
||||
}
|
||||
tDFUStatus;
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// The descriptor type for the DFU functional descriptor.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define USB_DFU_FUNC_DESCRIPTOR_TYPE \
|
||||
0x21
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// The subclass identifier for DFU as reported to the host in the
|
||||
// bInterfaceSubClass field of the DFU interface descriptor.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define USB_DFU_SUBCLASS 0x01
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// The protocol identifier for DFU as reported to the host in the
|
||||
// bInterfaceProtocol field of the DFU interface descriptor.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define USB_DFU_PROTOCOL 0x02
|
||||
#define USB_DFU_RUNTIME_PROTOCOL \
|
||||
0x01
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// DFU class-specific request identifiers.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define USBD_DFU_REQUEST_DETACH 0
|
||||
#define USBD_DFU_REQUEST_DNLOAD 1
|
||||
#define USBD_DFU_REQUEST_UPLOAD 2
|
||||
#define USBD_DFU_REQUEST_GETSTATUS \
|
||||
3
|
||||
#define USBD_DFU_REQUEST_CLRSTATUS \
|
||||
4
|
||||
#define USBD_DFU_REQUEST_GETSTATE \
|
||||
5
|
||||
#define USBD_DFU_REQUEST_ABORT 6
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Request 1KB blocks from the host. This value is published in the USB
|
||||
// functional descriptor.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define DFU_TRANSFER_SIZE 1024
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// USBLib-specific request identifier. This is used to determine whether
|
||||
// the target device supports our DFU command protocol. It is expected that
|
||||
// a device not supporting our extensions will stall this request. This
|
||||
// request is only supported while the DFU device is in eDFUStateIdle.
|
||||
//
|
||||
// An IN request containing the following parameters will result in the device
|
||||
// sending back a tDFUQueryTivaProtocol structure indicating that
|
||||
// USBLib extensions are supported. The actual values in wValue and wIndex
|
||||
// have no meaning other than to act as markers in the unlikely event that
|
||||
// another DFU device also chooses to use request ID 0x42 for some other
|
||||
// purpose.
|
||||
//
|
||||
// wValue - 0x23(REQUEST_TIVA_VALUE)
|
||||
// wIndex - Interface number
|
||||
// wLength - sizeof(tDFUQueryTivaProtocol)
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define USBD_DFU_REQUEST_TIVA 0x42
|
||||
#define REQUEST_TIVA_VALUE 0x23
|
||||
|
||||
#define DFU_PROTOCOL_TIVA_MARKER \
|
||||
0x4C4D
|
||||
#define DFU_PROTOCOL_TIVA_VERSION_1 \
|
||||
0x0001
|
||||
|
||||
#ifdef ewarm
|
||||
#pragma pack(1)
|
||||
#endif
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// The structure sent to the host when a valid USBD_DFU_REQUEST_TIVA is
|
||||
// received while the DFU device is in idle state.
|
||||
//
|
||||
//*****************************************************************************
|
||||
typedef struct
|
||||
{
|
||||
//
|
||||
// The protocol marker(DFU_PROTOCOL_TIVA_MARKER)
|
||||
//
|
||||
uint16_t ui16Marker;
|
||||
|
||||
//
|
||||
// The protocol version(DFU_PROTOCOL_TIVA_VERSION_1)
|
||||
//
|
||||
uint16_t ui16Version;
|
||||
}
|
||||
PACKED tDFUQueryTivaProtocol;
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Structure sent to the host in response to USBD_DFU_REQUEST_GETSTATUS.
|
||||
//
|
||||
//*****************************************************************************
|
||||
typedef struct
|
||||
{
|
||||
uint8_t bStatus;
|
||||
uint8_t bwPollTimeout[3];
|
||||
uint8_t bState;
|
||||
uint8_t iString;
|
||||
}
|
||||
PACKED tDFUGetStatusResponse;
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Firmware Download Commands
|
||||
//
|
||||
// The data passed on a USBD_DFU_REQUEST_DNLOAD request is comprised of a
|
||||
// header which instructs the boot loader how to interpret the block and
|
||||
// block-specific data. The following definitions relate to the download
|
||||
// block headers.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Supported command identifiers
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define DFU_CMD_PROG 0x01
|
||||
#define DFU_CMD_READ 0x02
|
||||
#define DFU_CMD_CHECK 0x03
|
||||
#define DFU_CMD_ERASE 0x04
|
||||
#define DFU_CMD_INFO 0x05
|
||||
#define DFU_CMD_BIN 0x06
|
||||
#define DFU_CMD_RESET 0x07
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Generic download command header.
|
||||
//
|
||||
//*****************************************************************************
|
||||
typedef struct
|
||||
{
|
||||
//
|
||||
// Command identifier.
|
||||
//
|
||||
uint8_t ui8Command;
|
||||
|
||||
//
|
||||
// Command-specific data elements.
|
||||
//
|
||||
uint8_t pui8Data[7];
|
||||
}
|
||||
PACKED tDFUDownloadHeader;
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Header for the DFU_CMD_PROG command.
|
||||
//
|
||||
// This command is used to program a section of the flash with the binary data
|
||||
// which immediately follows the header. The start address of the data is
|
||||
// expressed as a 1KB block number so 0 would represent the bottom of flash
|
||||
// (which, incidentally, the USB boot loader will not let you program) and 0x10
|
||||
// would represent address 16KB or 16384 (0x4000). The ui32Length field
|
||||
// contains the total number of bytes of data in the following programming
|
||||
// operation. The DFU device will not look for any command header on following
|
||||
// USBD_DFU_REQUEST_DNLOAD requests until the operation is completed or
|
||||
// aborted.
|
||||
//
|
||||
// By using this protocol, the DFU_CMD_PROG command header may be used as a
|
||||
// simple header on the binary files to be sent to the DFU device for
|
||||
// programming. If we enforce the requirement that the DFU_CMD_PROG header is
|
||||
// applied to each USBD_DFU_REQUEST_DNLOAD (one per block), this means that the
|
||||
// host-side DFU application must be aware of the underlying protocol and
|
||||
// insert these headers dynamically during programming operations. This could
|
||||
// be handled by post processing the binary to insert the headers at the
|
||||
// appropriate points but this would then tie the binary structure to the
|
||||
// chosen transfer size and break the operation if the transfer size were to
|
||||
// change in the future.
|
||||
//
|
||||
//*****************************************************************************
|
||||
typedef struct
|
||||
{
|
||||
//
|
||||
// DFU_CMD_PROG
|
||||
//
|
||||
uint8_t ui8Command;
|
||||
|
||||
//
|
||||
// Reserved - set to 0x00.
|
||||
//
|
||||
uint8_t ui8Reserved;
|
||||
|
||||
//
|
||||
// Block start address / 1024
|
||||
//
|
||||
uint16_t ui16StartAddr;
|
||||
|
||||
//
|
||||
// Total length, in bytes, of following data for the complete download
|
||||
// operation.
|
||||
//
|
||||
uint32_t ui32Length;
|
||||
}
|
||||
PACKED tDFUDownloadProgHeader;
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Header for the DFU_CMD_READ and DFU_CMD_CHECK commands.
|
||||
//
|
||||
// This command may be used to set the address range whose content will be
|
||||
// returned on subsequent USBD_DFU_REQUEST_UPLOAD requests from the host.
|
||||
//
|
||||
// To read back a the contents of a region of flash, the host should send
|
||||
// USBD_DFU_REQUEST_DNLOAD with ui8Command DFU_CMD_READ, ui16StartAddr set to
|
||||
// the 1KB block start address and ui32Length set to the number of bytes to
|
||||
// read. The host should then send one or more USBD_DFU_REQUEST_UPLOAD
|
||||
// requests to receive the current flash contents from the configured
|
||||
// addresses. Data returned will include an 8 byte DFU_CMD_PROG prefix
|
||||
// structure unless the prefix has been disabled by sending a DFU_CMD_BIN
|
||||
// command with the bBinary parameter set to 1.
|
||||
//
|
||||
// To check that a region of flash is erased, the DFU_CMD_CHECK command should
|
||||
// be sent with ui16StartAddr and ui32Length set to describe the region to
|
||||
// check. The host should then send a USBD_DFU_REQUEST_GETSTATUS. If the
|
||||
// erase check was successful, the returned bStatus value will be STATUS_OK,
|
||||
// otherwise it will be STATUS_ERR_CHECK_ERASED. Note that ui32Length passed
|
||||
// must be a multiple of 4. If this is not the case, the value will be
|
||||
// truncated before the check is performed.
|
||||
//
|
||||
//*****************************************************************************
|
||||
typedef struct
|
||||
{
|
||||
//
|
||||
// DFU_CMD_READ or DFU_CMD_CHECK
|
||||
//
|
||||
uint8_t ui8Command;
|
||||
|
||||
//
|
||||
// Reserved - write to 0
|
||||
//
|
||||
uint8_t ui8Reserved;
|
||||
|
||||
//
|
||||
// Block start address / 1024
|
||||
//
|
||||
uint16_t ui16StartAddr;
|
||||
|
||||
//
|
||||
// The number of bytes of data to read back or check.
|
||||
//
|
||||
uint32_t ui32Length;
|
||||
}
|
||||
PACKED tDFUDownloadReadCheckHeader;
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Header for the DFU_CMD_ERASE command.
|
||||
//
|
||||
// This command may be used to erase a number of flash blocks. The address of
|
||||
// the first block to be erased is passed in ui16StartAddr with ui16NumBlocks
|
||||
// containing the number of blocks to be erased from this address. The block
|
||||
// size of the device may be determined using the DFU_CMD_INFO command.
|
||||
//
|
||||
//*****************************************************************************
|
||||
typedef struct
|
||||
{
|
||||
//
|
||||
// DFU_CMD_ERASE
|
||||
//
|
||||
uint8_t ui8Command;
|
||||
|
||||
//
|
||||
// Reserved - set to 0.
|
||||
//
|
||||
uint8_t ui8Reserved;
|
||||
|
||||
//
|
||||
// Block start address / 1024
|
||||
//
|
||||
uint16_t ui16StartAddr;
|
||||
|
||||
//
|
||||
// The number of blocks to erase.
|
||||
//
|
||||
uint16_t ui16NumBlocks;
|
||||
|
||||
//
|
||||
// Reserved - set to 0.
|
||||
//
|
||||
uint8_t pui8Reserved2[2];
|
||||
}
|
||||
PACKED tDFUDownloadEraseHeader;
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Header for the DFU_CMD_INFO command.
|
||||
//
|
||||
// This command may be used to query information about the connected device.
|
||||
// After sending the command, the information is returned on the next
|
||||
// USBD_DFU_REQUEST_UPLOAD request.
|
||||
//
|
||||
//*****************************************************************************
|
||||
typedef struct
|
||||
{
|
||||
//
|
||||
// DFU_CMD_INFO
|
||||
//
|
||||
uint8_t ui8Command;
|
||||
|
||||
//
|
||||
// Reserved - set to 0.
|
||||
//
|
||||
uint8_t pui8Reserved[7];
|
||||
}
|
||||
PACKED tDFUDownloadInfoHeader;
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Header for the DFU_CMD_BIN command.
|
||||
//
|
||||
// This command may be used to set the format of uploaded data. By default,
|
||||
// images read using USBD_DFU_REQUEST_UPLOAD are formatted with the appropriate
|
||||
// header to allow the same image to be flashed back to the device and have it
|
||||
// located at the address from which it originated. This is a requirement of
|
||||
// the DFU class specification (section 6.2 "the uploaded image must be
|
||||
// usable in a subsequent download") but may not be helpful in some cases where
|
||||
// the application wishes to receive only the binary image from flash. To
|
||||
// instruct the DFU device to omit the position and size header, send this
|
||||
// command with the bBinary field set to \b true prior to issuing a
|
||||
// USBD_DFU_REQUEST_UPLOAD for image data. The format choice remains in effect
|
||||
// until the command is sent once again with bBinary set to \b false.
|
||||
//
|
||||
// Note that the format choice affects only image data sent and not responses
|
||||
// read via USBD_DFU_REQUEST_UPLOAD following USBLib-specific commands such
|
||||
// as DFU_CMD_INFO.
|
||||
//
|
||||
//*****************************************************************************
|
||||
typedef struct
|
||||
{
|
||||
//
|
||||
// DFU_CMD_BIN
|
||||
//
|
||||
uint8_t ui8Command;
|
||||
|
||||
//
|
||||
// Set to true to omit image header or false to include it (the default).
|
||||
//
|
||||
uint8_t ui8Binary;
|
||||
|
||||
//
|
||||
// Reserved - set to 0.
|
||||
//
|
||||
uint8_t pui8Reserved[6];
|
||||
}
|
||||
PACKED tDFUDownloadBinHeader;
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// The DFU_CMD_RESET command uses a tDFUDownloadHeader structure since
|
||||
// only the ui8Command field is important. This command causes an immediate
|
||||
// reset of the the target board.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! Payload returned in response to the DFU_CMD_INFO command.
|
||||
//!
|
||||
//! This is structure is returned in response to the first
|
||||
//! USBD_DFU_REQUEST_UPLOAD request following a DFU_CMD_INFO command.
|
||||
//
|
||||
//*****************************************************************************
|
||||
typedef struct
|
||||
{
|
||||
//
|
||||
//! The size of a flash block in bytes.
|
||||
//
|
||||
uint16_t ui16FlashBlockSize;
|
||||
|
||||
//
|
||||
//! The number of blocks of flash in the device. Total flash size is
|
||||
//! ui16NumFlashBlocks * ui16FlashBlockSize.
|
||||
//
|
||||
uint16_t ui16NumFlashBlocks;
|
||||
|
||||
//
|
||||
//! Information on the part number, family, version and package as
|
||||
//! read from SYSCTL register DID1.
|
||||
//
|
||||
uint32_t ui32PartInfo;
|
||||
|
||||
//
|
||||
//! Information on the part class and revision as read from SYSCTL DID0.
|
||||
//
|
||||
uint32_t ui32ClassInfo;
|
||||
|
||||
//
|
||||
//! Address 1 byte above the highest location the boot loader can access.
|
||||
//
|
||||
uint32_t ui32FlashTop;
|
||||
|
||||
//
|
||||
//! Lowest address the boot loader can write or erase.
|
||||
//
|
||||
uint32_t ui32AppStartAddr;
|
||||
}
|
||||
PACKED tDFUDeviceInfo;
|
||||
|
||||
#ifdef ewarm
|
||||
#pragma pack()
|
||||
#endif
|
||||
|
||||
#endif // __USBDFU_H__
|
|
@ -0,0 +1,885 @@
|
|||
//*****************************************************************************
|
||||
//
|
||||
// usbdma.c - USB Library DMA handling functions.
|
||||
//
|
||||
// Copyright (c) 2012-2013 Texas Instruments Incorporated. All rights reserved.
|
||||
// Software License Agreement
|
||||
//
|
||||
// Texas Instruments (TI) is supplying this software for use solely and
|
||||
// exclusively on TI's microcontroller products. The software is owned by
|
||||
// TI and/or its suppliers, and is protected under applicable copyright
|
||||
// laws. You may not combine this software with "viral" open-source
|
||||
// software in order to form a larger program.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
|
||||
// NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
|
||||
// NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
|
||||
// CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
|
||||
// DAMAGES, FOR ANY REASON WHATSOEVER.
|
||||
//
|
||||
// This is part of revision 1.1 of the Tiva USB Library.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "inc/hw_memmap.h"
|
||||
#include "inc/hw_types.h"
|
||||
#include "inc/hw_ints.h"
|
||||
#include "inc/hw_sysctl.h"
|
||||
#include "inc/hw_udma.h"
|
||||
#include "driverlib/debug.h"
|
||||
#include "driverlib/interrupt.h"
|
||||
#include "driverlib/rtos_bindings.h"
|
||||
#include "driverlib/usbdrv.h"
|
||||
#include "driverlib/rom.h"
|
||||
#include "driverlib/rom_map.h"
|
||||
#include "driverlib/udma.h"
|
||||
#include "usblib/usblib.h"
|
||||
#include "usblib/usblibpriv.h"
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! \addtogroup usblib_dma_api Internal USB DMA functions
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
static tUSBDMAInstance g_psUSBDMAInst[1];
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Macros used to determine if a uDMA endpoint configuration is used for
|
||||
// receive or transmit.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define UDMAConfigIsRx(ui32Config) \
|
||||
((ui32Config & UDMA_SRC_INC_NONE) == UDMA_SRC_INC_NONE)
|
||||
#define UDMAConfigIsTx(ui32Config) \
|
||||
((ui32Config & UDMA_DEST_INC_NONE) == UDMA_DEST_INC_NONE)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// USBLibDMAChannelStatus() for USB controllers that use the uDMA for DMA.
|
||||
//
|
||||
//*****************************************************************************
|
||||
static uint32_t
|
||||
uDMAUSBChannelStatus(tUSBDMAInstance *psUSBDMAInst, uint32_t ui32Channel)
|
||||
{
|
||||
uint32_t ui32Status;
|
||||
|
||||
//
|
||||
// Initialize the current status to no events.
|
||||
//
|
||||
ui32Status = USBLIBSTATUS_DMA_IDLE;
|
||||
|
||||
//
|
||||
// Check if there is a pending DMA transfer.
|
||||
//
|
||||
if(psUSBDMAInst->ui32Complete & (1 << (ui32Channel - 1)))
|
||||
{
|
||||
//
|
||||
// Return that the DMA transfer has completed and clear the
|
||||
// DMA pending flag.
|
||||
//
|
||||
ui32Status = USBLIBSTATUS_DMA_COMPLETE;
|
||||
}
|
||||
else if(psUSBDMAInst->ui32Pending & (1 << (ui32Channel - 1)))
|
||||
{
|
||||
//
|
||||
// DMA transfer is still pending.
|
||||
//
|
||||
ui32Status = USBLIBSTATUS_DMA_PENDING;
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
// DMA transfer is still pending.
|
||||
//
|
||||
ui32Status = USBLIBSTATUS_DMA_IDLE;
|
||||
}
|
||||
|
||||
return(ui32Status);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// USBLibDMAIntStatus() for USB controllers that use uDMA.
|
||||
//
|
||||
//*****************************************************************************
|
||||
static uint32_t
|
||||
uDMAUSBIntStatus(tUSBDMAInstance *psUSBDMAInst)
|
||||
{
|
||||
uint32_t ui32Status, ui32Pending;
|
||||
int32_t i32Channel;
|
||||
|
||||
//
|
||||
// Initialize the current status to no events.
|
||||
//
|
||||
ui32Status = 0;
|
||||
|
||||
//
|
||||
// No pending interrupts by default.
|
||||
//
|
||||
ui32Status = 0;
|
||||
|
||||
//
|
||||
// Save the pending channels.
|
||||
//
|
||||
ui32Pending = psUSBDMAInst->ui32Pending;
|
||||
|
||||
//
|
||||
// Loop through channels to find out if any pending DMA transfers have
|
||||
// completed.
|
||||
//
|
||||
for(i32Channel = 0; i32Channel < USB_MAX_DMA_CHANNELS; i32Channel++)
|
||||
{
|
||||
//
|
||||
// If pending and stopped then the DMA completed.
|
||||
//
|
||||
if((ui32Pending & 1) &&
|
||||
(MAP_uDMAChannelModeGet(i32Channel) == UDMA_MODE_STOP))
|
||||
{
|
||||
ui32Status |= (1 << i32Channel);
|
||||
}
|
||||
ui32Pending >>= 1;
|
||||
|
||||
//
|
||||
// Done if this is zero.
|
||||
//
|
||||
if(ui32Pending == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return(ui32Status);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// USBLibDMAIntStatusClear() for USB controllers that use uDMA for DMA.
|
||||
//
|
||||
//*****************************************************************************
|
||||
static void
|
||||
DMAUSBIntStatusClear(tUSBDMAInstance *psUSBDMAInst, uint32_t ui32Status)
|
||||
{
|
||||
//
|
||||
// Clear out the requested interrupts. Since the USB interface does not
|
||||
// have a true interrupt clear, this clears the current completed
|
||||
// status for the requested channels.
|
||||
//
|
||||
psUSBDMAInst->ui32Complete &= ~ui32Status;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// USBLibDMAIntHandler() for USB controllers that use uDMA for DMA.
|
||||
//
|
||||
//*****************************************************************************
|
||||
static void
|
||||
DMAUSBIntHandler(tUSBDMAInstance *psUSBDMAInst, uint32_t ui32DMAIntStatus)
|
||||
{
|
||||
uint32_t ui32Channel;
|
||||
|
||||
if(ui32DMAIntStatus == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// Determine if the uDMA is used or the USB DMA controller.
|
||||
//
|
||||
for(ui32Channel = 0; ui32Channel < USB_MAX_DMA_CHANNELS; ui32Channel++)
|
||||
{
|
||||
//
|
||||
// Mark any pending interrupts as completed.
|
||||
//
|
||||
if(ui32DMAIntStatus & 1)
|
||||
{
|
||||
psUSBDMAInst->ui32Pending &= ~(1 << ui32Channel);
|
||||
psUSBDMAInst->ui32Complete |= (1 << ui32Channel);
|
||||
}
|
||||
|
||||
//
|
||||
// Check the next channel.
|
||||
//
|
||||
ui32DMAIntStatus >>= 1;
|
||||
|
||||
//
|
||||
// Break if there are no more pending DMA interrupts.
|
||||
//
|
||||
if(ui32DMAIntStatus == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// USBLibDMAChannelEnable() for USB controllers that use uDMA.
|
||||
//
|
||||
//*****************************************************************************
|
||||
static void
|
||||
uDMAUSBChannelEnable(tUSBDMAInstance *psUSBDMAInst, uint32_t ui32Channel)
|
||||
{
|
||||
uint32_t ui32IntEnabled;
|
||||
|
||||
//
|
||||
// Save if the interrupt was enabled or not.
|
||||
//
|
||||
ui32IntEnabled = IntIsEnabled(psUSBDMAInst->ui32IntNum);
|
||||
|
||||
//
|
||||
// Disable the USB interrupt if it was enabled.
|
||||
//
|
||||
if(ui32IntEnabled)
|
||||
{
|
||||
OS_INT_DISABLE(psUSBDMAInst->ui32IntNum);
|
||||
}
|
||||
|
||||
//
|
||||
// Mark this channel as pending and not complete.
|
||||
//
|
||||
psUSBDMAInst->ui32Pending |= (1 << (ui32Channel - 1));
|
||||
psUSBDMAInst->ui32Complete &= ~(1 << (ui32Channel - 1));
|
||||
|
||||
//
|
||||
// Enable DMA for the endpoint.
|
||||
//
|
||||
if(UDMAConfigIsRx(psUSBDMAInst->pui32Config[ui32Channel - 1]))
|
||||
{
|
||||
MAP_USBEndpointDMAEnable(psUSBDMAInst->ui32Base,
|
||||
psUSBDMAInst->pui8Endpoint[ui32Channel - 1],
|
||||
USB_EP_DEV_OUT | USB_EP_HOST_IN);
|
||||
}
|
||||
else
|
||||
{
|
||||
MAP_USBEndpointDMAEnable(psUSBDMAInst->ui32Base,
|
||||
psUSBDMAInst->pui8Endpoint[ui32Channel - 1],
|
||||
USB_EP_DEV_IN | USB_EP_HOST_OUT);
|
||||
}
|
||||
|
||||
//
|
||||
// Enable the DMA in the uDMA controller.
|
||||
//
|
||||
MAP_uDMAChannelEnable(ui32Channel - 1);
|
||||
|
||||
//
|
||||
// Enable the USB interrupt if it was enabled before.
|
||||
//
|
||||
if(ui32IntEnabled)
|
||||
{
|
||||
OS_INT_ENABLE(psUSBDMAInst->ui32IntNum);
|
||||
}
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// USBLibDMAChannelDisable() for USB controllers that use uDMA.
|
||||
//
|
||||
//*****************************************************************************
|
||||
static void
|
||||
uDMAUSBChannelDisable(tUSBDMAInstance *psUSBDMAInst, uint32_t ui32Channel)
|
||||
{
|
||||
//
|
||||
// Disable DMA for the endpoint.
|
||||
//
|
||||
if(UDMAConfigIsRx(psUSBDMAInst->pui32Config[ui32Channel - 1]))
|
||||
{
|
||||
MAP_USBEndpointDMADisable(psUSBDMAInst->ui32Base,
|
||||
psUSBDMAInst->pui8Endpoint[ui32Channel - 1],
|
||||
USB_EP_DEV_OUT);
|
||||
}
|
||||
else
|
||||
{
|
||||
MAP_USBEndpointDMADisable(psUSBDMAInst->ui32Base,
|
||||
psUSBDMAInst->pui8Endpoint[ui32Channel - 1],
|
||||
USB_EP_DEV_IN);
|
||||
}
|
||||
|
||||
//
|
||||
// Disable the DMA channel in the uDMA controller.
|
||||
//
|
||||
MAP_uDMAChannelDisable(ui32Channel - 1);
|
||||
|
||||
//
|
||||
// Clear out any pending or complete flag set for this DMA channel.
|
||||
//
|
||||
psUSBDMAInst->ui32Pending &= ~(1 << (ui32Channel - 1));
|
||||
psUSBDMAInst->ui32Complete &= ~(1 << (ui32Channel - 1));
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// USBLibDMAChannelIntEnable() for USB controllers that use uDMA.
|
||||
//
|
||||
//*****************************************************************************
|
||||
static void
|
||||
uDMAUSBChannelIntEnable(tUSBDMAInstance *psUSBDMAInst, uint32_t ui32Channel)
|
||||
{
|
||||
//
|
||||
// There is no way to Enable channel interrupts when using uDMA.
|
||||
//
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// USBLibDMAChannelIntDisable() for USB controllers that use uDMA.
|
||||
//
|
||||
//*****************************************************************************
|
||||
static void
|
||||
uDMAUSBChannelIntDisable(tUSBDMAInstance *psUSBDMAInst, uint32_t ui32Channel)
|
||||
{
|
||||
//
|
||||
// There is no way to Disable channel interrupts when using uDMA.
|
||||
//
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// USBLibDMATransfer() for USB controllers that use the uDMA controller.
|
||||
//
|
||||
//*****************************************************************************
|
||||
static uint32_t
|
||||
uDMAUSBTransfer(tUSBDMAInstance *psUSBDMAInst, uint32_t ui32Channel,
|
||||
void *pvBuffer, uint32_t ui32Size)
|
||||
{
|
||||
void *pvFIFO;
|
||||
uint32_t uluDMAChannel;
|
||||
uint32_t ui32PacketCount;
|
||||
uint32_t ui32TransferCount;
|
||||
|
||||
if((ui32Size < 64) || ((uint32_t)pvBuffer & 0x3))
|
||||
{
|
||||
return(0);
|
||||
}
|
||||
|
||||
//
|
||||
// Mark this channel as pending and not complete.
|
||||
//
|
||||
psUSBDMAInst->ui32Pending |= (1 << (ui32Channel - 1));
|
||||
psUSBDMAInst->ui32Complete &= ~(1 << (ui32Channel - 1));
|
||||
|
||||
//
|
||||
// Save the pointer to the data and the byte count.
|
||||
//
|
||||
psUSBDMAInst->ppui32Data[ui32Channel - 1] = pvBuffer;
|
||||
psUSBDMAInst->pui32Count[ui32Channel - 1] = ui32Size;
|
||||
|
||||
//
|
||||
// Need the address of the FIFO.
|
||||
//
|
||||
pvFIFO = (void *)USBFIFOAddrGet(psUSBDMAInst->ui32Base,
|
||||
psUSBDMAInst->pui8Endpoint[ui32Channel - 1]);
|
||||
|
||||
//
|
||||
// Calculate the uDMA channel for this RX channel.
|
||||
//
|
||||
uluDMAChannel = UDMA_CHANNEL_USBEP1RX + ui32Channel - 1;
|
||||
|
||||
ui32TransferCount = ui32Size;
|
||||
|
||||
if((psUSBDMAInst->pui32Config[ui32Channel - 1] & UDMA_SIZE_32) ==
|
||||
UDMA_SIZE_32)
|
||||
{
|
||||
ui32TransferCount >>= 2;
|
||||
}
|
||||
else if((psUSBDMAInst->pui32Config[ui32Channel - 1] & UDMA_SIZE_32) ==
|
||||
UDMA_SIZE_32)
|
||||
{
|
||||
ui32TransferCount >>= 1;
|
||||
}
|
||||
|
||||
//
|
||||
// If source increment is none this is an RX transfer.
|
||||
//
|
||||
if(UDMAConfigIsRx(psUSBDMAInst->pui32Config[ui32Channel - 1]))
|
||||
{
|
||||
MAP_uDMAChannelTransferSet(uluDMAChannel, UDMA_MODE_BASIC, pvFIFO,
|
||||
pvBuffer, ui32TransferCount);
|
||||
}
|
||||
else
|
||||
{
|
||||
MAP_uDMAChannelTransferSet(uluDMAChannel, UDMA_MODE_BASIC, pvBuffer,
|
||||
pvFIFO, ui32TransferCount);
|
||||
}
|
||||
|
||||
//
|
||||
// Set the mode based on the size of the transfer. More than one
|
||||
// packet requires mode 1.
|
||||
//
|
||||
if(ui32Size > psUSBDMAInst->pui32MaxPacketSize[ui32Channel - 1])
|
||||
{
|
||||
//
|
||||
// Calculate the number of packets required for this transfer.
|
||||
//
|
||||
ui32PacketCount = ((ui32Size /
|
||||
psUSBDMAInst->pui32MaxPacketSize[ui32Channel - 1]));
|
||||
|
||||
//
|
||||
// Set the packet count so that the last packet does not generate
|
||||
// another IN request.
|
||||
//
|
||||
USBEndpointPacketCountSet(psUSBDMAInst->ui32Base,
|
||||
psUSBDMAInst->pui8Endpoint[ui32Channel - 1],
|
||||
ui32PacketCount);
|
||||
|
||||
//
|
||||
// Configure the USB endpoint in mode 1 for this DMA transfer.
|
||||
//
|
||||
USBEndpointDMAConfigSet(psUSBDMAInst->ui32Base,
|
||||
psUSBDMAInst->pui8Endpoint[ui32Channel - 1],
|
||||
psUSBDMAInst->pui32EPDMAMode1[ui32Channel - 1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
// Configure the USB endpoint in mode 0 for this DMA transfer.
|
||||
//
|
||||
USBEndpointDMAConfigSet(psUSBDMAInst->ui32Base,
|
||||
psUSBDMAInst->pui8Endpoint[ui32Channel - 1],
|
||||
psUSBDMAInst->pui32EPDMAMode0[ui32Channel -1]);
|
||||
}
|
||||
|
||||
//
|
||||
// Enable the uDMA channel to start the transfer
|
||||
//
|
||||
uDMAUSBChannelEnable(psUSBDMAInst, ui32Channel);
|
||||
|
||||
return(ui32Size);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// USBLibDMAChannelAllocate() for USB controllers that use uDMA for DMA.
|
||||
//
|
||||
//*****************************************************************************
|
||||
static uint32_t
|
||||
uDMAUSBChannelAllocate(tUSBDMAInstance *psUSBDMAInst, uint8_t ui8Endpoint,
|
||||
uint32_t ui32MaxPacketSize, uint32_t ui32Config)
|
||||
{
|
||||
uint32_t ui32Channel;
|
||||
|
||||
//
|
||||
// The DMA channels are organized in pairs on this controller and the
|
||||
// transmit channels are 1, 3, and 5 while receive are 0, 2, and 4.
|
||||
//
|
||||
if(ui32Config & USB_DMA_EP_RX)
|
||||
{
|
||||
ui32Channel = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
ui32Channel = 1;
|
||||
}
|
||||
|
||||
//
|
||||
// Search for an available DMA channel to use.
|
||||
//
|
||||
for(; ui32Channel < USB_MAX_DMA_CHANNELS_0; ui32Channel += 2)
|
||||
{
|
||||
//
|
||||
// If the current endpoint value is zero then this channel is
|
||||
// available.
|
||||
//
|
||||
if(psUSBDMAInst->pui8Endpoint[ui32Channel] == 0)
|
||||
{
|
||||
//
|
||||
// Save the endpoint for this DMA channel.
|
||||
//
|
||||
psUSBDMAInst->pui8Endpoint[ui32Channel] = ui8Endpoint;
|
||||
|
||||
//
|
||||
// Save the maximum packet size for the endpoint.
|
||||
//
|
||||
psUSBDMAInst->pui32MaxPacketSize[ui32Channel] = ui32MaxPacketSize;
|
||||
|
||||
//
|
||||
// Set the channel configuration based on the direction.
|
||||
//
|
||||
if(ui32Config & USB_DMA_EP_RX)
|
||||
{
|
||||
psUSBDMAInst->pui32Config[ui32Channel] =
|
||||
UDMA_SIZE_8 | UDMA_SRC_INC_NONE | UDMA_DST_INC_8 |
|
||||
UDMA_ARB_64;
|
||||
|
||||
//
|
||||
// If in device mode and Isochronous.
|
||||
//
|
||||
if(((ui32Config & USB_DMA_EP_HOST) == 0) &&
|
||||
((ui32Config & USB_DMA_EP_TYPE_M) == USB_DMA_EP_TYPE_ISOC))
|
||||
{
|
||||
//
|
||||
// USB_EP_AUTO_REQUEST is required for device
|
||||
// Isochronous endpoints.
|
||||
//
|
||||
psUSBDMAInst->pui32EPDMAMode0[ui32Channel] =
|
||||
USB_EP_DMA_MODE_0 |
|
||||
USB_EP_AUTO_REQUEST |
|
||||
USB_EP_HOST_IN;
|
||||
}
|
||||
else
|
||||
{
|
||||
psUSBDMAInst->pui32EPDMAMode0[ui32Channel] =
|
||||
USB_EP_DMA_MODE_0 |
|
||||
USB_EP_AUTO_CLEAR |
|
||||
USB_EP_HOST_IN;
|
||||
}
|
||||
|
||||
//
|
||||
// Do not set auto request in device mode unless it is an
|
||||
// isochronous endpoint.
|
||||
//
|
||||
if(((ui32Config & USB_DMA_EP_HOST) == 0) &&
|
||||
((ui32Config & USB_DMA_EP_TYPE_M) != USB_DMA_EP_TYPE_ISOC))
|
||||
{
|
||||
psUSBDMAInst->pui32EPDMAMode1[ui32Channel] =
|
||||
USB_EP_DMA_MODE_1 |
|
||||
USB_EP_HOST_IN |
|
||||
USB_EP_AUTO_CLEAR;
|
||||
}
|
||||
else
|
||||
{
|
||||
psUSBDMAInst->pui32EPDMAMode1[ui32Channel] =
|
||||
USB_EP_DMA_MODE_1 |
|
||||
USB_EP_HOST_IN |
|
||||
USB_EP_AUTO_REQUEST |
|
||||
USB_EP_AUTO_CLEAR;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
psUSBDMAInst->pui32Config[ui32Channel] =
|
||||
UDMA_SIZE_8 | UDMA_SRC_INC_8 | UDMA_DST_INC_NONE |
|
||||
UDMA_ARB_64;
|
||||
|
||||
psUSBDMAInst->pui32EPDMAMode0[ui32Channel] = USB_EP_DMA_MODE_0 |
|
||||
USB_EP_HOST_OUT;
|
||||
psUSBDMAInst->pui32EPDMAMode1[ui32Channel] = USB_EP_DMA_MODE_1 |
|
||||
USB_EP_HOST_OUT |
|
||||
USB_EP_AUTO_SET;
|
||||
}
|
||||
|
||||
//
|
||||
// Map the uDMA channel to the given endpoint.
|
||||
//
|
||||
MAP_USBEndpointDMAChannel(psUSBDMAInst->ui32Base, ui8Endpoint,
|
||||
ui32Channel);
|
||||
|
||||
//
|
||||
// Clear out the attributes on this channel.
|
||||
//
|
||||
MAP_uDMAChannelAttributeDisable(ui32Channel, UDMA_ATTR_ALL);
|
||||
|
||||
//
|
||||
// Configure the uDMA channel for the pipe
|
||||
//
|
||||
MAP_uDMAChannelControlSet(ui32Channel,
|
||||
psUSBDMAInst->pui32Config[ui32Channel]);
|
||||
|
||||
if(ui32Config & USB_DMA_EP_RX)
|
||||
{
|
||||
MAP_USBEndpointDMADisable(psUSBDMAInst->ui32Base, ui8Endpoint,
|
||||
USB_EP_DEV_OUT);
|
||||
}
|
||||
else
|
||||
{
|
||||
MAP_USBEndpointDMADisable(psUSBDMAInst->ui32Base, ui8Endpoint,
|
||||
USB_EP_DEV_IN);
|
||||
}
|
||||
|
||||
//
|
||||
// Outside of this function all channels are 1 based as
|
||||
// zero is not a valid channel.
|
||||
//
|
||||
return(ui32Channel + 1);
|
||||
}
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// USBLibDMAChannelRelease() for USB controllers that use uDMA for DMA.
|
||||
//
|
||||
//*****************************************************************************
|
||||
static void
|
||||
uDMAUSBChannelRelease(tUSBDMAInstance *psUSBDMAInst, uint8_t ui32Channel)
|
||||
{
|
||||
ASSERT(ui32Channel < USB_MAX_DMA_CHANNELS_0);
|
||||
|
||||
//
|
||||
// Clear out the attributes on this channel.
|
||||
//
|
||||
MAP_uDMAChannelAttributeDisable(ui32Channel - 1, UDMA_ATTR_ALL);
|
||||
|
||||
if(psUSBDMAInst->pui8Endpoint[ui32Channel] & USB_DMA_EP_RX)
|
||||
{
|
||||
MAP_USBEndpointDMADisable(psUSBDMAInst->ui32Base,
|
||||
(psUSBDMAInst->pui8Endpoint[ui32Channel] & ~USB_DMA_EP_RX),
|
||||
USB_EP_DEV_OUT);
|
||||
}
|
||||
else
|
||||
{
|
||||
MAP_USBEndpointDMADisable(psUSBDMAInst->ui32Base,
|
||||
(psUSBDMAInst->pui8Endpoint[ui32Channel] & ~USB_DMA_EP_RX),
|
||||
USB_EP_DEV_IN);
|
||||
}
|
||||
|
||||
//
|
||||
// Clear out the state for this endpoint.
|
||||
//
|
||||
psUSBDMAInst->pui8Endpoint[ui32Channel - 1] = 0;
|
||||
psUSBDMAInst->pui32Config[ui32Channel - 1] = 0;
|
||||
psUSBDMAInst->ui32Pending &= ~(1 << (ui32Channel - 1));
|
||||
psUSBDMAInst->ui32Complete &= ~(1 << (ui32Channel - 1));
|
||||
psUSBDMAInst->pui32MaxPacketSize[ui32Channel - 1] = 0;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// USBLibDMAUnitSizeSet() for USB controllers that use uDMA for DMA.
|
||||
//
|
||||
//*****************************************************************************
|
||||
static void
|
||||
uDMAUSBUnitSizeSet(tUSBDMAInstance *psUSBDMAInst, uint32_t ui32Channel,
|
||||
uint32_t ui32BitSize)
|
||||
{
|
||||
uint32_t ui32Value;
|
||||
|
||||
ASSERT((ui32BitSize == UDMA_SIZE_8) || (ui32BitSize == UDMA_SIZE_16) ||
|
||||
(ui32BitSize == UDMA_SIZE_32));
|
||||
|
||||
ASSERT(ui32Channel < USB_MAX_DMA_CHANNELS_0);
|
||||
|
||||
if(ui32BitSize == 8)
|
||||
{
|
||||
ui32Value = UDMA_SIZE_8;
|
||||
|
||||
if(UDMAConfigIsRx(psUSBDMAInst->pui32Config[ui32Channel - 1]))
|
||||
{
|
||||
//
|
||||
// Receive increments destination and not source.
|
||||
//
|
||||
ui32Value |= UDMA_DST_INC_8 | UDMA_SRC_INC_NONE;
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
// Transmit increments source and not destination.
|
||||
//
|
||||
ui32Value |= UDMA_SRC_INC_8 | UDMA_DST_INC_NONE;
|
||||
}
|
||||
}
|
||||
else if(ui32BitSize == 16)
|
||||
{
|
||||
ui32Value = UDMA_SIZE_16;
|
||||
|
||||
if(UDMAConfigIsRx(psUSBDMAInst->pui32Config[ui32Channel - 1]))
|
||||
{
|
||||
//
|
||||
// Receive increments destination and not source.
|
||||
//
|
||||
ui32Value |= UDMA_DST_INC_16 | UDMA_SRC_INC_NONE;
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
// Transmit increments source and not destination.
|
||||
//
|
||||
ui32Value |= UDMA_SRC_INC_16 | UDMA_DST_INC_NONE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ui32Value = UDMA_SIZE_32;
|
||||
|
||||
if(UDMAConfigIsRx(psUSBDMAInst->pui32Config[ui32Channel - 1]))
|
||||
{
|
||||
//
|
||||
// Receive increments destination and not source.
|
||||
//
|
||||
ui32Value |= (UDMA_DST_INC_32 | UDMA_SRC_INC_NONE);
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
// Transmit increments source and not destination.
|
||||
//
|
||||
ui32Value |= (UDMA_SRC_INC_32 | UDMA_DST_INC_NONE);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Keep the current arbitration size and or in the size.
|
||||
//
|
||||
psUSBDMAInst->pui32Config[ui32Channel - 1] &= 0x00ffffff;
|
||||
psUSBDMAInst->pui32Config[ui32Channel - 1] |= ui32Value;
|
||||
MAP_uDMAChannelControlSet(ui32Channel - 1,
|
||||
psUSBDMAInst->pui32Config[ui32Channel - 1]);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// USBLibDMAArbSizeSet() for USB controllers that use uDMA for DMA.
|
||||
//
|
||||
//*****************************************************************************
|
||||
static void
|
||||
uDMAUSBArbSizeSet(tUSBDMAInstance *psUSBDMAInst, uint32_t ui32Channel,
|
||||
uint32_t ui32ArbSize)
|
||||
{
|
||||
uint32_t ui32Value;
|
||||
|
||||
ASSERT(ui32Channel < USB_MAX_DMA_CHANNELS_0);
|
||||
|
||||
//
|
||||
// Get the arbitration size value.
|
||||
//
|
||||
if(ui32ArbSize == 2)
|
||||
{
|
||||
ui32Value = UDMA_ARB_2;
|
||||
}
|
||||
else if(ui32ArbSize == 4)
|
||||
{
|
||||
ui32Value = UDMA_ARB_4;
|
||||
}
|
||||
else if(ui32ArbSize == 8)
|
||||
{
|
||||
ui32Value = UDMA_ARB_8;
|
||||
}
|
||||
else if(ui32ArbSize == 16)
|
||||
{
|
||||
ui32Value = UDMA_ARB_16;
|
||||
}
|
||||
else if(ui32ArbSize == 32)
|
||||
{
|
||||
ui32Value = UDMA_ARB_32;
|
||||
}
|
||||
else if(ui32ArbSize == 64)
|
||||
{
|
||||
ui32Value = UDMA_ARB_64;
|
||||
}
|
||||
else if(ui32ArbSize == 128)
|
||||
{
|
||||
ui32Value = UDMA_ARB_128;
|
||||
}
|
||||
else if(ui32ArbSize == 256)
|
||||
{
|
||||
ui32Value = UDMA_ARB_256;
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
// Default to arbitration size of 1.
|
||||
//
|
||||
ui32Value = UDMA_ARB_1;
|
||||
}
|
||||
|
||||
//
|
||||
// Keep the current size and or in the new arbitration size.
|
||||
//
|
||||
psUSBDMAInst->pui32Config[ui32Channel - 1] &= 0xff000000;
|
||||
psUSBDMAInst->pui32Config[ui32Channel - 1] |= ui32Value;
|
||||
|
||||
//
|
||||
// Set the uDMA channel control, remember its channel starts at 0 and
|
||||
// not 1.
|
||||
//
|
||||
MAP_uDMAChannelControlSet(ui32Channel - 1,
|
||||
psUSBDMAInst->pui32Config[ui32Channel - 1]);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// USBLibDMAStatus() for USB controllers that use uDMA for DMA.
|
||||
//
|
||||
//*****************************************************************************
|
||||
static uint32_t
|
||||
DMAUSBStatus(tUSBDMAInstance *psUSBDMAInst)
|
||||
{
|
||||
return(0);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! This function is used to initialize the DMA interface for a USB instance.
|
||||
//!
|
||||
//! \param ui32Index is the index of the USB controller for this instance.
|
||||
//!
|
||||
//! This function performs any initialization and configuration of the DMA
|
||||
//! portions of the USB controller. This function returns a pointer that
|
||||
//! is used with the remaining USBLibDMA APIs or the function returns zero
|
||||
//! if the requested controller cannot support DMA. If this function is called
|
||||
//! when already initialized it will not reinitialize the DMA controller and
|
||||
//! will instead return the previously initialized DMA instance.
|
||||
//!
|
||||
//! \return A pointer to use with USBLibDMA APIs.
|
||||
//
|
||||
//*****************************************************************************
|
||||
tUSBDMAInstance *
|
||||
USBLibDMAInit(uint32_t ui32Index)
|
||||
{
|
||||
uint32_t ui32Channel;
|
||||
|
||||
ASSERT(ui32Index == 0);
|
||||
|
||||
//
|
||||
// Make sure that the DMA has not already been initialized.
|
||||
//
|
||||
if(g_psUSBDMAInst[0].ui32Base == USB0_BASE)
|
||||
{
|
||||
return(&g_psUSBDMAInst[0]);
|
||||
}
|
||||
|
||||
//
|
||||
// Save the base address of the USB controller.
|
||||
//
|
||||
g_psUSBDMAInst[0].ui32Base = USB0_BASE;
|
||||
|
||||
//
|
||||
// Save the interrupt number for the USB controller.
|
||||
//
|
||||
g_psUSBDMAInst[0].ui32IntNum = INT_USB0_BLIZZARD;
|
||||
|
||||
//
|
||||
// Initialize the function pointers.
|
||||
//
|
||||
g_psUSBDMAInst[0].pfnArbSizeSet = uDMAUSBArbSizeSet;
|
||||
g_psUSBDMAInst[0].pfnChannelAllocate = uDMAUSBChannelAllocate;
|
||||
g_psUSBDMAInst[0].pfnChannelDisable = uDMAUSBChannelDisable;
|
||||
g_psUSBDMAInst[0].pfnChannelEnable = uDMAUSBChannelEnable;
|
||||
g_psUSBDMAInst[0].pfnChannelIntEnable = uDMAUSBChannelIntEnable;
|
||||
g_psUSBDMAInst[0].pfnChannelIntDisable = uDMAUSBChannelIntDisable;
|
||||
g_psUSBDMAInst[0].pfnChannelRelease = uDMAUSBChannelRelease;
|
||||
g_psUSBDMAInst[0].pfnChannelStatus = uDMAUSBChannelStatus;
|
||||
g_psUSBDMAInst[0].pfnIntHandler = DMAUSBIntHandler;
|
||||
g_psUSBDMAInst[0].pfnIntStatus = uDMAUSBIntStatus;
|
||||
g_psUSBDMAInst[0].pfnIntStatusClear = DMAUSBIntStatusClear;
|
||||
g_psUSBDMAInst[0].pfnStatus = DMAUSBStatus;
|
||||
g_psUSBDMAInst[0].pfnTransfer = uDMAUSBTransfer;
|
||||
g_psUSBDMAInst[0].pfnUnitSizeSet = uDMAUSBUnitSizeSet;
|
||||
|
||||
//
|
||||
// Clear out the endpoint and the current configuration.
|
||||
//
|
||||
for(ui32Channel = 0; ui32Channel < USB_MAX_DMA_CHANNELS; ui32Channel++)
|
||||
{
|
||||
g_psUSBDMAInst[0].pui8Endpoint[ui32Channel] = 0;
|
||||
g_psUSBDMAInst[0].pui32Config[ui32Channel] = 0;
|
||||
g_psUSBDMAInst[0].ui32Pending = 0;
|
||||
g_psUSBDMAInst[0].ui32Complete = 0;
|
||||
}
|
||||
return(&g_psUSBDMAInst[0]);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Close the Doxygen group.
|
||||
//! @}
|
||||
//
|
||||
//*****************************************************************************
|
|
@ -0,0 +1,661 @@
|
|||
//*****************************************************************************
|
||||
//
|
||||
// usbhid.h - Definitions used by HID class devices and hosts.
|
||||
//
|
||||
// Copyright (c) 2008-2013 Texas Instruments Incorporated. All rights reserved.
|
||||
// Software License Agreement
|
||||
//
|
||||
// Texas Instruments (TI) is supplying this software for use solely and
|
||||
// exclusively on TI's microcontroller products. The software is owned by
|
||||
// TI and/or its suppliers, and is protected under applicable copyright
|
||||
// laws. You may not combine this software with "viral" open-source
|
||||
// software in order to form a larger program.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
|
||||
// NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
|
||||
// NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
|
||||
// CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
|
||||
// DAMAGES, FOR ANY REASON WHATSOEVER.
|
||||
//
|
||||
// This is part of revision 1.1 of the Tiva USB Library.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
#ifndef __USBHID_H__
|
||||
#define __USBHID_H__
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// If building with a C++ compiler, make all of the definitions in this header
|
||||
// have a C binding.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! \addtogroup hid_device_class_api
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// HID Interface descriptor Subclasses.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define USB_HID_SCLASS_NONE 0x00
|
||||
#define USB_HID_SCLASS_BOOT 0x01
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// USB Interface descriptor HID protocols.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define USB_HID_PROTOCOL_NONE 0
|
||||
#define USB_HID_PROTOCOL_KEYB 1
|
||||
#define USB_HID_PROTOCOL_MOUSE 2
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// HID Class descriptor types.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define USB_HID_DTYPE_HID 0x21
|
||||
#define USB_HID_DTYPE_REPORT 0x22
|
||||
#define USB_HID_DTYPE_PHYSICAL 0x23
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// HID USB requests.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define USBREQ_GET_REPORT 0x01
|
||||
#define USBREQ_GET_IDLE 0x02
|
||||
#define USBREQ_GET_PROTOCOL 0x03
|
||||
#define USBREQ_SET_REPORT 0x09
|
||||
#define USBREQ_SET_IDLE 0x0a
|
||||
#define USBREQ_SET_PROTOCOL 0x0b
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// GET_REPORT or SET_REPORT Definitions.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define USB_HID_REPORT_IN 0x01
|
||||
#define USB_HID_REPORT_OUTPUT 0x02
|
||||
#define USB_HID_REPORT_FEATURE 0x03
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// GET_PROTOCOL or SET_PROTOCOL Definitions.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define USB_HID_PROTOCOL_BOOT 0
|
||||
#define USB_HID_PROTOCOL_REPORT 1
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Report Values used with the Report macros.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define USB_HID_GENERIC_DESKTOP 0x01
|
||||
#define USB_HID_BUTTONS 0x09
|
||||
#define USB_HID_X 0x30
|
||||
#define USB_HID_Y 0x31
|
||||
|
||||
#define USB_HID_POINTER 0x01
|
||||
#define USB_HID_MOUSE 0x02
|
||||
#define USB_HID_KEYBOARD 0x06
|
||||
|
||||
#define USB_HID_PHYSICAL 0x00
|
||||
#define USB_HID_APPLICATION 0x01
|
||||
#define USB_HID_LOGICAL 0x02
|
||||
|
||||
#define USB_HID_USAGE_POINTER 0x0109
|
||||
#define USB_HID_USAGE_BUTTONS 0x0509
|
||||
#define USB_HID_USAGE_LEDS 0x0508
|
||||
#define USB_HID_USAGE_KEYCODES 0x0507
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// HID mouse button definitions as used in the first byte of the output report
|
||||
// used in the BIOS mouse protocol.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define HID_MOUSE_BUTTON_1 0x01
|
||||
#define HID_MOUSE_BUTTON_2 0x02
|
||||
#define HID_MOUSE_BUTTON_3 0x04
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// HID Keyboard LED definitions as used in the first byte of the output report
|
||||
// used in the BIOS keyboard protocol.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define HID_KEYB_NUM_LOCK 0x01
|
||||
#define HID_KEYB_CAPS_LOCK 0x02
|
||||
#define HID_KEYB_SCROLL_LOCK 0x04
|
||||
#define HID_KEYB_COMPOSE 0x08
|
||||
#define HID_KEYB_KANA 0x10
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// HID Keyboard key modifiers as provided in the first byte of the input report
|
||||
// used in the BIOS keyboard protocol.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define HID_KEYB_LEFT_CTRL 0x01
|
||||
#define HID_KEYB_LEFT_SHIFT 0x02
|
||||
#define HID_KEYB_LEFT_ALT 0x04
|
||||
#define HID_KEYB_LEFT_GUI 0x08
|
||||
#define HID_KEYB_RIGHT_CTRL 0x10
|
||||
#define HID_KEYB_RIGHT_SHIFT 0x20
|
||||
#define HID_KEYB_RIGHT_ALT 0x40
|
||||
#define HID_KEYB_RIGHT_GUI 0x80
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// A subset of the HID keyboard usage IDs.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define HID_KEYB_USAGE_RESERVED 0x00
|
||||
#define HID_KEYB_USAGE_ROLLOVER 0x01
|
||||
#define HID_KEYB_USAGE_A 0x04
|
||||
#define HID_KEYB_USAGE_B 0x05
|
||||
#define HID_KEYB_USAGE_C 0x06
|
||||
#define HID_KEYB_USAGE_D 0x07
|
||||
#define HID_KEYB_USAGE_E 0x08
|
||||
#define HID_KEYB_USAGE_F 0x09
|
||||
#define HID_KEYB_USAGE_G 0x0A
|
||||
#define HID_KEYB_USAGE_H 0x0B
|
||||
#define HID_KEYB_USAGE_I 0x0C
|
||||
#define HID_KEYB_USAGE_J 0x0D
|
||||
#define HID_KEYB_USAGE_K 0x0E
|
||||
#define HID_KEYB_USAGE_L 0x0F
|
||||
#define HID_KEYB_USAGE_M 0x10
|
||||
#define HID_KEYB_USAGE_N 0x11
|
||||
#define HID_KEYB_USAGE_O 0x12
|
||||
#define HID_KEYB_USAGE_P 0x13
|
||||
#define HID_KEYB_USAGE_Q 0x14
|
||||
#define HID_KEYB_USAGE_R 0x15
|
||||
#define HID_KEYB_USAGE_S 0x16
|
||||
#define HID_KEYB_USAGE_T 0x17
|
||||
#define HID_KEYB_USAGE_U 0x18
|
||||
#define HID_KEYB_USAGE_V 0x19
|
||||
#define HID_KEYB_USAGE_W 0x1A
|
||||
#define HID_KEYB_USAGE_X 0x1B
|
||||
#define HID_KEYB_USAGE_Y 0x1C
|
||||
#define HID_KEYB_USAGE_Z 0x1D
|
||||
#define HID_KEYB_USAGE_1 0x1E
|
||||
#define HID_KEYB_USAGE_2 0x1F
|
||||
#define HID_KEYB_USAGE_3 0x20
|
||||
#define HID_KEYB_USAGE_4 0x21
|
||||
#define HID_KEYB_USAGE_5 0x22
|
||||
#define HID_KEYB_USAGE_6 0x23
|
||||
#define HID_KEYB_USAGE_7 0x24
|
||||
#define HID_KEYB_USAGE_8 0x25
|
||||
#define HID_KEYB_USAGE_9 0x26
|
||||
#define HID_KEYB_USAGE_0 0x27
|
||||
#define HID_KEYB_USAGE_ENTER 0x28
|
||||
#define HID_KEYB_USAGE_ESCAPE 0x29
|
||||
#define HID_KEYB_USAGE_BACKSPACE \
|
||||
0x2A
|
||||
#define HID_KEYB_USAGE_TAB 0x2B
|
||||
#define HID_KEYB_USAGE_SPACE 0x2C
|
||||
#define HID_KEYB_USAGE_MINUS 0x2D
|
||||
#define HID_KEYB_USAGE_EQUAL 0x2E
|
||||
#define HID_KEYB_USAGE_LBRACKET 0x2F
|
||||
#define HID_KEYB_USAGE_RBRACKET 0x30
|
||||
#define HID_KEYB_USAGE_BSLASH 0x31
|
||||
#define HID_KEYB_USAGE_SEMICOLON \
|
||||
0x33
|
||||
#define HID_KEYB_USAGE_FQUOTE 0x34
|
||||
#define HID_KEYB_USAGE_BQUOTE 0x35
|
||||
#define HID_KEYB_USAGE_COMMA 0x36
|
||||
#define HID_KEYB_USAGE_PERIOD 0x37
|
||||
#define HID_KEYB_USAGE_FSLASH 0x38
|
||||
#define HID_KEYB_USAGE_CAPSLOCK 0x39
|
||||
#define HID_KEYB_USAGE_F1 0x3A
|
||||
#define HID_KEYB_USAGE_F2 0x3B
|
||||
#define HID_KEYB_USAGE_F3 0x3C
|
||||
#define HID_KEYB_USAGE_F4 0x3D
|
||||
#define HID_KEYB_USAGE_F5 0x3E
|
||||
#define HID_KEYB_USAGE_F6 0x3F
|
||||
#define HID_KEYB_USAGE_F7 0x40
|
||||
#define HID_KEYB_USAGE_F8 0x41
|
||||
#define HID_KEYB_USAGE_F9 0x42
|
||||
#define HID_KEYB_USAGE_F10 0x43
|
||||
#define HID_KEYB_USAGE_F11 0x44
|
||||
#define HID_KEYB_USAGE_F12 0x45
|
||||
#define HID_KEYB_USAGE_SCROLLOCK \
|
||||
0x47
|
||||
#define HID_KEYB_USAGE_PAGE_UP 0x4B
|
||||
#define HID_KEYB_USAGE_PAGE_DOWN \
|
||||
0x4E
|
||||
#define HID_KEYB_USAGE_RIGHT_ARROW \
|
||||
0x4F
|
||||
#define HID_KEYB_USAGE_LEFT_ARROW \
|
||||
0x50
|
||||
#define HID_KEYB_USAGE_DOWN_ARROW \
|
||||
0x51
|
||||
#define HID_KEYB_USAGE_UP_ARROW 0x52
|
||||
#define HID_KEYB_USAGE_NUMLOCK 0x53
|
||||
#define HID_KEYB_USAGE_KEYPAD_SLASH \
|
||||
0x54
|
||||
#define HID_KEYB_USAGE_KEYPAD_STAR \
|
||||
0x55
|
||||
#define HID_KEYB_USAGE_KEYPAD_MINUS \
|
||||
0x56
|
||||
#define HID_KEYB_USAGE_KEYPAD_PLUS \
|
||||
0x57
|
||||
#define HID_KEYB_USAGE_KEPAD_ENTER \
|
||||
0x58
|
||||
#define HID_KEYB_USAGE_KEYPAD_1 0x59
|
||||
#define HID_KEYB_USAGE_KEYPAD_2 0x5A
|
||||
#define HID_KEYB_USAGE_KEYPAD_3 0x5B
|
||||
#define HID_KEYB_USAGE_KEYPAD_4 0x5C
|
||||
#define HID_KEYB_USAGE_KEYPAD_5 0x5D
|
||||
#define HID_KEYB_USAGE_KEYPAD_6 0x5E
|
||||
#define HID_KEYB_USAGE_KEYPAD_7 0x5F
|
||||
#define HID_KEYB_USAGE_KEYPAD_8 0x60
|
||||
#define HID_KEYB_USAGE_KEYPAD_9 0x61
|
||||
#define HID_KEYB_USAGE_KEYPAD_0 0x62
|
||||
#define HID_KEYB_USAGE_KEPAD_PERIOD \
|
||||
0x63
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// HID descriptor country codes (most of these are described as "countries" in
|
||||
// the HID specification even though they are really languages).
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define USB_HID_COUNTRY_NONE 0x00
|
||||
#define USB_HID_COUNTRY_ARABIC 0x01
|
||||
#define USB_HID_COUNTRY_BELGIAN 0x02
|
||||
#define USB_HID_COUNTRY_CANADA_BI \
|
||||
0x03
|
||||
#define USB_HID_COUNTRY_CANADA_FR \
|
||||
0x04
|
||||
#define USB_HID_COUNTRY_CZECH_REPUBLIC \
|
||||
0x05
|
||||
#define USB_HID_COUNTRY_DANISH 0x06
|
||||
#define USB_HID_COUNTRY_FINNISH 0x07
|
||||
#define USB_HID_COUNTRY_FRENCH 0x08
|
||||
#define USB_HID_COUNTRY_GERMAN 0x09
|
||||
#define USB_HID_COUNTRY_GREEK 0x0A
|
||||
#define USB_HID_COUNTRY_HEBREW 0x0B
|
||||
#define USB_HID_COUNTRY_HUNGARY 0x0C
|
||||
#define USB_HID_COUNTRY_INTERNATIONAL_ISO \
|
||||
0x0D
|
||||
#define USB_HID_COUNTRY_ITALIAN 0x0E
|
||||
#define USB_HID_COUNTRY_JAPAN_KATAKANA \
|
||||
0x0F
|
||||
#define USB_HID_COUNTRY_KOREAN 0x10
|
||||
#define USB_HID_COUNTRY_LATIN_AMERICAN \
|
||||
0x11
|
||||
#define USB_HID_COUNTRY_NETHERLANDS \
|
||||
0x12
|
||||
#define USB_HID_COUNTRY_NORWEGIAN \
|
||||
0x13
|
||||
#define USB_HID_COUNTRY_PERSIAN 0x14
|
||||
#define USB_HID_COUNTRY_POLAND 0x15
|
||||
#define USB_HID_COUNTRY_PORTUGUESE \
|
||||
0x16
|
||||
#define USB_HID_COUNTRY_RUSSIA 0x17
|
||||
#define USB_HID_COUNTRY_SLOVAKIA \
|
||||
0x18
|
||||
#define USB_HID_COUNTRY_SPANISH 0x19
|
||||
#define USB_HID_COUNTRY_SWEDISH 0x1A
|
||||
#define USB_HID_COUNTRY_SWISS_FRENCH \
|
||||
0x1B
|
||||
#define USB_HID_COUNTRY_SWISS_GERMAN \
|
||||
0x1C
|
||||
#define USB_HID_COUNTRY_SWITZERLAND \
|
||||
0x1D
|
||||
#define USB_HID_COUNTRY_TAIWAN 0x1E
|
||||
#define USB_HID_COUNTRY_TURKISH_Q \
|
||||
0x1F
|
||||
#define USB_HID_COUNTRY_UK 0x20
|
||||
#define USB_HID_COUNTRY_US 0x21
|
||||
#define USB_HID_COUNTRY_YUGOSLAVIA \
|
||||
0x22
|
||||
#define USB_HID_COUNTRY_TURKISH_F \
|
||||
0x23
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Data flags used in Input item tags within report descriptors.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define USB_HID_INPUT_DATA 0x0000
|
||||
#define USB_HID_INPUT_CONSTANT 0x0001
|
||||
#define USB_HID_INPUT_ARRAY 0x0000
|
||||
#define USB_HID_INPUT_VARIABLE 0x0002
|
||||
#define USB_HID_INPUT_ABS 0x0000
|
||||
#define USB_HID_INPUT_RELATIVE 0x0004
|
||||
#define USB_HID_INPUT_NOWRAP 0x0000
|
||||
#define USB_HID_INPUT_WRAP 0x0008
|
||||
#define USB_HID_INPUT_LINEAR 0x0000
|
||||
#define USB_HID_INPUT_NONLINEAR 0x0010
|
||||
#define USB_HID_INPUT_PREFER 0x0000
|
||||
#define USB_HID_INPUT_NONPREFER 0x0020
|
||||
#define USB_HID_INPUT_NONULL 0x0000
|
||||
#define USB_HID_INPUT_NULL 0x0040
|
||||
#define USB_HID_INPUT_BITF 0x0100
|
||||
#define USB_HID_INPUT_BYTES 0x0000
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Data flags used in Feature item tags within report descriptors.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define USB_HID_FEATURE_DATA 0x0000
|
||||
#define USB_HID_FEATURE_CONSTANT \
|
||||
0x0001
|
||||
#define USB_HID_FEATURE_ARRAY 0x0000
|
||||
#define USB_HID_FEATURE_VARIABLE \
|
||||
0x0002
|
||||
#define USB_HID_FEATURE_ABS 0x0000
|
||||
#define USB_HID_FEATURE_RELATIVE \
|
||||
0x0004
|
||||
#define USB_HID_FEATURE_NOWRAP 0x0000
|
||||
#define USB_HID_FEATURE_WRAP 0x0008
|
||||
#define USB_HID_FEATURE_LINEAR 0x0000
|
||||
#define USB_HID_FEATURE_NONLINEAR \
|
||||
0x0010
|
||||
#define USB_HID_FEATURE_PREFER 0x0000
|
||||
#define USB_HID_FEATURE_NONPREFER \
|
||||
0x0020
|
||||
#define USB_HID_FEATURE_NONULL 0x0000
|
||||
#define USB_HID_FEATURE_NULL 0x0040
|
||||
#define USB_HID_FEATURE_BITF 0x0100
|
||||
#define USB_HID_FEATURE_BYTES 0x0000
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Data flags used in Output item tags within report descriptors.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define USB_HID_OUTPUT_DATA 0x0000
|
||||
#define USB_HID_OUTPUT_CONSTANT 0x0001
|
||||
#define USB_HID_OUTPUT_ARRAY 0x0000
|
||||
#define USB_HID_OUTPUT_VARIABLE 0x0002
|
||||
#define USB_HID_OUTPUT_ABS 0x0000
|
||||
#define USB_HID_OUTPUT_RELATIVE 0x0004
|
||||
#define USB_HID_OUTPUT_NOWRAP 0x0000
|
||||
#define USB_HID_OUTPUT_WRAP 0x0008
|
||||
#define USB_HID_OUTPUT_LINEAR 0x0000
|
||||
#define USB_HID_OUTPUT_NONLINEAR \
|
||||
0x0010
|
||||
#define USB_HID_OUTPUT_PREFER 0x0000
|
||||
#define USB_HID_OUTPUT_NONPREFER \
|
||||
0x0020
|
||||
#define USB_HID_OUTPUT_NONULL 0x0000
|
||||
#define USB_HID_OUTPUT_NULL 0x0040
|
||||
#define USB_HID_OUTPUT_BITF 0x0100
|
||||
#define USB_HID_OUTPUT_BYTES 0x0000
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Physical descriptor bias values.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define USB_HID_BIAS_NOT_APPLICABLE \
|
||||
0x00
|
||||
#define USB_HID_BIAS_RIGHT_HAND 0x01
|
||||
#define USB_HID_BIAS_LEFT_HAND 0x02
|
||||
#define USB_HID_BIAS_BOTH_HANDS 0x03
|
||||
#define USB_HID_BIAS_EITHER_HAND \
|
||||
0x04
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Physical descriptor designator values.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define USB_HID_DESIGNATOR_NONE 0x00
|
||||
#define USB_HID_DESIGNATOR_HAND 0x01
|
||||
#define USB_HID_DESIGNATOR_EYEBALL \
|
||||
0x02
|
||||
#define USB_HID_DESIGNATOR_EYEBROW \
|
||||
0x03
|
||||
#define USB_HID_DESIGNATOR_EYELID \
|
||||
0x04
|
||||
#define USB_HID_DESIGNATOR_EAR 0x05
|
||||
#define USB_HID_DESIGNATOR_NOSE 0x06
|
||||
#define USB_HID_DESIGNATOR_MOUTH \
|
||||
0x07
|
||||
#define USB_HID_DESIGNATOR_UPPER_LIP \
|
||||
0x08
|
||||
#define USB_HID_DESIGNATOR_LOWER_LIP \
|
||||
0x09
|
||||
#define USB_HID_DESIGNATOR_JAW 0x0A
|
||||
#define USB_HID_DESIGNATOR_NECK 0x0B
|
||||
#define USB_HID_DESIGNATOR_UPPER_ARM \
|
||||
0x0C
|
||||
#define USB_HID_DESIGNATOR_ELBOW \
|
||||
0x0D
|
||||
#define USB_HID_DESIGNATOR_FOREARM \
|
||||
0x0E
|
||||
#define USB_HID_DESIGNATOR_WRIST \
|
||||
0x0F
|
||||
#define USB_HID_DESIGNATOR_PALM 0x10
|
||||
#define USB_HID_DESIGNATOR_THUMB \
|
||||
0x11
|
||||
#define USB_HID_DESIGNATOR_INDEX_FINGER \
|
||||
0x12
|
||||
#define USB_HID_DESIGNATOR_MIDDLE_FINGER \
|
||||
0x13
|
||||
#define USB_HID_DESIGNATOR_RING_FINGER \
|
||||
0x14
|
||||
#define USB_HID_DESIGNATOR_LITTLE_FINGER \
|
||||
0x15
|
||||
#define USB_HID_DESIGNATOR_HEAD 0x16
|
||||
#define USB_HID_DESIGNATOR_SHOULDER \
|
||||
0x17
|
||||
#define USB_HID_DESIGNATOR_HIP 0x18
|
||||
#define USB_HID_DESIGNATOR_WAIST \
|
||||
0x19
|
||||
#define USB_HID_DESIGNATOR_THIGH \
|
||||
0x1A
|
||||
#define USB_HID_DESIGNATOR_KNEE 0x1B
|
||||
#define USB_HID_DESIGNATOR_CALF 0x1C
|
||||
#define USB_HID_DESIGNATOR_ANKLE \
|
||||
0x1D
|
||||
#define USB_HID_DESIGNATOR_FOOT 0x1E
|
||||
#define USB_HID_DESIGNATOR_HEEL 0x1F
|
||||
#define USB_HID_DESIGNATOR_BALL_OF_FOOT \
|
||||
0x20
|
||||
#define USB_HID_DESIGNATOR_BIG_TOE \
|
||||
0x21
|
||||
#define USB_HID_DESIGNATOR_SECOND_TOE \
|
||||
0x22
|
||||
#define USB_HID_DESIGNATOR_THIRD_TOE \
|
||||
0x23
|
||||
#define USB_HID_DESIGNATOR_FOURTH_TOE \
|
||||
0x24
|
||||
#define USB_HID_DESIGNATOR_LITTLE_TOE \
|
||||
0x25
|
||||
#define USB_HID_DESIGNATOR_BROW 0x26
|
||||
#define USB_HID_DESIGNATOR_CHEEK \
|
||||
0x27
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Physical descriptor qualifier values.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define USB_HID_QUALIFIER_NOT_APPLICABLE \
|
||||
(0x00 << 5)
|
||||
#define USB_HID_QUALIFIER_RIGHT (0x01 << 5)
|
||||
#define USB_HID_QUALIFIER_LEFT (0x02 << 5)
|
||||
#define USB_HID_QUALIFIER_BOTH (0x03 << 5)
|
||||
#define USB_HID_QUALIFIER_EITHER \
|
||||
(0x04 << 5)
|
||||
#define USB_HID_QUALIFIER_CENTER \
|
||||
(0x05 << 5)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// This is the maximum value for a usage code.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define USBH_HID_MAX_USAGE 256
|
||||
#define USBH_HID_CAPS_ARRAY_SZ (USBH_HID_MAX_USAGE/sizeof(uint32_t))
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// All structures defined in this section of the header require byte packing of
|
||||
// fields. This is usually accomplished using the PACKED macro but, for IAR
|
||||
// Embedded Workbench, this requires a pragma.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#ifdef ewarm
|
||||
#pragma pack(1)
|
||||
#endif
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! The class descriptor information structure is used to announce the presence
|
||||
//! of HID-specific class descriptors within the HID descriptor.
|
||||
//
|
||||
//*****************************************************************************
|
||||
typedef struct
|
||||
{
|
||||
//
|
||||
//! The type of HID class descriptor. This will be USB_HID_DTYPE_REPORT or
|
||||
//! USB_HID_DTYPE_PHYSICAL.
|
||||
//
|
||||
uint8_t bDescriptorType;
|
||||
|
||||
//
|
||||
//! The total length of the HID class descriptor.
|
||||
//
|
||||
uint16_t wDescriptorLength;
|
||||
}
|
||||
PACKED tHIDClassDescriptorInfo;
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! The HID descriptor is inserted following the interface descriptor and
|
||||
//! before the endpoint descriptors for a HID class device.
|
||||
//
|
||||
//*****************************************************************************
|
||||
typedef struct
|
||||
{
|
||||
//
|
||||
//! The length of this descriptor in bytes.
|
||||
//
|
||||
uint8_t bLength;
|
||||
|
||||
//
|
||||
//! The type of the descriptor. For a HID descriptor, this will be
|
||||
//! USB_HID_DTYPE_HID (0x21).
|
||||
//
|
||||
uint8_t bDescriptorType;
|
||||
|
||||
//
|
||||
//! A BCD value identifying the HID Class specification release supported
|
||||
//! by the device. For version 1.11, for example, this value would be
|
||||
//! 0x0111.
|
||||
//
|
||||
uint16_t bcdHID;
|
||||
|
||||
//
|
||||
//! The country code for which this hardware is localized or 0 if no
|
||||
//! localization has been performed. Valid country (or language) codes are
|
||||
//! in labels of the form USB_HID_COUNTRY_xxx.
|
||||
uint8_t bCountryCode;
|
||||
|
||||
//
|
||||
//! The number of class-specific descriptors that exist for this device.
|
||||
//! This indicates the number of class descriptor information structures
|
||||
//! that are appended to this structure and must be at least 1 (since all
|
||||
//! HID devices must publish at least 1 report descriptor).
|
||||
//
|
||||
uint8_t bNumDescriptors;
|
||||
|
||||
//
|
||||
//! A table announcing each of the class-specific descriptors that this
|
||||
//! device publishes. The actual number of entries in the array is given
|
||||
//! by the bNumDescriptors field.
|
||||
//
|
||||
tHIDClassDescriptorInfo sClassDescriptor[1];
|
||||
}
|
||||
PACKED tHIDDescriptor;
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Return to default packing when using the IAR Embedded Workbench compiler.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#ifdef ewarm
|
||||
#pragma pack()
|
||||
#endif
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! This structure defines the mapping of USB usage identifiers to printable
|
||||
//! characters. The structure has three members that hold this information.
|
||||
//! The ui8BytesPerChar, indicates the number of bytes per character in
|
||||
//! the table. The pui32CapsLock array holds a packed bit array of usage
|
||||
//! identifiers that can be modified by the Caps Lock key. The pCharMapping
|
||||
//! array is treated as a double indexed array with two "columns". In the case
|
||||
//! of a single byte character it is treated as pairs of 8 bit values for
|
||||
//! unshifted and shifted values. In the case of a double byte characters it
|
||||
//! is treated as pairs of 16 bit values.
|
||||
//
|
||||
//*****************************************************************************
|
||||
typedef struct
|
||||
{
|
||||
//
|
||||
//! Number of bytes per character in the pCharMapping table of this
|
||||
//! structure.
|
||||
//
|
||||
uint8_t ui8BytesPerChar;
|
||||
|
||||
//
|
||||
//! This is a packed bitmasked structure with a one bit flags that
|
||||
//! indicates if the corresponding Usage ID is affected by the Caps Lock
|
||||
//! key.
|
||||
//
|
||||
uint32_t pui32CapsLock[USBH_HID_CAPS_ARRAY_SZ];
|
||||
|
||||
//
|
||||
//! This is the indexed table of Usage ID to character value. It must be
|
||||
//! at least ui8BytesPerChar * 2 * USBH_HID_MAX_USAGE bytes in size as it
|
||||
//! is treated as a double indexed array.
|
||||
//
|
||||
void *pvCharMapping;
|
||||
}
|
||||
tHIDKeyboardUsageTable;
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// The US Keyboard mapping used by USB keyboard usage ID to character mapping.
|
||||
//
|
||||
//*****************************************************************************
|
||||
extern const tHIDKeyboardUsageTable g_sUSKeyboardMap;
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Close the Doxygen group.
|
||||
//! @}
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Mark the end of the C bindings section for C++ compilers.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // __USBHID_H__
|
|
@ -0,0 +1,145 @@
|
|||
//*****************************************************************************
|
||||
//
|
||||
// usbkeyboardmap.c - This file holds the table to enable USB keyboard usage
|
||||
// identifiers to be mapped to printable characters.
|
||||
//
|
||||
// Copyright (c) 2008-2013 Texas Instruments Incorporated. All rights reserved.
|
||||
// Software License Agreement
|
||||
//
|
||||
// Texas Instruments (TI) is supplying this software for use solely and
|
||||
// exclusively on TI's microcontroller products. The software is owned by
|
||||
// TI and/or its suppliers, and is protected under applicable copyright
|
||||
// laws. You may not combine this software with "viral" open-source
|
||||
// software in order to form a larger program.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
|
||||
// NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
|
||||
// NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
|
||||
// CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
|
||||
// DAMAGES, FOR ANY REASON WHATSOEVER.
|
||||
//
|
||||
// This is part of revision 1.1 of the Tiva USB Library.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "inc/hw_types.h"
|
||||
#include "usblib/usblib.h"
|
||||
#include "usblib/usbhid.h"
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// This is the array that hold the unshifted and shifted ASCII character for
|
||||
// each usage ID.
|
||||
//
|
||||
//*****************************************************************************
|
||||
const uint8_t g_pui8KeyBoardMap[USBH_HID_MAX_USAGE][2] =
|
||||
{
|
||||
//
|
||||
// Usage ID to character mapping Usage ID CAPS Lock
|
||||
//
|
||||
{0, 0}, {0, 0}, {0, 0}, {0, 0}, // 0 - 3 0
|
||||
{'a', 'A'}, {'b', 'B'}, {'c', 'C'}, {'d', 'D'}, // 4 - 7 f
|
||||
{'e', 'E'}, {'f', 'F'}, {'g', 'G'}, {'h', 'H'}, // 8 - 11 f
|
||||
{'i', 'I'}, {'j', 'J'}, {'k', 'K'}, {'l', 'L'}, // 12 - 15 f
|
||||
{'m', 'M'}, {'n', 'N'}, {'o', 'O'}, {'p', 'P'}, // 16 - 19 f
|
||||
{'q', 'Q'}, {'r', 'R'}, {'s', 'S'}, {'t', 'T'}, // 20 - 23 f
|
||||
{'u', 'U'}, {'v', 'V'}, {'w', 'W'}, {'x', 'X'}, // 24 - 27 f
|
||||
{'y', 'Y'}, {'z', 'Z'}, {'1', '!'}, {'2', '@'}, // 28 - 31 3
|
||||
|
||||
{'3', '#'}, {'4', '$'}, {'5', '%'}, {'6', '^'}, // 32 - 35 0
|
||||
{'7', '&'}, {'8', '*'}, {'9', '('}, {'0', ')'}, // 36 - 39 0
|
||||
{'\n', '\n'}, {0, 0}, {0, 0}, {'\t', '\t'}, // 40 - 43 0
|
||||
{' ', ' '}, {'-', '_'}, {'=', '+'}, {'[', '{'}, // 44 - 47 0
|
||||
{']', '}'}, {'\\', '|'},{'`', '~'}, {';', ':'}, // 48 - 51 0
|
||||
{'\'', '"'}, {'`', '~'}, {',', '<'}, {'.', '>'},// 52 - 55 0
|
||||
{'/', '?'}, {0, 0}, {0, 0}, {0, 0}, // 56 - 59 0
|
||||
{0, 0}, {0, 0}, {0, 0}, {0, 0}, // 60 - 63 0
|
||||
|
||||
{0, 0}, {0, 0}, {0, 0}, {0, 0}, // 64 - 67 0
|
||||
{0, 0}, {0, 0}, {0, 0}, {0, 0}, // 68 - 71 0
|
||||
{0, 0}, {0, 0}, {0, 0}, {0, 0}, // 72 - 75 0
|
||||
{0, 0}, {0, 0}, {0, 0}, {0, 0}, // 76 - 79 0
|
||||
{0, 0}, {0, 0}, {0, 0}, {0, 0}, // 80 - 83 0
|
||||
{'/', '/'}, {'*', '*'}, {'-', '-'}, {'+', '+'}, // 84 - 87 0
|
||||
{'\n', '\n'}, {'1', 0}, {'2', 0}, {'3', 0}, // 88 - 91 0
|
||||
{'4', 0}, {'5', 0}, {'6', 0}, {'7', 0}, // 92 - 95 0
|
||||
|
||||
{'8', 0}, {'9', 0}, {'0', 0}, {'.', 0}, // 96 - 99 0
|
||||
{'\\', '|'},{0, 0}, {0, 0}, {'=', '+'}, // 100 - 103 0
|
||||
{0, 0}, {0, 0}, {0, 0}, {0, 0}, // 104 - 107 0
|
||||
{0, 0}, {0, 0}, {0, 0}, {0, 0}, // 108 - 111 0
|
||||
{0, 0}, {0, 0}, {0, 0}, {0, 0}, // 112 - 115 0
|
||||
{0, 0}, {0, 0}, {0, 0}, {0, 0}, // 116 - 119 0
|
||||
{0, 0}, {0, 0}, {0, 0}, {0, 0}, // 120 - 123 0
|
||||
{0, 0}, {0, 0}, {0, 0}, {0, 0}, // 124 - 127 0
|
||||
{0, 0}, {0, 0}, {0, 0}, {0, 0}, // 128 - 131 0
|
||||
|
||||
{0, 0}, {',', ','}, {'=', '='}, {0, 0}, // 132 - 135 0
|
||||
{0, 0}, {0, 0}, {0, 0}, {0, 0}, // 136 - 139 0
|
||||
{0, 0}, {0, 0}, {0, 0}, {0, 0}, // 140 - 143 0
|
||||
{0, 0}, {0, 0}, {0, 0}, {0, 0}, // 144 - 147 0
|
||||
{0, 0}, {0, 0}, {0, 0}, {0, 0}, // 148 - 151 0
|
||||
{0, 0}, {0, 0}, {0, 0}, {0, 0}, // 152 - 155 0
|
||||
{0, 0}, {0, 0}, {0, 0}, {0, 0}, // 156 - 159 0
|
||||
{0, 0}, {0, 0}, {0, 0}, {0, 0}, // 160 - 163 0
|
||||
|
||||
{0, 0}, {0, 0}, {0, 0}, {0, 0}, // 164 - 167 0
|
||||
{0, 0}, {0, 0}, {0, 0}, {0, 0}, // 168 - 171 0
|
||||
{0, 0}, {0, 0}, {0, 0}, {0, 0}, // 172 - 175 0
|
||||
{0, 0}, {0, 0}, {0, 0}, {0, 0}, // 174 - 179 0
|
||||
{0, 0}, {0, 0}, {'(', '('}, {')', ')'}, // 180 - 183 0
|
||||
{'{', '{'}, {'}', '}'}, {'\t', '\t'}, {0, 0}, // 184 - 187 0
|
||||
{'A', 'A'}, {'B', 'B'}, {'C', 'C'}, {'D', 'D'}, // 188 - 191 0
|
||||
{'E', 'E'}, {'F', 'F'}, {0, 0}, {'^', '^'}, // 192 - 195 0
|
||||
|
||||
{'%', '%'}, {'<', '<'}, {'>', '>'}, {'&', '&'}, // 196 - 199 0
|
||||
{'&', '&'}, {'|', '|'}, {'|', '|'}, {':', ':'}, // 200 - 203 0
|
||||
{'#', '#'}, {' ', ' '}, {'@', '@'}, {'!', '!'}, // 204 - 207 0
|
||||
{0, 0}, {0, 0}, {0, 0}, {0, 0}, // 208 - 211 0
|
||||
{0, 0}, {0, 0}, {0, 0}, {0, 0}, // 212 - 215 0
|
||||
{0, 0}, {0, 0}, {0, 0}, {0, 0}, // 216 - 219 0
|
||||
{0, 0}, {0, 0}, {0, 0}, {0, 0}, // 220 - 223 0
|
||||
|
||||
{0, 0}, {0, 0}, {0, 0}, {0, 0}, // 224 - 227 0
|
||||
{0, 0}, {0, 0}, {0, 0}, {0, 0}, // 228 - 231 0
|
||||
{0, 0}, {0, 0}, {0, 0}, {0, 0}, // 232 - 235 0
|
||||
{0, 0}, {0, 0}, {0, 0}, {0, 0}, // 236 - 239 0
|
||||
{0, 0}, {0, 0}, {0, 0}, {0, 0}, // 240 - 243 0
|
||||
{0, 0}, {0, 0}, {0, 0}, {0, 0}, // 244 - 247 0
|
||||
{0, 0}, {0, 0}, {0, 0}, {0, 0}, // 248 - 251 0
|
||||
{0, 0}, {0, 0}, {0, 0}, {0, 0}, // 252 - 255 0
|
||||
};
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// This is the structure that defines the mapping of USB usage IDs to ASCII
|
||||
// values for printing.
|
||||
//
|
||||
//*****************************************************************************
|
||||
const tHIDKeyboardUsageTable g_sUSKeyboardMap =
|
||||
{
|
||||
//
|
||||
// One byte per character.
|
||||
//
|
||||
1,
|
||||
//
|
||||
// Packed bit array of usages codes that are effected by Caps Lock state.
|
||||
//
|
||||
{
|
||||
0x3ffffff0, // Alpha characters are only one affected by CAPS LOCK
|
||||
0x00000000,
|
||||
0x00000000,
|
||||
0x00000000,
|
||||
0x00000000,
|
||||
0x00000000,
|
||||
0x00000000,
|
||||
0x00000000,
|
||||
},
|
||||
//
|
||||
// The large table of the direct mapping of usage id's to ascii characters.
|
||||
//
|
||||
(void *)g_pui8KeyBoardMap
|
||||
};
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,525 @@
|
|||
//*****************************************************************************
|
||||
//
|
||||
// usblibpriv.h - Private header file used to share internal variables and
|
||||
// function prototypes between the various modules in the USB
|
||||
// library. This header MUST NOT be used by application code.
|
||||
//
|
||||
// Copyright (c) 2008-2013 Texas Instruments Incorporated. All rights reserved.
|
||||
// Software License Agreement
|
||||
//
|
||||
// Texas Instruments (TI) is supplying this software for use solely and
|
||||
// exclusively on TI's microcontroller products. The software is owned by
|
||||
// TI and/or its suppliers, and is protected under applicable copyright
|
||||
// laws. You may not combine this software with "viral" open-source
|
||||
// software in order to form a larger program.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
|
||||
// NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
|
||||
// NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
|
||||
// CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
|
||||
// DAMAGES, FOR ANY REASON WHATSOEVER.
|
||||
//
|
||||
// This is part of revision 1.1 of the Tiva USB Library.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
#ifndef __USBLIBPRIV_H__
|
||||
#define __USBLIBPRIV_H__
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// If building with a C++ compiler, make all of the definitions in this header
|
||||
// have a C binding.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! \addtogroup usblib_dma_api
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Internal interrupt handlers called from the main vectors in device and
|
||||
// host mode.
|
||||
//
|
||||
//*****************************************************************************
|
||||
extern void USBDeviceIntHandlerInternal(uint32_t ui32Index,
|
||||
uint32_t ui32Status);
|
||||
extern void USBHostIntHandlerInternal(uint32_t ui32Index, uint32_t ui32Status);
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// The maximum number of tick handlers that can be registered in a system.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define MAX_USB_TICK_HANDLERS 6
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// This value defines the number of SOF ticks that must pass before a call
|
||||
// is made to InternalUSBStartOfFrameTick. The value 5 ensures that the
|
||||
// function is called every 5 milliseconds assuming that SOF interrupts are
|
||||
// enabled and SOF is present.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define USB_SOF_TICK_DIVIDE 5
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Tick handler function pointer type.
|
||||
//
|
||||
//*****************************************************************************
|
||||
typedef void(* tUSBTickHandler)(void *pvInstance, uint32_t ui32TicksmS);
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Internal functions use to initialize the tick handler and register tick
|
||||
// callbacks.
|
||||
//
|
||||
//*****************************************************************************
|
||||
extern void InternalUSBTickInit(void);
|
||||
extern void InternalUSBTickReset(void);
|
||||
extern int32_t InternalUSBRegisterTickHandler(tUSBTickHandler pfnHandler,
|
||||
void *pvInstance);
|
||||
extern void InternalUSBStartOfFrameTick(uint32_t ui32TicksmS);
|
||||
extern void InternalUSBHCDSendEvent(uint32_t ui32Index, tEventInfo *psEvent,
|
||||
uint32_t ui32EvFlag);
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// g_ui32CurrentUSBTick holds the elapsed time in milliseconds since the
|
||||
// tick module was first initialized based on calls to the function
|
||||
// InternalUSBStartOfFrameTick. The granularity is USB_SOF_TICK_DIVIDE
|
||||
// milliseconds.
|
||||
//
|
||||
//*****************************************************************************
|
||||
extern uint32_t g_ui32CurrentUSBTick;
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// g_ui32USBSOFCount is a global counter for Start of Frame interrupts. It is
|
||||
// incremented by the low level device- or host-mode interrupt handlers.
|
||||
//
|
||||
//*****************************************************************************
|
||||
extern uint32_t g_ui32USBSOFCount;
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// InternalUSBGetTime is a macro which will return the system time in
|
||||
// milliseconds as calculated based on calls to the function
|
||||
// InternalUSBStartOfFrameTick. The granularity is USB_SOF_TICK_DIVIDE
|
||||
// milliseconds.
|
||||
//
|
||||
// Currently, this merely returns the value of a global variable.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define InternalUSBGetTime() g_ui32CurrentUSBTick
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Macros to convert between USB controller base address and an index. These
|
||||
// are currently trivial but are included to allow for the possibility of
|
||||
// supporting more than one controller in the future.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define USBBaseToIndex(BaseAddr)(0)
|
||||
#define USBIndexToBase(Index) (USB0_BASE)
|
||||
|
||||
//
|
||||
// Maximum number of channels for Type 0 USB controllers.
|
||||
//
|
||||
#define USB_MAX_DMA_CHANNELS_0 6
|
||||
|
||||
//
|
||||
// Maximum number of channels for all other USB controllers.
|
||||
//
|
||||
#define USB_MAX_DMA_CHANNELS 8
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Values returned by the USBLibDMAChannelStatus() function.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define USBLIBSTATUS_DMA_IDLE 0x00000000
|
||||
#define USBLIBSTATUS_DMA_COMPLETE \
|
||||
0x00000001
|
||||
#define USBLIBSTATUS_DMA_ERROR 0x00000002
|
||||
#define USBLIBSTATUS_DMA_PENDING \
|
||||
0x00000004
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// DMA endpoint types used with the USBLibDMAChannelAllocate() function.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define USB_DMA_EP_RX 0x00000080
|
||||
#define USB_DMA_EP_TX 0x00000000
|
||||
#define USB_DMA_EP_HOST 0x00000040
|
||||
#define USB_DMA_EP_DEVICE 0x00000000
|
||||
#define USB_DMA_EP_TYPE_CTRL 0x00000000
|
||||
#define USB_DMA_EP_TYPE_ISOC 0x00000001
|
||||
#define USB_DMA_EP_TYPE_BULK 0x00000002
|
||||
#define USB_DMA_EP_TYPE_INT 0x00000003
|
||||
#define USB_DMA_EP_TYPE_M 0x00000003
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// This is the internal instance data for the DMA functions and should not
|
||||
// be modified outside the usbdma.c file.
|
||||
//
|
||||
//*****************************************************************************
|
||||
struct tUSBDMAInstance
|
||||
{
|
||||
uint32_t ui32Base;
|
||||
|
||||
uint32_t ui32IntNum;
|
||||
|
||||
uint32_t pui32Config[USB_MAX_DMA_CHANNELS];
|
||||
|
||||
uint32_t pui32MaxPacketSize[USB_MAX_DMA_CHANNELS];
|
||||
|
||||
uint32_t *ppui32Data[USB_MAX_DMA_CHANNELS];
|
||||
|
||||
uint32_t pui32Count[USB_MAX_DMA_CHANNELS];
|
||||
|
||||
uint8_t pui8Endpoint[USB_MAX_DMA_CHANNELS];
|
||||
|
||||
uint32_t pui32EPDMAMode0[USB_MAX_DMA_CHANNELS];
|
||||
|
||||
uint32_t pui32EPDMAMode1[USB_MAX_DMA_CHANNELS];
|
||||
|
||||
uint32_t ui32Pending;
|
||||
|
||||
uint32_t ui32Complete;
|
||||
|
||||
void (* pfnArbSizeSet)(tUSBDMAInstance *psUSBDMAInst, uint32_t ui32Channel,
|
||||
uint32_t ui32ArbSize);
|
||||
uint32_t (* pfnChannelAllocate)(tUSBDMAInstance *psUSBDMAInst,
|
||||
uint8_t ui8Endpoint,
|
||||
uint32_t ui32MaxPacketSize,
|
||||
uint32_t ui32Config);
|
||||
void (* pfnChannelEnable)(tUSBDMAInstance *psUSBDMAInst,
|
||||
uint32_t ui32Channel);
|
||||
void (* pfnChannelDisable)(tUSBDMAInstance *psUSBDMAInst,
|
||||
uint32_t ui32Channel);
|
||||
void (* pfnChannelRelease)(tUSBDMAInstance *psUSBDMAInst,
|
||||
uint8_t ui8Endpoint);
|
||||
uint32_t (* pfnChannelStatus)(tUSBDMAInstance *psUSBDMAInst,
|
||||
uint32_t ui32Channel);
|
||||
void (* pfnChannelIntDisable)(tUSBDMAInstance *psUSBDMAInst,
|
||||
uint32_t ui32Channel);
|
||||
void (* pfnChannelIntEnable)(tUSBDMAInstance *psUSBDMAInst,
|
||||
uint32_t ui32Channel);
|
||||
void (* pfnIntHandler)(tUSBDMAInstance *psUSBDMAInst,
|
||||
uint32_t ui32Status);
|
||||
uint32_t (* pfnIntStatus)(tUSBDMAInstance *psUSBDMAInst);
|
||||
void (* pfnIntStatusClear)(tUSBDMAInstance *psUSBDMAInst,
|
||||
uint32_t ui32Status);
|
||||
uint32_t (* pfnStatus)(tUSBDMAInstance *psUSBDMAInst);
|
||||
uint32_t (* pfnTransfer)(tUSBDMAInstance *psUSBDMAInst,
|
||||
uint32_t ui32Channel, void *pvBuffer,
|
||||
uint32_t ui32Size);
|
||||
void (* pfnUnitSizeSet)(tUSBDMAInstance *psUSBDMAInst,
|
||||
uint32_t ui32Channel,
|
||||
uint32_t ui32BitSize);
|
||||
};
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// These are the USB libraries DMA functions.
|
||||
//
|
||||
//*****************************************************************************
|
||||
extern tUSBDMAInstance * USBLibDMAInit(uint32_t ui32Index);
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! This function returns the current DMA status for a given DMA channel.
|
||||
//!
|
||||
//! \param psUSBDMAInst is the DMA structure pointer for this instance.
|
||||
//! \param ui32Channel is the DMA channel number used to retrieve the DMA
|
||||
//! status.
|
||||
//!
|
||||
//! This function returns the current status of a DMA transfer on a given
|
||||
//! DMA channel. The DMA channel is specified by the \e ui32Channel parameter.
|
||||
//!
|
||||
//! \return This function returns one of the \b USBLIBSTATUS_DMA_* values.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define USBLibDMAChannelStatus(psUSBDMAInst, ui32Channel) \
|
||||
psUSBDMAInst->pfnChannelStatus(psUSBDMAInst, ui32Channel)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! This function is used to return any global status information for USB DMA.
|
||||
//!
|
||||
//! \param psUSBDMAInst is a generic instance pointer that can be used to
|
||||
//! distinguish between different hardware instances.
|
||||
//!
|
||||
//! This function performs returns the global status for the USB DMA
|
||||
//! interface.
|
||||
//!
|
||||
//! \return Always returns 0.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define USBLibDMAStatus(psUSBDMAInst) psUSBDMAInst->pfnStatus(psUSBDMAInst)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! This function returns the current DMA interrupt status.
|
||||
//!
|
||||
//! \param psUSBDMAInst is the DMA structure pointer for this instance.
|
||||
//!
|
||||
//! This function returns the interrupt status for all DMA channels. The value
|
||||
//! returned is a per channel interrupt mapping with the DMA channels mapped
|
||||
//! into bits 0-31 by channel number with channel 1 starting at bit 0.
|
||||
//!
|
||||
//! \note This function does not return an endpoint interrupt status, but the
|
||||
//! interrupt status for the DMA interface used with the USB controller.
|
||||
//!
|
||||
//! \return This function returns the pending DMA interrupts.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define USBLibDMAIntStatus(psUSBDMAInst) \
|
||||
psUSBDMAInst->pfnIntStatus(psUSBDMAInst)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! This function clears the requested DMA interrupt status.
|
||||
//!
|
||||
//! \param psUSBDMAInst is the DMA structure pointer for this instance.
|
||||
//! \param ui32Status contains the interrupts to clear.
|
||||
//!
|
||||
//! This function clears the current DMA interrupt status for the
|
||||
//! controller specified by the \e ui32Instance parameter. The \e ui32Status
|
||||
//! value has the same format as the value returned from the
|
||||
//! USBLibDMAIntStatus() function which is a per channel interrupt mapping.
|
||||
//! The DMA channels are mapped into bits 0-31 by channel number with channel 1
|
||||
//!starting at bit 0.
|
||||
//!
|
||||
//! \return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define USBLibDMAIntStatusClear(psUSBDMAInst, ui32Status) \
|
||||
psUSBDMAInst->pfnIntStatusClear(psUSBDMAInst, ui32Status)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! This function enables DMA for a given channel.
|
||||
//!
|
||||
//! \param psUSBDMAInst is the DMA structure pointer for this instance.
|
||||
//! \param ui32Channel is the DMA channel to enable.
|
||||
//!
|
||||
//! This function enables DMA on the channel number passed in the
|
||||
//! \e ui32Channel parameter.
|
||||
//!
|
||||
//! \return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define USBLibDMAChannelEnable(psUSBDMAInst, ui32Channel) \
|
||||
psUSBDMAInst->pfnChannelEnable(psUSBDMAInst, ui32Channel)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! This function disables DMA for a given DMA channel.
|
||||
//!
|
||||
//! \param psUSBDMAInst is the DMA structure pointer for this instance.
|
||||
//! \param ui32Channel is the DMA channel to disable.
|
||||
//!
|
||||
//! This function disables DMA on the channel number passed in the
|
||||
//!\e ui32Channel parameter.
|
||||
//!
|
||||
//! \return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define USBLibDMAChannelDisable(psUSBDMAInst, ui32Channel) \
|
||||
psUSBDMAInst->pfnChannelDisable(psUSBDMAInst, ui32Channel)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! This function is configures a USB transfer on a given DMA channel.
|
||||
//!
|
||||
//! \param psUSBDMAInst is the DMA structure pointer for this instance.
|
||||
//! \param ui32Channel is the DMA channel to use.
|
||||
//! \param pvBuffer is a pointer to the buffer to use for the transfer.
|
||||
//! \param ui32Size is the size of the data to be transferred in bytes.
|
||||
//!
|
||||
//! This function is called to configure a transfer using the USB
|
||||
//! controller depending on the parameters. The \e ui32Channel parameter
|
||||
//! holds the channel number to use for this transfer which must have already
|
||||
//! been allocated with a call to the USBLibDMAChannelAllocate() function. The
|
||||
//! transaction is configured to transfer \e ui32Size bytes to/from the buffer
|
||||
//! held in the \e pvBuffer pointer.
|
||||
//!
|
||||
//! \return This function returns the number of bytes scheduled to be
|
||||
//! transferred.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define USBLibDMATransfer(psUSBDMAInst, ui32Channel, pvBuffer, ui32Size) \
|
||||
psUSBDMAInst->pfnTransfer(psUSBDMAInst, ui32Channel, \
|
||||
pvBuffer, ui32Size)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! This function is called by the USB interrupt handler.
|
||||
//!
|
||||
//! \param psUSBDMAInst is the DMA structure pointer for this instance.
|
||||
//! \param ui32Status is the DMA interrupt status.
|
||||
//!
|
||||
//! This function is called by the USB interrupt handler to allow the DMA
|
||||
//! interface to handle interrupts outside of the context of the normal USB
|
||||
//! interrupt handler. The \e ui32Status is the current DMA interrupt status
|
||||
//! at the time of the USB interrupt. Since some DMA controller interrupts are
|
||||
//! cleared automatically when read, this value must be retrieved by calling
|
||||
//! the USBLibDMAIntStatus() function and passed into this function.
|
||||
//!
|
||||
//! \return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define USBLibDMAIntHandler(psUSBDMAInst, ui32Status) \
|
||||
psUSBDMAInst->pfnIntHandler(psUSBDMAInst, ui32Status)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! This function is used to assign a DMA channel to an endpoint.
|
||||
//!
|
||||
//! \param psUSBDMAInst is the DMA instance data for a USB controller.
|
||||
//! \param ui8Endpoint is the endpoint number to assign a DMA channel.
|
||||
//! \param ui32MaxPacketSize is the maximum packet size for the endpoint
|
||||
//! assigned that is being assigned to the DMA channel.
|
||||
//! \param ui32Config are the basic configuration options for the DMA channel.
|
||||
//!
|
||||
//! This function assigns a DMA channel to a given endpoint. The
|
||||
//! \e ui8Endpoint parameter is the zero based endpoint number that is assigned
|
||||
//! a DMA channel. The \e ui32Config parameter contains any configuration
|
||||
//! options for the DMA channel. The current options include the following:
|
||||
//! - \b USB_DMA_EP_TX - this request is for a transmit DMA channel.
|
||||
//! - \b USB_DMA_EP_RX - this request is for a receive DMA channel.
|
||||
//!
|
||||
//! \note The maximum number of available DMA channels to endpoints varies
|
||||
//! between devices.
|
||||
//!
|
||||
//! \return Zero or the DMA channel assigned to the endpoint.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define USBLibDMAChannelAllocate(psUSBDMAInst, ui8Endpoint, ui32MaxPacketSize,\
|
||||
ui32Config) \
|
||||
psUSBDMAInst->pfnChannelAllocate(psUSBDMAInst, \
|
||||
ui8Endpoint, \
|
||||
ui32MaxPacketSize, \
|
||||
ui32Config)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! This function is used to free a DMA channel that was assigned to an
|
||||
//! endpoint.
|
||||
//!
|
||||
//! \param psUSBDMAInst is the DMA instance data for a USB controller.
|
||||
//! \param ui8Endpoint is the DMA channel number to free up.
|
||||
//!
|
||||
//! This function frees up a DMA channel that was allocated to an endpoint
|
||||
//! by the USBLibDMAChannelAllocate() function.
|
||||
//!
|
||||
//! \return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define USBLibDMAChannelRelease(psUSBDMAInst, ui8Endpoint) \
|
||||
psUSBDMAInst->pfnChannelRelease(psUSBDMAInst, ui8Endpoint)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! This function is used to set the individual transfer size of a DMA channel.
|
||||
//!
|
||||
//! \param psUSBDMAInst is the DMA instance data for a USB controller.
|
||||
//! \param ui32Channel is the DMA channel number to modify.
|
||||
//! \param ui32BitSize is the individual transfer size in bits(8, 16 or 32).
|
||||
//!
|
||||
//! This function configures the individual transfer size of the DMA channel
|
||||
//! provided in the \e ui32Channel parameter. The \e ui32Channel must already
|
||||
//! be allocated to an endpoint by calling the USBLibDMAChannelAllocate()
|
||||
//! function. The \e ui32BitSize parameter should be on of the following
|
||||
//! values: 8, 16 or 32.
|
||||
//!
|
||||
//! \return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define USBLibDMAUnitSizeSet(psUSBDMAInst, ui32Channel, ui32BitSize) \
|
||||
psUSBDMAInst->pfnUnitSizeSet(psUSBDMAInst, ui32Channel, \
|
||||
ui32BitSize);
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! This function is used to set the arbitration size for a DMA channel.
|
||||
//!
|
||||
//! \param psUSBDMAInst is the DMA instance data for a USB controller.
|
||||
//! \param ui32Channel is the DMA channel number to modify.
|
||||
//! \param ui32ArbSize is the transfer arbitration size in bytes.
|
||||
//!
|
||||
//! This function configures the individual transfer size of the DMA channel
|
||||
//! provided in the \e ui32Channel parameter. The \e ui32Channel must already
|
||||
//! be allocated to an endpoint by calling the USBLibDMAChannelAllocate()
|
||||
//! function.
|
||||
//!
|
||||
//! \return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define USBLibDMAArbSizeSet(psUSBDMAInst, ui32Channel, ui32ArbSize) \
|
||||
psUSBDMAInst->pfnArbSizeSet(psUSBDMAInst, ui32Channel, \
|
||||
ui32ArbSize);
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! This function enables the DMA interrupt for a given channel.
|
||||
//!
|
||||
//! \param psUSBDMAInst is the DMA structure pointer for this instance.
|
||||
//! \param ui32Channel is the DMA channel interrupt to enable.
|
||||
//!
|
||||
//! This function enables DMA interrupt on the channel number passed in the
|
||||
//! \e ui32Channel parameter.
|
||||
//!
|
||||
//! \return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define USBLibDMAChannelIntEnable(psUSBDMAInst, ui32Channel) \
|
||||
psUSBDMAInst->pfnChannelIntEnable(psUSBDMAInst, ui32Channel)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! This function disables DMA interrupt for a given DMA channel.
|
||||
//!
|
||||
//! \param psUSBDMAInst is the DMA structure pointer for this instance.
|
||||
//! \param ui32Channel is the DMA channel interrupt to disable.
|
||||
//!
|
||||
//! This function disables the DMA interrupt on the channel number passed in
|
||||
//! the \e ui32Channel parameter.
|
||||
//!
|
||||
//! \return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define USBLibDMAChannelIntDisable(psUSBDMAInst, ui32Channel) \
|
||||
psUSBDMAInst->pfnChannelIntDisable(psUSBDMAInst, ui32Channel)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Mark the end of the C bindings section for C++ compilers.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Close the Doxygen group.
|
||||
//! @}
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
#endif // __USBLIBPRIV_H__
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,393 @@
|
|||
//*****************************************************************************
|
||||
//
|
||||
// usbmsc.h - Generic types and defines use by the mass storage class.
|
||||
//
|
||||
// Copyright (c) 2008-2013 Texas Instruments Incorporated. All rights reserved.
|
||||
// Software License Agreement
|
||||
//
|
||||
// Texas Instruments (TI) is supplying this software for use solely and
|
||||
// exclusively on TI's microcontroller products. The software is owned by
|
||||
// TI and/or its suppliers, and is protected under applicable copyright
|
||||
// laws. You may not combine this software with "viral" open-source
|
||||
// software in order to form a larger program.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
|
||||
// NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
|
||||
// NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
|
||||
// CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
|
||||
// DAMAGES, FOR ANY REASON WHATSOEVER.
|
||||
//
|
||||
// This is part of revision 1.1 of the Tiva USB Library.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
#ifndef __USBMSC_H__
|
||||
#define __USBMSC_H__
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// If building with a C++ compiler, make all of the definitions in this header
|
||||
// have a C binding.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// The request for the maximum number of logical units on a mass storage
|
||||
// device.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define USBREQ_GET_MAX_LUN 0xfe
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// The signatures defined by USB MSC class specification.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define CBW_SIGNATURE 0x43425355
|
||||
#define CSW_SIGNATURE 0x53425355
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Flag for the bmCBWFlags member of tMSCCBW
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define CBWFLAGS_DIR_M 0x80
|
||||
#define CBWFLAGS_DIR_IN 0x80
|
||||
#define CBWFLAGS_DIR_OUT 0x00
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// All structures defined in this section of the header require byte packing of
|
||||
// fields. This is usually accomplished using the PACKED macro but, for IAR
|
||||
// Embedded Workbench, this requries a pragma.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#ifdef ewarm
|
||||
#pragma pack(1)
|
||||
#endif
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// The following packed structure is used to access the Command Block Wrapper
|
||||
// (CBW) data structure that is used when communicating with USB Mass Storage
|
||||
// Class devices.
|
||||
//
|
||||
//*****************************************************************************
|
||||
typedef struct
|
||||
{
|
||||
//
|
||||
// Signature that helps identify this data packet as a CBW. The signature
|
||||
// field shall contain the value 0x43425355 (little endian), indicating a
|
||||
// CBW.
|
||||
//
|
||||
uint32_t dCBWSignature;
|
||||
|
||||
//
|
||||
// The Command Block Tag sent by the host controller. The device shall
|
||||
// echo the contents of this field back to the host in the dCSWTag field
|
||||
// of the associated CSW. The dCSWTag positively associates a CSW with the
|
||||
// corresponding CBW.
|
||||
//
|
||||
uint32_t dCBWTag;
|
||||
|
||||
//
|
||||
// The number of bytes of data that the host expects to transfer on the
|
||||
// Bulk-In or Bulk-Out endpoint (as indicated by the Direction bit) during
|
||||
// the execution of this command. If this field is zero, the device and
|
||||
// the host will not transfer data between the CBW and the associated CSW,
|
||||
// and the device will ignore the value of the Direction bit in
|
||||
// bmCBWFlags.
|
||||
//
|
||||
uint32_t dCBWDataTransferLength;
|
||||
|
||||
//
|
||||
// The device will ignore these bits if the dCBWDataTransferLength value
|
||||
// is set to 0.
|
||||
//
|
||||
// The bits of this field are defined as follows:
|
||||
// Bit 7 Direction
|
||||
// 0 = Data-Out from host to the device,
|
||||
// 1 = Data-In from the device to the host.
|
||||
// Bit 6 Obsolete - The host shall set this bit to zero.
|
||||
// Bits 5..0 Reserved - the host shall set these bits to zero.
|
||||
//
|
||||
uint8_t bmCBWFlags;
|
||||
|
||||
//
|
||||
// The device Logical Unit Number (LUN) to which the command block is being
|
||||
// sent. For devices that support multiple LUNs, the host shall place into
|
||||
// this field the LUN to which this command block is addressed. Otherwise,
|
||||
// the host shall set this field to zero.
|
||||
//
|
||||
uint8_t bCBWLUN;
|
||||
|
||||
//
|
||||
// The valid length of the CBWCB in bytes. This defines the valid length
|
||||
// of the command block. The only legal values are 1 through 16. All
|
||||
// other values are reserved.
|
||||
//
|
||||
uint8_t bCBWCBLength;
|
||||
|
||||
//
|
||||
// This array holds the command block to be executed by the device. The
|
||||
// MSC device will interpret the first bCBWCBLength bytes in this field as
|
||||
// a command block as defined by the command set identified by
|
||||
// bInterfaceSubClass. If the command set supported by the device uses
|
||||
// command blocks of fewer than 16 bytes in length, the significant bytes
|
||||
// shall be transferred first, beginning with the byte at offset 15. The
|
||||
// device will ignore the content of the CBWCB field past the byte at
|
||||
// offset (15 + bCBWCBLength - 1).
|
||||
//
|
||||
uint8_t CBWCB[16];
|
||||
}
|
||||
PACKED tMSCCBW;
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Flags for the bCSWStatus member of tMSCCSW
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define CSWSTATUS_CMD_SUCCESS 0
|
||||
#define CSWSTATUS_CMD_FAILED 1
|
||||
#define CSWSTATUS_PHASE_ERROR 2
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// This structure encapsulates the Command Status Word (CSW) structure that is
|
||||
// sent in response to all CBW commands.
|
||||
//
|
||||
//*****************************************************************************
|
||||
typedef struct
|
||||
{
|
||||
//
|
||||
// Signature that identifies this data packet as a CSW. The signature
|
||||
// field must contain the value 53425355h (little endian) to indicate CSW.
|
||||
//
|
||||
uint32_t dCSWSignature;
|
||||
|
||||
//
|
||||
// The device will set this field to the value received in the dCBWTag of
|
||||
// the associated CBW.
|
||||
//
|
||||
uint32_t dCSWTag;
|
||||
|
||||
//
|
||||
// For OUT transactions the device will fill the dCSWDataResidue field with
|
||||
// the difference between the amount of data expected as stated in the
|
||||
// dCBWDataTransferLength, and the actual amount of data processed by the
|
||||
// device. For IN transactions the device will fill the dCSWDataResidue
|
||||
// field with the difference between the amount of data expected as stated
|
||||
// in the dCBWDataTransferLength and the actual amount of relevant data
|
||||
// sent by the device. The dCSWDataResidue will not exceed the value sent
|
||||
// in the dCBWDataTransferLength.
|
||||
//
|
||||
uint32_t dCSWDataResidue;
|
||||
|
||||
//
|
||||
// The bCSWStatus field indicates the success or failure of the command.
|
||||
// The device shall set this byte to zero if the command completed
|
||||
// successfully. A non-zero value shall indicate a failure during command
|
||||
// execution.
|
||||
//
|
||||
uint8_t bCSWStatus;
|
||||
}
|
||||
PACKED tMSCCSW;
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Return to default packing when using the IAR Embedded Workbench compiler.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#ifdef ewarm
|
||||
#pragma pack()
|
||||
#endif
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// SCSI Command return codes.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define SCSI_CMD_STATUS_PASS 0x00
|
||||
#define SCSI_CMD_STATUS_FAIL 0x01
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// SCSI commands.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define SCSI_TEST_UNIT_READY 0x00
|
||||
#define SCSI_REQUEST_SENSE 0x03
|
||||
#define SCSI_INQUIRY_CMD 0x12
|
||||
#define SCSI_MODE_SENSE_6 0x1a
|
||||
#define SCSI_READ_CAPACITIES 0x23
|
||||
#define SCSI_READ_CAPACITY 0x25
|
||||
#define SCSI_READ_10 0x28
|
||||
#define SCSI_WRITE_10 0x2a
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// SCSI Test Unit Ready definitions.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// SCSI Inquiry command definitions.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Size of the SCSI inquiry response data.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define SCSI_INQUIRY_DATA_SZ 36
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Offset 0 of the Inquiry Data.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define SCSI_INQ_PQ_M 0xe0 // Peripheral Qualifier Mask.
|
||||
#define SCSI_INQ_PQ_CNCT 0x00 // Device connected.
|
||||
#define SCSI_INQ_PQ_DISC 0x20 // Device disconnected.
|
||||
#define SCSI_INQ_PDT_M 0x1f // Peripheral Device Type Mask.
|
||||
#define SCSI_INQ_PDT_SBC 0x00 // Direct Access device.
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Offset 1 of the Inquiry Data.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define SCSI_INQ_RMB 0x80 // Device is removable.
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Macro to check if removeable.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define SCSIIsRemovable(pData) \
|
||||
(((uint8_t *)pData)[1] & SCSI_INQ_RMB)
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// SCSI Read Capacity definitions.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Size of the SCSI Read Capacity response data.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define SCSI_READ_CAPACITY_SZ 0x08
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// SCSI Mode Sense definitions, these are passed in via the ui32Flags parameter
|
||||
// of the SCSIModeSense() function call.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Disable block descriptors.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define SCSI_MS_DBD 0x00000800
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Page Code values, used in combination with Page Control values.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define SCSI_MS_PC_VENDOR 0x00000000
|
||||
#define SCSI_MS_PC_DISCO 0x00020000
|
||||
#define SCSI_MS_PC_CONTROL 0x000a0000
|
||||
#define SCSI_MS_PC_LUN 0x00180000
|
||||
#define SCSI_MS_PC_PORT 0x00190000
|
||||
#define SCSI_MS_PC_POWER 0x001a0000
|
||||
#define SCSI_MS_PC_INFORM 0x001c0000
|
||||
#define SCSI_MS_PC_ALL 0x003f0000
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Page Control values.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define SCSI_MS_PC_CURRENT 0x00000000
|
||||
#define SCSI_MS_PC_CHANGEABLE 0x00400000
|
||||
#define SCSI_MS_PC_DEFAULT 0x00800000
|
||||
#define SCSI_MS_PC_SAVED 0x00c00000
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Request Sense Definitions.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Size of the data returned by the Request Sense command.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define SCSI_REQUEST_SENSE_SZ 18
|
||||
|
||||
#define SCSI_RS_SKEY 2 // Sense Key offset.
|
||||
#define SCSI_RS_SKEY_AD_SKEY 12 // Additional Sense Key offset.
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Offset 0 in the Request Sense response.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define SCSI_RS_VALID 0x80 // Response is valid.
|
||||
#define SCSI_RS_CUR_ERRORS 0x70 // Current errors returned.
|
||||
#define SCSI_RS_DEFER_ERRORS 0x71 // Deferred errors returned.
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Offset 2 in the Request Sense response.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define SCSI_RS_KEY_M 0x0f // Sense Key.
|
||||
#define SCSI_RS_KEY_NO_SENSE 0x00 // No Sense Data.
|
||||
#define SCSI_RS_KEY_RECOVRD_ERR 0x01 // Recovered Error.
|
||||
#define SCSI_RS_KEY_NOT_READY 0x02 // Not Ready.
|
||||
#define SCSI_RS_KEY_MEDIUM_ERR 0x03 // Error in the media.
|
||||
#define SCSI_RS_KEY_HW_ERR 0x04 // Hardware Error, non recoverable.
|
||||
#define SCSI_RS_KEY_ILGL_RQST 0x05 // Illegal request.
|
||||
#define SCSI_RS_KEY_UNIT_ATTN 0x06 // Unit changed or reset.
|
||||
#define SCSI_RS_KEY_DATA_PROT 0x07 // Write Protect error.
|
||||
#define SCSI_RS_KEY_BLANK_CHK 0x08 // Write once error, block not clear.
|
||||
#define SCSI_RS_KEY_ABORT 0x0b // Last command was aborted.
|
||||
#define SCSI_RS_ILI 0x20 // Incorrect length indicator.
|
||||
#define SCSI_RS_EOM 0x40 // End of medium condition.
|
||||
#define SCSI_RS_FILEMARK 0x80 // Command has read a filemark/setmark.
|
||||
#define SCSI_RS_MED_NOT_PRSNT 0x003a // Medium not present.
|
||||
#define SCSI_RS_MED_NOTRDY2RDY 0x0028 // Not ready to ready transition.
|
||||
#define SCSI_RS_PV_INVALID 0x0226 // Parameter Value Invalid.
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Additional information for SCSI_RS_KEY_NOT_READY
|
||||
//
|
||||
//*****************************************************************************
|
||||
#define SCSI_RS_KEY_NOTPRSNT 0x3A // Media Not Present.
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Mark the end of the C bindings section for C++ compilers.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // __USBMSC_H__
|
|
@ -0,0 +1,715 @@
|
|||
//*****************************************************************************
|
||||
//
|
||||
// usbringbuf.c - USB library ring buffer management utilities.
|
||||
//
|
||||
// Copyright (c) 2008-2013 Texas Instruments Incorporated. All rights reserved.
|
||||
// Software License Agreement
|
||||
//
|
||||
// Texas Instruments (TI) is supplying this software for use solely and
|
||||
// exclusively on TI's microcontroller products. The software is owned by
|
||||
// TI and/or its suppliers, and is protected under applicable copyright
|
||||
// laws. You may not combine this software with "viral" open-source
|
||||
// software in order to form a larger program.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
|
||||
// NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
|
||||
// NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
|
||||
// CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
|
||||
// DAMAGES, FOR ANY REASON WHATSOEVER.
|
||||
//
|
||||
// This is part of revision 1.1 of the Tiva USB Library.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "inc/hw_types.h"
|
||||
#include "driverlib/debug.h"
|
||||
#include "driverlib/interrupt.h"
|
||||
#include "usblib/usblib.h"
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! \addtogroup usblib_buffer_api
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Define NULL, if not already defined.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#ifndef NULL
|
||||
#define NULL ((void *)0)
|
||||
#endif
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Change the value of a variable atomically.
|
||||
//
|
||||
// \param pui32Val points to the index whose value is to be modified.
|
||||
// \param ui32Delta is the number of bytes to increment the index by.
|
||||
// \param ui32Size is the size of the buffer the index refers to.
|
||||
//
|
||||
// This function is used to increment a read or write buffer index that may be
|
||||
// written in various different contexts. It ensures that the
|
||||
// read/modify/write sequence is not interrupted and, hence, guards against
|
||||
// corruption of the variable. The new value is adjusted for buffer wrap.
|
||||
//
|
||||
// \return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
static void
|
||||
UpdateIndexAtomic(volatile uint32_t *pui32Val, uint32_t ui32Delta,
|
||||
uint32_t ui32Size)
|
||||
{
|
||||
bool bIntsOff;
|
||||
|
||||
//
|
||||
// Turn interrupts off temporarily.
|
||||
//
|
||||
bIntsOff = IntMasterDisable();
|
||||
|
||||
//
|
||||
// Update the variable value.
|
||||
//
|
||||
*pui32Val += ui32Delta;
|
||||
|
||||
//
|
||||
// Correct for wrap. We use a loop here since we don't want to use a
|
||||
// modulus operation with interrupts off but we don't want to fail in
|
||||
// case ui32Delta is greater than ui32Size (which is extremely unlikely
|
||||
// but...)
|
||||
//
|
||||
while(*pui32Val >= ui32Size)
|
||||
{
|
||||
*pui32Val -= ui32Size;
|
||||
}
|
||||
|
||||
//
|
||||
// Restore the interrupt state
|
||||
//
|
||||
if(!bIntsOff)
|
||||
{
|
||||
IntMasterEnable();
|
||||
}
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! Determines whether a ring buffer is full or not.
|
||||
//!
|
||||
//! \param psUSBRingBuf is the ring buffer object to empty.
|
||||
//!
|
||||
//! This function is used to determine whether or not a given ring buffer is
|
||||
//! full. The structure is specifically to ensure that we do not see
|
||||
//! warnings from the compiler related to the order of volatile accesses
|
||||
//! being undefined.
|
||||
//!
|
||||
//! \return Returns \b true if the buffer is full or \b false otherwise.
|
||||
//
|
||||
//*****************************************************************************
|
||||
bool
|
||||
USBRingBufFull(tUSBRingBufObject *psUSBRingBuf)
|
||||
{
|
||||
uint32_t ui32Write;
|
||||
uint32_t ui32Read;
|
||||
|
||||
//
|
||||
// Check the arguments.
|
||||
//
|
||||
ASSERT(psUSBRingBuf != NULL);
|
||||
|
||||
//
|
||||
// Copy the Read/Write indices for calculation.
|
||||
//
|
||||
ui32Write = psUSBRingBuf->ui32WriteIndex;
|
||||
ui32Read = psUSBRingBuf->ui32ReadIndex;
|
||||
|
||||
//
|
||||
// Return the full status of the buffer.
|
||||
//
|
||||
return((((ui32Write + 1) % psUSBRingBuf->ui32Size) == ui32Read) ? true :
|
||||
false);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! Determines whether a ring buffer is empty or not.
|
||||
//!
|
||||
//! \param psUSBRingBuf is the ring buffer object to empty.
|
||||
//!
|
||||
//! This function is used to determine whether or not a given ring buffer is
|
||||
//! empty. The structure is specifically to ensure that we do not see
|
||||
//! warnings from the compiler related to the order of volatile accesses
|
||||
//! being undefined.
|
||||
//!
|
||||
//! \return Returns \b true if the buffer is empty or \b false otherwise.
|
||||
//
|
||||
//*****************************************************************************
|
||||
bool
|
||||
USBRingBufEmpty(tUSBRingBufObject *psUSBRingBuf)
|
||||
{
|
||||
uint32_t ui32Write;
|
||||
uint32_t ui32Read;
|
||||
|
||||
//
|
||||
// Check the arguments.
|
||||
//
|
||||
ASSERT(psUSBRingBuf != NULL);
|
||||
|
||||
//
|
||||
// Copy the Read/Write indices for calculation.
|
||||
//
|
||||
ui32Write = psUSBRingBuf->ui32WriteIndex;
|
||||
ui32Read = psUSBRingBuf->ui32ReadIndex;
|
||||
|
||||
//
|
||||
// Return the empty status of the buffer.
|
||||
//
|
||||
return((ui32Write == ui32Read) ? true : false);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! Empties the ring buffer.
|
||||
//!
|
||||
//! \param psUSBRingBuf is the ring buffer object to empty.
|
||||
//!
|
||||
//! Discards all data from the ring buffer.
|
||||
//!
|
||||
//! \return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
USBRingBufFlush(tUSBRingBufObject *psUSBRingBuf)
|
||||
{
|
||||
bool bIntsOff;
|
||||
|
||||
//
|
||||
// Check the arguments.
|
||||
//
|
||||
ASSERT(psUSBRingBuf != NULL);
|
||||
|
||||
//
|
||||
// Set the Read/Write pointers to be the same. Do this with interrupts
|
||||
// disabled to prevent the possibility of corruption of the read index.
|
||||
//
|
||||
bIntsOff = IntMasterDisable();
|
||||
psUSBRingBuf->ui32ReadIndex = psUSBRingBuf->ui32WriteIndex;
|
||||
if(!bIntsOff)
|
||||
{
|
||||
IntMasterEnable();
|
||||
}
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! Returns number of bytes stored in ring buffer.
|
||||
//!
|
||||
//! \param psUSBRingBuf is the ring buffer object to check.
|
||||
//!
|
||||
//! This function returns the number of bytes stored in the ring buffer.
|
||||
//!
|
||||
//! \return Returns the number of bytes stored in the ring buffer.
|
||||
//
|
||||
//*****************************************************************************
|
||||
uint32_t
|
||||
USBRingBufUsed(tUSBRingBufObject *psUSBRingBuf)
|
||||
{
|
||||
uint32_t ui32Write;
|
||||
uint32_t ui32Read;
|
||||
|
||||
//
|
||||
// Check the arguments.
|
||||
//
|
||||
ASSERT(psUSBRingBuf != NULL);
|
||||
|
||||
//
|
||||
// Copy the Read/Write indices for calculation.
|
||||
//
|
||||
ui32Write = psUSBRingBuf->ui32WriteIndex;
|
||||
ui32Read = psUSBRingBuf->ui32ReadIndex;
|
||||
|
||||
//
|
||||
// Return the number of bytes contained in the ring buffer.
|
||||
//
|
||||
return((ui32Write >= ui32Read) ? (ui32Write - ui32Read) :
|
||||
(psUSBRingBuf->ui32Size - (ui32Read - ui32Write)));
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! Returns number of bytes available in a ring buffer.
|
||||
//!
|
||||
//! \param psUSBRingBuf is the ring buffer object to check.
|
||||
//!
|
||||
//! This function returns the number of bytes available in the ring buffer.
|
||||
//!
|
||||
//! \return Returns the number of bytes available in the ring buffer.
|
||||
//
|
||||
//*****************************************************************************
|
||||
uint32_t
|
||||
USBRingBufFree(tUSBRingBufObject *psUSBRingBuf)
|
||||
{
|
||||
//
|
||||
// Check the arguments.
|
||||
//
|
||||
ASSERT(psUSBRingBuf != NULL);
|
||||
|
||||
//
|
||||
// Return the number of bytes available in the ring buffer.
|
||||
//
|
||||
return((psUSBRingBuf->ui32Size - 1) - USBRingBufUsed(psUSBRingBuf));
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! Returns number of contiguous bytes of data stored in ring buffer ahead of
|
||||
//! the current read pointer.
|
||||
//!
|
||||
//! \param psUSBRingBuf is the ring buffer object to check.
|
||||
//!
|
||||
//! This function returns the number of contiguous bytes of data available in
|
||||
//! the ring buffer ahead of the current read pointer. This represents the
|
||||
//! largest block of data which does not straddle the buffer wrap.
|
||||
//!
|
||||
//! \return Returns the number of contiguous bytes available.
|
||||
//
|
||||
//*****************************************************************************
|
||||
uint32_t
|
||||
USBRingBufContigUsed(tUSBRingBufObject *psUSBRingBuf)
|
||||
{
|
||||
uint32_t ui32Write;
|
||||
uint32_t ui32Read;
|
||||
|
||||
//
|
||||
// Check the arguments.
|
||||
//
|
||||
ASSERT(psUSBRingBuf != NULL);
|
||||
|
||||
//
|
||||
// Copy the Read/Write indices for calculation.
|
||||
//
|
||||
ui32Write = psUSBRingBuf->ui32WriteIndex;
|
||||
ui32Read = psUSBRingBuf->ui32ReadIndex;
|
||||
|
||||
//
|
||||
// Return the number of contiguous bytes available.
|
||||
//
|
||||
return((ui32Write >= ui32Read) ? (ui32Write - ui32Read) :
|
||||
(psUSBRingBuf->ui32Size - ui32Read));
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! Returns number of contiguous free bytes available in a ring buffer.
|
||||
//!
|
||||
//! \param psUSBRingBuf is the ring buffer object to check.
|
||||
//!
|
||||
//! This function returns the number of contiguous free bytes ahead of the
|
||||
//! current write pointer in the ring buffer.
|
||||
//!
|
||||
//! \return Returns the number of contiguous bytes available in the ring
|
||||
//! buffer.
|
||||
//
|
||||
//*****************************************************************************
|
||||
uint32_t
|
||||
USBRingBufContigFree(tUSBRingBufObject *psUSBRingBuf)
|
||||
{
|
||||
uint32_t ui32Write;
|
||||
uint32_t ui32Read;
|
||||
|
||||
//
|
||||
// Check the arguments.
|
||||
//
|
||||
ASSERT(psUSBRingBuf != NULL);
|
||||
|
||||
//
|
||||
// Copy the Read/Write indices for calculation.
|
||||
//
|
||||
ui32Write = psUSBRingBuf->ui32WriteIndex;
|
||||
ui32Read = psUSBRingBuf->ui32ReadIndex;
|
||||
|
||||
//
|
||||
// Return the number of contiguous bytes available.
|
||||
//
|
||||
if(ui32Read > ui32Write)
|
||||
{
|
||||
//
|
||||
// The read pointer is above the write pointer so the amount of free
|
||||
// space is the difference between the two indices minus 1 to account
|
||||
// for the buffer full condition (write index one behind read index).
|
||||
//
|
||||
return((ui32Read - ui32Write) - 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
// If the write pointer is above the read pointer, the amount of free
|
||||
// space is the size of the buffer minus the write index. We need to
|
||||
// add a special-case adjustment if the read index is 0 since we need
|
||||
// to leave 1 byte empty to ensure we can tell the difference between
|
||||
// the buffer being full and empty.
|
||||
//
|
||||
return(psUSBRingBuf->ui32Size - ui32Write - ((ui32Read == 0) ? 1 : 0));
|
||||
}
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! Returns the size in bytes of a ring buffer.
|
||||
//!
|
||||
//! \param psUSBRingBuf is the ring buffer object to check.
|
||||
//!
|
||||
//! This function returns the size of the ring buffer.
|
||||
//!
|
||||
//! \return Returns the size in bytes of the ring buffer.
|
||||
//
|
||||
//*****************************************************************************
|
||||
uint32_t
|
||||
USBRingBufSize(tUSBRingBufObject *psUSBRingBuf)
|
||||
{
|
||||
//
|
||||
// Check the arguments.
|
||||
//
|
||||
ASSERT(psUSBRingBuf != NULL);
|
||||
|
||||
//
|
||||
// Return the number of bytes available in the ring buffer.
|
||||
//
|
||||
return(psUSBRingBuf->ui32Size);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! Reads a single byte of data from a ring buffer.
|
||||
//!
|
||||
//! \param psUSBRingBuf points to the ring buffer to be written to.
|
||||
//!
|
||||
//! This function reads a single byte of data from a ring buffer.
|
||||
//!
|
||||
//! \return The byte read from the ring buffer.
|
||||
//
|
||||
//*****************************************************************************
|
||||
uint8_t
|
||||
USBRingBufReadOne(tUSBRingBufObject *psUSBRingBuf)
|
||||
{
|
||||
uint8_t ui8Temp;
|
||||
|
||||
//
|
||||
// Check the arguments.
|
||||
//
|
||||
ASSERT(psUSBRingBuf != NULL);
|
||||
|
||||
//
|
||||
// Verify that space is available in the buffer.
|
||||
//
|
||||
ASSERT(USBRingBufUsed(psUSBRingBuf) != 0);
|
||||
|
||||
//
|
||||
// Write the data byte.
|
||||
//
|
||||
ui8Temp = psUSBRingBuf->pui8Buf[psUSBRingBuf->ui32ReadIndex];
|
||||
|
||||
//
|
||||
// Increment the read index.
|
||||
//
|
||||
UpdateIndexAtomic(&psUSBRingBuf->ui32ReadIndex, 1, psUSBRingBuf->ui32Size);
|
||||
|
||||
//
|
||||
// Return the character read.
|
||||
//
|
||||
return(ui8Temp);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! Reads data from a ring buffer.
|
||||
//!
|
||||
//! \param psUSBRingBuf points to the ring buffer to be read from.
|
||||
//! \param pui8Data points to where the data should be stored.
|
||||
//! \param ui32Length is the number of bytes to be read.
|
||||
//!
|
||||
//! This function reads a sequence of bytes from a ring buffer.
|
||||
//!
|
||||
//! \return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
USBRingBufRead(tUSBRingBufObject *psUSBRingBuf, uint8_t *pui8Data,
|
||||
uint32_t ui32Length)
|
||||
{
|
||||
uint32_t ui32Temp;
|
||||
|
||||
//
|
||||
// Check the arguments.
|
||||
//
|
||||
ASSERT(psUSBRingBuf != NULL);
|
||||
ASSERT(pui8Data != NULL);
|
||||
ASSERT(ui32Length != 0);
|
||||
|
||||
//
|
||||
// Verify that data is available in the buffer.
|
||||
//
|
||||
ASSERT(ui32Length <= USBRingBufUsed(psUSBRingBuf));
|
||||
|
||||
//
|
||||
// Read the data from the ring buffer.
|
||||
//
|
||||
for(ui32Temp = 0; ui32Temp < ui32Length; ui32Temp++)
|
||||
{
|
||||
pui8Data[ui32Temp] = USBRingBufReadOne(psUSBRingBuf);
|
||||
}
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! Removes bytes from the ring buffer by advancing the read index.
|
||||
//!
|
||||
//! \param psUSBRingBuf points to the ring buffer from which bytes are to be
|
||||
//! removed.
|
||||
//! \param ui32NumBytes is the number of bytes to be removed from the buffer.
|
||||
//!
|
||||
//! This function advances the ring buffer read index by a given number of
|
||||
//! bytes, removing that number of bytes of data from the buffer. If
|
||||
//! \e ui32NumBytes is larger than the number of bytes currently in the buffer,
|
||||
//! the buffer is emptied.
|
||||
//!
|
||||
//! \return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
USBRingBufAdvanceRead(tUSBRingBufObject *psUSBRingBuf, uint32_t ui32NumBytes)
|
||||
{
|
||||
uint32_t ui32Count;
|
||||
|
||||
//
|
||||
// Check the arguments.
|
||||
//
|
||||
ASSERT(psUSBRingBuf != NULL);
|
||||
|
||||
//
|
||||
// Make sure that we are not being asked to remove more data than is
|
||||
// there to be removed.
|
||||
//
|
||||
ui32Count = USBRingBufUsed(psUSBRingBuf);
|
||||
ui32Count = (ui32Count < ui32NumBytes) ? ui32Count : ui32NumBytes;
|
||||
|
||||
//
|
||||
// Advance the buffer read index by the required number of bytes.
|
||||
//
|
||||
UpdateIndexAtomic(&psUSBRingBuf->ui32ReadIndex, ui32Count,
|
||||
psUSBRingBuf->ui32Size);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! Adds bytes to the ring buffer by advancing the write index.
|
||||
//!
|
||||
//! \param psUSBRingBuf points to the ring buffer to which bytes have been
|
||||
//! added.
|
||||
//! \param ui32NumBytes is the number of bytes added to the buffer.
|
||||
//!
|
||||
//! This function should be used by clients who wish to add data to the buffer
|
||||
//! directly rather than via calls to USBRingBufWrite() or
|
||||
//! USBRingBufWriteOne(). It advances the write index by a given number of
|
||||
//! bytes.
|
||||
//!
|
||||
//! \note It is considered an error if the \e ui32NumBytes parameter is larger
|
||||
//! than the amount of free space in the buffer and a debug build of this
|
||||
//! function will fail (ASSERT) if this condition is detected. In a release
|
||||
//! build, the buffer read pointer will be advanced if too much data is written
|
||||
//! but this will, of course, result in some of the oldest data in the buffer
|
||||
//! being discarded and also, depending upon how data is being read from
|
||||
//! the buffer, may result in a race condition which could corrupt the read
|
||||
//! pointer.
|
||||
//!
|
||||
//! \return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
USBRingBufAdvanceWrite(tUSBRingBufObject *psUSBRingBuf, uint32_t ui32NumBytes)
|
||||
{
|
||||
uint32_t ui32Count;
|
||||
|
||||
//
|
||||
// Check the arguments.
|
||||
//
|
||||
ASSERT(psUSBRingBuf != NULL);
|
||||
|
||||
//
|
||||
// Make sure we were not asked to add a silly number of bytes.
|
||||
//
|
||||
ASSERT(ui32NumBytes <= psUSBRingBuf->ui32Size);
|
||||
|
||||
//
|
||||
// Determine how much free space we currently think the buffer has.
|
||||
//
|
||||
ui32Count = USBRingBufFree(psUSBRingBuf);
|
||||
|
||||
//
|
||||
// Check that the client has not added more data to the buffer than there
|
||||
// is space for. In this case, corruption may have occurred since the
|
||||
// buffer may have been read under interrupt context while the writer was
|
||||
// busy trashing the area around the read pointer.
|
||||
//
|
||||
ASSERT(ui32Count >= ui32NumBytes);
|
||||
|
||||
//
|
||||
// Update the write pointer.
|
||||
//
|
||||
psUSBRingBuf->ui32WriteIndex += ui32NumBytes;
|
||||
|
||||
//
|
||||
// Check and correct for wrap.
|
||||
//
|
||||
if(psUSBRingBuf->ui32WriteIndex >= psUSBRingBuf->ui32Size)
|
||||
{
|
||||
psUSBRingBuf->ui32WriteIndex -= psUSBRingBuf->ui32Size;
|
||||
}
|
||||
|
||||
//
|
||||
// Did the client add more bytes than the buffer had free space for? This
|
||||
// should be considered a bug since, unless this function is called in
|
||||
// the same context as the code which is reading from the buffer, writing
|
||||
// over the earliest data can cause corrupted data to be read. The
|
||||
// ASSERT above catches this in debug builds but, in release builds, we
|
||||
// go ahead and try to fix up the read pointer appropriately.
|
||||
//
|
||||
if(ui32Count < ui32NumBytes)
|
||||
{
|
||||
//
|
||||
// Yes - we need to advance the read pointer to ahead of the write
|
||||
// pointer to discard some of the oldest data.
|
||||
//
|
||||
psUSBRingBuf->ui32ReadIndex = psUSBRingBuf->ui32WriteIndex + 1;
|
||||
|
||||
//
|
||||
// Correct for buffer wrap if necessary.
|
||||
//
|
||||
if(psUSBRingBuf->ui32ReadIndex >= psUSBRingBuf->ui32Size)
|
||||
{
|
||||
psUSBRingBuf->ui32ReadIndex -= psUSBRingBuf->ui32Size;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! Writes a single byte of data to a ring buffer.
|
||||
//!
|
||||
//! \param psUSBRingBuf points to the ring buffer to be written to.
|
||||
//! \param ui8Data is the byte to be written.
|
||||
//!
|
||||
//! This function writes a single byte of data into a ring buffer.
|
||||
//!
|
||||
//! \return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
USBRingBufWriteOne(tUSBRingBufObject *psUSBRingBuf, uint8_t ui8Data)
|
||||
{
|
||||
//
|
||||
// Check the arguments.
|
||||
//
|
||||
ASSERT(psUSBRingBuf != NULL);
|
||||
|
||||
//
|
||||
// Verify that space is available in the buffer.
|
||||
//
|
||||
ASSERT(USBRingBufFree(psUSBRingBuf) != 0);
|
||||
|
||||
//
|
||||
// Write the data byte.
|
||||
//
|
||||
psUSBRingBuf->pui8Buf[psUSBRingBuf->ui32WriteIndex] = ui8Data;
|
||||
|
||||
//
|
||||
// Increment the write index.
|
||||
//
|
||||
UpdateIndexAtomic(&psUSBRingBuf->ui32WriteIndex, 1,
|
||||
psUSBRingBuf->ui32Size);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! Writes data to a ring buffer.
|
||||
//!
|
||||
//! \param psUSBRingBuf points to the ring buffer to be written to.
|
||||
//! \param pui8Data points to the data to be written.
|
||||
//! \param ui32Length is the number of bytes to be written.
|
||||
//!
|
||||
//! This function write a sequence of bytes into a ring buffer.
|
||||
//!
|
||||
//! \return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
USBRingBufWrite(tUSBRingBufObject *psUSBRingBuf, const uint8_t *pui8Data,
|
||||
uint32_t ui32Length)
|
||||
{
|
||||
uint32_t ui32Temp;
|
||||
|
||||
//
|
||||
// Check the arguments.
|
||||
//
|
||||
ASSERT(psUSBRingBuf != NULL);
|
||||
ASSERT(pui8Data != NULL);
|
||||
ASSERT(ui32Length != 0);
|
||||
|
||||
//
|
||||
// Verify that space is available in the buffer.
|
||||
//
|
||||
ASSERT(ui32Length <= USBRingBufFree(psUSBRingBuf));
|
||||
|
||||
//
|
||||
// Write the data into the ring buffer.
|
||||
//
|
||||
for(ui32Temp = 0; ui32Temp < ui32Length; ui32Temp++)
|
||||
{
|
||||
USBRingBufWriteOne(psUSBRingBuf, pui8Data[ui32Temp]);
|
||||
}
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! Initializes a ring buffer object.
|
||||
//!
|
||||
//! \param psUSBRingBuf points to the ring buffer to be initialized.
|
||||
//! \param pui8Buf points to the data buffer to be used for the ring buffer.
|
||||
//! \param ui32Size is the size of the buffer in bytes.
|
||||
//!
|
||||
//! This function initializes a ring buffer object, preparing it to store data.
|
||||
//!
|
||||
//! \return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
USBRingBufInit(tUSBRingBufObject *psUSBRingBuf, uint8_t *pui8Buf,
|
||||
uint32_t ui32Size)
|
||||
{
|
||||
//
|
||||
// Check the arguments.
|
||||
//
|
||||
ASSERT(psUSBRingBuf != NULL);
|
||||
ASSERT(pui8Buf != NULL);
|
||||
ASSERT(ui32Size != 0);
|
||||
|
||||
//
|
||||
// Initialize the ring buffer object.
|
||||
//
|
||||
psUSBRingBuf->ui32Size = ui32Size;
|
||||
psUSBRingBuf->pui8Buf = pui8Buf;
|
||||
psUSBRingBuf->ui32WriteIndex = psUSBRingBuf->ui32ReadIndex = 0;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Close the Doxygen group.
|
||||
//! @}
|
||||
//
|
||||
//*****************************************************************************
|
|
@ -0,0 +1,217 @@
|
|||
//*****************************************************************************
|
||||
//
|
||||
// usbtick.c - Functions related to USB stack tick timer handling.
|
||||
//
|
||||
// Copyright (c) 2008-2013 Texas Instruments Incorporated. All rights reserved.
|
||||
// Software License Agreement
|
||||
//
|
||||
// Texas Instruments (TI) is supplying this software for use solely and
|
||||
// exclusively on TI's microcontroller products. The software is owned by
|
||||
// TI and/or its suppliers, and is protected under applicable copyright
|
||||
// laws. You may not combine this software with "viral" open-source
|
||||
// software in order to form a larger program.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
|
||||
// NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
|
||||
// NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
|
||||
// CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
|
||||
// DAMAGES, FOR ANY REASON WHATSOEVER.
|
||||
//
|
||||
// This is part of revision 1.1 of the Tiva USB Library.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "inc/hw_types.h"
|
||||
#include "driverlib/debug.h"
|
||||
#include "usblib/usblib.h"
|
||||
#include "usblib/usblibpriv.h"
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! \addtogroup general_usblib_api
|
||||
//! @{
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// These are the internal timer tick handlers used by the USB stack. Handlers
|
||||
// in g_pfnTickHandlers are called in the context of the USB SOF interrupt
|
||||
// every USB_SOF_TICK_DIVIDE milliseconds.
|
||||
//
|
||||
//*****************************************************************************
|
||||
tUSBTickHandler g_pfnTickHandlers[MAX_USB_TICK_HANDLERS];
|
||||
void *g_pvTickInstance[MAX_USB_TICK_HANDLERS];
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Flag to indicate whether or not we have been initialized.
|
||||
//
|
||||
//*****************************************************************************
|
||||
bool g_bUSBTimerInitialized = false;
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// This is the current tick value in ms for the system. This is used for all
|
||||
// instances of USB controllers and for all timer tick handlers.
|
||||
//
|
||||
//*****************************************************************************
|
||||
uint32_t g_ui32CurrentUSBTick = 0;
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// This is the total number of SOF interrupts received since the system
|
||||
// booted. The value is incremented by the low level device- or host-interrupt
|
||||
// handler functions.
|
||||
//
|
||||
//*****************************************************************************
|
||||
uint32_t g_ui32USBSOFCount = 0;
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// This internal function initializes the variables used in processing timer
|
||||
// ticks.
|
||||
//
|
||||
// This function should only be called from within the USB library. It is set
|
||||
// up to ensure that it can be called multiple times if necessary without
|
||||
// the previous configuration being erased (to cater for OTG mode switching).
|
||||
//
|
||||
// \return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
InternalUSBTickInit(void)
|
||||
{
|
||||
uint32_t ui32Loop;
|
||||
|
||||
if(!g_bUSBTimerInitialized)
|
||||
{
|
||||
for(ui32Loop = 0; ui32Loop < MAX_USB_TICK_HANDLERS; ui32Loop++)
|
||||
{
|
||||
g_pfnTickHandlers[ui32Loop] = (tUSBTickHandler)0;
|
||||
g_pvTickInstance[ui32Loop] = 0;
|
||||
}
|
||||
|
||||
g_bUSBTimerInitialized = true;
|
||||
}
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// This internal function resets the USB tick handler.
|
||||
//
|
||||
// This function should only be called from within the USB library. It will
|
||||
// clear out the tick handler state and should be called to allow the tick
|
||||
// handlers to be initialized once USBDCDInit() function is called.
|
||||
//
|
||||
// \return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
InternalUSBTickReset(void)
|
||||
{
|
||||
//
|
||||
// Reset the initialized flag so that the next time InternalUSBTickInit()
|
||||
// is called.
|
||||
//
|
||||
g_bUSBTimerInitialized = 0;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// This internal function handles registering OTG, Host, or Device SOF timer
|
||||
// handler functions.
|
||||
//
|
||||
// \param pfHandler specifies the handler to call for the given type of
|
||||
// handler.
|
||||
// \param pvInstance is the instance pointer that will be returned to the
|
||||
// function provided in the \e pfHandler function.
|
||||
//
|
||||
// This function should only be called inside the USB library and only as a
|
||||
// result to a call to reinitialize the stack in a new mode. Currently the
|
||||
// following 3 types of timer tick handlers can be registered:
|
||||
// TICK_HANDLER_OTG, TICK_HANDLER_HOST, or TICK_HANDLER_DEVICE. Handlers
|
||||
// registered via this function are called in the context of the SOF interrupt.
|
||||
//
|
||||
// \return A value of zero means that the tick handler was registered and any
|
||||
// other value indicates an error.
|
||||
//
|
||||
//*****************************************************************************
|
||||
int32_t
|
||||
InternalUSBRegisterTickHandler(tUSBTickHandler pfHandler, void *pvInstance)
|
||||
{
|
||||
int32_t i32Idx;
|
||||
|
||||
for(i32Idx = 0; i32Idx < MAX_USB_TICK_HANDLERS; i32Idx++)
|
||||
{
|
||||
if(g_pfnTickHandlers[i32Idx] == 0)
|
||||
{
|
||||
//
|
||||
// Save the handler.
|
||||
//
|
||||
g_pfnTickHandlers[i32Idx] = pfHandler;
|
||||
|
||||
//
|
||||
// Save the instance data.
|
||||
//
|
||||
g_pvTickInstance[i32Idx] = pvInstance;
|
||||
}
|
||||
}
|
||||
|
||||
if(i32Idx == MAX_USB_TICK_HANDLERS)
|
||||
{
|
||||
return(-1);
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! \internal
|
||||
//!
|
||||
//! Calls internal handlers in response to a tick based on the start of frame
|
||||
//! interrupt.
|
||||
//!
|
||||
//! \param ui32TicksmS specifies how many milliseconds have passed since the
|
||||
//! last call to this function.
|
||||
//!
|
||||
//! This function is called every 5mS in the context of the Start of Frame
|
||||
//! (SOF) interrupt. It is used to call any registered internal tick
|
||||
//! functions.
|
||||
//!
|
||||
//! This function should only be called from within the USB library.
|
||||
//!
|
||||
//! \return None.
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
InternalUSBStartOfFrameTick(uint32_t ui32TicksmS)
|
||||
{
|
||||
int32_t i32Idx;
|
||||
|
||||
//
|
||||
// Advance time.
|
||||
//
|
||||
g_ui32CurrentUSBTick += ui32TicksmS;
|
||||
|
||||
//
|
||||
// Call any registered SOF tick handlers.
|
||||
//
|
||||
for(i32Idx = 0; i32Idx < MAX_USB_TICK_HANDLERS; i32Idx++)
|
||||
{
|
||||
if(g_pfnTickHandlers[i32Idx])
|
||||
{
|
||||
g_pfnTickHandlers[i32Idx](g_pvTickInstance[i32Idx], ui32TicksmS);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Close the Doxygen group.
|
||||
//! @}
|
||||
//
|
||||
//*****************************************************************************
|
|
@ -103,6 +103,18 @@ static void Init(void)
|
|||
(UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE |
|
||||
UART_CONFIG_PAR_NONE));
|
||||
#endif
|
||||
#if (BOOT_COM_USB_ENABLE > 0)
|
||||
/* enable the GPIO peripheral used for USB, and configure the USB pins */
|
||||
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
|
||||
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOL);
|
||||
GPIOPinTypeUSBAnalog(GPIO_PORTB_BASE, GPIO_PIN_0 | GPIO_PIN_1);
|
||||
GPIOPinTypeUSBAnalog(GPIO_PORTL_BASE, GPIO_PIN_6 | GPIO_PIN_7);
|
||||
#endif
|
||||
/* enable the GPIO port to which the SELECT button is connected */
|
||||
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOM);
|
||||
/* configure the SELECT button pin as an input with pull-up */
|
||||
GPIODirModeSet(GPIO_PORTM_BASE, GPIO_PIN_4, GPIO_DIR_MODE_IN);
|
||||
GPIOPadConfigSet(GPIO_PORTM_BASE, GPIO_PIN_4, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU);
|
||||
} /*** end of Init ***/
|
||||
|
||||
|
||||
|
|
Binary file not shown.
|
@ -1,308 +1,308 @@
|
|||
S01C000064656D6F70726F675F646B5F746D3463313233672E73726563A9
|
||||
S11360005804002089720000A1720000A1720000EF
|
||||
S1136010A1720000A1720000A1720000A172000030
|
||||
S1136020A1720000A1720000A1720000A172000020
|
||||
S1136030A1720000A1720000A1720000AB6A00000E
|
||||
S1136040A1720000A1720000A1720000A172000000
|
||||
S1136050A1720000A1720000A1720000A1720000F0
|
||||
S1136060A1720000A1720000A1720000A1720000E0
|
||||
S1136070A1720000A1720000A1720000A1720000D0
|
||||
S1136080A1720000A1720000A1720000A1720000C0
|
||||
S1136090A1720000A1720000A1720000A1720000B0
|
||||
S11360A0A1720000A1720000A1720000A1720000A0
|
||||
S11360B0A1720000A1720000A1720000A172000090
|
||||
S11360C0A1720000A1720000A1720000A172000080
|
||||
S11360D0A1720000A1720000A1720000A172000070
|
||||
S11360E0A1720000A1720000A1720000A172000060
|
||||
S11360F0A1720000A1720000A1720000A172000050
|
||||
S1136100A1720000A1720000A1720000A17200003F
|
||||
S1136110A1720000A1720000A1720000A17200002F
|
||||
S1136120A1720000A1720000A1720000A17200001F
|
||||
S1136130A1720000A1720000A1720000A17200000F
|
||||
S1136140A1720000A1720000A1720000A1720000FF
|
||||
S1136150A1720000A1720000A1720000A1720000EF
|
||||
S1136160A1720000A1720000A1720000A1720000DF
|
||||
S1136170A1720000A1720000A1720000A1720000CF
|
||||
S1136180A1720000A1720000A1720000A1720000BF
|
||||
S1136190A1720000A1720000A1720000A1720000AF
|
||||
S11361A0A1720000A1720000A1720000A17200009F
|
||||
S11361B0A1720000A1720000A1720000A17200008F
|
||||
S11361C0A1720000A1720000A1720000A17200007F
|
||||
S11361D0A1720000A1720000A1720000A17200006F
|
||||
S11361E0A1720000A1720000A1720000A17200005F
|
||||
S11361F0A1720000A1720000A1720000A17200004F
|
||||
S1136200A1720000A1720000A1720000A17200003E
|
||||
S1136210A1720000A1720000A1720000A17200002E
|
||||
S1136220A1720000A1720000A1720000A17200001E
|
||||
S1136230A1720000A1720000A1720000A17200000E
|
||||
S1136240A1720000A1720000A1720000A1720000FE
|
||||
S1136250A1720000A1720000A1720000A1720000EE
|
||||
S1136260A1720000A1720000A1720000EE11AA55F3
|
||||
S1136270DFF81015884200F02E81DFF80C158842F3
|
||||
S113628000F02981DFF80415884200F02481DFF84A
|
||||
S11362900015884200F01F81DFF8F814884200F0EE
|
||||
S11362A01A81DFF8F414884200F01581DFF8EC1449
|
||||
S11362B0884200F01081DFF8E814884200F00B8176
|
||||
S11362C0DFF8E014884200F00681DFF8DC1488422D
|
||||
S11362D000F00181DFF8D414884200F0FC80DFF87C
|
||||
S11362E0D014884200F0F780DFF8C814884200F028
|
||||
S11362F0F280DFF8C414884200F0ED80DFF8BC14AB
|
||||
S1136300884200F0E880DFF8B814884200F0E380A7
|
||||
S1136310DFF8B014884200F0DE80DFF8AC14884265
|
||||
S113632000F0D980DFF8A414884200F0D480DFF8AC
|
||||
S1136330A014884200F0CF80DFF89814884200F05F
|
||||
S1136340CA80DFF89414884200F0C580DFF88C140A
|
||||
S1136350884200F0C080DFF88814884200F0BB80D7
|
||||
S1136360DFF88014884200F0B680DFF87C1488429D
|
||||
S113637000F0B180DFF87414884200F0AC80DFF8DC
|
||||
S11363807014884200F0A780DFF86814884200F097
|
||||
S1136390A280DFF86414884200F09D80DFF85C146A
|
||||
S11363A0884200F09880DFF85814884200F0938007
|
||||
S11363B0DFF85014884200F08E80DFF84C148842D5
|
||||
S11363C000F08980DFF84414884200F08480DFF80C
|
||||
S11363D04014884200F07F80DFF8381488427AD075
|
||||
S11363E0DFF83414884276D0DFF83014884272D053
|
||||
S11363F0DFF82C1488426ED0DFF8281488426AD063
|
||||
S1136400DFF82414884266D0DFF82014884262D072
|
||||
S1136410DFF81C1488425ED0DFF8181488425AD082
|
||||
S1136420DFF81414884256D0DFF81014884252D092
|
||||
S1136430DFF80C1488424ED0DFF8081488424AD0A2
|
||||
S1136440DFF80414884246D0DFF80014884242D0B2
|
||||
S1136450DFF8FC1388423ED0DFF8F81388423AD0C4
|
||||
S1136460DFF8F413884236D0DFF8F013884232D0D4
|
||||
S1136470DFF8EC1388422ED0DFF8E81388422AD0E4
|
||||
S1136480DFF8E413884226D0DFF8E013884222D0F4
|
||||
S1136490DFF8DC1388421ED010F1805F1BD0DFF8D8
|
||||
S11364A0D413884217D0DFF8D013884213D0DFF812
|
||||
S11364B0CC1388420FD0DFF8C81388420BD0DFF822
|
||||
S11364C0C413884207D0DFF8C013884203D0DFF832
|
||||
S11364D0BC13884201D1012000E00020C0B2704703
|
||||
S11364E010B504002000FFF7C3FE002805D140F2D8
|
||||
S11364F04321DFF89C0300F00EFAC4F30720DFF811
|
||||
S113650094130818E1B2890051EA401050F0844015
|
||||
S11365100121016010BDDFF88C03DFF88C130160EA
|
||||
S1136520FEE700000138FDD17047704770B50400E4
|
||||
S1136530DFF864030568DFF87403066855F4006542
|
||||
S113654035F4800556F40066DFF84C030560DFF887
|
||||
S11365505C03066015F0010014F0010191F00101E3
|
||||
S1136560C0B208421ED074F001000540DFF82803D1
|
||||
S11365700560002E07D516F07000302809D016F0FB
|
||||
S11365807000702805D0002E08D415F03000302893
|
||||
S113659004D14FF48050FFF7C5FF03E05FF40020FF
|
||||
S11365A0FFF7C0FF35F4FE6514F4FE600543DFF821
|
||||
S11365B000030640DFF8FC022040064314F0080004
|
||||
S11365C056EAC006DFF8D0020560DFF8E002066094
|
||||
S11365D01020FFF7A7FF35F4005514F400500543CD
|
||||
S11365E036F4005614F400500643DFF8B00240219C
|
||||
S11365F00160002E06D5DFF8B4020660DFF89802C9
|
||||
S1136600056005E0DFF890020560DFF8A00206608F
|
||||
S1136610DFF8A4020540DFF8A4022040054336F069
|
||||
S1136620FC5614F0FC500643600008D555F4800570
|
||||
S113663036F48006DFF888022040064301E036F095
|
||||
S1136640804620050ED44FF4004000E0401E002890
|
||||
S113665004D0DFF84C1209684906F7D535F4006513
|
||||
S113666036F40066DFF830020560DFF840020660A9
|
||||
S11366701020FFF757FF70BD38B5DFF848020068F7
|
||||
S1136680DFF844120840DFF84412884205D040F293
|
||||
S11366909761DFF8FC0100F03EF9DFF8FC010168C6
|
||||
S11366A0DFF808020268002A02D512F0700001E047
|
||||
S11366B011F03000002808D0102849D020284AD0F2
|
||||
S11366C030284BD070284CD04EE0C1F38410DFF852
|
||||
S11366D0003253F82000DFF8FC31134013F1004F6F
|
||||
S11366E003D0002A1DD40B051BD4DFF8EC311B6842
|
||||
S11366F0DFF8E8412468C4F304256D1C14F01F047A
|
||||
S1136700641C04FB05F46400B0FBF4F09C05A40DC8
|
||||
S1136710C3F3892303FB00F39B0A04FB003051F409
|
||||
S113672080014B022DD5002A26D553001ED5DFF853
|
||||
S1136730A431134013F1004F03D0002A16D40905E5
|
||||
S113674014D44000C2F38651491CB0FBF1F018E0A8
|
||||
S1136750DFF88C01BFE7DFF88C01BCE747F230506B
|
||||
S1136760B9E74FF40040B6E700200AE0C2F3C55190
|
||||
S1136770491CB0FBF1F004E0C1F3C351491CB0FB68
|
||||
S1136780F1F032BD003800F0013800F0003400F0C0
|
||||
S1136790013400F0023400F0003C00F0013C00F051
|
||||
S11367A0023C00F0005800F0005400F0000800F033
|
||||
S11367B0010800F0020800F0030800F0040800F0EB
|
||||
S11367C0050800F0060800F0070800F0080800F0CB
|
||||
S11367D0090800F00A0800F00B0800F00C0800F0AB
|
||||
S11367E00D0800F00E0800F00F0800F0100800F08B
|
||||
S11367F0001400F0002000F0012000F0022000F05E
|
||||
S1136800032000F0042000F0052000F0004800F010
|
||||
S1136810005000F0004000F0014000F0004400F09F
|
||||
S1136820014400F0001C00F0011C00F0021C00F008
|
||||
S1136830031C00F0000400F0010400F0020400F066
|
||||
S1136840030400F0040400F0050400F0001800F054
|
||||
S1136850011800F0021800F0031800F0041800F00A
|
||||
S1136860051800F0061800F0071800F0000C00F0FE
|
||||
S1136870002800F0010000F0005C00F0015C00F072
|
||||
S1136880025C00F0035C00F0045C00F0055C00F0C6
|
||||
S1136890B470000000E60F4060E00F4058E00F4085
|
||||
S11368A050E00F400CED00E00400FA0570E00F40EA
|
||||
S11368B08FFFFF7F30000080FEFF3FF80100C0071C
|
||||
S11368C00000404000E00F400000FF700000051091
|
||||
S11368D0487000000008008060E10F4064E10F4050
|
||||
S11368E00024F40000093D0080B500F007F800F032
|
||||
S11368F021F800F08FF800F033F8FAE780B500F0E3
|
||||
S1136900B3F80748FFF712FE00F076F800F0B6F887
|
||||
S113691000F0D4F801BD034A106003480160FEE7AB
|
||||
S11369204005C001480000204C00002080B5FFF75E
|
||||
S1136930F2FD01BD80B52A48FFF7D2FD2948FFF7D3
|
||||
S1136940CFFD03215FF0402000F03DFAFFF794FEF5
|
||||
S113695060234FF461420100234800F0A4FA01BD12
|
||||
S113696080B52248007800280BD1214800F02BF88C
|
||||
S1136970012827D11D48012101701E480021017002
|
||||
S113698020E01C4800781A494018401C00F01BF80D
|
||||
S1136990012817D117480078401C1649087015487B
|
||||
S11369A000781349097888420CD1104800210170FD
|
||||
S11369B00F484078FF2805D10D488078002801D180
|
||||
S11369C0FFF7B4FF01BD10B50400074800F0E1FA79
|
||||
S11369D010F1010F02D02070012000E0002010BD52
|
||||
S11369E0001800F0000800F000C00040550000202E
|
||||
S11369F0000000205400002080B51748FFF770FD08
|
||||
S1136A000421164800F0C3F900220421134800F0C1
|
||||
S1136A10AAF901BD10B500F045F80400104800685B
|
||||
S1136A20201AB0F5FA7F16D30E480078002808D152
|
||||
S1136A300C480121017004220421084800F093F954
|
||||
S1136A4007E008480021017000220421034800F0F7
|
||||
S1136A508AF90348046010BD060800F00060024093
|
||||
S1136A6044000020560000200348006850F04040D5
|
||||
S1136A70014908607047000034EF00E080B5FFF77B
|
||||
S1136A80FBFD4FF47A71B0FBF1F000F0B9FA00F0BD
|
||||
S1136A90A9FA00F0AEFA002000F001F801BD0649A1
|
||||
S1136AA00860704704480068704703480068401C49
|
||||
S1136AB001490860704700005000002080B500F0D4
|
||||
S1136AC0B5FA01BDB0F1402F5BD0DFF83013884236
|
||||
S1136AD057D0DFF82C13884253D0DFF828138842AC
|
||||
S1136AE04FD0DFF8241388424BD0DFF820138842BC
|
||||
S1136AF047D0DFF81C13884243D0DFF818138842CC
|
||||
S1136B003FD0DFF8141388423BD0DFF810138842DB
|
||||
S1136B1037D0DFF80C13884233D0DFF808138842EB
|
||||
S1136B202FD0DFF8041388422BD0DFF800138842FB
|
||||
S1136B3027D0DFF8FC12884223D0DFF8F81288420D
|
||||
S1136B401FD0DFF8F41288421BD0DFF8F01288421D
|
||||
S1136B5017D0DFF8EC12884213D0DFF8E81288422D
|
||||
S1136B600FD0DFF8E41288420BD0DFF8E01288423D
|
||||
S1136B7007D0DFF8DC12884203D0DFF8D81288424D
|
||||
S1136B8001D1012000E00020C0B2704770B50400BC
|
||||
S1136B900D0016002000FFF795FF002804D1FB210B
|
||||
S1136BA0DFF8B402FFF7B7FE002E08D0012E06D09E
|
||||
S1136BB0022E04D0FE21DFF8A002FFF7ACFEF0079E
|
||||
S1136BC005D514F580600068EDB2284304E014F59F
|
||||
S1136BD080600068EDB2A84314F580610860B007D6
|
||||
S1136BE005D514F584600068EDB2284304E014F57B
|
||||
S1136BF084600068EDB2A84314F58461086070BD38
|
||||
S1136C00F8B504000D0017001E002000FFF75AFF1E
|
||||
S1136C10002805D140F2E111DFF83C02FFF77BFECA
|
||||
S1136C20012F0BD0022F09D0042F07D00C2F05D031
|
||||
S1136C3040F2E511DFF82002FFF76DFE082E0DD0BB
|
||||
S1136C400A2E0BD00C2E09D0092E07D0002E05D009
|
||||
S1136C504FF4F571DFF80002FFF75DFEF80705D584
|
||||
S1136C6014F5A0600068EDB2284304E014F5A060B8
|
||||
S1136C700068EDB2A84314F5A0610860B80704D514
|
||||
S1136C80D4F80405EDB2284303E0D4F80405EDB2CA
|
||||
S1136C90A843C4F80405780705D514F5A160006875
|
||||
S1136CA0EDB2284304E014F5A1600068EDB2A843F6
|
||||
S1136CB014F5A1610860380705D514F5A3600068D0
|
||||
S1136CC0EDB2284304E014F5A3600068EDB2A843D4
|
||||
S1136CD014F5A3610860F00704D5D4F80C05EDB2EF
|
||||
S1136CE0284303E0D4F80C05EDB2A843C4F80C051E
|
||||
S1136CF0B00705D514F5A2600068EDB2284304E09E
|
||||
S1136D0014F5A2600068EDB2A84314F5A26108600E
|
||||
S1136D10700704D5D4F81405EDB2284303E0D4F881
|
||||
S1136D201405EDB2A843C4F81405300704D5D4F80B
|
||||
S1136D301C05EDB2284303E0D4F81C05EDB2A843CA
|
||||
S1136D40C4F81C05002E05D114F5A5600068EDB249
|
||||
S1136D50284304E014F5A5600068EDB2A84314F5D7
|
||||
S1136D60A5610860F1BD70B504000D001600200097
|
||||
S1136D70FFF7A8FE002805D140F28531DFF8D800DE
|
||||
S1136D80FFF7C9FDEDB2F6B244F8256070BD38B521
|
||||
S1136D9004000D002000FFF795FE002805D14FF4F4
|
||||
S1136DA09E61DFF8B400FFF7B6FD08230122290035
|
||||
S1136DB0C9B22000FFF724FF01222900C9B2200034
|
||||
S1136DC0FFF7E4FE31BD38B504000D002000FFF7E5
|
||||
S1136DD079FE002804D14FF4D7611F48FFF79BFDCB
|
||||
S1136DE002222900C9B22000FFF7D0FE08230122A5
|
||||
S1136DF02900C9B22000FFF703FF31BD0080054020
|
||||
S1136E0000500040009005400060004000A0054094
|
||||
S1136E100070004000B005400040024000C0054042
|
||||
S1136E200050024000D005400060024000E00540F0
|
||||
S1136E300070024000F0054000D00340000006400E
|
||||
S1136E400010064000200640003006400040064086
|
||||
S1136E50005006400060064074710000DFF85C11C9
|
||||
S1136E6088421BD0DFF85811884217D0DFF854113C
|
||||
S1136E70884213D0DFF8501188420FD0DFF84C114C
|
||||
S1136E8088420BD0DFF84811884207D0DFF844115C
|
||||
S1136E90884203D0DFF84011884201D1012000E08C
|
||||
S1136EA00020C0B27047F8B504000F0016001D00A2
|
||||
S1136EB02000FFF7D3FF002805D14FF4B271DFF8AB
|
||||
S1136EC01C01FFF728FD002E05D140F26511DFF803
|
||||
S1136ED00C01FFF720FDB7EBC60F05D24FF4B371D9
|
||||
S1136EE0DFF8F800FFF717FD200000F038F8B7EBE3
|
||||
S1136EF0061F05D2206B50F020002063760803E0C3
|
||||
S1136F00206B30F020002063F800B0FBF6F0401C4A
|
||||
S1136F104008810961624021B0FBF1F202FB1102D9
|
||||
S1136F20A262E5620020A061200000F001F8F1BD3A
|
||||
S1136F3010B504002000FFF791FF002805D140F2AE
|
||||
S1136F40F511DFF89800FFF7E6FCE06A50F0100056
|
||||
S1136F50E062206B40F201310843206310BD10B59C
|
||||
S1136F6004002000FFF77AFF002805D140F2152124
|
||||
S1136F70DFF86800FFF7CFFCA0690007FCD4E06AE3
|
||||
S1136F8030F01000E062206BDFF8541008402063FA
|
||||
S1136F9010BD10B504002000FFF760FF002805D1E4
|
||||
S1136FA04FF48D61DFF83400FFF7B5FCA069C0062B
|
||||
S1136FB001D4206801E05FF0FF3010BD00C0004044
|
||||
S1136FC000D0004000E0004000F00040000001401C
|
||||
S1136FD0001001400020014000300140D071000049
|
||||
S1136FE0FEFCFFFF0E48006850F005000C490860E5
|
||||
S1136FF070470B48006850F0020009490860704768
|
||||
S113700010B50400002C02D0B4F1807F03D9E22132
|
||||
S11370100448FFF780FC601E0349086010BD0000AF
|
||||
S113702010E000E01471000014E000E080B500F00E
|
||||
S113703007F8002801D0012000E00020C0B202BD02
|
||||
S1137040EFF3108062B6704740420F0000201C002E
|
||||
S113705080841E0000802500999E36000040380080
|
||||
S113706000093D0000803E0000004B00404B4C00F6
|
||||
S113707000204E00808D5B0000C05D000080700029
|
||||
S113708000127A0000007D0080969800001BB70073
|
||||
S11370900080BB00C0E8CE00647ADA000024F4006B
|
||||
S11370A00000FA0080A81201002D310100366E01A3
|
||||
S11370B040787D01433A5C576F726B5C736F667402
|
||||
S11370C0776172655C4F70656E424C545C546172BA
|
||||
S11370D06765745C44656D6F5C41524D434D345F2C
|
||||
S11370E0544D34435F444B5F544D34433132334742
|
||||
S11370F05F4941525C50726F675C6C69625C647298
|
||||
S1137100697665726C69625C73797363746C2E63FF
|
||||
S113711000000000433A5C576F726B5C736F6674D7
|
||||
S1137120776172655C4F70656E424C545C54617259
|
||||
S11371306765745C44656D6F5C41524D434D345FCB
|
||||
S1137140544D34435F444B5F544D344331323347E1
|
||||
S11371505F4941525C50726F675C6C69625C647237
|
||||
S1137160697665726C69625C7379737469636B2E9A
|
||||
S113717063000000433A5C576F726B5C736F667414
|
||||
S1137180776172655C4F70656E424C545C546172F9
|
||||
S11371906765745C44656D6F5C41524D434D345F6B
|
||||
S11371A0544D34435F444B5F544D34433132334781
|
||||
S11371B05F4941525C50726F675C6C69625C6472D7
|
||||
S11371C0697665726C69625C6770696F2E63000032
|
||||
S11371D0433A5C576F726B5C736F66747761726568
|
||||
S11371E05C4F70656E424C545C5461726765745CAC
|
||||
S11371F044656D6F5C41524D434D345F544D34438F
|
||||
S11372005F444B5F544D3443313233475F494152FD
|
||||
S11372105C50726F675C6C69625C647269766572FB
|
||||
S11372206C69625C756172742E63000010B5074965
|
||||
S113723079441831064C7C44163404E00A68081D6D
|
||||
S1137240511888470146A142F8D110BD2C00000016
|
||||
S11372503800000050F8041B61B150F8042BD30728
|
||||
S113726044BFA9F101039A18002342F8043B091F03
|
||||
S1137270FAD1EFE770470000DDFFFFFF5800000080
|
||||
S1137280000000200000000080B50448006850F4AD
|
||||
S113729070000249086000F005F801BD88ED00E0C7
|
||||
S11372A0FEE70000034B9D46C046C04600F004F8CC
|
||||
S11372B000F010F8580400204EF68851CEF2000178
|
||||
S11372C0086840F4700008604FF00070E1EE100AA6
|
||||
S11372D07047000000F009F8002801D0FFF7A6FF6E
|
||||
S11372E00020FFF701FB00F002F80120704700F0D6
|
||||
S11372F001B800000746384600F002F8FBE700003A
|
||||
S113730080B5C046C046024A11001820ABBEFBE758
|
||||
S1077310260002004D
|
||||
S90372A5E5
|
||||
S11380005804002089920000A1920000A19200006F
|
||||
S1138010A1920000A1920000A1920000A192000090
|
||||
S1138020A1920000A1920000A1920000A192000080
|
||||
S1138030A1920000A1920000A1920000AB8A00006E
|
||||
S1138040A1920000A1920000A1920000A192000060
|
||||
S1138050A1920000A1920000A1920000A192000050
|
||||
S1138060A1920000A1920000A1920000A192000040
|
||||
S1138070A1920000A1920000A1920000A192000030
|
||||
S1138080A1920000A1920000A1920000A192000020
|
||||
S1138090A1920000A1920000A1920000A192000010
|
||||
S11380A0A1920000A1920000A1920000A192000000
|
||||
S11380B0A1920000A1920000A1920000A1920000F0
|
||||
S11380C0A1920000A1920000A1920000A1920000E0
|
||||
S11380D0A1920000A1920000A1920000A1920000D0
|
||||
S11380E0A1920000A1920000A1920000A1920000C0
|
||||
S11380F0A1920000A1920000A1920000A1920000B0
|
||||
S1138100A1920000A1920000A1920000A19200009F
|
||||
S1138110A1920000A1920000A1920000A19200008F
|
||||
S1138120A1920000A1920000A1920000A19200007F
|
||||
S1138130A1920000A1920000A1920000A19200006F
|
||||
S1138140A1920000A1920000A1920000A19200005F
|
||||
S1138150A1920000A1920000A1920000A19200004F
|
||||
S1138160A1920000A1920000A1920000A19200003F
|
||||
S1138170A1920000A1920000A1920000A19200002F
|
||||
S1138180A1920000A1920000A1920000A19200001F
|
||||
S1138190A1920000A1920000A1920000A19200000F
|
||||
S11381A0A1920000A1920000A1920000A1920000FF
|
||||
S11381B0A1920000A1920000A1920000A1920000EF
|
||||
S11381C0A1920000A1920000A1920000A1920000DF
|
||||
S11381D0A1920000A1920000A1920000A1920000CF
|
||||
S11381E0A1920000A1920000A1920000A1920000BF
|
||||
S11381F0A1920000A1920000A1920000A1920000AF
|
||||
S1138200A1920000A1920000A1920000A19200009E
|
||||
S1138210A1920000A1920000A1920000A19200008E
|
||||
S1138220A1920000A1920000A1920000A19200007E
|
||||
S1138230A1920000A1920000A1920000A19200006E
|
||||
S1138240A1920000A1920000A1920000A19200005E
|
||||
S1138250A1920000A1920000A1920000A19200004E
|
||||
S1138260A1920000A1920000A1920000EE11AA5573
|
||||
S1138270DFF81015884200F02E81DFF80C158842D3
|
||||
S113828000F02981DFF80415884200F02481DFF82A
|
||||
S11382900015884200F01F81DFF8F814884200F0CE
|
||||
S11382A01A81DFF8F414884200F01581DFF8EC1429
|
||||
S11382B0884200F01081DFF8E814884200F00B8156
|
||||
S11382C0DFF8E014884200F00681DFF8DC1488420D
|
||||
S11382D000F00181DFF8D414884200F0FC80DFF85C
|
||||
S11382E0D014884200F0F780DFF8C814884200F008
|
||||
S11382F0F280DFF8C414884200F0ED80DFF8BC148B
|
||||
S1138300884200F0E880DFF8B814884200F0E38087
|
||||
S1138310DFF8B014884200F0DE80DFF8AC14884245
|
||||
S113832000F0D980DFF8A414884200F0D480DFF88C
|
||||
S1138330A014884200F0CF80DFF89814884200F03F
|
||||
S1138340CA80DFF89414884200F0C580DFF88C14EA
|
||||
S1138350884200F0C080DFF88814884200F0BB80B7
|
||||
S1138360DFF88014884200F0B680DFF87C1488427D
|
||||
S113837000F0B180DFF87414884200F0AC80DFF8BC
|
||||
S11383807014884200F0A780DFF86814884200F077
|
||||
S1138390A280DFF86414884200F09D80DFF85C144A
|
||||
S11383A0884200F09880DFF85814884200F09380E7
|
||||
S11383B0DFF85014884200F08E80DFF84C148842B5
|
||||
S11383C000F08980DFF84414884200F08480DFF8EC
|
||||
S11383D04014884200F07F80DFF8381488427AD055
|
||||
S11383E0DFF83414884276D0DFF83014884272D033
|
||||
S11383F0DFF82C1488426ED0DFF8281488426AD043
|
||||
S1138400DFF82414884266D0DFF82014884262D052
|
||||
S1138410DFF81C1488425ED0DFF8181488425AD062
|
||||
S1138420DFF81414884256D0DFF81014884252D072
|
||||
S1138430DFF80C1488424ED0DFF8081488424AD082
|
||||
S1138440DFF80414884246D0DFF80014884242D092
|
||||
S1138450DFF8FC1388423ED0DFF8F81388423AD0A4
|
||||
S1138460DFF8F413884236D0DFF8F013884232D0B4
|
||||
S1138470DFF8EC1388422ED0DFF8E81388422AD0C4
|
||||
S1138480DFF8E413884226D0DFF8E013884222D0D4
|
||||
S1138490DFF8DC1388421ED010F1805F1BD0DFF8B8
|
||||
S11384A0D413884217D0DFF8D013884213D0DFF8F2
|
||||
S11384B0CC1388420FD0DFF8C81388420BD0DFF802
|
||||
S11384C0C413884207D0DFF8C013884203D0DFF812
|
||||
S11384D0BC13884201D1012000E00020C0B27047E3
|
||||
S11384E010B504002000FFF7C3FE002805D140F2B8
|
||||
S11384F04321DFF89C0300F00EFAC4F30720DFF8F1
|
||||
S113850094130818E1B2890051EA401050F08440F5
|
||||
S11385100121016010BDDFF88C03DFF88C130160CA
|
||||
S1138520FEE700000138FDD17047704770B50400C4
|
||||
S1138530DFF864030568DFF87403066855F4006522
|
||||
S113854035F4800556F40066DFF84C030560DFF867
|
||||
S11385505C03066015F0010014F0010191F00101C3
|
||||
S1138560C0B208421ED074F001000540DFF82803B1
|
||||
S11385700560002E07D516F07000302809D016F0DB
|
||||
S11385807000702805D0002E08D415F03000302873
|
||||
S113859004D14FF48050FFF7C5FF03E05FF40020DF
|
||||
S11385A0FFF7C0FF35F4FE6514F4FE600543DFF801
|
||||
S11385B000030640DFF8FC022040064314F00800E4
|
||||
S11385C056EAC006DFF8D0020560DFF8E002066074
|
||||
S11385D01020FFF7A7FF35F4005514F400500543AD
|
||||
S11385E036F4005614F400500643DFF8B00240217C
|
||||
S11385F00160002E06D5DFF8B4020660DFF89802A9
|
||||
S1138600056005E0DFF890020560DFF8A00206606F
|
||||
S1138610DFF8A4020540DFF8A4022040054336F049
|
||||
S1138620FC5614F0FC500643600008D555F4800550
|
||||
S113863036F48006DFF888022040064301E036F075
|
||||
S1138640804620050ED44FF4004000E0401E002870
|
||||
S113865004D0DFF84C1209684906F7D535F40065F3
|
||||
S113866036F40066DFF830020560DFF84002066089
|
||||
S11386701020FFF757FF70BD38B5DFF848020068D7
|
||||
S1138680DFF844120840DFF84412884205D040F273
|
||||
S11386909761DFF8FC0100F03EF9DFF8FC010168A6
|
||||
S11386A0DFF808020268002A02D512F0700001E027
|
||||
S11386B011F03000002808D0102849D020284AD0D2
|
||||
S11386C030284BD070284CD04EE0C1F38410DFF832
|
||||
S11386D0003253F82000DFF8FC31134013F1004F4F
|
||||
S11386E003D0002A1DD40B051BD4DFF8EC311B6822
|
||||
S11386F0DFF8E8412468C4F304256D1C14F01F045A
|
||||
S1138700641C04FB05F46400B0FBF4F09C05A40DA8
|
||||
S1138710C3F3892303FB00F39B0A04FB003051F4E9
|
||||
S113872080014B022DD5002A26D553001ED5DFF833
|
||||
S1138730A431134013F1004F03D0002A16D40905C5
|
||||
S113874014D44000C2F38651491CB0FBF1F018E088
|
||||
S1138750DFF88C01BFE7DFF88C01BCE747F230504B
|
||||
S1138760B9E74FF40040B6E700200AE0C2F3C55170
|
||||
S1138770491CB0FBF1F004E0C1F3C351491CB0FB48
|
||||
S1138780F1F032BD003800F0013800F0003400F0A0
|
||||
S1138790013400F0023400F0003C00F0013C00F031
|
||||
S11387A0023C00F0005800F0005400F0000800F013
|
||||
S11387B0010800F0020800F0030800F0040800F0CB
|
||||
S11387C0050800F0060800F0070800F0080800F0AB
|
||||
S11387D0090800F00A0800F00B0800F00C0800F08B
|
||||
S11387E00D0800F00E0800F00F0800F0100800F06B
|
||||
S11387F0001400F0002000F0012000F0022000F03E
|
||||
S1138800032000F0042000F0052000F0004800F0F0
|
||||
S1138810005000F0004000F0014000F0004400F07F
|
||||
S1138820014400F0001C00F0011C00F0021C00F0E8
|
||||
S1138830031C00F0000400F0010400F0020400F046
|
||||
S1138840030400F0040400F0050400F0001800F034
|
||||
S1138850011800F0021800F0031800F0041800F0EA
|
||||
S1138860051800F0061800F0071800F0000C00F0DE
|
||||
S1138870002800F0010000F0005C00F0015C00F052
|
||||
S1138880025C00F0035C00F0045C00F0055C00F0A6
|
||||
S1138890B490000000E60F4060E00F4058E00F4045
|
||||
S11388A050E00F400CED00E00400FA0570E00F40CA
|
||||
S11388B08FFFFF7F30000080FEFF3FF80100C007FC
|
||||
S11388C00000404000E00F400000FF700000051071
|
||||
S11388D0489000000008008060E10F4064E10F4010
|
||||
S11388E00024F40000093D0080B500F007F800F012
|
||||
S11388F021F800F08FF800F033F8FAE780B500F0C3
|
||||
S1138900B3F80748FFF712FE00F076F800F0B6F867
|
||||
S113891000F0D4F801BD034A106003480160FEE78B
|
||||
S11389204005C001480000204C00002080B5FFF73E
|
||||
S1138930F2FD01BD80B52A48FFF7D2FD2948FFF7B3
|
||||
S1138940CFFD03215FF0402000F03DFAFFF794FED5
|
||||
S113895060234FF461420100234800F0A4FA01BDF2
|
||||
S113896080B52248007800280BD1214800F02BF86C
|
||||
S1138970012827D11D48012101701E4800210170E2
|
||||
S113898020E01C4800781A494018401C00F01BF8ED
|
||||
S1138990012817D117480078401C1649087015485B
|
||||
S11389A000781349097888420CD1104800210170DD
|
||||
S11389B00F484078FF2805D10D488078002801D160
|
||||
S11389C0FFF7B4FF01BD10B50400074800F0E1FA59
|
||||
S11389D010F1010F02D02070012000E0002010BD32
|
||||
S11389E0001800F0000800F000C00040550000200E
|
||||
S11389F0000000205400002080B51748FFF770FDE8
|
||||
S1138A000421164800F0C3F900220421134800F0A1
|
||||
S1138A10AAF901BD10B500F045F80400104800683B
|
||||
S1138A20201AB0F5FA7F16D30E480078002808D132
|
||||
S1138A300C480121017004220421084800F093F934
|
||||
S1138A4007E008480021017000220421034800F0D7
|
||||
S1138A508AF90348046010BD060800F00060024073
|
||||
S1138A6044000020560000200348006850F04040B5
|
||||
S1138A70014908607047000034EF00E080B5FFF75B
|
||||
S1138A80FBFD4FF47A71B0FBF1F000F0B9FA00F09D
|
||||
S1138A90A9FA00F0AEFA002000F001F801BD064981
|
||||
S1138AA00860704704480068704703480068401C29
|
||||
S1138AB001490860704700005000002080B500F0B4
|
||||
S1138AC0B5FA01BDB0F1402F5BD0DFF83013884216
|
||||
S1138AD057D0DFF82C13884253D0DFF8281388428C
|
||||
S1138AE04FD0DFF8241388424BD0DFF8201388429C
|
||||
S1138AF047D0DFF81C13884243D0DFF818138842AC
|
||||
S1138B003FD0DFF8141388423BD0DFF810138842BB
|
||||
S1138B1037D0DFF80C13884233D0DFF808138842CB
|
||||
S1138B202FD0DFF8041388422BD0DFF800138842DB
|
||||
S1138B3027D0DFF8FC12884223D0DFF8F8128842ED
|
||||
S1138B401FD0DFF8F41288421BD0DFF8F0128842FD
|
||||
S1138B5017D0DFF8EC12884213D0DFF8E81288420D
|
||||
S1138B600FD0DFF8E41288420BD0DFF8E01288421D
|
||||
S1138B7007D0DFF8DC12884203D0DFF8D81288422D
|
||||
S1138B8001D1012000E00020C0B2704770B504009C
|
||||
S1138B900D0016002000FFF795FF002804D1FB21EB
|
||||
S1138BA0DFF8B402FFF7B7FE002E08D0012E06D07E
|
||||
S1138BB0022E04D0FE21DFF8A002FFF7ACFEF0077E
|
||||
S1138BC005D514F580600068EDB2284304E014F57F
|
||||
S1138BD080600068EDB2A84314F580610860B007B6
|
||||
S1138BE005D514F584600068EDB2284304E014F55B
|
||||
S1138BF084600068EDB2A84314F58461086070BD18
|
||||
S1138C00F8B504000D0017001E002000FFF75AFFFE
|
||||
S1138C10002805D140F2E111DFF83C02FFF77BFEAA
|
||||
S1138C20012F0BD0022F09D0042F07D00C2F05D011
|
||||
S1138C3040F2E511DFF82002FFF76DFE082E0DD09B
|
||||
S1138C400A2E0BD00C2E09D0092E07D0002E05D0E9
|
||||
S1138C504FF4F571DFF80002FFF75DFEF80705D564
|
||||
S1138C6014F5A0600068EDB2284304E014F5A06098
|
||||
S1138C700068EDB2A84314F5A0610860B80704D5F4
|
||||
S1138C80D4F80405EDB2284303E0D4F80405EDB2AA
|
||||
S1138C90A843C4F80405780705D514F5A160006855
|
||||
S1138CA0EDB2284304E014F5A1600068EDB2A843D6
|
||||
S1138CB014F5A1610860380705D514F5A3600068B0
|
||||
S1138CC0EDB2284304E014F5A3600068EDB2A843B4
|
||||
S1138CD014F5A3610860F00704D5D4F80C05EDB2CF
|
||||
S1138CE0284303E0D4F80C05EDB2A843C4F80C05FE
|
||||
S1138CF0B00705D514F5A2600068EDB2284304E07E
|
||||
S1138D0014F5A2600068EDB2A84314F5A2610860EE
|
||||
S1138D10700704D5D4F81405EDB2284303E0D4F861
|
||||
S1138D201405EDB2A843C4F81405300704D5D4F8EB
|
||||
S1138D301C05EDB2284303E0D4F81C05EDB2A843AA
|
||||
S1138D40C4F81C05002E05D114F5A5600068EDB229
|
||||
S1138D50284304E014F5A5600068EDB2A84314F5B7
|
||||
S1138D60A5610860F1BD70B504000D001600200077
|
||||
S1138D70FFF7A8FE002805D140F28531DFF8D800BE
|
||||
S1138D80FFF7C9FDEDB2F6B244F8256070BD38B501
|
||||
S1138D9004000D002000FFF795FE002805D14FF4D4
|
||||
S1138DA09E61DFF8B400FFF7B6FD08230122290015
|
||||
S1138DB0C9B22000FFF724FF01222900C9B2200014
|
||||
S1138DC0FFF7E4FE31BD38B504000D002000FFF7C5
|
||||
S1138DD079FE002804D14FF4D7611F48FFF79BFDAB
|
||||
S1138DE002222900C9B22000FFF7D0FE0823012285
|
||||
S1138DF02900C9B22000FFF703FF31BD0080054000
|
||||
S1138E0000500040009005400060004000A0054074
|
||||
S1138E100070004000B005400040024000C0054022
|
||||
S1138E200050024000D005400060024000E00540D0
|
||||
S1138E300070024000F0054000D0034000000640EE
|
||||
S1138E400010064000200640003006400040064066
|
||||
S1138E50005006400060064074910000DFF85C1189
|
||||
S1138E6088421BD0DFF85811884217D0DFF854111C
|
||||
S1138E70884213D0DFF8501188420FD0DFF84C112C
|
||||
S1138E8088420BD0DFF84811884207D0DFF844113C
|
||||
S1138E90884203D0DFF84011884201D1012000E06C
|
||||
S1138EA00020C0B27047F8B504000F0016001D0082
|
||||
S1138EB02000FFF7D3FF002805D14FF4B271DFF88B
|
||||
S1138EC01C01FFF728FD002E05D140F26511DFF8E3
|
||||
S1138ED00C01FFF720FDB7EBC60F05D24FF4B371B9
|
||||
S1138EE0DFF8F800FFF717FD200000F038F8B7EBC3
|
||||
S1138EF0061F05D2206B50F020002063760803E0A3
|
||||
S1138F00206B30F020002063F800B0FBF6F0401C2A
|
||||
S1138F104008810961624021B0FBF1F202FB1102B9
|
||||
S1138F20A262E5620020A061200000F001F8F1BD1A
|
||||
S1138F3010B504002000FFF791FF002805D140F28E
|
||||
S1138F40F511DFF89800FFF7E6FCE06A50F0100036
|
||||
S1138F50E062206B40F201310843206310BD10B57C
|
||||
S1138F6004002000FFF77AFF002805D140F2152104
|
||||
S1138F70DFF86800FFF7CFFCA0690007FCD4E06AC3
|
||||
S1138F8030F01000E062206BDFF8541008402063DA
|
||||
S1138F9010BD10B504002000FFF760FF002805D1C4
|
||||
S1138FA04FF48D61DFF83400FFF7B5FCA069C0060B
|
||||
S1138FB001D4206801E05FF0FF3010BD00C0004024
|
||||
S1138FC000D0004000E0004000F0004000000140FC
|
||||
S1138FD0001001400020014000300140D091000009
|
||||
S1138FE0FEFCFFFF0E48006850F005000C490860C5
|
||||
S1138FF070470B48006850F0020009490860704748
|
||||
S113900010B50400002C02D0B4F1807F03D9E22112
|
||||
S11390100448FFF780FC601E0349086010BD00008F
|
||||
S113902010E000E01491000014E000E080B500F0CE
|
||||
S113903007F8002801D0012000E00020C0B202BDE2
|
||||
S1139040EFF3108062B6704740420F0000201C000E
|
||||
S113905080841E0000802500999E36000040380060
|
||||
S113906000093D0000803E0000004B00404B4C00D6
|
||||
S113907000204E00808D5B0000C05D000080700009
|
||||
S113908000127A0000007D0080969800001BB70053
|
||||
S11390900080BB00C0E8CE00647ADA000024F4004B
|
||||
S11390A00000FA0080A81201002D310100366E0183
|
||||
S11390B040787D01433A5C576F726B5C736F6674E2
|
||||
S11390C0776172655C4F70656E424C545C5461729A
|
||||
S11390D06765745C44656D6F5C41524D434D345F0C
|
||||
S11390E0544D34435F444B5F544D34433132334722
|
||||
S11390F05F4941525C50726F675C6C69625C647278
|
||||
S1139100697665726C69625C73797363746C2E63DF
|
||||
S113911000000000433A5C576F726B5C736F6674B7
|
||||
S1139120776172655C4F70656E424C545C54617239
|
||||
S11391306765745C44656D6F5C41524D434D345FAB
|
||||
S1139140544D34435F444B5F544D344331323347C1
|
||||
S11391505F4941525C50726F675C6C69625C647217
|
||||
S1139160697665726C69625C7379737469636B2E7A
|
||||
S113917063000000433A5C576F726B5C736F6674F4
|
||||
S1139180776172655C4F70656E424C545C546172D9
|
||||
S11391906765745C44656D6F5C41524D434D345F4B
|
||||
S11391A0544D34435F444B5F544D34433132334761
|
||||
S11391B05F4941525C50726F675C6C69625C6472B7
|
||||
S11391C0697665726C69625C6770696F2E63000012
|
||||
S11391D0433A5C576F726B5C736F66747761726548
|
||||
S11391E05C4F70656E424C545C5461726765745C8C
|
||||
S11391F044656D6F5C41524D434D345F544D34436F
|
||||
S11392005F444B5F544D3443313233475F494152DD
|
||||
S11392105C50726F675C6C69625C647269766572DB
|
||||
S11392206C69625C756172742E63000010B5074945
|
||||
S113923079441831064C7C44163404E00A68081D4D
|
||||
S1139240511888470146A142F8D110BD2C000000F6
|
||||
S11392503800000050F8041B61B150F8042BD30708
|
||||
S113926044BFA9F101039A18002342F8043B091FE3
|
||||
S1139270FAD1EFE770470000DDFFFFFF5800000060
|
||||
S1139280000000200000000080B50448006850F48D
|
||||
S113929070000249086000F005F801BD88ED00E0A7
|
||||
S11392A0FEE70000034B9D46C046C04600F004F8AC
|
||||
S11392B000F010F8580400204EF68851CEF2000158
|
||||
S11392C0086840F4700008604FF00070E1EE100A86
|
||||
S11392D07047000000F009F8002801D0FFF7A6FF4E
|
||||
S11392E00020FFF701FB00F002F80120704700F0B6
|
||||
S11392F001B800000746384600F002F8FBE700001A
|
||||
S113930080B5C046C046024A11001820ABBEFBE738
|
||||
S1079310260002002D
|
||||
S90392A5C5
|
||||
|
|
|
@ -49,7 +49,6 @@ static void BootActivate(void)
|
|||
} /*** end of BootActivate ***/
|
||||
|
||||
|
||||
#if (BOOT_COM_UART_ENABLE > 0)
|
||||
/****************************************************************************************
|
||||
* U N I V E R S A L A S Y N C H R O N O U S R X T X I N T E R F A C E
|
||||
****************************************************************************************/
|
||||
|
@ -153,7 +152,6 @@ static unsigned char UartReceiveByte(unsigned char *data)
|
|||
/* inform caller that no new data was received */
|
||||
return 0;
|
||||
} /*** end of UartReceiveByte ***/
|
||||
#endif /* BOOT_COM_UART_ENABLE > 0 */
|
||||
|
||||
|
||||
/*********************************** end of boot.c *************************************/
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
<Build><ColumnWidth0>20</ColumnWidth0><ColumnWidth1>1395</ColumnWidth1><ColumnWidth2>372</ColumnWidth2><ColumnWidth3>93</ColumnWidth3></Build><Find-All-Declarations><ColumnWidth0>142</ColumnWidth0><ColumnWidth1>20</ColumnWidth1><ColumnWidth2>243</ColumnWidth2></Find-All-Declarations><TerminalIO/><Debug-Log><ColumnWidth0>18</ColumnWidth0><ColumnWidth1>371</ColumnWidth1></Debug-Log></Static>
|
||||
<Windows>
|
||||
|
||||
<Wnd0>
|
||||
<Wnd2>
|
||||
<Tabs>
|
||||
<Tab>
|
||||
<Identity>TabID-23736-13759</Identity>
|
||||
|
@ -29,20 +29,20 @@
|
|||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
<SelectedTab>0</SelectedTab></Wnd0><Wnd1><Tabs><Tab><Identity>TabID-11003-23003</Identity><TabName>Build</TabName><Factory>Build</Factory><Session/></Tab><Tab><Identity>TabID-13665-29690</Identity><TabName>Find All Declarations</TabName><Factory>Find-All-Declarations</Factory><Session/></Tab><Tab><Identity>TabID-2562-1429</Identity><TabName>Debug Log</TabName><Factory>Debug-Log</Factory><Session/></Tab></Tabs><SelectedTab>0</SelectedTab></Wnd1></Windows>
|
||||
<SelectedTab>0</SelectedTab></Wnd2><Wnd3><Tabs><Tab><Identity>TabID-11003-23003</Identity><TabName>Build</TabName><Factory>Build</Factory><Session/></Tab><Tab><Identity>TabID-13665-29690</Identity><TabName>Find All Declarations</TabName><Factory>Find-All-Declarations</Factory><Session/></Tab><Tab><Identity>TabID-2562-1429</Identity><TabName>Debug Log</TabName><Factory>Debug-Log</Factory><Session/></Tab></Tabs><SelectedTab>0</SelectedTab></Wnd3></Windows>
|
||||
<Editor>
|
||||
|
||||
|
||||
|
||||
|
||||
<Pane><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\..\main.c</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>0</YPos2><SelStart2>300</SelStart2><SelEnd2>300</SelEnd2></Tab><ActiveTab>0</ActiveTab></Pane><ActivePane>0</ActivePane><Sizes><Pane><X>1000000</X><Y>1000000</Y></Pane></Sizes><SplitMode>1</SplitMode></Editor>
|
||||
<Pane><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\..\main.c</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>0</YPos2><SelStart2>300</SelStart2><SelEnd2>300</SelEnd2></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\..\boot.c</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>0</YPos2><SelStart2>22</SelStart2><SelEnd2>22</SelEnd2></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\..\header.h</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>0</YPos2><SelStart2>2178</SelStart2><SelEnd2>2178</SelEnd2></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\..\led.c</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>0</YPos2><SelStart2>2428</SelStart2><SelEnd2>2428</SelEnd2></Tab><ActiveTab>3</ActiveTab></Pane><ActivePane>0</ActivePane><Sizes><Pane><X>1000000</X><Y>1000000</Y></Pane></Sizes><SplitMode>1</SplitMode></Editor>
|
||||
<Positions>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<Top><Row0><Sizes><Toolbar-02bbfc58><key>iaridepm.enu1</key></Toolbar-02bbfc58></Sizes></Row0></Top><Left><Row0><Sizes><Wnd0><Rect><Top>-2</Top><Left>-2</Left><Bottom>579</Bottom><Right>418</Right><x>-2</x><y>-2</y><xscreen>200</xscreen><yscreen>200</yscreen><sizeHorzCX>104167</sizeHorzCX><sizeHorzCY>198413</sizeHorzCY><sizeVertCX>218750</sizeVertCX><sizeVertCY>576389</sizeVertCY></Rect></Wnd0><Wnd1><Rect><Top>0</Top><Left>0</Left><Bottom>6881384</Bottom><Right>7536751</Right><x>-2</x><y>577</y><xscreen>1924</xscreen><yscreen>200</yscreen><sizeHorzCX>1002083</sizeHorzCX><sizeHorzCY>198413</sizeHorzCY><sizeVertCX>218750</sizeVertCX><sizeVertCY>382937</sizeVertCY></Rect></Wnd1></Sizes></Row0></Left><Right><Row0><Sizes/></Row0></Right><Bottom><Row0><Sizes/></Row0></Bottom><Float><Sizes/></Float></Positions>
|
||||
<Top><Row0><Sizes><Toolbar-00c6fc58><key>iaridepm.enu1</key></Toolbar-00c6fc58></Sizes></Row0></Top><Left><Row0><Sizes><Wnd2><Rect><Top>-2</Top><Left>-2</Left><Bottom>579</Bottom><Right>418</Right><x>-2</x><y>-2</y><xscreen>200</xscreen><yscreen>200</yscreen><sizeHorzCX>104167</sizeHorzCX><sizeHorzCY>198413</sizeHorzCY><sizeVertCX>218750</sizeVertCX><sizeVertCY>576389</sizeVertCY></Rect></Wnd2><Wnd3><Rect><Top>0</Top><Left>0</Left><Bottom>1852142180</Bottom><Right>1818847232</Right><x>-2</x><y>577</y><xscreen>1924</xscreen><yscreen>200</yscreen><sizeHorzCX>1002083</sizeHorzCX><sizeHorzCY>198413</sizeHorzCY><sizeVertCX>218750</sizeVertCX><sizeVertCY>382937</sizeVertCY></Rect></Wnd3></Sizes></Row0></Left><Right><Row0><Sizes/></Row0></Right><Bottom><Row0><Sizes/></Row0></Bottom><Float><Sizes/></Float></Positions>
|
||||
</Desktop>
|
||||
</Workspace>
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,7 +1,7 @@
|
|||
/*-Specials-*/
|
||||
define symbol __ICFEDIT_intvec_start__ = 0x00006000;
|
||||
define symbol __ICFEDIT_intvec_start__ = 0x00008000;
|
||||
/*-Memory Regions-*/
|
||||
define symbol __ICFEDIT_region_ROM_start__ = 0x00006000;
|
||||
define symbol __ICFEDIT_region_ROM_start__ = 0x00008000;
|
||||
define symbol __ICFEDIT_region_ROM_end__ = 0x0003FFFF;
|
||||
define symbol __ICFEDIT_region_RAM_start__ = 0x20000000;
|
||||
define symbol __ICFEDIT_region_RAM_end__ = 0x20007FFF;
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
define symbol __ICFEDIT_intvec_start__ = 0x00000000;
|
||||
/*-Memory Regions-*/
|
||||
define symbol __ICFEDIT_region_ROM_start__ = 0x00000000;
|
||||
define symbol __ICFEDIT_region_ROM_end__ = 0x00005FFF;
|
||||
define symbol __ICFEDIT_region_ROM_end__ = 0x00007FFF;
|
||||
define symbol __ICFEDIT_region_RAM_start__ = 0x20000000;
|
||||
define symbol __ICFEDIT_region_RAM_end__ = 0x20001FFF;
|
||||
/*-Sizes-*/
|
||||
|
|
|
@ -135,101 +135,101 @@ __root const tIsrFunc __vector_table[] @ ".intvec" =
|
|||
{ UnusedISR }, /* CAN2 */
|
||||
{ UnusedISR }, /* Ethernet */
|
||||
{ UnusedISR }, /* Hibernate */
|
||||
{ UnusedISR }, /* USB0 */
|
||||
{ UnusedISR }, /* PWM Generator 3 */
|
||||
{ UnusedISR }, /* uDMA Software Transfer */
|
||||
{ UnusedISR }, /* uDMA Error */
|
||||
{ UnusedISR }, /* ADC1 Sequence 0 */
|
||||
{ UnusedISR }, /* ADC1 Sequence 1 */
|
||||
{ UnusedISR }, /* ADC1 Sequence 2 */
|
||||
{ UnusedISR }, /* ADC1 Sequence 3 */
|
||||
{ UnusedISR }, /* Reserved */
|
||||
{ UnusedISR }, /* Reserved */
|
||||
{ UnusedISR }, /* GPIO Port J */
|
||||
{ UnusedISR }, /* GPIO Port K */
|
||||
{ UnusedISR }, /* GPIO Port L */
|
||||
{ UnusedISR }, /* SSI2 Rx and Tx */
|
||||
{ UnusedISR }, /* SSI3 Rx and Tx */
|
||||
{ UnusedISR }, /* UART3 Rx and Tx */
|
||||
{ UnusedISR }, /* UART4 Rx and Tx */
|
||||
{ UnusedISR }, /* UART5 Rx and Tx */
|
||||
{ UnusedISR }, /* UART6 Rx and Tx */
|
||||
{ UnusedISR }, /* UART7 Rx and Tx */
|
||||
{ UnusedISR }, /* Reserved */
|
||||
{ UnusedISR }, /* Reserved */
|
||||
{ UnusedISR }, /* Reserved */
|
||||
{ UnusedISR }, /* Reserved */
|
||||
{ UnusedISR }, /* I2C2 Master and Slave */
|
||||
{ UnusedISR }, /* I2C3 Master and Slave */
|
||||
{ UnusedISR }, /* Timer 4 subtimer A */
|
||||
{ UnusedISR }, /* Timer 4 subtimer B */
|
||||
{ UnusedISR }, /* Reserved */
|
||||
{ UnusedISR }, /* Reserved */
|
||||
{ UnusedISR }, /* Reserved */
|
||||
{ UnusedISR }, /* Reserved */
|
||||
{ UnusedISR }, /* Reserved */
|
||||
{ UnusedISR }, /* Reserved */
|
||||
{ UnusedISR }, /* Reserved */
|
||||
{ UnusedISR }, /* Reserved */
|
||||
{ UnusedISR }, /* Reserved */
|
||||
{ UnusedISR }, /* Reserved */
|
||||
{ UnusedISR }, /* Reserved */
|
||||
{ UnusedISR }, /* Reserved */
|
||||
{ UnusedISR }, /* Reserved */
|
||||
{ UnusedISR }, /* Reserved */
|
||||
{ UnusedISR }, /* Reserved */
|
||||
{ UnusedISR }, /* Reserved */
|
||||
{ UnusedISR }, /* Reserved */
|
||||
{ UnusedISR }, /* Reserved */
|
||||
{ UnusedISR }, /* Reserved */
|
||||
{ UnusedISR }, /* Reserved */
|
||||
{ UnusedISR }, /* Timer 5 subtimer A */
|
||||
{ UnusedISR }, /* Timer 5 subtimer B */
|
||||
{ UnusedISR }, /* Wide Timer 0 subtimer A */
|
||||
{ UnusedISR }, /* Wide Timer 0 subtimer B */
|
||||
{ UnusedISR }, /* Wide Timer 1 subtimer A */
|
||||
{ UnusedISR }, /* Wide Timer 1 subtimer B */
|
||||
{ UnusedISR }, /* Wide Timer 2 subtimer A */
|
||||
{ UnusedISR }, /* Wide Timer 2 subtimer B */
|
||||
{ UnusedISR }, /* Wide Timer 3 subtimer A */
|
||||
{ UnusedISR }, /* Wide Timer 3 subtimer B */
|
||||
{ UnusedISR }, /* Wide Timer 4 subtimer A */
|
||||
{ UnusedISR }, /* Wide Timer 4 subtimer B */
|
||||
{ UnusedISR }, /* Wide Timer 5 subtimer A */
|
||||
{ UnusedISR }, /* Wide Timer 5 subtimer B */
|
||||
{ UnusedISR }, /* FPU */
|
||||
{ UnusedISR }, /* Reserved */
|
||||
{ UnusedISR }, /* Reserved */
|
||||
{ UnusedISR }, /* I2C4 Master and Slave */
|
||||
{ UnusedISR }, /* I2C5 Master and Slave */
|
||||
{ UnusedISR }, /* GPIO Port M */
|
||||
{ UnusedISR }, /* GPIO Port N */
|
||||
{ UnusedISR }, /* Quadrature Encoder 2 */
|
||||
{ UnusedISR }, /* Reserved */
|
||||
{ UnusedISR }, /* Reserved */
|
||||
{ UnusedISR }, /* GPIO Port P (Summary or P0) */
|
||||
{ UnusedISR }, /* GPIO Port P1 */
|
||||
{ UnusedISR }, /* GPIO Port P2 */
|
||||
{ UnusedISR }, /* GPIO Port P3 */
|
||||
{ UnusedISR }, /* GPIO Port P4 */
|
||||
{ UnusedISR }, /* GPIO Port P5 */
|
||||
{ UnusedISR }, /* GPIO Port P6 */
|
||||
{ UnusedISR }, /* GPIO Port P7 */
|
||||
{ UnusedISR }, /* GPIO Port Q (Summary or Q0) */
|
||||
{ UnusedISR }, /* GPIO Port Q1 */
|
||||
{ UnusedISR }, /* GPIO Port Q2 */
|
||||
{ UnusedISR }, /* GPIO Port Q3 */
|
||||
{ UnusedISR }, /* GPIO Port Q4 */
|
||||
{ UnusedISR }, /* GPIO Port Q5 */
|
||||
{ UnusedISR }, /* GPIO Port Q6 */
|
||||
{ UnusedISR }, /* GPIO Port Q7 */
|
||||
{ UnusedISR }, /* GPIO Port R */
|
||||
{ UnusedISR }, /* GPIO Port S */
|
||||
{ UnusedISR }, /* PWM 1 Generator 0 */
|
||||
{ UnusedISR }, /* PWM 1 Generator 1 */
|
||||
{ UnusedISR }, /* PWM 1 Generator 2 */
|
||||
{ UnusedISR }, /* PWM 1 Generator 3 */
|
||||
{ UnusedISR } /* PWM 1 Fault */
|
||||
{ UnusedISR }, /* USB0 */
|
||||
{ UnusedISR }, /* PWM Generator 3 */
|
||||
{ UnusedISR }, /* uDMA Software Transfer */
|
||||
{ UnusedISR }, /* uDMA Error */
|
||||
{ UnusedISR }, /* ADC1 Sequence 0 */
|
||||
{ UnusedISR }, /* ADC1 Sequence 1 */
|
||||
{ UnusedISR }, /* ADC1 Sequence 2 */
|
||||
{ UnusedISR }, /* ADC1 Sequence 3 */
|
||||
{ UnusedISR }, /* Reserved */
|
||||
{ UnusedISR }, /* Reserved */
|
||||
{ UnusedISR }, /* GPIO Port J */
|
||||
{ UnusedISR }, /* GPIO Port K */
|
||||
{ UnusedISR }, /* GPIO Port L */
|
||||
{ UnusedISR }, /* SSI2 Rx and Tx */
|
||||
{ UnusedISR }, /* SSI3 Rx and Tx */
|
||||
{ UnusedISR }, /* UART3 Rx and Tx */
|
||||
{ UnusedISR }, /* UART4 Rx and Tx */
|
||||
{ UnusedISR }, /* UART5 Rx and Tx */
|
||||
{ UnusedISR }, /* UART6 Rx and Tx */
|
||||
{ UnusedISR }, /* UART7 Rx and Tx */
|
||||
{ UnusedISR }, /* Reserved */
|
||||
{ UnusedISR }, /* Reserved */
|
||||
{ UnusedISR }, /* Reserved */
|
||||
{ UnusedISR }, /* Reserved */
|
||||
{ UnusedISR }, /* I2C2 Master and Slave */
|
||||
{ UnusedISR }, /* I2C3 Master and Slave */
|
||||
{ UnusedISR }, /* Timer 4 subtimer A */
|
||||
{ UnusedISR }, /* Timer 4 subtimer B */
|
||||
{ UnusedISR }, /* Reserved */
|
||||
{ UnusedISR }, /* Reserved */
|
||||
{ UnusedISR }, /* Reserved */
|
||||
{ UnusedISR }, /* Reserved */
|
||||
{ UnusedISR }, /* Reserved */
|
||||
{ UnusedISR }, /* Reserved */
|
||||
{ UnusedISR }, /* Reserved */
|
||||
{ UnusedISR }, /* Reserved */
|
||||
{ UnusedISR }, /* Reserved */
|
||||
{ UnusedISR }, /* Reserved */
|
||||
{ UnusedISR }, /* Reserved */
|
||||
{ UnusedISR }, /* Reserved */
|
||||
{ UnusedISR }, /* Reserved */
|
||||
{ UnusedISR }, /* Reserved */
|
||||
{ UnusedISR }, /* Reserved */
|
||||
{ UnusedISR }, /* Reserved */
|
||||
{ UnusedISR }, /* Reserved */
|
||||
{ UnusedISR }, /* Reserved */
|
||||
{ UnusedISR }, /* Reserved */
|
||||
{ UnusedISR }, /* Reserved */
|
||||
{ UnusedISR }, /* Timer 5 subtimer A */
|
||||
{ UnusedISR }, /* Timer 5 subtimer B */
|
||||
{ UnusedISR }, /* Wide Timer 0 subtimer A */
|
||||
{ UnusedISR }, /* Wide Timer 0 subtimer B */
|
||||
{ UnusedISR }, /* Wide Timer 1 subtimer A */
|
||||
{ UnusedISR }, /* Wide Timer 1 subtimer B */
|
||||
{ UnusedISR }, /* Wide Timer 2 subtimer A */
|
||||
{ UnusedISR }, /* Wide Timer 2 subtimer B */
|
||||
{ UnusedISR }, /* Wide Timer 3 subtimer A */
|
||||
{ UnusedISR }, /* Wide Timer 3 subtimer B */
|
||||
{ UnusedISR }, /* Wide Timer 4 subtimer A */
|
||||
{ UnusedISR }, /* Wide Timer 4 subtimer B */
|
||||
{ UnusedISR }, /* Wide Timer 5 subtimer A */
|
||||
{ UnusedISR }, /* Wide Timer 5 subtimer B */
|
||||
{ UnusedISR }, /* FPU */
|
||||
{ UnusedISR }, /* Reserved */
|
||||
{ UnusedISR }, /* Reserved */
|
||||
{ UnusedISR }, /* I2C4 Master and Slave */
|
||||
{ UnusedISR }, /* I2C5 Master and Slave */
|
||||
{ UnusedISR }, /* GPIO Port M */
|
||||
{ UnusedISR }, /* GPIO Port N */
|
||||
{ UnusedISR }, /* Quadrature Encoder 2 */
|
||||
{ UnusedISR }, /* Reserved */
|
||||
{ UnusedISR }, /* Reserved */
|
||||
{ UnusedISR }, /* GPIO Port P (Summary or P0) */
|
||||
{ UnusedISR }, /* GPIO Port P1 */
|
||||
{ UnusedISR }, /* GPIO Port P2 */
|
||||
{ UnusedISR }, /* GPIO Port P3 */
|
||||
{ UnusedISR }, /* GPIO Port P4 */
|
||||
{ UnusedISR }, /* GPIO Port P5 */
|
||||
{ UnusedISR }, /* GPIO Port P6 */
|
||||
{ UnusedISR }, /* GPIO Port P7 */
|
||||
{ UnusedISR }, /* GPIO Port Q (Summary or Q0) */
|
||||
{ UnusedISR }, /* GPIO Port Q1 */
|
||||
{ UnusedISR }, /* GPIO Port Q2 */
|
||||
{ UnusedISR }, /* GPIO Port Q3 */
|
||||
{ UnusedISR }, /* GPIO Port Q4 */
|
||||
{ UnusedISR }, /* GPIO Port Q5 */
|
||||
{ UnusedISR }, /* GPIO Port Q6 */
|
||||
{ UnusedISR }, /* GPIO Port Q7 */
|
||||
{ UnusedISR }, /* GPIO Port R */
|
||||
{ UnusedISR }, /* GPIO Port S */
|
||||
{ UnusedISR }, /* PWM 1 Generator 0 */
|
||||
{ UnusedISR }, /* PWM 1 Generator 1 */
|
||||
{ UnusedISR }, /* PWM 1 Generator 2 */
|
||||
{ UnusedISR }, /* PWM 1 Generator 3 */
|
||||
{ UnusedISR } /* PWM 1 Fault */
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -40,25 +40,14 @@
|
|||
/****************************************************************************************
|
||||
* Macro definitions
|
||||
****************************************************************************************/
|
||||
#if (BOOT_FILE_SYS_ENABLE > 0)
|
||||
/** \brief Pointer to the user program's reset vector. Note that this needs to be
|
||||
* changed in case the reserved memory for the bootloader is more than 0x6000.
|
||||
*/
|
||||
#define CPU_USER_PROGRAM_STARTADDR_PTR ((blt_addr) 0x00006004)
|
||||
/** \brief Pointer to the user program's vector table. Note that this needs to be
|
||||
* changed in case the reserved memory for the bootloader is more than 0x6000.
|
||||
*/
|
||||
#define CPU_USER_PROGRAM_VECTABLE_OFFSET ((blt_int32u)0x00006000)
|
||||
#else
|
||||
/** \brief Pointer to the user program's reset vector. Note that this needs to be
|
||||
* changed in case the reserved memory for the bootloader is more than 0x2000.
|
||||
*/
|
||||
#define CPU_USER_PROGRAM_STARTADDR_PTR ((blt_addr) 0x00002004)
|
||||
/** \brief Pointer to the user program's vector table. Note that this needs to be
|
||||
* changed in case the reserved memory for the bootloader is more than 0x2000.
|
||||
*/
|
||||
#define CPU_USER_PROGRAM_VECTABLE_OFFSET ((blt_int32u)0x00002000)
|
||||
#endif
|
||||
/** \brief Pointer to the user program's reset vector. Note that this needs to be
|
||||
* changed in case the reserved memory for the bootloader is other than 0x8000.
|
||||
*/
|
||||
#define CPU_USER_PROGRAM_STARTADDR_PTR ((blt_addr) 0x00008004)
|
||||
/** \brief Pointer to the user program's vector table. Note that this needs to be
|
||||
* changed in case the reserved memory for the bootloader is other than 0x8000.
|
||||
*/
|
||||
#define CPU_USER_PROGRAM_VECTABLE_OFFSET ((blt_int32u)0x00008000)
|
||||
|
||||
|
||||
/****************************************************************************************
|
||||
|
|
|
@ -113,20 +113,18 @@ static blt_addr FlashGetSectorSize(blt_int8u sector);
|
|||
*/
|
||||
static const tFlashSector flashLayout[] =
|
||||
{
|
||||
#if (BOOT_FILE_SYS_ENABLE > 0)
|
||||
/* the size of the bootloader with support for firmware update from a locally attached
|
||||
* storage disk is larger so the start address of the user program is at a different
|
||||
* location.
|
||||
/* with just UART supported, the bootloader needs 0x2000 in size. enabling support for
|
||||
* for firmware update from a locally attached storage disk and USB instead of UART,
|
||||
* the required size can be close to 0x8000 (32kb). this is the default configuration,
|
||||
* but can be changed by the user if less space is required. If changed, then also
|
||||
* change the start address of the user program in its linker script file.
|
||||
* additionally, the macros CPU_USER_PROGRAM_STARTADDR_PTR and
|
||||
* CPU_USER_PROGRAM_VECTABLE_OFFSET should be updated in file cpu.c.
|
||||
*/
|
||||
/* { 0x00000000, 0x02000, 0}, flash sector 0 - reserved for bootloader */
|
||||
/* { 0x00002000, 0x02000, 1}, flash sector 1 - reserved for bootloader */
|
||||
/* { 0x00004000, 0x02000, 2}, flash sector 2 - reserved for bootloader */
|
||||
#else
|
||||
/* { 0x00000000, 0x02000, 0}, flash sector 0 - 8kb */
|
||||
{ 0x00002000, 0x02000, 1}, /* flash sector 1 - 8kb */
|
||||
{ 0x00004000, 0x02000, 2}, /* flash sector 2 - 8kb */
|
||||
#endif
|
||||
{ 0x00006000, 0x02000, 3}, /* flash sector 3 - 8kb */
|
||||
/* { 0x00006000, 0x02000, 3}, flash sector 3 - reserved for bootloader */
|
||||
#if (BOOT_NVM_SIZE_KB > 32)
|
||||
{ 0x00008000, 0x02000, 4}, /* flash sector 4 - 8kb */
|
||||
{ 0x0000A000, 0x02000, 5}, /* flash sector 5 - 8kb */
|
||||
|
|
|
@ -0,0 +1,593 @@
|
|||
/************************************************************************************//**
|
||||
* \file Source\ARMCM4_TM4C\usb.c
|
||||
* \brief Bootloader USB communication interface source file.
|
||||
* \ingroup Target_ARMCM4_TM4C
|
||||
* \internal
|
||||
*----------------------------------------------------------------------------------------
|
||||
* C O P Y R I G H T
|
||||
*----------------------------------------------------------------------------------------
|
||||
* Copyright (c) 2014 by Feaser http://www.feaser.com All rights reserved
|
||||
*
|
||||
*----------------------------------------------------------------------------------------
|
||||
* L I C E N S E
|
||||
*----------------------------------------------------------------------------------------
|
||||
* This file is part of OpenBLT. OpenBLT is free software: you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* OpenBLT is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with OpenBLT.
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* A special exception to the GPL is included to allow you to distribute a combined work
|
||||
* that includes OpenBLT without being obliged to provide the source code for any
|
||||
* proprietary components. The exception text is included at the bottom of the license
|
||||
* file <license.html>.
|
||||
*
|
||||
* \endinternal
|
||||
****************************************************************************************/
|
||||
|
||||
/****************************************************************************************
|
||||
* Include files
|
||||
****************************************************************************************/
|
||||
#include "boot.h" /* bootloader generic header */
|
||||
#if (BOOT_COM_USB_ENABLE > 0)
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "usblib.h"
|
||||
#include "usbdevice.h"
|
||||
#include "usbdbulk.h"
|
||||
#include "usb_bulk_structs.h"
|
||||
|
||||
|
||||
/****************************************************************************************
|
||||
* Macro definitions
|
||||
****************************************************************************************/
|
||||
/** \brief Total number of fifo buffers. */
|
||||
#define FIFO_MAX_BUFFERS (2)
|
||||
/** \brief Invalid value for a fifo buffer handle. */
|
||||
#define FIFO_ERR_INVALID_HANDLE (255)
|
||||
/** \brief Number of bytes that fit in the fifo pipe. */
|
||||
#define FIFO_PIPE_SIZE (64)
|
||||
|
||||
|
||||
/****************************************************************************************
|
||||
* Type definitions
|
||||
****************************************************************************************/
|
||||
/** \brief Structure type for fifo control. */
|
||||
typedef struct t_fifo_ctrl
|
||||
{
|
||||
blt_int8u *startptr; /**< pointer to start of buffer */
|
||||
blt_int8u *endptr; /**< pointer to end of buffer */
|
||||
blt_int8u *readptr; /**< pointer to next read location */
|
||||
blt_int8u *writeptr; /**< pointer to next free location */
|
||||
blt_int8u length; /**< number of buffer elements */
|
||||
blt_int8u entries; /**< # of full buffer elements */
|
||||
blt_int8u handle; /**< handle of the buffer */
|
||||
struct t_fifo_ctrl *fifoctrlptr; /**< pointer to free buffer control */
|
||||
} tFifoCtrl;
|
||||
|
||||
/** \brief Structure type for a fifo pipe. */
|
||||
typedef struct
|
||||
{
|
||||
blt_int8u handle; /**< fifo handle */
|
||||
blt_int8u data[FIFO_PIPE_SIZE]; /**< fifo data buffer */
|
||||
} tFifoPipe; /**< USB pipe fifo type */
|
||||
|
||||
|
||||
/****************************************************************************************
|
||||
* Hook functions
|
||||
****************************************************************************************/
|
||||
extern void UsbEnterLowPowerModeHook(void);
|
||||
extern void UsbLeaveLowPowerModeHook(void);
|
||||
extern void UsbConnectHook(blt_bool connect);
|
||||
|
||||
|
||||
/****************************************************************************************
|
||||
* Function prototypes
|
||||
****************************************************************************************/
|
||||
static blt_bool UsbReceiveByte(blt_int8u *data);
|
||||
static blt_bool UsbTransmitByte(blt_int8u data);
|
||||
static void UsbTransmitPipeBulkIN(void);
|
||||
static void UsbReceivePipeBulkOUT(blt_int8u *data, blt_int32u len);
|
||||
static void UsbFifoMgrInit(void);
|
||||
static blt_int8u UsbFifoMgrCreate(blt_int8u *buffer, blt_int8u length);
|
||||
static blt_bool UsbFifoMgrWrite(blt_int8u handle, blt_int8u data);
|
||||
static blt_bool UsbFifoMgrRead(blt_int8u handle, blt_int8u *data);
|
||||
static blt_int8u UsbFifoMgrScan(blt_int8u handle);
|
||||
|
||||
|
||||
/****************************************************************************************
|
||||
* Local data declarations
|
||||
****************************************************************************************/
|
||||
/** \brief Local variable that holds the fifo control structures. */
|
||||
static tFifoCtrl fifoCtrl[FIFO_MAX_BUFFERS];
|
||||
/** \brief Local pointer that points to the next free fifo control structure. */
|
||||
static tFifoCtrl *fifoCtrlFree;
|
||||
/** \brief Fifo pipe used for the bulk in endpoint. */
|
||||
static tFifoPipe fifoPipeBulkIN;
|
||||
/** \brief Fifo pipe used for the bulk out endpoint. */
|
||||
static tFifoPipe fifoPipeBulkOUT;
|
||||
/** \brief Holds a handle to the bulk device instance. */
|
||||
static tBulkInstance *instanceHandle;
|
||||
|
||||
|
||||
/************************************************************************************//**
|
||||
** \brief Initializes the USB communication interface.
|
||||
** \return none.
|
||||
**
|
||||
****************************************************************************************/
|
||||
void UsbInit(void)
|
||||
{
|
||||
/* initialize the FIFO manager */
|
||||
UsbFifoMgrInit();
|
||||
/* place 2 buffers under FIFO management */
|
||||
fifoPipeBulkIN.handle = UsbFifoMgrCreate(fifoPipeBulkIN.data, FIFO_PIPE_SIZE);
|
||||
fifoPipeBulkOUT.handle = UsbFifoMgrCreate(fifoPipeBulkOUT.data, FIFO_PIPE_SIZE);
|
||||
/* validate fifo handles */
|
||||
ASSERT_RT( (fifoPipeBulkIN.handle != FIFO_ERR_INVALID_HANDLE) && \
|
||||
(fifoPipeBulkOUT.handle != FIFO_ERR_INVALID_HANDLE) );
|
||||
/* initialize the transmit and receive buffers */
|
||||
USBBufferInit(&g_sTxBuffer);
|
||||
USBBufferInit(&g_sRxBuffer);
|
||||
/* pass our device information to the USB library and place the device on the bus */
|
||||
instanceHandle = USBDBulkInit(0, &g_sBulkDevice);
|
||||
ASSERT_RT(instanceHandle != BLT_NULL);
|
||||
} /*** end of UsbInit ***/
|
||||
|
||||
|
||||
/************************************************************************************//**
|
||||
** \brief Releases the USB communication interface.
|
||||
** \return none.
|
||||
**
|
||||
****************************************************************************************/
|
||||
void UsbFree(void)
|
||||
{
|
||||
/* shut down the bulk device */
|
||||
USBDBulkTerm(instanceHandle);
|
||||
/* disconnect the USB device from the USB host */
|
||||
UsbConnectHook(BLT_FALSE);
|
||||
} /*** end of UsbFree ***/
|
||||
|
||||
|
||||
/************************************************************************************//**
|
||||
** \brief Transmits a packet formatted for the communication interface.
|
||||
** \param data Pointer to byte array with data that it to be transmitted.
|
||||
** \param len Number of bytes that are to be transmitted.
|
||||
** \return none.
|
||||
**
|
||||
****************************************************************************************/
|
||||
void UsbTransmitPacket(blt_int8u *data, blt_int8u len)
|
||||
{
|
||||
blt_int16u data_index;
|
||||
|
||||
/* verify validity of the len-parameter */
|
||||
ASSERT_RT(len <= BOOT_COM_TX_MAX_DATA);
|
||||
|
||||
/* first transmit the length of the packet */
|
||||
ASSERT_RT(UsbTransmitByte(len) == BLT_TRUE);
|
||||
|
||||
/* transmit all the packet bytes one-by-one */
|
||||
for (data_index = 0; data_index < len; data_index++)
|
||||
{
|
||||
/* keep the watchdog happy */
|
||||
CopService();
|
||||
/* write byte */
|
||||
ASSERT_RT(UsbTransmitByte(data[data_index]) == BLT_TRUE);
|
||||
}
|
||||
|
||||
/* start the transmission */
|
||||
UsbTransmitPipeBulkIN();
|
||||
} /*** end of UsbTransmitPacket ***/
|
||||
|
||||
|
||||
/************************************************************************************//**
|
||||
** \brief Receives a communication interface packet if one is present.
|
||||
** \param data Pointer to byte array where the data is to be stored.
|
||||
** \return BLT_TRUE if a packet was received, BLT_FALSE otherwise.
|
||||
**
|
||||
****************************************************************************************/
|
||||
blt_bool UsbReceivePacket(blt_int8u *data)
|
||||
{
|
||||
static blt_int8u xcpCtoReqPacket[XCP_CTO_PACKET_LEN+1]; /* one extra for length */
|
||||
static blt_int8u xcpCtoRxLength;
|
||||
static blt_bool xcpCtoRxInProgress = BLT_FALSE;
|
||||
|
||||
/* poll for USB events */
|
||||
USB0DeviceIntHandler();
|
||||
|
||||
/* start of cto packet received? */
|
||||
if (xcpCtoRxInProgress == BLT_FALSE)
|
||||
{
|
||||
/* store the message length when received */
|
||||
if (UsbReceiveByte(&xcpCtoReqPacket[0]) == BLT_TRUE)
|
||||
{
|
||||
/* indicate that a cto packet is being received */
|
||||
xcpCtoRxInProgress = BLT_TRUE;
|
||||
|
||||
/* reset packet data count */
|
||||
xcpCtoRxLength = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* store the next packet byte */
|
||||
if (UsbReceiveByte(&xcpCtoReqPacket[xcpCtoRxLength+1]) == BLT_TRUE)
|
||||
{
|
||||
/* increment the packet data count */
|
||||
xcpCtoRxLength++;
|
||||
|
||||
/* check to see if the entire packet was received */
|
||||
if (xcpCtoRxLength == xcpCtoReqPacket[0])
|
||||
{
|
||||
/* copy the packet data */
|
||||
CpuMemCopy((blt_int32u)data, (blt_int32u)&xcpCtoReqPacket[1], xcpCtoRxLength);
|
||||
/* done with cto packet reception */
|
||||
xcpCtoRxInProgress = BLT_FALSE;
|
||||
|
||||
/* packet reception complete */
|
||||
return BLT_TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* packet reception not yet complete */
|
||||
return BLT_FALSE;
|
||||
} /*** end of UsbReceivePacket ***/
|
||||
|
||||
|
||||
/************************************************************************************//**
|
||||
** \brief Receives a communication interface byte if one is present.
|
||||
** \param data Pointer to byte where the data is to be stored.
|
||||
** \return BLT_TRUE if a byte was received, BLT_FALSE otherwise.
|
||||
**
|
||||
****************************************************************************************/
|
||||
static blt_bool UsbReceiveByte(blt_int8u *data)
|
||||
{
|
||||
blt_bool result;
|
||||
|
||||
/* obtain data from the fifo */
|
||||
result = UsbFifoMgrRead(fifoPipeBulkOUT.handle, data);
|
||||
return result;
|
||||
} /*** end of UsbReceiveByte ***/
|
||||
|
||||
|
||||
/************************************************************************************//**
|
||||
** \brief Transmits a communication interface byte.
|
||||
** \param data Value of byte that is to be transmitted.
|
||||
** \return BLT_TRUE if the byte was transmitted, BLT_FALSE otherwise.
|
||||
**
|
||||
****************************************************************************************/
|
||||
static blt_bool UsbTransmitByte(blt_int8u data)
|
||||
{
|
||||
blt_bool result;
|
||||
|
||||
/* write data from to fifo */
|
||||
result = UsbFifoMgrWrite(fifoPipeBulkIN.handle, data);
|
||||
return result;
|
||||
} /*** end of UsbTransmitByte ***/
|
||||
|
||||
|
||||
/************************************************************************************//**
|
||||
** \brief Checks if there is still data left to transmit and if so submits it
|
||||
** for transmission with the USB endpoint.
|
||||
** \return none.
|
||||
**
|
||||
****************************************************************************************/
|
||||
static void UsbTransmitPipeBulkIN(void)
|
||||
{
|
||||
tUSBRingBufObject txRing;
|
||||
blt_int32u txSpace;
|
||||
blt_int32u txWriteIdx;
|
||||
blt_int8u nr_of_bytes_for_tx_endpoint;
|
||||
blt_int8u byte_counter;
|
||||
blt_int8u byte_value;
|
||||
blt_bool result;
|
||||
|
||||
/* read how many bytes should be transmitted */
|
||||
nr_of_bytes_for_tx_endpoint = UsbFifoMgrScan(fifoPipeBulkIN.handle);
|
||||
/* only continue if there is actually data left to transmit */
|
||||
if (nr_of_bytes_for_tx_endpoint == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
/* get information about the USB transmit buffer */
|
||||
USBBufferInfoGet(&g_sTxBuffer, &txRing);
|
||||
/* determine how many bytes will still fit in the tx buffer */
|
||||
txSpace = USBBufferSpaceAvailable(&g_sTxBuffer);
|
||||
/* only transmit the amount of bytes that will fit in the tx buffer */
|
||||
if (nr_of_bytes_for_tx_endpoint > txSpace)
|
||||
{
|
||||
nr_of_bytes_for_tx_endpoint = txSpace;
|
||||
}
|
||||
/* determine write index for the tx buffer */
|
||||
txWriteIdx = txRing.ui32WriteIndex;
|
||||
|
||||
/* copy the transmit data to the transmit buffer */
|
||||
for (byte_counter=0; byte_counter < nr_of_bytes_for_tx_endpoint; byte_counter++)
|
||||
{
|
||||
/* obtain data from the fifo */
|
||||
result = UsbFifoMgrRead(fifoPipeBulkIN.handle, &byte_value);
|
||||
ASSERT_RT(result == BLT_TRUE);
|
||||
/* store it in the transmit buffer */
|
||||
g_pui8USBTxBuffer[txWriteIdx] = byte_value;
|
||||
/* increment index with wrapping */
|
||||
txWriteIdx++;
|
||||
if (txWriteIdx >= BULK_BUFFER_SIZE)
|
||||
{
|
||||
txWriteIdx = 0;
|
||||
}
|
||||
}
|
||||
/* inform the usb library that new data are ready for transmission */
|
||||
USBBufferDataWritten(&g_sTxBuffer, nr_of_bytes_for_tx_endpoint);
|
||||
} /*** end of UsbTransmitPipeBulkIN ***/
|
||||
|
||||
|
||||
/************************************************************************************//**
|
||||
** \brief Stores data that was received on the Bulk OUT pipe in the fifo.
|
||||
** \param data Pointer to buffer with the newly received data
|
||||
** \param len Number of received data bytes.
|
||||
** \return none.
|
||||
**
|
||||
****************************************************************************************/
|
||||
static void UsbReceivePipeBulkOUT(blt_int8u *data, blt_int32u len)
|
||||
{
|
||||
blt_int32u byte_counter;
|
||||
blt_bool result;
|
||||
blt_int32u rxReadIdx;
|
||||
|
||||
|
||||
/* determine read index for the rx buffer */
|
||||
rxReadIdx = (uint32_t)(data - g_pui8USBRxBuffer);
|
||||
|
||||
/* store the received data in the reception fifo */
|
||||
for (byte_counter=0; byte_counter<len; byte_counter++)
|
||||
{
|
||||
/* add the data to the fifo */
|
||||
result = UsbFifoMgrWrite(fifoPipeBulkOUT.handle, g_pui8USBRxBuffer[rxReadIdx]);
|
||||
/* verify that the fifo wasn't full */
|
||||
ASSERT_RT(result == BLT_TRUE);
|
||||
/* increment index with wrapping */
|
||||
rxReadIdx++;
|
||||
if (rxReadIdx >= BULK_BUFFER_SIZE)
|
||||
{
|
||||
rxReadIdx = 0;
|
||||
}
|
||||
}
|
||||
} /*** end of UsbReceivePipeBulkOUT ***/
|
||||
|
||||
|
||||
/************************************************************************************//**
|
||||
** \brief Handles bulk driver notifications related to the transmit channel (data to
|
||||
** the USB host).
|
||||
** \param pvCBData is the client-supplied callback pointer for this channel.
|
||||
** \param ui32Event identifies the event we are being notified about.
|
||||
** \param ui32MsgValue is an event-specific value.
|
||||
** \param pvMsgData is an event-specific pointer.
|
||||
** \return The return value is event-specific.
|
||||
**
|
||||
****************************************************************************************/
|
||||
uint32_t UsbBulkTxHandler(void *pvCBData, uint32_t ui32Event, uint32_t ui32MsgValue, void *pvMsgData)
|
||||
{
|
||||
if(ui32Event == USB_EVENT_TX_COMPLETE)
|
||||
{
|
||||
/* check if more data is waiting to be transmitted */
|
||||
UsbTransmitPipeBulkIN();
|
||||
}
|
||||
return 0;
|
||||
} /*** end of UsbBulkTxHandler ***/
|
||||
|
||||
|
||||
/************************************************************************************//**
|
||||
** \brief Handles bulk driver notifications related to the receive channel (data from
|
||||
** the USB host).
|
||||
** \param pvCBData is the client-supplied callback pointer for this channel.
|
||||
** \param ui32Event identifies the event we are being notified about.
|
||||
** \param ui32MsgValue is an event-specific value.
|
||||
** \param pvMsgData is an event-specific pointer.
|
||||
** \return The return value is event-specific.
|
||||
**
|
||||
****************************************************************************************/
|
||||
uint32_t UsbBulkRxHandler(void *pvCBData, uint32_t ui32Event, uint32_t ui32MsgValue, void *pvMsgData)
|
||||
{
|
||||
/* which event are we being sent? */
|
||||
switch(ui32Event)
|
||||
{
|
||||
/* we are connected to a host and communication is now possible */
|
||||
case USB_EVENT_CONNECTED:
|
||||
{
|
||||
/* flush our buffers */
|
||||
USBBufferFlush(&g_sTxBuffer);
|
||||
USBBufferFlush(&g_sRxBuffer);
|
||||
break;
|
||||
}
|
||||
|
||||
/* the host has disconnected */
|
||||
case USB_EVENT_DISCONNECTED:
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
/* a new packet has been received */
|
||||
case USB_EVENT_RX_AVAILABLE:
|
||||
{
|
||||
/* handle all newly received bytes */
|
||||
UsbReceivePipeBulkOUT(pvMsgData, ui32MsgValue);
|
||||
return ui32MsgValue;
|
||||
}
|
||||
|
||||
/* ignore SUSPEND and RESUME for now */
|
||||
case USB_EVENT_SUSPEND:
|
||||
/* power-off system clocks and power */
|
||||
UsbEnterLowPowerModeHook();
|
||||
break;
|
||||
|
||||
case USB_EVENT_RESUME:
|
||||
/* restore power and system clocks */
|
||||
UsbLeaveLowPowerModeHook();
|
||||
break;
|
||||
|
||||
/* ignore all other events and return 0 */
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
} /*** end of UsbBulkRxHandler ***/
|
||||
|
||||
|
||||
/************************************************************************************//**
|
||||
** \brief Initializes the fifo manager. Each controlled fifo is assigned a
|
||||
** unique handle, which is the same as its index into fifoCtrl[]. Each
|
||||
** controlled fifo holds a pointer to the next free fifo control.
|
||||
** For the last fifo in fifoCtrl[] this one is set to a null-pointer as
|
||||
** an out of fifo control indicator. Function should be called once
|
||||
** before any of the other fifo management functions are called.
|
||||
** \return none.
|
||||
**
|
||||
****************************************************************************************/
|
||||
static void UsbFifoMgrInit(void)
|
||||
{
|
||||
blt_int8u i;
|
||||
tFifoCtrl *pbc1, *pbc2;
|
||||
|
||||
pbc1 = &fifoCtrl[0];
|
||||
pbc2 = &fifoCtrl[1];
|
||||
/* assign fifo handles and pointer to next free fifo */
|
||||
for (i = 0; i < (FIFO_MAX_BUFFERS - 1); i++)
|
||||
{
|
||||
pbc1->handle = i;
|
||||
pbc1->fifoctrlptr = pbc2;
|
||||
pbc1++;
|
||||
pbc2++;
|
||||
}
|
||||
/* initialize handle for the last one and use null-pointer for the next free fifo */
|
||||
pbc1->handle = i;
|
||||
pbc1->fifoctrlptr = (tFifoCtrl *)0;
|
||||
fifoCtrlFree = &fifoCtrl[0];
|
||||
} /*** end of UsbFifoMgrInit ***/
|
||||
|
||||
|
||||
/************************************************************************************//**
|
||||
** \brief Places a data storage array under fifo management control. A handle
|
||||
** for identifying the fifo in subsequent fifo management function
|
||||
** calls is returned, if successful.
|
||||
** \param buffer Pointer to the first element in the data storage fifo.
|
||||
** \param length Maximum number of data elements that can be stored in the fifo.
|
||||
** \return Fifo handle if successfull, or FIFO_ERR_INVALID_HANDLE.
|
||||
**
|
||||
****************************************************************************************/
|
||||
static blt_int8u UsbFifoMgrCreate(blt_int8u *buffer, blt_int8u length)
|
||||
{
|
||||
tFifoCtrl *pbc;
|
||||
|
||||
/* first determine if these is still a free fifo control available */
|
||||
if (fifoCtrlFree == (tFifoCtrl *)0)
|
||||
{
|
||||
return FIFO_ERR_INVALID_HANDLE;
|
||||
}
|
||||
/* store pointer to free fifo and update pointer to next free one */
|
||||
pbc = fifoCtrlFree;
|
||||
fifoCtrlFree = pbc->fifoctrlptr;
|
||||
|
||||
/* initialize the buffer control */
|
||||
pbc->length = length;
|
||||
pbc->readptr = buffer;
|
||||
pbc->writeptr = buffer;
|
||||
pbc->entries = 0;
|
||||
pbc->startptr = buffer;
|
||||
pbc->endptr = (blt_int8u*)(buffer + length - 1);
|
||||
|
||||
/* return the handle to the successfully created fifo control */
|
||||
return pbc->handle;
|
||||
} /*** end of UsbFifoMgrCreate ***/
|
||||
|
||||
|
||||
/************************************************************************************//**
|
||||
** \brief Stores data in the fifo.
|
||||
** \param handle Identifies the fifo to write data to.
|
||||
** \param data Pointer to the data that is to be written to the fifo.
|
||||
** \return BLT_TRUE if the data was successfully stored in the fifo, BLT_FALSE
|
||||
** otherwise.
|
||||
**
|
||||
****************************************************************************************/
|
||||
static blt_bool UsbFifoMgrWrite(blt_int8u handle, blt_int8u data)
|
||||
{
|
||||
/* check the validity of the handle parameter */
|
||||
ASSERT_RT(handle < FIFO_MAX_BUFFERS);
|
||||
/* check if fifo is full */
|
||||
if (fifoCtrl[handle].entries == fifoCtrl[handle].length)
|
||||
{
|
||||
return BLT_FALSE;
|
||||
}
|
||||
/* copy data to fifo */
|
||||
*fifoCtrl[handle].writeptr = data;
|
||||
/* data written so update number of entries */
|
||||
fifoCtrl[handle].entries++;
|
||||
/* update write pointer */
|
||||
fifoCtrl[handle].writeptr++;
|
||||
/* check end of fifo */
|
||||
if (fifoCtrl[handle].writeptr > fifoCtrl[handle].endptr)
|
||||
{
|
||||
/* set write pointer to start of the cyclic fifo */
|
||||
fifoCtrl[handle].writeptr = fifoCtrl[handle].startptr;
|
||||
}
|
||||
/* still here so all is okay */
|
||||
return BLT_TRUE;
|
||||
} /*** end of UsbFifoMgrWrite ***/
|
||||
|
||||
|
||||
/************************************************************************************//**
|
||||
** \brief Retrieves data from the fifo.
|
||||
** \param handle Identifies the fifo to read data from.
|
||||
** \param data Pointer to where the read data is to be stored.
|
||||
** \return BLT_TRUE if the data was successfully read from the fifo, BLT_FALSE
|
||||
** otherwise.
|
||||
**
|
||||
****************************************************************************************/
|
||||
static blt_bool UsbFifoMgrRead(blt_int8u handle, blt_int8u *data)
|
||||
{
|
||||
/* check the validity of the handle parameter */
|
||||
ASSERT_RT(handle < FIFO_MAX_BUFFERS);
|
||||
/* check if fifo is empty */
|
||||
if (fifoCtrl[handle].entries == 0)
|
||||
{
|
||||
return BLT_FALSE;
|
||||
}
|
||||
/* read the data */
|
||||
*data = *fifoCtrl[handle].readptr;
|
||||
/* data read so update number of entries */
|
||||
fifoCtrl[handle].entries--;
|
||||
/* update read pointer */
|
||||
fifoCtrl[handle].readptr++;
|
||||
/* check end of fifo */
|
||||
if (fifoCtrl[handle].readptr > fifoCtrl[handle].endptr)
|
||||
{
|
||||
/* set read pointer to start of the cyclic fifo */
|
||||
fifoCtrl[handle].readptr = fifoCtrl[handle].startptr;
|
||||
}
|
||||
/* still here so all is good */
|
||||
return BLT_TRUE;
|
||||
} /*** end of UsbFifoMgrRead ***/
|
||||
|
||||
|
||||
/************************************************************************************//**
|
||||
** \brief Returns the number of data entries currently present in the fifo.
|
||||
** \param handle Identifies the fifo that is to be scanned.
|
||||
** \return Number of data entries in the fifo if successful, otherwise 0.
|
||||
**
|
||||
****************************************************************************************/
|
||||
static blt_int8u UsbFifoMgrScan(blt_int8u handle)
|
||||
{
|
||||
/* check the validity of the handle parameter */
|
||||
ASSERT_RT(handle < FIFO_MAX_BUFFERS);
|
||||
/* read and return the number of data entries */
|
||||
return fifoCtrl[handle].entries;
|
||||
} /*** end of UsbFifoMgrScan ***/
|
||||
#endif /* BOOT_COM_USB_ENABLE > 0 */
|
||||
|
||||
|
||||
/*********************************** end of usb.c **************************************/
|
|
@ -0,0 +1,48 @@
|
|||
/************************************************************************************//**
|
||||
* \file Source\ARMCM4_TM4C\usb.h
|
||||
* \brief Bootloader USB communication interface header file.
|
||||
* \ingroup Target_ARMCM4_TM4C
|
||||
* \internal
|
||||
*----------------------------------------------------------------------------------------
|
||||
* C O P Y R I G H T
|
||||
*----------------------------------------------------------------------------------------
|
||||
* Copyright (c) 2011 by Feaser http://www.feaser.com All rights reserved
|
||||
*
|
||||
*----------------------------------------------------------------------------------------
|
||||
* L I C E N S E
|
||||
*----------------------------------------------------------------------------------------
|
||||
* This file is part of OpenBLT. OpenBLT is free software: you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* OpenBLT is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with OpenBLT.
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* A special exception to the GPL is included to allow you to distribute a combined work
|
||||
* that includes OpenBLT without being obliged to provide the source code for any
|
||||
* proprietary components. The exception text is included at the bottom of the license
|
||||
* file <license.html>.
|
||||
*
|
||||
* \endinternal
|
||||
****************************************************************************************/
|
||||
#ifndef USB_H
|
||||
#define USB_H
|
||||
|
||||
#if (BOOT_COM_USB_ENABLE > 0)
|
||||
/****************************************************************************************
|
||||
* Function prototypes
|
||||
****************************************************************************************/
|
||||
void UsbInit(void);
|
||||
void UsbFree(void);
|
||||
void UsbTransmitPacket(blt_int8u *data, blt_int8u len);
|
||||
blt_bool UsbReceivePacket(blt_int8u *data);
|
||||
#endif /* BOOT_COM_USB_ENABLE > 0 */
|
||||
|
||||
|
||||
#endif /* USB_H */
|
||||
/*********************************** end of usb.h **************************************/
|
Loading…
Reference in New Issue