mirror of
https://github.com/FreeRTOS/FreeRTOS.git
synced 2026-08-23 08:48:46 +08:00
Core kernel code:
Allow the stats formatting functions to be built in without stdio.h being included inside tasks.c. Kernel port code: - Slight change to the Cortex-A GIC-less port to move all non portable code to the application level. SAMA5D4 demo project: - Update the Atmel provided library to V1.1. - Create a DDR build configuration. - Ensure interrupts are all edge sensitive. - Update the regtest code to use all 32 flop registers.
This commit is contained in:
-8
@@ -186,8 +186,6 @@ uint8_t *pc1, *pc2;
|
||||
usTemp = ( ( *pc2 ) << 8 ) | *pc1;
|
||||
|
||||
return usTemp;
|
||||
#warning The above code replaces the line below to ensure aborts are not received due to unaligned accesses. Alternatively use the --no_unaligned_access compiler option.
|
||||
//return endpoint->wMaxPacketSize;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -208,15 +206,9 @@ uint8_t USBEndpointDescriptor_GetInterval(
|
||||
* \param configuration Pointer to a USBConfigurationDescriptor instance.
|
||||
* \return Total length (in bytes) of the configuration.
|
||||
*/
|
||||
volatile unsigned long ulCount = 0;
|
||||
uint32_t USBConfigurationDescriptor_GetTotalLength(
|
||||
const USBConfigurationDescriptor *configuration)
|
||||
{
|
||||
ulCount++;
|
||||
if( ulCount == 5 )
|
||||
{
|
||||
__asm volatile( "NOP" );
|
||||
}
|
||||
return configuration->wTotalLength;
|
||||
}
|
||||
|
||||
|
||||
-1
@@ -54,7 +54,6 @@
|
||||
WEAK void USBDCallbacks_Initialized(void)
|
||||
{
|
||||
/* Does nothing */
|
||||
__asm volatile( "NOP" );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -114,7 +114,7 @@ void vConfigureTickInterrupt( void )
|
||||
is shared with other system peripherals, so System_Handler() must be
|
||||
installed in place of FreeRTOS_Tick_Handler() if other system handlers are
|
||||
required. The tick must be given the lowest priority (0 in the SAMA5 AIC) */
|
||||
IRQ_ConfigureIT( ID_PIT, 0, FreeRTOS_Tick_Handler );
|
||||
IRQ_ConfigureIT( ID_PIT, AIC_SMR_SRCTYPE_EXT_POSITIVE_EDGE, FreeRTOS_Tick_Handler );
|
||||
/* See commend directly above IRQ_ConfigureIT( ID_PIT, 0, System_Handler ); */
|
||||
IRQ_EnableIT( ID_PIT );
|
||||
PIT_EnableIT();
|
||||
|
||||
@@ -214,7 +214,7 @@
|
||||
</option>
|
||||
<option>
|
||||
<name>CCDiagSuppress</name>
|
||||
<state>Pa131</state>
|
||||
<state>Pa131, Pa039</state>
|
||||
</option>
|
||||
<option>
|
||||
<name>CCDiagRemark</name>
|
||||
|
||||
@@ -97,7 +97,7 @@
|
||||
|
||||
/* Set mainCREATE_SIMPLE_BLINKY_DEMO_ONLY to one to run the simple blinky demo,
|
||||
or 0 to run the more comprehensive test and demo application. */
|
||||
#define mainCREATE_SIMPLE_BLINKY_DEMO_ONLY 0
|
||||
#define mainCREATE_SIMPLE_BLINKY_DEMO_ONLY 1
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
@@ -124,11 +124,8 @@ void vApplicationStackOverflowHook( TaskHandle_t pxTask, char *pcTaskName );
|
||||
void vApplicationTickHook( void );
|
||||
|
||||
/* Prototype for the IRQ handler called by the generic Cortex-A5 RTOS port
|
||||
layer. The address of the ISR is passed into this function as a parameter.
|
||||
Note this level of indirection could be removed by creating a SAMA5 specific
|
||||
port layer that calls the IRQ directly from the port layer rather than via this
|
||||
application callback. */
|
||||
void vApplicationIRQHandler( uint32_t ulInterruptVectorAddress );
|
||||
layer. */
|
||||
void vApplicationIRQHandler( void );
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
@@ -164,7 +161,12 @@ static void prvSetupHardware( void )
|
||||
/* Configure ports used by LEDs. */
|
||||
vParTestInitialise();
|
||||
|
||||
CP15_EnableIcache();
|
||||
#if defined (ddram)
|
||||
MMU_Initialize( ( uint32_t * ) 0x30C000 );
|
||||
CP15_EnableMMU();
|
||||
CP15_EnableDcache();
|
||||
CP15_EnableIcache();
|
||||
#endif
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
@@ -175,8 +177,9 @@ void vApplicationMallocFailedHook( void )
|
||||
internally by FreeRTOS API functions that create tasks, queues, software
|
||||
timers, and semaphores. The size of the FreeRTOS heap is set by the
|
||||
configTOTAL_HEAP_SIZE configuration constant in FreeRTOSConfig.h. */
|
||||
taskDISABLE_INTERRUPTS();
|
||||
for( ;; );
|
||||
|
||||
/* Force an assert. */
|
||||
configASSERT( ( volatile void * ) NULL );
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
@@ -188,8 +191,9 @@ void vApplicationStackOverflowHook( TaskHandle_t pxTask, char *pcTaskName )
|
||||
/* Run time stack overflow checking is performed if
|
||||
configCHECK_FOR_STACK_OVERFLOW is defined to 1 or 2. This hook
|
||||
function is called if a stack overflow is detected. */
|
||||
taskDISABLE_INTERRUPTS();
|
||||
for( ;; );
|
||||
|
||||
/* Force an assert. */
|
||||
configASSERT( ( volatile void * ) NULL );
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
@@ -251,19 +255,19 @@ void vApplicationTickHook( void )
|
||||
|
||||
/* The function called by the RTOS port layer after it has managed interrupt
|
||||
entry. */
|
||||
void vApplicationIRQHandler( uint32_t ulInterruptVectorAddress )
|
||||
void vApplicationIRQHandler( void )
|
||||
{
|
||||
typedef void (*ISRFunction_t)( void );
|
||||
ISRFunction_t pxISRFunction;
|
||||
volatile uint32_t * pulAIC_IVR = ( uint32_t * ) configINTERRUPT_VECTOR_ADDRESS;
|
||||
|
||||
/* On the SAMA5 the parameter is a pointer to the ISR handling function. */
|
||||
pxISRFunction = ( ISRFunction_t ) ulInterruptVectorAddress;
|
||||
/* Obtain the address of the interrupt handler from the AIR. */
|
||||
pxISRFunction = ( ISRFunction_t ) *pulAIC_IVR;
|
||||
|
||||
/* Write back to the SAMA5's interrupt controller's IVR register in case the
|
||||
CPU is in protect mode. If the interrupt controller is not in protect mode
|
||||
then this write is not necessary. */
|
||||
*pulAIC_IVR = 0;
|
||||
*pulAIC_IVR = ( uint32_t ) pxISRFunction;
|
||||
|
||||
/* Ensure the write takes before re-enabling interrupts. */
|
||||
__DSB();
|
||||
|
||||
@@ -51,20 +51,20 @@
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
<SelectedTab>0</SelectedTab></Wnd0><Wnd5><Tabs><Tab><Identity>TabID-31713-7906</Identity><TabName>Debug Log</TabName><Factory>Debug-Log</Factory><Session/></Tab></Tabs><SelectedTab>0</SelectedTab></Wnd5></Windows>
|
||||
<SelectedTab>0</SelectedTab></Wnd0><Wnd3><Tabs><Tab><Identity>TabID-31713-7906</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>127</YPos2><SelStart2>6411</SelStart2><SelEnd2>6411</SelEnd2></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\Full_Demo\main_full.c</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>63</YPos2><SelStart2>0</SelStart2><SelEnd2>0</SelEnd2></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\blinky_demo\main_blinky.c</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>63</YPos2><SelStart2>1373</SelStart2><SelEnd2>1373</SelEnd2></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\..\Common\Minimal\GenQTest.c</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>796</YPos2><SelStart2>27238</SelStart2><SelEnd2>27238</SelEnd2></Tab><ActiveTab>3</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$\CDCCommandConsole.c</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>441</YPos2><SelStart2>16342</SelStart2><SelEnd2>16359</SelEnd2></Tab><ActiveTab>0</ActiveTab><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>111</YPos2><SelStart2>6131</SelStart2><SelEnd2>6131</SelEnd2></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\..\..\Source\portable\IAR\ARM_CA5_No_GIC\portASM.s</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>117</YPos2><SelStart2>5123</SelStart2><SelEnd2>5123</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-011172A8><key>iaridepm.enu1</key></Toolbar-011172A8></Sizes></Row0><Row1><Sizes><Toolbar-07251300><key>debuggergui.enu1</key></Toolbar-07251300></Sizes></Row1></Top><Left><Row0><Sizes><Wnd0><Rect><Top>-2</Top><Left>-2</Left><Bottom>718</Bottom><Right>332</Right><x>-2</x><y>-2</y><xscreen>200</xscreen><yscreen>200</yscreen><sizeHorzCX>119048</sizeHorzCX><sizeHorzCY>203252</sizeHorzCY><sizeVertCX>198810</sizeVertCX><sizeVertCY>731707</sizeVertCY></Rect></Wnd0></Sizes></Row0></Left><Right><Row0><Sizes/></Row0></Right><Bottom><Row0><Sizes><Wnd5><Rect><Top>-2</Top><Left>-2</Left><Bottom>198</Bottom><Right>1682</Right><x>-2</x><y>-2</y><xscreen>1684</xscreen><yscreen>200</yscreen><sizeHorzCX>1002381</sizeHorzCX><sizeHorzCY>203252</sizeHorzCY><sizeVertCX>119048</sizeVertCX><sizeVertCY>203252</sizeVertCY></Rect></Wnd5></Sizes></Row0></Bottom><Float><Sizes/></Float></Positions>
|
||||
<Top><Row0><Sizes><Toolbar-002781D8><key>iaridepm.enu1</key></Toolbar-002781D8></Sizes></Row0><Row1><Sizes><Toolbar-1A6225A0><key>debuggergui.enu1</key></Toolbar-1A6225A0></Sizes></Row1></Top><Left><Row0><Sizes><Wnd0><Rect><Top>-2</Top><Left>-2</Left><Bottom>718</Bottom><Right>332</Right><x>-2</x><y>-2</y><xscreen>200</xscreen><yscreen>200</yscreen><sizeHorzCX>119048</sizeHorzCX><sizeHorzCY>203252</sizeHorzCY><sizeVertCX>198810</sizeVertCX><sizeVertCY>731707</sizeVertCY></Rect></Wnd0></Sizes></Row0></Left><Right><Row0><Sizes/></Row0></Right><Bottom><Row0><Sizes><Wnd3><Rect><Top>-2</Top><Left>-2</Left><Bottom>198</Bottom><Right>1682</Right><x>-2</x><y>-2</y><xscreen>1684</xscreen><yscreen>200</yscreen><sizeHorzCX>1002381</sizeHorzCX><sizeHorzCY>203252</sizeHorzCY><sizeVertCX>119048</sizeVertCX><sizeVertCY>203252</sizeVertCY></Rect></Wnd3></Sizes></Row0></Bottom><Float><Sizes/></Float></Positions>
|
||||
</Desktop>
|
||||
</Project>
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ Watch0=_ 0 "" 0 "" 0 "" 0 "" 0 0 0 0
|
||||
Watch1=_ 0 "" 0 "" 0 "" 0 "" 0 0 0 0
|
||||
CStepIntDis=_ 0
|
||||
[DebugChecksum]
|
||||
Checksum=-1280642381
|
||||
Checksum=1420081031
|
||||
[Exceptions]
|
||||
StopOnUncaught=_ 0
|
||||
StopOnThrow=_ 0
|
||||
@@ -42,8 +42,9 @@ Exclusions=
|
||||
[Disassemble mode]
|
||||
mode=0
|
||||
[Breakpoints2]
|
||||
Bp0=_ 1 "EMUL_CODE" "{$PROJ_DIR$\main.c}.221.2" 0 0 1 "" 0 "" 0
|
||||
Count=1
|
||||
Bp0=_ 1 "EMUL_CODE" "{$PROJ_DIR$\main.c}.229.3" 0 0 1 "" 0 "" 0
|
||||
Bp1=_ 1 "EMUL_CODE" "{$PROJ_DIR$\CDCCommandConsole.c}.397.9" 0 0 1 "" 0 "" 0
|
||||
Count=2
|
||||
[Aliases]
|
||||
Count=0
|
||||
SuppressDialog=0
|
||||
|
||||
@@ -32,11 +32,11 @@
|
||||
|
||||
|
||||
<ColumnWidth0>20</ColumnWidth0><ColumnWidth1>1216</ColumnWidth1><ColumnWidth2>324</ColumnWidth2><ColumnWidth3>81</ColumnWidth3></Build>
|
||||
<Debug-Log><ColumnWidth0>18</ColumnWidth0><ColumnWidth1>1624</ColumnWidth1></Debug-Log><TerminalIO/><Select-Ambiguous-Definitions><ColumnWidth0>552</ColumnWidth0><ColumnWidth1>78</ColumnWidth1><ColumnWidth2>946</ColumnWidth2></Select-Ambiguous-Definitions><Find-in-Files><ColumnWidth0>497</ColumnWidth0><ColumnWidth1>82</ColumnWidth1><ColumnWidth2>746</ColumnWidth2><ColumnWidth3>331</ColumnWidth3></Find-in-Files><Breakpoints><col-names><item>Breakpoint</item><item>_I0</item></col-names><col-widths><item>500</item><item>35</item></col-widths><PreferedWindows><Position>3</Position><ScreenPosX>0</ScreenPosX><ScreenPosY>0</ScreenPosY><Windows/></PreferedWindows></Breakpoints></Static>
|
||||
<Debug-Log><ColumnWidth0>18</ColumnWidth0><ColumnWidth1>1624</ColumnWidth1></Debug-Log><TerminalIO/><Select-Ambiguous-Definitions><ColumnWidth0>552</ColumnWidth0><ColumnWidth1>78</ColumnWidth1><ColumnWidth2>946</ColumnWidth2></Select-Ambiguous-Definitions><Find-in-Files><ColumnWidth0>846</ColumnWidth0><ColumnWidth1>82</ColumnWidth1><ColumnWidth2>746</ColumnWidth2><ColumnWidth3>331</ColumnWidth3></Find-in-Files><Breakpoints><col-names><item>Breakpoint</item><item>_I0</item></col-names><col-widths><item>500</item><item>35</item></col-widths><PreferedWindows><Position>3</Position><ScreenPosX>0</ScreenPosX><ScreenPosY>0</ScreenPosY><Windows/></PreferedWindows></Breakpoints></Static>
|
||||
<Windows>
|
||||
|
||||
|
||||
<Wnd0>
|
||||
<Wnd2>
|
||||
<Tabs>
|
||||
<Tab>
|
||||
<Identity>TabID-22351-19008</Identity>
|
||||
@@ -48,7 +48,7 @@
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
<SelectedTab>0</SelectedTab></Wnd0><Wnd2>
|
||||
<SelectedTab>0</SelectedTab></Wnd2><Wnd3>
|
||||
<Tabs>
|
||||
<Tab>
|
||||
<Identity>TabID-21076-19237</Identity>
|
||||
@@ -58,20 +58,20 @@
|
||||
</Tab>
|
||||
<Tab><Identity>TabID-23502-23081</Identity><TabName>Debug Log</TabName><Factory>Debug-Log</Factory><Session/></Tab><Tab><Identity>TabID-24431-23894</Identity><TabName>Ambiguous Definitions</TabName><Factory>Select-Ambiguous-Definitions</Factory><Session/></Tab><Tab><Identity>TabID-9033-6116</Identity><TabName>Find in Files</TabName><Factory>Find-in-Files</Factory><Session/></Tab></Tabs>
|
||||
|
||||
<SelectedTab>0</SelectedTab></Wnd2></Windows>
|
||||
<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>63</YPos2><SelStart2>5074</SelStart2><SelEnd2>5074</SelEnd2></Tab><ActiveTab>0</ActiveTab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\Full_Demo\main_full.c</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>63</YPos2><SelStart2>0</SelStart2><SelEnd2>0</SelEnd2></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\blinky_demo\main_blinky.c</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>63</YPos2><SelStart2>1373</SelStart2><SelEnd2>1373</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$\main.c</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>63</YPos2><SelStart2>5118</SelStart2><SelEnd2>5118</SelEnd2></Tab><ActiveTab>0</ActiveTab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\blinky_demo\main_blinky.c</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>63</YPos2><SelStart2>0</SelStart2><SelEnd2>0</SelEnd2></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\Full_Demo\main_full.c</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>63</YPos2><SelStart2>924</SelStart2><SelEnd2>924</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-011172A8><key>iaridepm.enu1</key></Toolbar-011172A8></Sizes></Row0><Row1><Sizes/></Row1></Top><Left><Row0><Sizes><Wnd0><Rect><Top>-2</Top><Left>-2</Left><Bottom>668</Bottom><Right>352</Right><x>-2</x><y>-2</y><xscreen>190</xscreen><yscreen>170</yscreen><sizeHorzCX>113095</sizeHorzCX><sizeHorzCY>172764</sizeHorzCY><sizeVertCX>210714</sizeVertCX><sizeVertCY>680894</sizeVertCY></Rect></Wnd0></Sizes></Row0></Left><Right><Row0><Sizes/></Row0></Right><Bottom><Row0><Sizes><Wnd2><Rect><Top>-2</Top><Left>-2</Left><Bottom>272</Bottom><Right>1682</Right><x>-2</x><y>-2</y><xscreen>1684</xscreen><yscreen>274</yscreen><sizeHorzCX>1002381</sizeHorzCX><sizeHorzCY>278455</sizeHorzCY><sizeVertCX>113095</sizeVertCX><sizeVertCY>172764</sizeVertCY></Rect></Wnd2></Sizes></Row0></Bottom><Float><Sizes/></Float></Positions>
|
||||
<Top><Row0><Sizes><Toolbar-002781D8><key>iaridepm.enu1</key></Toolbar-002781D8></Sizes></Row0><Row1><Sizes/></Row1></Top><Left><Row0><Sizes><Wnd2><Rect><Top>-2</Top><Left>-2</Left><Bottom>668</Bottom><Right>352</Right><x>-2</x><y>-2</y><xscreen>190</xscreen><yscreen>170</yscreen><sizeHorzCX>113095</sizeHorzCX><sizeHorzCY>172764</sizeHorzCY><sizeVertCX>210714</sizeVertCX><sizeVertCY>680894</sizeVertCY></Rect></Wnd2></Sizes></Row0></Left><Right><Row0><Sizes/></Row0></Right><Bottom><Row0><Sizes><Wnd3><Rect><Top>-2</Top><Left>-2</Left><Bottom>272</Bottom><Right>1682</Right><x>-2</x><y>-2</y><xscreen>1684</xscreen><yscreen>274</yscreen><sizeHorzCX>1002381</sizeHorzCX><sizeHorzCY>278455</sizeHorzCY><sizeVertCX>113095</sizeVertCX><sizeVertCY>172764</sizeVertCY></Rect></Wnd3></Sizes></Row0></Bottom><Float><Sizes/></Float></Positions>
|
||||
</Desktop>
|
||||
</Workspace>
|
||||
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
[MainWindow]
|
||||
WindowPlacement=_ 68 69 855 818 3
|
||||
WindowPlacement=_ 90 4 1190 900 3
|
||||
|
||||
+20
@@ -105,6 +105,22 @@ typedef void (*fGmacdTransferCallback)(uint32_t status);
|
||||
/** Wakeup callback */
|
||||
typedef void (*fGmacdWakeupCallback)(void);
|
||||
|
||||
/**
|
||||
* GMAC scatter-gather entry.
|
||||
*/
|
||||
typedef struct _GmacSG {
|
||||
uint32_t size;
|
||||
void *pBuffer;
|
||||
} sGmacSG;
|
||||
|
||||
/**
|
||||
* GMAC scatter-gather list.
|
||||
*/
|
||||
typedef struct _GmacSGList {
|
||||
uint32_t len;
|
||||
sGmacSG *sg;
|
||||
} sGmacSGList;
|
||||
|
||||
/**
|
||||
* GMAC driver struct.
|
||||
*/
|
||||
@@ -175,6 +191,10 @@ extern uint8_t GMACD_InitTransfer( sGmacd *pGmacd,
|
||||
|
||||
extern void GMACD_Reset(sGmacd *pGmacd);
|
||||
|
||||
extern uint8_t GMACD_SendSG(sGmacd *pGmacd,
|
||||
const sGmacSGList *sgl,
|
||||
fGmacdTransferCallback fTxCb);
|
||||
|
||||
extern uint8_t GMACD_Send(sGmacd *pGmacd,
|
||||
void *pBuffer,
|
||||
uint32_t size,
|
||||
|
||||
+4
-4
@@ -6,13 +6,13 @@ define symbol __ICFEDIT_region_RAM_start__ = 0x200000;
|
||||
define symbol __ICFEDIT_region_RAM_end__ = 0x21FFFF;
|
||||
/*-Sizes-*/
|
||||
define symbol __ICFEDIT_size_vectors__ = 0x100;
|
||||
define symbol __ICFEDIT_size_cstack__ = 0x4000;
|
||||
define symbol __ICFEDIT_size_irqstack__ = 0x60;
|
||||
define symbol __ICFEDIT_size_cstack__ = 0x900;
|
||||
define symbol __ICFEDIT_size_irqstack__ = 0x400;
|
||||
define symbol __ICFEDIT_size_fiqstack__ = 0x60;
|
||||
define symbol __ICFEDIT_size_abtstack__ = 0x60;
|
||||
define symbol __ICFEDIT_size_undstack__ = 0x40;
|
||||
|
||||
define symbol __ICFEDIT_size_heap__ = 0x400;
|
||||
define symbol __ICFEDIT_size_heap__ = 0x0;
|
||||
/*-Exports-*/
|
||||
export symbol __ICFEDIT_region_RAM_start__;
|
||||
export symbol __ICFEDIT_region_RAM_end__;
|
||||
@@ -35,7 +35,7 @@ define block ABT_STACK with alignment = 8, size = __ICFEDIT_size_abtstack__ { };
|
||||
define block UND_STACK with alignment = 8, size = __ICFEDIT_size_undstack__ { };
|
||||
define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { };
|
||||
|
||||
initialize by copy with packing=none { readwrite };
|
||||
initialize by copy with packing=none { readwrite };
|
||||
do not initialize { readonly section .noinit };
|
||||
|
||||
place in VEC_region { section .vectors };
|
||||
|
||||
+4
-11
@@ -208,6 +208,7 @@ void v_ARM_ClrCPSR_bits(unsigned int mask)
|
||||
asm("AND R0, R0, R1"); // Calculate new CPSR value
|
||||
asm("MSR CPSR_c,R0"); // Set new value
|
||||
asm("bx lr");
|
||||
( void ) mask;
|
||||
}
|
||||
|
||||
void Dummy_Handler( void );
|
||||
@@ -285,23 +286,15 @@ void Spurious_Handler( void );
|
||||
/**
|
||||
* \brief Dummy default handler.
|
||||
*/
|
||||
volatile uint32_t ulx = 0;
|
||||
void Dummy_Handler( void )
|
||||
{
|
||||
while ( ulx == 0 )
|
||||
{
|
||||
__asm volatile( "NOP" );
|
||||
}
|
||||
ulx = 0;
|
||||
while ( 1 ) ;
|
||||
}
|
||||
|
||||
volatile uint32_t ulSpuriousCount = 0;
|
||||
void Spurious_Handler( void )
|
||||
{
|
||||
while ( ulx == 0 )
|
||||
{
|
||||
__asm volatile( "NOP" );
|
||||
}
|
||||
ulx = 0;
|
||||
ulSpuriousCount++;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+32
-31
@@ -27,12 +27,12 @@
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/** \addtogroup ddrd_module
|
||||
/** \addtogroup ddrd_module
|
||||
*
|
||||
* The DDR/SDR SDRAM Controller (DDRSDRC) is a multiport memory controller. It comprises
|
||||
* four slave AHB interfaces. All simultaneous accesses (four independent AHB ports) are interleaved
|
||||
* to maximize memory bandwidth and minimize transaction latency due to SDRAM protocol.
|
||||
*
|
||||
*
|
||||
* \section ddr2 Configures DDR2
|
||||
*
|
||||
* The DDR2-SDRAM devices are initialized by the following sequence:
|
||||
@@ -77,8 +77,8 @@
|
||||
* <li> Step 1. Program the memory device type into the Memory Device Register</li>
|
||||
* <li> Step 2. Program the features of the SDR-SDRAM device into the Timing Register and into the Configuration Register.</li>
|
||||
* <li> Step 3. For low-power SDRAM, temperature-compensated self refresh (TCSR), drive strength (DS) and partial array self refresh (PASR) must be set in the Low-power Register.</li>
|
||||
* <li> Step 4. A NOP command is issued to the SDR-SDRAM. Program NOP command into Mode Register, the application must
|
||||
* set Mode to 1 in the Mode Register. Perform a write access to any SDR-SDRAM address to acknowledge this command.
|
||||
* <li> Step 4. A NOP command is issued to the SDR-SDRAM. Program NOP command into Mode Register, the application must
|
||||
* set Mode to 1 in the Mode Register. Perform a write access to any SDR-SDRAM address to acknowledge this command.
|
||||
* Now the clock which drives SDR-SDRAM device is enabled.</li>
|
||||
* <li> Step 5. An all banks precharge command is issued to the SDR-SDRAM. Program all banks precharge command into Mode Register, the application must set Mode to 2 in the
|
||||
* Mode Register . Perform a write access to any SDRSDRAM address to acknowledge this command.</li>
|
||||
@@ -95,8 +95,8 @@
|
||||
/*@{*/
|
||||
/*@}*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* \file
|
||||
*
|
||||
@@ -104,7 +104,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Headers
|
||||
*----------------------------------------------------------------------------*/
|
||||
@@ -139,8 +139,9 @@ void BOARD_RemapRam( void )
|
||||
*/
|
||||
void BOARD_ConfigureVddMemSel( uint8_t VddMemSel )
|
||||
{
|
||||
( void ) VddMemSel;
|
||||
}
|
||||
|
||||
|
||||
#define DDR2_BA0(r) (1 << (26 + r))
|
||||
#define DDR2_BA1(r) (1 << (27 + r))
|
||||
|
||||
@@ -149,17 +150,17 @@ void BOARD_ConfigureVddMemSel( uint8_t VddMemSel )
|
||||
static void matrix_configure_slave_ddr(void)
|
||||
{
|
||||
int ddr_port;
|
||||
|
||||
|
||||
/* Disable write protection */
|
||||
MATRIX0->MATRIX_WPMR = MPDDRC_WPMR_WPKEY_PASSWD;
|
||||
|
||||
|
||||
/* Partition internal SRAM */
|
||||
MATRIX0->MATRIX_SSR[11] = 0;
|
||||
MATRIX0->MATRIX_SRTSR[11] = 0x05;
|
||||
MATRIX0->MATRIX_SASSR[11] = 0x04;
|
||||
|
||||
|
||||
ddr_port = 1;
|
||||
|
||||
|
||||
/* Partition external DDR */
|
||||
/* DDR port 0 not used from NWd */
|
||||
for (ddr_port = 1 ; ddr_port < 8 ; ddr_port++) {
|
||||
@@ -198,7 +199,7 @@ static void matrix_configure_slave_nand(void)
|
||||
Refresh count: 8K
|
||||
Row address: A[12:0] (8K)
|
||||
Column address A[9:0] (1K)
|
||||
Bank address BA[2:0] a(24,25) (8)
|
||||
Bank address BA[2:0] a(24,25) (8)
|
||||
*/
|
||||
void BOARD_ConfigureDdram( void )
|
||||
{
|
||||
@@ -206,13 +207,13 @@ void BOARD_ConfigureDdram( void )
|
||||
volatile uint32_t i;
|
||||
|
||||
volatile uint32_t dummy_value;
|
||||
|
||||
|
||||
matrix_configure_slave_ddr();
|
||||
|
||||
/* Enable DDR2 clock x2 in PMC */
|
||||
PMC->PMC_PCER0 = (1 << (ID_MPDDRC));
|
||||
PMC->PMC_SCER |= PMC_SCER_DDRCK;
|
||||
|
||||
|
||||
/* MPDDRC I/O Calibration Register */
|
||||
dummy_value = MPDDRC->MPDDRC_IO_CALIBR;
|
||||
dummy_value &= ~MPDDRC_IO_CALIBR_RDIV_Msk;
|
||||
@@ -227,7 +228,7 @@ void BOARD_ConfigureDdram( void )
|
||||
/* Step 1: Program the memory device type */
|
||||
/* DBW = 0 (32 bits bus wide); Memory Device = 6 = DDR2-SDRAM = 0x00000006*/
|
||||
|
||||
MPDDRC->MPDDRC_MD = MPDDRC_MD_MD_DDR2_SDRAM | MPDDRC_MD_DBW_DBW_32_BITS;
|
||||
MPDDRC->MPDDRC_MD = MPDDRC_MD_MD_DDR2_SDRAM | MPDDRC_MD_DBW_DBW_32_BITS;
|
||||
|
||||
MPDDRC->MPDDRC_RD_DATA_PATH = MPDDRC_RD_DATA_PATH_SHIFT_SAMPLING_SHIFT_ONE_CYCLE;
|
||||
|
||||
@@ -241,8 +242,8 @@ void BOARD_ConfigureDdram( void )
|
||||
MPDDRC_CR_NB_8_BANKS |
|
||||
MPDDRC_CR_NDQS_DISABLED |
|
||||
MPDDRC_CR_UNAL_SUPPORTED |
|
||||
MPDDRC_CR_OCD_DDR2_EXITCALIB;
|
||||
|
||||
MPDDRC_CR_OCD_DDR2_EXITCALIB;
|
||||
|
||||
MPDDRC->MPDDRC_TPR0 = MPDDRC_TPR0_TRAS(8) // 40 ns
|
||||
| MPDDRC_TPR0_TRCD(3) // 12.5 ns
|
||||
| MPDDRC_TPR0_TWR(3) // 15 ns
|
||||
@@ -251,14 +252,14 @@ void BOARD_ConfigureDdram( void )
|
||||
| MPDDRC_TPR0_TRRD(2) // 8 ns
|
||||
| MPDDRC_TPR0_TWTR(2) // 2 clock cycle
|
||||
| MPDDRC_TPR0_TMRD(2); // 2 clock cycles
|
||||
|
||||
|
||||
|
||||
MPDDRC->MPDDRC_TPR1 = MPDDRC_TPR1_TRFC(23)
|
||||
| MPDDRC_TPR1_TXSNR(25)
|
||||
| MPDDRC_TPR1_TXSRD(200)
|
||||
| MPDDRC_TPR1_TXP(2);
|
||||
|
||||
MPDDRC->MPDDRC_TPR2 = MPDDRC_TPR2_TXARD(8)
|
||||
MPDDRC->MPDDRC_TPR2 = MPDDRC_TPR2_TXARD(8)
|
||||
| MPDDRC_TPR2_TXARDS(2)
|
||||
| MPDDRC_TPR2_TRPA(3)
|
||||
| MPDDRC_TPR2_TRTP(2)
|
||||
@@ -267,19 +268,19 @@ void BOARD_ConfigureDdram( void )
|
||||
/* DDRSDRC Low-power Register */
|
||||
for (i = 0; i < 13300; i++) {
|
||||
asm("nop");
|
||||
}
|
||||
}
|
||||
|
||||
/* Step 3: An NOP command is issued to the DDR2-SDRAM. Program the NOP command into
|
||||
the Mode Register, the application must set MODE to 1 in the Mode Register. */
|
||||
MPDDRC->MPDDRC_MR = MPDDRC_MR_MODE_NOP_CMD;
|
||||
/* Perform a write access to any DDR2-SDRAM address to acknowledge this command */
|
||||
*pDdr = 0; /* Now clocks which drive DDR2-SDRAM device are enabled.*/
|
||||
|
||||
|
||||
/* A minimum pause of 200 ¦Ìs is provided to precede any signal toggle. (6 core cycles per iteration, core is at 396MHz: min 13200 loops) */
|
||||
for (i = 0; i < 13300; i++) {
|
||||
asm("nop");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* Step 4: An NOP command is issued to the DDR2-SDRAM */
|
||||
MPDDRC->MPDDRC_MR = MPDDRC_MR_MODE_NOP_CMD;
|
||||
/* Perform a write access to any DDR2-SDRAM address to acknowledge this command.*/
|
||||
@@ -288,7 +289,7 @@ void BOARD_ConfigureDdram( void )
|
||||
for (i = 0; i < 100; i++) {
|
||||
asm("nop");
|
||||
}
|
||||
|
||||
|
||||
/* Step 5: An all banks precharge command is issued to the DDR2-SDRAM. */
|
||||
MPDDRC->MPDDRC_MR = MPDDRC_MR_MODE_PRCGALL_CMD;
|
||||
/* Perform a write access to any DDR2-SDRAM address to acknowledge this command.*/
|
||||
@@ -332,7 +333,7 @@ void BOARD_ConfigureDdram( void )
|
||||
for (i = 0; i < 100; i++) {
|
||||
asm("nop");
|
||||
}
|
||||
|
||||
|
||||
/* Step 11: An all banks precharge command is issued to the DDR2-SDRAM. */
|
||||
MPDDRC->MPDDRC_MR = MPDDRC_MR_MODE_PRCGALL_CMD;
|
||||
*(pDdr) = 0; /* Perform a write access to any DDR2-SDRAM address to acknowledge this command */
|
||||
@@ -357,7 +358,7 @@ void BOARD_ConfigureDdram( void )
|
||||
}
|
||||
|
||||
/* Step 13: Program DLL field into the Configuration Register to low(Disable DLL reset). */
|
||||
MPDDRC->MPDDRC_CR &= ~MPDDRC_CR_DLL_RESET_ENABLED;
|
||||
MPDDRC->MPDDRC_CR &= ~MPDDRC_CR_DLL_RESET_ENABLED;
|
||||
|
||||
/* Step 14: A Mode Register set (MRS) cycle is issued to program the parameters of the DDR2-SDRAM devices. */
|
||||
MPDDRC->MPDDRC_MR = MPDDRC_MR_MODE_LMR_CMD;
|
||||
@@ -393,10 +394,10 @@ void BOARD_ConfigureDdram( void )
|
||||
MPDDRC->MPDDRC_MR = MPDDRC_MR_MODE_NORMAL_CMD;
|
||||
*(pDdr) = 0;
|
||||
|
||||
/* Step 21: Write the refresh rate into the count field in the Refresh Timer register. The DDR2-SDRAM device requires a refresh every 15.625 ¦Ìs or 7.81 ¦Ìs.
|
||||
/* Step 21: Write the refresh rate into the count field in the Refresh Timer register. The DDR2-SDRAM device requires a refresh every 15.625 ¦Ìs or 7.81 ¦Ìs.
|
||||
With a 100MHz frequency, the refresh timer count register must to be set with (15.625 /100 MHz) = 1562 i.e. 0x061A or (7.81 /100MHz) = 781 i.e. 0x030d. */
|
||||
/* For MT47H64M16HR, The refresh period is 64ms (commercial), This equates to an average
|
||||
refresh rate of 7.8125¦Ìs (commercial), To ensure all rows of all banks are properly
|
||||
refresh rate of 7.8125¦Ìs (commercial), To ensure all rows of all banks are properly
|
||||
refreshed, 8192 REFRESH commands must be issued every 64ms (commercial) */
|
||||
/* ((64 x 10(^-3))/8192) x133 x (10^6) */
|
||||
MPDDRC->MPDDRC_RTR = MPDDRC_RTR_COUNT(0x2b0); /* Set Refresh timer 7.8125 us*/
|
||||
@@ -447,7 +448,7 @@ void BOARD_ConfigureNandFlash( uint8_t busWidth )
|
||||
HSMC->HSMC_CS_NUMBER[3].HSMC_MODE = HSMC_MODE_READ_MODE |
|
||||
HSMC_MODE_WRITE_MODE |
|
||||
((busWidth == 8 )? HSMC_MODE_DBW_BIT_8 :HSMC_MODE_DBW_BIT_16) |
|
||||
HSMC_MODE_TDF_CYCLES(1);
|
||||
HSMC_MODE_TDF_CYCLES(1);
|
||||
}
|
||||
|
||||
|
||||
@@ -455,7 +456,7 @@ void BOARD_ConfigureNorFlash( uint8_t busWidth )
|
||||
{
|
||||
uint32_t dbw;
|
||||
PMC_EnablePeripheral(ID_HSMC);
|
||||
if (busWidth == 8)
|
||||
if (busWidth == 8)
|
||||
{
|
||||
dbw = HSMC_MODE_DBW_BIT_8;
|
||||
}
|
||||
|
||||
+307
-185
File diff suppressed because it is too large
Load Diff
@@ -77,7 +77,7 @@
|
||||
*/
|
||||
|
||||
/** Softpack Version */
|
||||
#define SOFTPACK_VERSION "1.0"
|
||||
#define SOFTPACK_VERSION "1.1"
|
||||
|
||||
#define TRACE_LEVEL_DEBUG 5
|
||||
#define TRACE_LEVEL_INFO 4
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* SAM Software Package License
|
||||
* SAM Software Package License
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2013, Atmel Corporation
|
||||
*
|
||||
@@ -151,6 +151,8 @@ extern void PIO_InitializeInterrupts( uint32_t dwPriority )
|
||||
{
|
||||
TRACE_DEBUG( "PIO_Initialize()\n\r" ) ;
|
||||
|
||||
( void ) dwPriority;
|
||||
|
||||
/* Reset sources */
|
||||
_dwNumSources = 0 ;
|
||||
|
||||
@@ -234,7 +236,7 @@ extern void PIO_ConfigureIt( const Pin *pPin )
|
||||
}
|
||||
|
||||
/* if bit field of selected pin is 1, set as edge detection source */
|
||||
if (pPin->attribute & PIO_IT_EDGE)
|
||||
if (pPin->attribute & PIO_IT_EDGE)
|
||||
pio->PIO_ESR = pPin->mask;
|
||||
else
|
||||
pio->PIO_LSR = pPin->mask;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,71 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2008, Atmel Corporation
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the disclaimer below.
|
||||
*
|
||||
* Atmel's name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/** \file
|
||||
Implementation of the CDCLineCoding class.
|
||||
*/
|
||||
/** \addtogroup usb_cdc
|
||||
*@{
|
||||
*/
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Headers
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
#include <CDCRequests.h>
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Exported functions
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* Initializes the bitrate, number of stop bits, parity checking and
|
||||
* number of data bits of a CDCLineCoding object.
|
||||
* \param lineCoding Pointer to a CDCLineCoding instance.
|
||||
* \param bitrate Bitrate of the virtual COM connection.
|
||||
* \param stopbits Number of stop bits
|
||||
* (\ref usb_cdc_stop CDC LineCoding StopBits).
|
||||
* \param parity Parity check type
|
||||
* (\ref usb_cdc_parity CDC LineCoding ParityChecking).
|
||||
* \param databits Number of data bits.
|
||||
*/
|
||||
void CDCLineCoding_Initialize(CDCLineCoding *lineCoding,
|
||||
uint32_t bitrate,
|
||||
uint8_t stopbits,
|
||||
uint8_t parity,
|
||||
uint8_t databits)
|
||||
{
|
||||
lineCoding->dwDTERate = bitrate;
|
||||
lineCoding->bCharFormat = stopbits;
|
||||
lineCoding->bParityType = parity;
|
||||
lineCoding->bDataBits = databits;
|
||||
}
|
||||
|
||||
/**@}*/
|
||||
|
||||
+87
@@ -0,0 +1,87 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2008, Atmel Corporation
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the disclaimer below.
|
||||
*
|
||||
* Atmel's name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/** \file
|
||||
*
|
||||
* Implementation of the CDCSetControlLineStateRequest class.
|
||||
*/
|
||||
|
||||
/** \addtogroup usb_cdc
|
||||
*@{
|
||||
*/
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Headers
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
#include <CDCRequests.h>
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Exported functions
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* Notifies if the given request indicates that the DTE signal is present.
|
||||
* \param request Pointer to a USBGenericRequest instance.
|
||||
* \return 1 if the DTE signal is present, otherwise 0.
|
||||
*/
|
||||
uint8_t CDCSetControlLineStateRequest_IsDtePresent(
|
||||
const USBGenericRequest *request)
|
||||
{
|
||||
if ((USBGenericRequest_GetValue(request) & 0x0001) != 0) {
|
||||
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Notifies if the given request indicates that the device carrier should
|
||||
* be activated.
|
||||
* \param request Pointer to a USBGenericRequest instance.
|
||||
* \return 1 is the device should activate its carrier, 0 otherwise.
|
||||
*/
|
||||
uint8_t CDCSetControlLineStateRequest_ActivateCarrier(
|
||||
const USBGenericRequest *request)
|
||||
{
|
||||
if ((USBGenericRequest_GetValue(request) & 0x0002) != 0) {
|
||||
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**@}*/
|
||||
|
||||
@@ -0,0 +1,319 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2010, Atmel Corporation
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the disclaimer below.
|
||||
*
|
||||
* Atmel's name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/** \file
|
||||
*
|
||||
* Implements for USB descriptor methods described by the USB specification.
|
||||
*/
|
||||
|
||||
/** \addtogroup usb_descriptor
|
||||
*@{
|
||||
*/
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Headers
|
||||
*------------------------------------------------------------------------------*/
|
||||
|
||||
#include "USBDescriptors.h"
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Exported functions
|
||||
*------------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* Returns the length of a descriptor.
|
||||
* \param descriptor Pointer to a USBGenericDescriptor instance.
|
||||
* \return Length of descriptor in bytes.
|
||||
*/
|
||||
uint32_t USBGenericDescriptor_GetLength(
|
||||
const USBGenericDescriptor *descriptor)
|
||||
{
|
||||
return descriptor->bLength;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the type of a descriptor.
|
||||
* \param descriptor Pointer to a USBGenericDescriptor instance.
|
||||
* \return Type of descriptor.
|
||||
*/
|
||||
uint8_t USBGenericDescriptor_GetType(
|
||||
const USBGenericDescriptor *descriptor)
|
||||
{
|
||||
return descriptor->bDescriptorType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a pointer to the descriptor right after the given one, when
|
||||
* parsing a Configuration descriptor.
|
||||
* \param descriptor - Pointer to a USBGenericDescriptor instance.
|
||||
* \return Pointer to the next descriptor.
|
||||
*/
|
||||
USBGenericDescriptor *USBGenericDescriptor_GetNextDescriptor(
|
||||
const USBGenericDescriptor *descriptor)
|
||||
{
|
||||
return (USBGenericDescriptor *)
|
||||
(((char *) descriptor) + USBGenericDescriptor_GetLength(descriptor));
|
||||
}
|
||||
|
||||
/** Parses the given descriptor list via costomized function.
|
||||
* \param descriptor Pointer to the start of the whole descriptors list.
|
||||
* \param totalLength Total size of descriptors in bytes.
|
||||
* \param parseFunction Function to parse each descriptor scanned.
|
||||
* Return 0 to continue parsing.
|
||||
* \param parseArg Argument passed to parse function.
|
||||
* \return Pointer to USBGenericDescriptor instance for next descriptor.
|
||||
*/
|
||||
USBGenericDescriptor *USBGenericDescriptor_Parse(
|
||||
const USBGenericDescriptor *descriptor,
|
||||
uint32_t totalLength,
|
||||
USBDescriptorParseFunction parseFunction,
|
||||
void *parseArg)
|
||||
{
|
||||
int32_t size = totalLength;
|
||||
|
||||
if (size == 0)
|
||||
return 0;
|
||||
|
||||
/* Start parsing descriptors */
|
||||
while (1) {
|
||||
|
||||
uint32_t parseRC = 0;
|
||||
|
||||
/* Parse current descriptor */
|
||||
if (parseFunction) {
|
||||
|
||||
parseRC = parseFunction((void*)descriptor, parseArg);
|
||||
}
|
||||
|
||||
/* Get next descriptor */
|
||||
size -= USBGenericDescriptor_GetLength(descriptor);
|
||||
descriptor = USBGenericDescriptor_GetNextDescriptor(descriptor);
|
||||
|
||||
if (size) {
|
||||
if (parseRC != 0) {
|
||||
|
||||
return (USBGenericDescriptor *)descriptor;
|
||||
}
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
/* No descriptors remaining */
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the number of an endpoint given its descriptor.
|
||||
* \param endpoint Pointer to a USBEndpointDescriptor instance.
|
||||
* \return Endpoint number.
|
||||
*/
|
||||
uint8_t USBEndpointDescriptor_GetNumber(
|
||||
const USBEndpointDescriptor *endpoint)
|
||||
{
|
||||
return endpoint->bEndpointAddress & 0xF;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the direction of an endpoint given its descriptor.
|
||||
* \param endpoint Pointer to a USBEndpointDescriptor instance.
|
||||
* \return Endpoint direction (see \ref usb_ep_dir).
|
||||
*/
|
||||
uint8_t USBEndpointDescriptor_GetDirection(
|
||||
const USBEndpointDescriptor *endpoint)
|
||||
{
|
||||
if ((endpoint->bEndpointAddress & 0x80) != 0) {
|
||||
|
||||
return USBEndpointDescriptor_IN;
|
||||
}
|
||||
else {
|
||||
|
||||
return USBEndpointDescriptor_OUT;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the type of an endpoint given its descriptor.
|
||||
* \param endpoint Pointer to a USBEndpointDescriptor instance.
|
||||
* \return Endpoint type (see \ref usb_ep_type).
|
||||
*/
|
||||
uint8_t USBEndpointDescriptor_GetType(
|
||||
const USBEndpointDescriptor *endpoint)
|
||||
{
|
||||
return endpoint->bmAttributes & 0x3;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the maximum size of a packet (in bytes) on an endpoint given
|
||||
* its descriptor.
|
||||
* \param endpoint - Pointer to a USBEndpointDescriptor instance.
|
||||
* \return Maximum packet size of endpoint.
|
||||
*/
|
||||
uint16_t USBEndpointDescriptor_GetMaxPacketSize(
|
||||
const USBEndpointDescriptor *endpoint)
|
||||
{
|
||||
uint16_t usTemp;
|
||||
uint8_t *pc1, *pc2;
|
||||
|
||||
/* Note this is an unaligned access hence it is performed as two byte
|
||||
accesses. */
|
||||
pc1 = ( uint8_t * ) &( endpoint->wMaxPacketSize );
|
||||
pc2 = pc1 + 1;
|
||||
usTemp = ( ( *pc2 ) << 8 ) | *pc1;
|
||||
|
||||
return usTemp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the polling interval on an endpoint given its descriptor.
|
||||
* \param endpoint - Pointer to a USBEndpointDescriptor instance.
|
||||
* \return Polling interval of endpoint.
|
||||
*/
|
||||
uint8_t USBEndpointDescriptor_GetInterval(
|
||||
const USBEndpointDescriptor *endpoint)
|
||||
{
|
||||
return endpoint->bInterval;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/** Returns the total length of a configuration, i.e. including the
|
||||
* descriptors following it.
|
||||
* \param configuration Pointer to a USBConfigurationDescriptor instance.
|
||||
* \return Total length (in bytes) of the configuration.
|
||||
*/
|
||||
uint32_t USBConfigurationDescriptor_GetTotalLength(
|
||||
const USBConfigurationDescriptor *configuration)
|
||||
{
|
||||
return configuration->wTotalLength;
|
||||
}
|
||||
|
||||
/** Returns the number of interfaces in a configuration.
|
||||
* \param configuration Pointer to a USBConfigurationDescriptor instance.
|
||||
* \return Number of interfaces in configuration.
|
||||
*/
|
||||
unsigned char USBConfigurationDescriptor_GetNumInterfaces(
|
||||
const USBConfigurationDescriptor *configuration)
|
||||
{
|
||||
return configuration->bNumInterfaces;
|
||||
}
|
||||
|
||||
/** Indicates if the device is self-powered when in a given configuration.
|
||||
* \param configuration Pointer to a USBConfigurationDescriptor instance.
|
||||
* \return 1 if the device is self-powered when in the given configuration;
|
||||
* otherwise 0.
|
||||
*/
|
||||
unsigned char USBConfigurationDescriptor_IsSelfPowered(
|
||||
const USBConfigurationDescriptor *configuration)
|
||||
{
|
||||
if ((configuration->bmAttributes & (1 << 6)) != 0) {
|
||||
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/** Parses the given Configuration descriptor (followed by relevant
|
||||
* interface, endpoint and class-specific descriptors) into three arrays.
|
||||
* *Each array must have its size equal or greater to the number of
|
||||
* descriptors it stores plus one*. A null-value is inserted after the last
|
||||
* descriptor of each type to indicate the array end.
|
||||
*
|
||||
* Note that if the pointer to an array is null (0), nothing is stored in
|
||||
* it.
|
||||
* \param configuration Pointer to the start of the whole Configuration
|
||||
* descriptor.
|
||||
* \param interfaces Pointer to the Interface descriptor array.
|
||||
* \param endpoints Pointer to the Endpoint descriptor array.
|
||||
* \param others Pointer to the class-specific descriptor array.
|
||||
*/
|
||||
void USBConfigurationDescriptor_Parse(
|
||||
const USBConfigurationDescriptor *configuration,
|
||||
USBInterfaceDescriptor **interfaces,
|
||||
USBEndpointDescriptor **endpoints,
|
||||
USBGenericDescriptor **others)
|
||||
{
|
||||
/* Get size of configuration to parse */
|
||||
int size = USBConfigurationDescriptor_GetTotalLength(configuration);
|
||||
size -= sizeof(USBConfigurationDescriptor);
|
||||
|
||||
/* Start parsing descriptors */
|
||||
USBGenericDescriptor *descriptor = (USBGenericDescriptor *) configuration;
|
||||
while (size > 0) {
|
||||
|
||||
/* Get next descriptor */
|
||||
descriptor = USBGenericDescriptor_GetNextDescriptor(descriptor);
|
||||
size -= USBGenericDescriptor_GetLength(descriptor);
|
||||
|
||||
/* Store descriptor in correponding array */
|
||||
if (USBGenericDescriptor_GetType(descriptor)
|
||||
== USBGenericDescriptor_INTERFACE) {
|
||||
|
||||
if (interfaces) {
|
||||
|
||||
*interfaces = (USBInterfaceDescriptor *) descriptor;
|
||||
interfaces++;
|
||||
}
|
||||
}
|
||||
else if (USBGenericDescriptor_GetType(descriptor)
|
||||
== USBGenericDescriptor_ENDPOINT) {
|
||||
|
||||
if (endpoints) {
|
||||
|
||||
*endpoints = (USBEndpointDescriptor *) descriptor;
|
||||
endpoints++;
|
||||
}
|
||||
}
|
||||
else if (others) {
|
||||
|
||||
*others = descriptor;
|
||||
others++;
|
||||
}
|
||||
}
|
||||
|
||||
/* Null-terminate arrays */
|
||||
if (interfaces) {
|
||||
|
||||
*interfaces = 0;
|
||||
}
|
||||
if (endpoints) {
|
||||
|
||||
*endpoints = 0;
|
||||
}
|
||||
if (others) {
|
||||
|
||||
*others = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**@}*/
|
||||
|
||||
@@ -0,0 +1,244 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2010, Atmel Corporation
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the disclaimer below.
|
||||
*
|
||||
* Atmel's name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* \section Purpose
|
||||
*
|
||||
* Implements for USB requests described by the USB specification.
|
||||
*/
|
||||
|
||||
/** \addtogroup usb_request
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Headers
|
||||
*------------------------------------------------------------------------------*/
|
||||
|
||||
#include <USBRequests.h>
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Exported functions
|
||||
*------------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* Returns the type of the given request.
|
||||
* \param request Pointer to a USBGenericRequest instance.
|
||||
* \return "USB Request Types"
|
||||
*/
|
||||
extern uint8_t USBGenericRequest_GetType(const USBGenericRequest *request)
|
||||
{
|
||||
return ((request->bmRequestType >> 5) & 0x3);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the request code of the given request.
|
||||
* \param request Pointer to a USBGenericRequest instance.
|
||||
* \return Request code.
|
||||
* \sa "USB Request Codes"
|
||||
*/
|
||||
uint8_t USBGenericRequest_GetRequest(const USBGenericRequest *request)
|
||||
{
|
||||
return request->bRequest;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the wValue field of the given request.
|
||||
* \param request - Pointer to a USBGenericRequest instance.
|
||||
* \return Request value.
|
||||
*/
|
||||
uint16_t USBGenericRequest_GetValue(const USBGenericRequest *request)
|
||||
{
|
||||
return request->wValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the wIndex field of the given request.
|
||||
* \param request Pointer to a USBGenericRequest instance.
|
||||
* \return Request index;
|
||||
*/
|
||||
uint16_t USBGenericRequest_GetIndex(const USBGenericRequest *request)
|
||||
{
|
||||
return request->wIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the expected length of the data phase following a request.
|
||||
* \param request Pointer to a USBGenericRequest instance.
|
||||
* \return Length of data phase.
|
||||
*/
|
||||
uint16_t USBGenericRequest_GetLength(const USBGenericRequest *request)
|
||||
{
|
||||
return request->wLength;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the endpoint number targetted by a given request.
|
||||
* \param request Pointer to a USBGenericRequest instance.
|
||||
* \return Endpoint number.
|
||||
*/
|
||||
uint8_t USBGenericRequest_GetEndpointNumber(
|
||||
const USBGenericRequest *request)
|
||||
{
|
||||
return USBGenericRequest_GetIndex(request) & 0xF;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the intended recipient of a given request.
|
||||
* \param request Pointer to a USBGenericRequest instance.
|
||||
* \return Request recipient.
|
||||
* \sa "USB Request Recipients"
|
||||
*/
|
||||
uint8_t USBGenericRequest_GetRecipient(const USBGenericRequest *request)
|
||||
{
|
||||
/* Recipient is in bits [0..4] of the bmRequestType field */
|
||||
return request->bmRequestType & 0xF;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the direction of the data transfer following the given request.
|
||||
* \param request Pointer to a USBGenericRequest instance.
|
||||
* \return Transfer direction.
|
||||
* \sa "USB Request Directions"
|
||||
*/
|
||||
uint8_t USBGenericRequest_GetDirection(const USBGenericRequest *request)
|
||||
{
|
||||
/* Transfer direction is located in bit D7 of the bmRequestType field */
|
||||
if ((request->bmRequestType & 0x80) != 0) {
|
||||
|
||||
return USBGenericRequest_IN;
|
||||
}
|
||||
else {
|
||||
|
||||
return USBGenericRequest_OUT;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the type of the descriptor requested by the host given the
|
||||
* corresponding GET_DESCRIPTOR request.
|
||||
* \param request Pointer to a USBGenericDescriptor instance.
|
||||
* \return Type of the requested descriptor.
|
||||
*/
|
||||
uint8_t USBGetDescriptorRequest_GetDescriptorType(
|
||||
const USBGenericRequest *request)
|
||||
{
|
||||
/* Requested descriptor type is in the high-byte of the wValue field */
|
||||
return (USBGenericRequest_GetValue(request) >> 8) & 0xFF;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the index of the requested descriptor, given the corresponding
|
||||
* GET_DESCRIPTOR request.
|
||||
* \param request Pointer to a USBGenericDescriptor instance.
|
||||
* \return Index of the requested descriptor.
|
||||
*/
|
||||
uint8_t USBGetDescriptorRequest_GetDescriptorIndex(
|
||||
const USBGenericRequest *request)
|
||||
{
|
||||
/* Requested descriptor index if in the low byte of the wValue field */
|
||||
return USBGenericRequest_GetValue(request) & 0xFF;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the address that the device must take in response to a
|
||||
* SET_ADDRESS request.
|
||||
* \param request Pointer to a USBGenericRequest instance.
|
||||
* \return New device address.
|
||||
*/
|
||||
uint8_t USBSetAddressRequest_GetAddress(const USBGenericRequest *request)
|
||||
{
|
||||
return USBGenericRequest_GetValue(request) & 0x7F;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the number of the configuration that should be set in response
|
||||
* to the given SET_CONFIGURATION request.
|
||||
* \param request Pointer to a USBGenericRequest instance.
|
||||
* \return Number of the requested configuration.
|
||||
*/
|
||||
uint8_t USBSetConfigurationRequest_GetConfiguration(
|
||||
const USBGenericRequest *request)
|
||||
{
|
||||
return USBGenericRequest_GetValue(request);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Indicates which interface is targetted by a GET_INTERFACE or
|
||||
* SET_INTERFACE request.
|
||||
* \param request Pointer to a USBGenericRequest instance.
|
||||
* \return Interface number.
|
||||
*/
|
||||
uint8_t USBInterfaceRequest_GetInterface(const USBGenericRequest *request)
|
||||
{
|
||||
return (USBGenericRequest_GetIndex(request) & 0xFF);
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates the new alternate setting that the interface targetted by a
|
||||
* SET_INTERFACE request should use.
|
||||
* \param request Pointer to a USBGenericRequest instance.
|
||||
* \return New active setting for the interface.
|
||||
*/
|
||||
uint8_t USBInterfaceRequest_GetAlternateSetting(
|
||||
const USBGenericRequest *request)
|
||||
{
|
||||
return (USBGenericRequest_GetValue(request) & 0xFF);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the feature selector of a given CLEAR_FEATURE or SET_FEATURE
|
||||
* request.
|
||||
* \param request Pointer to a USBGenericRequest instance.
|
||||
* \return Feature selector.
|
||||
*/
|
||||
uint8_t USBFeatureRequest_GetFeatureSelector(
|
||||
const USBGenericRequest *request)
|
||||
{
|
||||
return USBGenericRequest_GetValue(request);
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates the test that the device must undertake following a
|
||||
* SET_FEATURE request.
|
||||
* \param request Pointer to a USBGenericRequest instance.
|
||||
* \return Test selector.
|
||||
*/
|
||||
uint8_t USBFeatureRequest_GetTestSelector(
|
||||
const USBGenericRequest *request)
|
||||
{
|
||||
return (USBGenericRequest_GetIndex(request) >> 8) & 0xFF;
|
||||
}
|
||||
|
||||
/**@}*/
|
||||
BIN
Binary file not shown.
|
After Width: | Height: | Size: 11 KiB |
BIN
Binary file not shown.
|
After Width: | Height: | Size: 8.6 KiB |
+228
@@ -0,0 +1,228 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2008, Atmel Corporation
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the disclaimer below.
|
||||
*
|
||||
* Atmel's name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**\file
|
||||
* Implementation of a single CDC serial port function for USB device.
|
||||
*/
|
||||
|
||||
/** \addtogroup usbd_cdc
|
||||
*@{
|
||||
*/
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Headers
|
||||
*------------------------------------------------------------------------------*/
|
||||
|
||||
#include "CDCDSerial.h"
|
||||
|
||||
#include <USBLib_Trace.h>
|
||||
#include <USBDDriver.h>
|
||||
#include <USBD_HAL.h>
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Types
|
||||
*------------------------------------------------------------------------------*/
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Internal variables
|
||||
*------------------------------------------------------------------------------*/
|
||||
|
||||
/** Serial Port instance list */
|
||||
static CDCDSerialPort cdcdSerial;
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Internal functions
|
||||
*------------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* USB CDC Serial Port Event Handler.
|
||||
* \param event Event code.
|
||||
* \param param Event parameter.
|
||||
*/
|
||||
static uint32_t CDCDSerial_EventHandler(uint32_t event,
|
||||
uint32_t param)
|
||||
{
|
||||
switch (event) {
|
||||
case CDCDSerialPortEvent_SETCONTROLLINESTATE:
|
||||
{
|
||||
if (CDCDSerial_ControlLineStateChanged != NULL) {
|
||||
CDCDSerial_ControlLineStateChanged(
|
||||
(param & CDCControlLineState_DTR) > 0,
|
||||
(param & CDCControlLineState_RTS) > 0);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case CDCDSerialPortEvent_SETLINECODING:
|
||||
{
|
||||
if (NULL != CDCDSerial_LineCodingIsToChange) {
|
||||
event = CDCDSerial_LineCodingIsToChange(
|
||||
(CDCLineCoding*)param);
|
||||
if (event != USBRC_SUCCESS)
|
||||
return event;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return USBRC_SUCCESS;
|
||||
}
|
||||
|
||||
return USBRC_SUCCESS;
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Exported functions
|
||||
*------------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* Initializes the USB Device CDC serial driver & USBD Driver.
|
||||
* \param pUsbd Pointer to USBDDriver instance.
|
||||
* \param bInterfaceNb Interface number for the function.
|
||||
*/
|
||||
void CDCDSerial_Initialize(
|
||||
USBDDriver *pUsbd, uint8_t bInterfaceNb)
|
||||
{
|
||||
CDCDSerialPort *pCdcd = &cdcdSerial;
|
||||
|
||||
TRACE_INFO("CDCDSerial_Initialize\n\r");
|
||||
|
||||
/* Initialize serial port function */
|
||||
CDCDSerialPort_Initialize(
|
||||
pCdcd, pUsbd,
|
||||
(CDCDSerialPortEventHandler)CDCDSerial_EventHandler,
|
||||
0,
|
||||
bInterfaceNb, 2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoked whenever the device is changed by the
|
||||
* host.
|
||||
* \pDescriptors Pointer to the descriptors for function configure.
|
||||
* \wLength Length of descriptors in number of bytes.
|
||||
*/
|
||||
void CDCDSerial_ConfigureFunction(USBGenericDescriptor *pDescriptors,
|
||||
uint16_t wLength)
|
||||
{
|
||||
CDCDSerialPort *pCdcd = &cdcdSerial;
|
||||
CDCDSerialPort_ParseInterfaces(pCdcd,
|
||||
(USBGenericDescriptor*)pDescriptors,
|
||||
wLength);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles CDC-specific SETUP requests. Should be called from a
|
||||
* re-implementation of USBDCallbacks_RequestReceived() method.
|
||||
* \param request Pointer to a USBGenericRequest instance.
|
||||
*/
|
||||
uint32_t CDCDSerial_RequestHandler(const USBGenericRequest *request)
|
||||
{
|
||||
CDCDSerialPort * pCdcd = &cdcdSerial;
|
||||
|
||||
TRACE_INFO_WP("Cdcf ");
|
||||
return CDCDSerialPort_RequestHandler(pCdcd, request);
|
||||
}
|
||||
|
||||
/**
|
||||
* Receives data from the host through the virtual COM port created by
|
||||
* the CDC device serial driver. This function behaves like USBD_Read.
|
||||
* \param data Pointer to the data buffer to put received data.
|
||||
* \param size Size of the data buffer in bytes.
|
||||
* \param callback Optional callback function to invoke when the transfer
|
||||
* finishes.
|
||||
* \param argument Optional argument to the callback function.
|
||||
* \return USBD_STATUS_SUCCESS if the read operation has been started normally;
|
||||
* otherwise, the corresponding error code.
|
||||
*/
|
||||
uint32_t CDCDSerial_Read(void *data,
|
||||
uint32_t size,
|
||||
TransferCallback callback,
|
||||
void *argument)
|
||||
{
|
||||
CDCDSerialPort * pCdcd = &cdcdSerial;
|
||||
return CDCDSerialPort_Read(pCdcd, data, size, callback, argument);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a data buffer through the virtual COM port created by the CDC
|
||||
* device serial driver. This function behaves exactly like USBD_Write.
|
||||
* \param data Pointer to the data buffer to send.
|
||||
* \param size Size of the data buffer in bytes.
|
||||
* \param callback Optional callback function to invoke when the transfer
|
||||
* finishes.
|
||||
* \param argument Optional argument to the callback function.
|
||||
* \return USBD_STATUS_SUCCESS if the read operation has been started normally;
|
||||
* otherwise, the corresponding error code.
|
||||
*/
|
||||
uint32_t CDCDSerial_Write(void *data,
|
||||
uint32_t size,
|
||||
TransferCallback callback,
|
||||
void *argument)
|
||||
{
|
||||
CDCDSerialPort * pCdcd = &cdcdSerial;
|
||||
return CDCDSerialPort_Write(pCdcd, data, size, callback, argument);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current control line state of the RS-232 line.
|
||||
*/
|
||||
uint8_t CDCDSerial_GetControlLineState(void)
|
||||
{
|
||||
CDCDSerialPort * pCdcd = &cdcdSerial;
|
||||
return CDCDSerialPort_GetControlLineState(pCdcd);
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy current line coding settings to pointered space.
|
||||
* \param pLineCoding Pointer to CDCLineCoding instance.
|
||||
*/
|
||||
void CDCDSerial_GetLineCoding(CDCLineCoding* pLineCoding)
|
||||
{
|
||||
CDCDSerialPort * pCdcd = &cdcdSerial;
|
||||
CDCDSerialPort_GetLineCoding(pCdcd, pLineCoding);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current status of the RS-232 line.
|
||||
*/
|
||||
uint16_t CDCDSerial_GetSerialState(void)
|
||||
{
|
||||
CDCDSerialPort * pCdcd = &cdcdSerial;
|
||||
return CDCDSerialPort_GetSerialState(pCdcd);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the current serial state of the device to the given value.
|
||||
* \param serialState New device state.
|
||||
*/
|
||||
void CDCDSerial_SetSerialState(uint16_t serialState)
|
||||
{
|
||||
CDCDSerialPort * pCdcd = &cdcdSerial;
|
||||
CDCDSerialPort_SetSerialState(pCdcd, serialState);
|
||||
}
|
||||
|
||||
/**@}*/
|
||||
+116
@@ -0,0 +1,116 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2008, Atmel Corporation
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the disclaimer below.
|
||||
*
|
||||
* Atmel's name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**\file
|
||||
* Title: CDCDSerialDriver implementation
|
||||
*
|
||||
* About: Purpose
|
||||
* Implementation of the CDCDSerialDriver class methods.
|
||||
*/
|
||||
|
||||
/** \addtogroup usbd_cdc
|
||||
*@{
|
||||
*/
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Headers
|
||||
*------------------------------------------------------------------------------*/
|
||||
|
||||
#include "CDCDSerialDriver.h"
|
||||
|
||||
#include <USBLib_Trace.h>
|
||||
#include <USBDDriver.h>
|
||||
#include <USBD_HAL.h>
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Types
|
||||
*------------------------------------------------------------------------------*/
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Internal variables
|
||||
*------------------------------------------------------------------------------*/
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Internal functions
|
||||
*------------------------------------------------------------------------------*/
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Exported functions
|
||||
*------------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* Initializes the USB Device CDC serial driver & USBD Driver.
|
||||
* \param pDescriptors Pointer to Descriptors list for CDC Serial Device.
|
||||
*/
|
||||
void CDCDSerialDriver_Initialize(const USBDDriverDescriptors *pDescriptors)
|
||||
{
|
||||
USBDDriver *pUsbd = USBD_GetDriver();
|
||||
|
||||
/* Initialize the standard driver */
|
||||
USBDDriver_Initialize(pUsbd,
|
||||
pDescriptors,
|
||||
0); /* Multiple settings for interfaces not supported */
|
||||
|
||||
CDCDSerial_Initialize(pUsbd, CDCDSerialDriver_CC_INTERFACE);
|
||||
|
||||
/* Initialize the USB driver */
|
||||
USBD_Init();
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoked whenever the active configuration of device is changed by the
|
||||
* host.
|
||||
* \param cfgnum Configuration number.
|
||||
*/
|
||||
void CDCDSerialDriver_ConfigurationChangedHandler(uint8_t cfgnum)
|
||||
{
|
||||
USBDDriver *pUsbd = USBD_GetDriver();
|
||||
USBConfigurationDescriptor *pDesc;
|
||||
if (cfgnum) {
|
||||
pDesc = USBDDriver_GetCfgDescriptors(pUsbd, cfgnum);
|
||||
CDCDSerial_ConfigureFunction((USBGenericDescriptor *)pDesc,
|
||||
pDesc->wTotalLength);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles CDC-specific SETUP requests. Should be called from a
|
||||
* re-implementation of USBDCallbacks_RequestReceived() method.
|
||||
* \param request Pointer to a USBGenericRequest instance.
|
||||
*/
|
||||
void CDCDSerialDriver_RequestHandler(const USBGenericRequest *request)
|
||||
{
|
||||
USBDDriver *pUsbd = USBD_GetDriver();
|
||||
TRACE_INFO_WP("NewReq ");
|
||||
if (CDCDSerial_RequestHandler(request))
|
||||
USBDDriver_RequestHandler(pUsbd, request);
|
||||
}
|
||||
|
||||
/**@}*/
|
||||
|
||||
+458
@@ -0,0 +1,458 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2008, Atmel Corporation
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the disclaimer below.
|
||||
*
|
||||
* Atmel's name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**\file
|
||||
* Implementation of the CDCDSerialPort class methods.
|
||||
*/
|
||||
|
||||
/** \addtogroup usbd_cdc
|
||||
*@{
|
||||
*/
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Headers
|
||||
*------------------------------------------------------------------------------*/
|
||||
|
||||
#include <CDCDSerialPort.h>
|
||||
#include <CDCDescriptors.h>
|
||||
#include <USBLib_Trace.h>
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Types
|
||||
*------------------------------------------------------------------------------*/
|
||||
|
||||
/** Parse data extention for descriptor parsing */
|
||||
typedef struct _CDCDParseData {
|
||||
/** Pointer to CDCDSerialPort instance */
|
||||
CDCDSerialPort * pCdcd;
|
||||
/** Pointer to found interface descriptor */
|
||||
USBInterfaceDescriptor * pIfDesc;
|
||||
|
||||
} CDCDParseData;
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Internal variables
|
||||
*------------------------------------------------------------------------------*/
|
||||
|
||||
/** Line coding values */
|
||||
static CDCLineCoding lineCoding;
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Internal functions
|
||||
*------------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* Parse descriptors: Interface, Bulk IN/OUT, Interrupt IN.
|
||||
* \param desc Pointer to descriptor list.
|
||||
* \param arg Argument, pointer to AUDDParseData instance.
|
||||
*/
|
||||
static uint32_t _Interfaces_Parse(USBGenericDescriptor *pDesc,
|
||||
CDCDParseData * pArg)
|
||||
{
|
||||
CDCDSerialPort *pCdcd = pArg->pCdcd;
|
||||
|
||||
/* Not a valid descriptor */
|
||||
if (pDesc->bLength == 0)
|
||||
return USBRC_PARAM_ERR;
|
||||
|
||||
/* Find interface descriptor */
|
||||
if (pDesc->bDescriptorType == USBGenericDescriptor_INTERFACE) {
|
||||
USBInterfaceDescriptor *pIf = (USBInterfaceDescriptor*)pDesc;
|
||||
|
||||
/* Obtain interface from descriptor */
|
||||
if (pCdcd->bInterfaceNdx == 0xFF) {
|
||||
/* First interface is communication */
|
||||
if (pIf->bInterfaceClass ==
|
||||
CDCCommunicationInterfaceDescriptor_CLASS) {
|
||||
pCdcd->bInterfaceNdx = pIf->bInterfaceNumber;
|
||||
pCdcd->bNumInterface = 2;
|
||||
}
|
||||
/* Only data interface */
|
||||
else if(pIf->bInterfaceClass == CDCDataInterfaceDescriptor_CLASS) {
|
||||
pCdcd->bInterfaceNdx = pIf->bInterfaceNumber;
|
||||
pCdcd->bNumInterface = 1;
|
||||
}
|
||||
pArg->pIfDesc = pIf;
|
||||
}
|
||||
else if (pCdcd->bInterfaceNdx <= pIf->bInterfaceNumber
|
||||
&& pCdcd->bInterfaceNdx + pCdcd->bNumInterface
|
||||
> pIf->bInterfaceNumber) {
|
||||
pArg->pIfDesc = pIf;
|
||||
}
|
||||
}
|
||||
|
||||
/* Parse valid interfaces */
|
||||
if (pArg->pIfDesc == 0)
|
||||
return 0;
|
||||
|
||||
/* Find endpoint descriptors */
|
||||
if (pDesc->bDescriptorType == USBGenericDescriptor_ENDPOINT) {
|
||||
USBEndpointDescriptor *pEp = (USBEndpointDescriptor*)pDesc;
|
||||
switch(pEp->bmAttributes & 0x3) {
|
||||
case USBEndpointDescriptor_INTERRUPT:
|
||||
if (pEp->bEndpointAddress & 0x80)
|
||||
pCdcd->bIntInPIPE = pEp->bEndpointAddress & 0x7F;
|
||||
break;
|
||||
case USBEndpointDescriptor_BULK:
|
||||
if (pEp->bEndpointAddress & 0x80)
|
||||
pCdcd->bBulkInPIPE = pEp->bEndpointAddress & 0x7F;
|
||||
else
|
||||
pCdcd->bBulkOutPIPE = pEp->bEndpointAddress;
|
||||
}
|
||||
}
|
||||
|
||||
if ( pCdcd->bInterfaceNdx != 0xFF
|
||||
&& pCdcd->bBulkInPIPE != 0
|
||||
&& pCdcd->bBulkOutPIPE != 0)
|
||||
return USBRC_FINISHED;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback function which should be invoked after the data of a
|
||||
* SetLineCoding request has been retrieved. Sends a zero-length packet
|
||||
* to the host for acknowledging the request.
|
||||
* \param pCdcd Pointer to CDCDSerialPort instance.
|
||||
*/
|
||||
static void _SetLineCodingCallback(CDCDSerialPort * pCdcd)
|
||||
{
|
||||
uint32_t exec = 1;
|
||||
if (pCdcd->fEventHandler) {
|
||||
uint32_t rc = pCdcd->fEventHandler(
|
||||
CDCDSerialPortEvent_SETLINECODING,
|
||||
(uint32_t)(&lineCoding),
|
||||
pCdcd->pArg);
|
||||
if (rc == USBD_STATUS_SUCCESS) {
|
||||
pCdcd->lineCoding.dwDTERate = lineCoding.dwDTERate;
|
||||
pCdcd->lineCoding.bCharFormat = lineCoding.bCharFormat;
|
||||
pCdcd->lineCoding.bParityType = lineCoding.bParityType;
|
||||
pCdcd->lineCoding.bDataBits = lineCoding.bDataBits;
|
||||
}
|
||||
else
|
||||
exec = 0;
|
||||
}
|
||||
if (exec) USBD_Write(0, 0, 0, 0, 0);
|
||||
else USBD_Stall(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Receives new line coding information from the USB host.
|
||||
* \param pCdcd Pointer to CDCDSerialPort instance.
|
||||
*/
|
||||
static void _SetLineCoding(CDCDSerialPort * pCdcd)
|
||||
{
|
||||
TRACE_INFO_WP("sLineCoding ");
|
||||
|
||||
USBD_Read(0,
|
||||
(void *) & (lineCoding),
|
||||
sizeof(CDCLineCoding),
|
||||
(TransferCallback)_SetLineCodingCallback,
|
||||
(void*)pCdcd);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends the current line coding information to the host through Control
|
||||
* endpoint 0.
|
||||
* \param pCdcd Pointer to CDCDSerialPort instance.
|
||||
*/
|
||||
static void _GetLineCoding(CDCDSerialPort * pCdcd)
|
||||
{
|
||||
TRACE_INFO_WP("gLineCoding ");
|
||||
|
||||
USBD_Write(0,
|
||||
(void *) &(pCdcd->lineCoding),
|
||||
sizeof(CDCLineCoding),
|
||||
0,
|
||||
0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes the state of the serial driver according to the information
|
||||
* sent by the host via a SetControlLineState request, and acknowledges
|
||||
* the request with a zero-length packet.
|
||||
* \param pCdcd Pointer to CDCDSerialPort instance.
|
||||
* \param request Pointer to a USBGenericRequest instance.
|
||||
*/
|
||||
static void _SetControlLineState(
|
||||
CDCDSerialPort * pCdcd,
|
||||
const USBGenericRequest *request)
|
||||
{
|
||||
#if (TRACE_LEVEL >= TRACE_LEVEL_INFO)
|
||||
uint8_t DTR, RTS;
|
||||
|
||||
DTR = ((request->wValue & CDCControlLineState_DTR) > 0);
|
||||
RTS = ((request->wValue & CDCControlLineState_RTS) > 0);
|
||||
TRACE_INFO_WP("sControlLineState(%d, %d) ", DTR, RTS);
|
||||
#endif
|
||||
|
||||
pCdcd->bControlLineState = (uint8_t)request->wValue;
|
||||
USBD_Write(0, 0, 0, 0, 0);
|
||||
|
||||
if (pCdcd->fEventHandler)
|
||||
pCdcd->fEventHandler(CDCDSerialPortEvent_SETCONTROLLINESTATE,
|
||||
|
||||
(uint32_t)pCdcd->bControlLineState,
|
||||
pCdcd->pArg);
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Exported functions
|
||||
*------------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* Initializes the USB Device CDC serial port function.
|
||||
* \param pCdcd Pointer to CDCDSerialPort instance.
|
||||
* \param pUsbd Pointer to USBDDriver instance.
|
||||
* \param fEventHandler Pointer to event handler function.
|
||||
* \param firstInterface First interface index for the function
|
||||
* (0xFF to parse from descriptors).
|
||||
* \param numInterface Number of interfaces for the function.
|
||||
*/
|
||||
void CDCDSerialPort_Initialize(CDCDSerialPort * pCdcd,
|
||||
USBDDriver * pUsbd,
|
||||
CDCDSerialPortEventHandler fEventHandler,
|
||||
void * pArg,
|
||||
uint8_t firstInterface,uint8_t numInterface)
|
||||
{
|
||||
TRACE_INFO("CDCDSerialPort_Initialize\n\r");
|
||||
|
||||
/* Initialize event handler */
|
||||
pCdcd->fEventHandler = fEventHandler;
|
||||
pCdcd->pArg = pArg;
|
||||
|
||||
/* Initialize USB Device Driver interface */
|
||||
pCdcd->pUsbd = pUsbd;
|
||||
pCdcd->bInterfaceNdx = firstInterface;
|
||||
pCdcd->bNumInterface = numInterface;
|
||||
pCdcd->bIntInPIPE = 0;
|
||||
pCdcd->bBulkInPIPE = 0;
|
||||
pCdcd->bBulkOutPIPE = 0;
|
||||
|
||||
/* Initialize Abstract Control Model attributes */
|
||||
pCdcd->bControlLineState = 0;
|
||||
pCdcd->wSerialState = 0;
|
||||
CDCLineCoding_Initialize(&(pCdcd->lineCoding),
|
||||
115200,
|
||||
CDCLineCoding_ONESTOPBIT,
|
||||
CDCLineCoding_NOPARITY,
|
||||
8);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse CDC Serial Port information for CDCDSerialPort instance.
|
||||
* Accepted interfaces:
|
||||
* - Communication Interface + Data Interface
|
||||
* - Data Interface ONLY
|
||||
* \param pCdcd Pointer to CDCDSerialPort instance.
|
||||
* \param pDescriptors Pointer to descriptor list.
|
||||
* \param dwLength Descriptor list size in bytes.
|
||||
*/
|
||||
USBGenericDescriptor *CDCDSerialPort_ParseInterfaces(
|
||||
CDCDSerialPort *pCdcd,
|
||||
USBGenericDescriptor *pDescriptors,
|
||||
uint32_t dwLength)
|
||||
{
|
||||
CDCDParseData parseData;
|
||||
|
||||
parseData.pCdcd = pCdcd;
|
||||
parseData.pIfDesc = 0;
|
||||
|
||||
return USBGenericDescriptor_Parse(
|
||||
pDescriptors, dwLength,
|
||||
(USBDescriptorParseFunction)_Interfaces_Parse,
|
||||
&parseData);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Handles CDC-specific SETUP requests. Should be called from a
|
||||
* re-implementation of USBDCallbacks_RequestReceived() method.
|
||||
* \param pCdcd Pointer to CDCDSerialPort instance.
|
||||
* \param request Pointer to a USBGenericRequest instance.
|
||||
* \return USBRC_SUCCESS if request handled, otherwise error.
|
||||
*/
|
||||
uint32_t CDCDSerialPort_RequestHandler(
|
||||
CDCDSerialPort *pCdcd,
|
||||
const USBGenericRequest *request)
|
||||
{
|
||||
if (USBGenericRequest_GetType(request) != USBGenericRequest_CLASS)
|
||||
return USBRC_PARAM_ERR;
|
||||
|
||||
TRACE_INFO_WP("Cdcs ");
|
||||
|
||||
/* Validate interface */
|
||||
if (request->wIndex >= pCdcd->bInterfaceNdx &&
|
||||
request->wIndex < pCdcd->bInterfaceNdx + pCdcd->bNumInterface) {
|
||||
}
|
||||
else {
|
||||
return USBRC_PARAM_ERR;
|
||||
}
|
||||
|
||||
/* Handle the request */
|
||||
switch (USBGenericRequest_GetRequest(request)) {
|
||||
|
||||
case CDCGenericRequest_SETLINECODING:
|
||||
|
||||
_SetLineCoding(pCdcd);
|
||||
break;
|
||||
|
||||
case CDCGenericRequest_GETLINECODING:
|
||||
|
||||
_GetLineCoding(pCdcd);
|
||||
break;
|
||||
|
||||
case CDCGenericRequest_SETCONTROLLINESTATE:
|
||||
|
||||
_SetControlLineState(pCdcd, request);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
return USBRC_PARAM_ERR;
|
||||
}
|
||||
|
||||
return USBRC_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Receives data from the host through the virtual COM port created by
|
||||
* the CDC device serial driver. This function behaves like USBD_Read.
|
||||
* \param pCdcd Pointer to CDCDSerialPort instance.
|
||||
* \param pData Pointer to the data buffer to put received data.
|
||||
* \param dwSize Size of the data buffer in bytes.
|
||||
* \param fCallback Optional callback function to invoke when the transfer
|
||||
* finishes.
|
||||
* \param pArg Optional argument to the callback function.
|
||||
* \return USBD_STATUS_SUCCESS if the read operation has been started normally;
|
||||
* otherwise, the corresponding error code.
|
||||
*/
|
||||
uint32_t CDCDSerialPort_Read(const CDCDSerialPort * pCdcd,
|
||||
void * pData,uint32_t dwSize,
|
||||
TransferCallback fCallback,void * pArg)
|
||||
{
|
||||
if (pCdcd->bBulkOutPIPE == 0)
|
||||
return USBRC_PARAM_ERR;
|
||||
|
||||
return USBD_Read(pCdcd->bBulkOutPIPE,
|
||||
pData, dwSize,
|
||||
fCallback, pArg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a data buffer through the virtual COM port created by the CDC
|
||||
* device serial driver. This function behaves exactly like USBD_Write.
|
||||
* \param pCdcd Pointer to CDCDSerialPort instance.
|
||||
* \param pData Pointer to the data buffer to send.
|
||||
* \param dwSize Size of the data buffer in bytes.
|
||||
* \param fCallback Optional callback function to invoke when the transfer
|
||||
* finishes.
|
||||
* \param pArg Optional argument to the callback function.
|
||||
* \return USBD_STATUS_SUCCESS if the read operation has been started normally;
|
||||
* otherwise, the corresponding error code.
|
||||
*/
|
||||
uint32_t CDCDSerialPort_Write(const CDCDSerialPort * pCdcd,
|
||||
void * pData, uint32_t dwSize,
|
||||
TransferCallback fCallback, void * pArg)
|
||||
{
|
||||
if (pCdcd->bBulkInPIPE == 0)
|
||||
return USBRC_PARAM_ERR;
|
||||
|
||||
return USBD_Write(pCdcd->bBulkInPIPE,
|
||||
pData, dwSize,
|
||||
fCallback, pArg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current control line state of the RS-232 line.
|
||||
* \param pCdcd Pointer to CDCDSerialPort instance.
|
||||
*/
|
||||
uint8_t CDCDSerialPort_GetControlLineState(const CDCDSerialPort * pCdcd)
|
||||
{
|
||||
return pCdcd->bControlLineState;
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy current line coding settings to pointered space.
|
||||
* \param pCdcd Pointer to CDCDSerialPort instance.
|
||||
* \param pLineCoding Pointer to CDCLineCoding instance.
|
||||
*/
|
||||
void CDCDSerialPort_GetLineCoding(const CDCDSerialPort * pCdcd,
|
||||
CDCLineCoding* pLineCoding)
|
||||
{
|
||||
if (pLineCoding) {
|
||||
pLineCoding->dwDTERate = pCdcd->lineCoding.dwDTERate;
|
||||
pLineCoding->bCharFormat = pCdcd->lineCoding.bCharFormat;
|
||||
pLineCoding->bParityType = pCdcd->lineCoding.bParityType;
|
||||
pLineCoding->bDataBits = pCdcd->lineCoding.bDataBits;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current status of the RS-232 line.
|
||||
* \param pCdcd Pointer to CDCDSerialPort instance.
|
||||
*/
|
||||
uint16_t CDCDSerialPort_GetSerialState(const CDCDSerialPort * pCdcd)
|
||||
{
|
||||
return pCdcd->wSerialState;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the current serial state of the device to the given value.
|
||||
* \param pCdcd Pointer to CDCDSerialPort instance.
|
||||
* \param wSerialState New device state.
|
||||
*/
|
||||
void CDCDSerialPort_SetSerialState(CDCDSerialPort * pCdcd,
|
||||
uint16_t wSerialState)
|
||||
{
|
||||
if (pCdcd->bIntInPIPE == 0)
|
||||
return;
|
||||
|
||||
/* If new state is different from previous one, send a notification to the
|
||||
host */
|
||||
if (pCdcd->wSerialState != wSerialState) {
|
||||
|
||||
pCdcd->wSerialState = wSerialState;
|
||||
USBD_Write(pCdcd->bIntInPIPE,
|
||||
&(pCdcd->wSerialState),
|
||||
2,
|
||||
0,
|
||||
0);
|
||||
|
||||
/* Reset one-time flags */
|
||||
pCdcd->wSerialState &= ~(CDCSerialState_OVERRUN
|
||||
| CDCSerialState_PARITY
|
||||
| CDCSerialState_FRAMING
|
||||
| CDCSerialState_RINGSIGNAL
|
||||
| CDCSerialState_BREAK);
|
||||
}
|
||||
}
|
||||
|
||||
/**@}*/
|
||||
|
||||
+70
@@ -0,0 +1,70 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2010, Atmel Corporation
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the disclaimer below.
|
||||
*
|
||||
* Atmel's name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
* Headers
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
/* These headers were introduced in C99
|
||||
by working group ISO/IEC JTC1/SC22/WG14. */
|
||||
#include <stdint.h>
|
||||
|
||||
#include "CDCDSerial.h"
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
* Default callback functions
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* Invoked when the CDC LineCoding is requested to changed
|
||||
* \param port Port number.
|
||||
* \param pLineCoding Pointer to new LineCoding settings.
|
||||
* \return USBRC_SUCCESS if ready to receive the line coding.
|
||||
*/
|
||||
extern WEAK uint8_t CDCDSerial_LineCodingIsToChange(
|
||||
CDCLineCoding * pLineCoding)
|
||||
{
|
||||
/* Accept any of linecoding settings */
|
||||
pLineCoding = pLineCoding;
|
||||
return USBRC_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoked when the CDC ControlLineState is changed
|
||||
* \param port Port number.
|
||||
* \param DTR New DTR value.
|
||||
* \param RTS New RTS value.
|
||||
*/
|
||||
extern WEAK void CDCDSerial_ControlLineStateChanged(uint8_t DTR,
|
||||
uint8_t RTS)
|
||||
{
|
||||
/* Do nothing */
|
||||
DTR = DTR; RTS = RTS;
|
||||
}
|
||||
|
||||
BIN
Binary file not shown.
|
After Width: | Height: | Size: 28 KiB |
BIN
Binary file not shown.
|
After Width: | Height: | Size: 9.9 KiB |
@@ -0,0 +1,45 @@
|
||||
; $Id: 6119.inf,v 1.1.2.1 2006/12/05 08:33:25 danielru Exp $
|
||||
|
||||
[Version] ; Version section
|
||||
Signature="$Chicago$" ; All Windows versions
|
||||
Class=Ports ; This is a serial port driver
|
||||
ClassGuid={4D36E978-E325-11CE-BFC1-08002BE10318} ; Associated GUID
|
||||
Provider=%ATMEL% ; Driver is provided by ATMEL
|
||||
DriverVer=09/12/2006,1.1.1.5 ; Driver version 1.1.1.5 published on 23 February 2007
|
||||
|
||||
[DestinationDirs] ; DestinationDirs section
|
||||
DefaultDestDir=12 ; Default install directory is \drivers or \IOSubSys
|
||||
|
||||
[Manufacturer] ; Manufacturer section
|
||||
%ATMEL%=AtmelMfg ; Only one manufacturer (ATMEL), models section is named
|
||||
; AtmelMfg
|
||||
|
||||
[AtmelMfg] ; Models section corresponding to ATMEL
|
||||
%USBtoSerialConverter%=USBtoSer.Install,USB\VID_03EB&PID_6119 ; Identifies a device with ATMEL Vendor ID (03EBh) and
|
||||
; Product ID equal to 6119h. Corresponding Install section
|
||||
; is named USBtoSer.Install
|
||||
|
||||
[USBtoSer.Install] ; Install section
|
||||
include=mdmcpq.inf
|
||||
CopyFiles=FakeModemCopyFileSection
|
||||
AddReg=USBtoSer.AddReg ; Registry keys to add are listed in USBtoSer.AddReg
|
||||
|
||||
[USBtoSer.AddReg] ; AddReg section
|
||||
HKR,,DevLoader,,*ntkern ;
|
||||
HKR,,NTMPDriver,,usbser.sys
|
||||
HKR,,EnumPropPages32,,"MsPorts.dll,SerialPortPropPageProvider"
|
||||
|
||||
[USBtoSer.Install.Services] ; Services section
|
||||
AddService=usbser,0x00000002,USBtoSer.AddService ; Assign usbser as the PnP driver for the device
|
||||
|
||||
[USBtoSer.AddService] ; Service install section
|
||||
DisplayName=%USBSer% ; Name of the serial driver
|
||||
ServiceType=1 ; Service kernel driver
|
||||
StartType=3 ; Driver is started by the PnP manager
|
||||
ErrorControl=1 ; Warn about errors
|
||||
ServiceBinary=%12%\usbser.sys ; Driver filename
|
||||
|
||||
[Strings] ; Strings section
|
||||
ATMEL="ATMEL Corp." ; String value for the ATMEL symbol
|
||||
USBtoSerialConverter="AT91 USB to Serial Converter" ; String value for the USBtoSerialConverter symbol
|
||||
USBSer="USB Serial Driver" ; String value for the USBSer symbol
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,89 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2008, Atmel Corporation
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the disclaimer below.
|
||||
*
|
||||
* Atmel's name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* Definitions of callbacks used by the USBD API to notify the user
|
||||
* application of incoming events. These functions are declared as 'weak',
|
||||
* so they can be re-implemented elsewhere in the application in a
|
||||
* transparent way.
|
||||
*
|
||||
* \addtogroup usbd_interface
|
||||
*@{
|
||||
*/
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Headers
|
||||
*------------------------------------------------------------------------------*/
|
||||
|
||||
#include "USBD.h"
|
||||
#include "USBDDriver.h"
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Exported function
|
||||
*------------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* Invoked after the USB driver has been initialized. By default, do nothing.
|
||||
*/
|
||||
WEAK void USBDCallbacks_Initialized(void)
|
||||
{
|
||||
/* Does nothing */
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoked when the USB driver is reset. Does nothing by default.
|
||||
*/
|
||||
WEAK void USBDCallbacks_Reset(void)
|
||||
{
|
||||
/* Does nothing*/
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoked when the USB device gets suspended. By default, do nothing.
|
||||
*/
|
||||
WEAK void USBDCallbacks_Suspended(void) {}
|
||||
|
||||
/**
|
||||
* Invoked when the USB device leaves the Suspended state. By default,
|
||||
* Do nothing.
|
||||
*/
|
||||
WEAK void USBDCallbacks_Resumed(void) {}
|
||||
|
||||
/**
|
||||
* USBDCallbacks_RequestReceived - Invoked when a new SETUP request is
|
||||
* received. Does nothing by default.
|
||||
* \param request Pointer to the request to handle.
|
||||
*/
|
||||
WEAK void USBDCallbacks_RequestReceived(const USBGenericRequest *request)
|
||||
{
|
||||
/* Does basic enumeration */
|
||||
USBDDriver_RequestHandler(USBD_GetDriver(), request);
|
||||
}
|
||||
|
||||
/**@}*/
|
||||
File diff suppressed because it is too large
Load Diff
+84
@@ -0,0 +1,84 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2008, Atmel Corporation
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the disclaimer below.
|
||||
*
|
||||
* Atmel's name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/** \file
|
||||
*
|
||||
* \section Purpose
|
||||
*
|
||||
* Definition of several callbacks which are triggered by the USB software
|
||||
* driver after receiving specific requests.
|
||||
*
|
||||
* \section Usage
|
||||
*
|
||||
* -# Re-implement the USBDDriverCallbacks_ConfigurationChanged
|
||||
* callback to know when the hosts changes the active configuration of
|
||||
* the device.
|
||||
* -# Re-implement the USBDDriverCallbacks_InterfaceSettingChanged
|
||||
* callback to get notified whenever the active setting of an interface
|
||||
* is changed by the host.
|
||||
*
|
||||
* \addtogroup usbd_interface
|
||||
*@{
|
||||
*/
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Headers
|
||||
*------------------------------------------------------------------------------*/
|
||||
|
||||
#include "USBDDriver.h"
|
||||
#include <USBLib_Trace.h>
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Global functions
|
||||
*------------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* Indicates that the current configuration of the device has changed.
|
||||
* \param cfgnum New device configuration index.
|
||||
*/
|
||||
WEAK void USBDDriverCallbacks_ConfigurationChanged(uint8_t cfgnum)
|
||||
{
|
||||
cfgnum = cfgnum;
|
||||
TRACE_INFO_WP("cfgChanged%d ", cfgnum);
|
||||
}
|
||||
|
||||
/**
|
||||
* Notifies of a change in the currently active setting of an interface.
|
||||
* \param interface Number of the interface whose setting has changed.
|
||||
* \param setting New interface setting.
|
||||
*/
|
||||
WEAK void USBDDriverCallbacks_InterfaceSettingChanged(
|
||||
uint8_t interface,
|
||||
uint8_t setting)
|
||||
{
|
||||
interface = interface; setting = setting;
|
||||
TRACE_INFO_WP("ifSettingChanged%d.%d ", interface, setting);
|
||||
}
|
||||
|
||||
/**@}*/
|
||||
+1675
File diff suppressed because it is too large
Load Diff
+2198
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,307 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2010, Atmel Corporation
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the disclaimer below.
|
||||
*
|
||||
* Atmel's name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
*
|
||||
* \section Purpose
|
||||
*
|
||||
* Definitions and methods for USB composite device implement.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CDCAUDDDRIVER_H
|
||||
#define CDCAUDDDRIVER_H
|
||||
/** \addtogroup usbd_composite_cdcaud
|
||||
*@{
|
||||
*/
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
* Headers
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#include <USBRequests.h>
|
||||
#include <CDCDescriptors.h>
|
||||
#include <AUDDescriptors.h>
|
||||
#include "USBD.h"
|
||||
#include <USBDDriver.h>
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
* Definitions
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
/** \addtogroup usbd_cdc_aud_desc USB CDC(Serial) + AUD(Speaker) Definitions
|
||||
* @{
|
||||
*/
|
||||
/** Number of interfaces of the device (5, can be 4 if no mic support */
|
||||
#define CDCAUDDDriverDescriptors_MaxNumInterfaces 5
|
||||
/** Number of the CDC interface. */
|
||||
#define CDCAUDDDriverDescriptors_CDC_INTERFACE 0
|
||||
/** Number of the Audio interface. */
|
||||
#define CDCAUDDDriverDescriptors_AUD_INTERFACE 2
|
||||
/** Number of Audio function channels (M,L,R) */
|
||||
#define AUDD_NumChannels 3
|
||||
/** @}*/
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
* Types
|
||||
*---------------------------------------------------------------------------*/
|
||||
#pragma pack(1)
|
||||
#if defined ( __CC_ARM ) /* Keil ¦ÌVision 4 */
|
||||
#elif defined ( __ICCARM__ ) /* IAR Ewarm */
|
||||
#define __attribute__(...)
|
||||
#define __packed__ packed
|
||||
#elif defined ( __GNUC__ ) /* GCC CS3 */
|
||||
#define __packed__ aligned(1)
|
||||
#endif
|
||||
|
||||
/** Audio header descriptor with 1 interface */
|
||||
typedef struct _AUDHeaderDescriptor1{
|
||||
|
||||
/** Header descriptor.*/
|
||||
AUDHeaderDescriptor header;
|
||||
/** Id of the first grouped interface.*/
|
||||
uint8_t bInterface0;
|
||||
|
||||
} __attribute__ ((__packed__)) AUDHeaderDescriptor1;
|
||||
|
||||
/** Audio header descriptor with 2 interface */
|
||||
typedef struct _AUDHeaderDescriptor2 {
|
||||
|
||||
/** Header descriptor. */
|
||||
AUDHeaderDescriptor header;
|
||||
/** Id of the first grouped interface - Speaker. */
|
||||
uint8_t bInterface0;
|
||||
/** Id of the second grouped interface - Speakerphone. */
|
||||
uint8_t bInterface1;
|
||||
|
||||
} __attribute__ ((__packed__)) AUDHeaderDescriptor2; /* GCC */
|
||||
|
||||
/**
|
||||
* Feature unit descriptor with 3 channel controls (master, right, left).
|
||||
*/
|
||||
typedef struct _AUDFeatureUnitDescriptor3{
|
||||
|
||||
/** Feature unit descriptor.*/
|
||||
AUDFeatureUnitDescriptor feature;
|
||||
/** Available controls for each channel.*/
|
||||
uint8_t bmaControls[AUDD_NumChannels];
|
||||
/** Index of a string descriptor for the feature unit.*/
|
||||
uint8_t iFeature;
|
||||
|
||||
} __attribute__ ((__packed__)) AUDFeatureUnitDescriptor3;
|
||||
|
||||
/**
|
||||
* List of descriptors for detailling the audio control interface of a
|
||||
* device using a USB audio speaker function.
|
||||
*/
|
||||
typedef struct _AUDDSpeakerAcDescriptors{
|
||||
|
||||
/** Header descriptor (with one slave interface).*/
|
||||
AUDHeaderDescriptor1 header;
|
||||
/** Input terminal descriptor.*/
|
||||
AUDInputTerminalDescriptor input;
|
||||
/** Output terminal descriptor.*/
|
||||
AUDOutputTerminalDescriptor output;
|
||||
/** Feature unit descriptor.*/
|
||||
AUDFeatureUnitDescriptor3 feature;
|
||||
|
||||
} __attribute__ ((__packed__)) AUDDSpeakerAcDescriptors;
|
||||
|
||||
/**
|
||||
* List of descriptors for detailling the audio control interface of a
|
||||
* device using a USB Audio Speakerphoneer function.
|
||||
*/
|
||||
typedef struct _AUDDSpeakerPhoneAcDescriptors {
|
||||
|
||||
/** Header descriptor (with one slave interface). */
|
||||
AUDHeaderDescriptor2 header;
|
||||
/** Input terminal descriptor. */
|
||||
AUDInputTerminalDescriptor inputSpeakerPhone;
|
||||
/** Output terminal descriptor. */
|
||||
AUDOutputTerminalDescriptor outputSpeakerPhone;
|
||||
/** Feature unit descriptor - SpeakerPhone. */
|
||||
AUDFeatureUnitDescriptor3 featureSpeakerPhone;
|
||||
/** Input terminal descriptor. */
|
||||
AUDInputTerminalDescriptor inputRec;
|
||||
/** Output terminal descriptor. */
|
||||
AUDOutputTerminalDescriptor outputRec;
|
||||
/** Feature unit descriptor - SpeakerPhonephone. */
|
||||
AUDFeatureUnitDescriptor3 featureRec;
|
||||
|
||||
} __attribute__ ((__packed__)) AUDDSpeakerPhoneAcDescriptors;
|
||||
|
||||
/**
|
||||
* Format type I descriptor with one discrete sampling frequency.
|
||||
*/
|
||||
typedef struct _AUDFormatTypeOneDescriptor1{
|
||||
|
||||
/** Format type I descriptor.*/
|
||||
AUDFormatTypeOneDescriptor formatType;
|
||||
/** Sampling frequency in Hz.*/
|
||||
uint8_t tSamFreq[3];
|
||||
|
||||
} __attribute__ ((__packed__)) AUDFormatTypeOneDescriptor1;
|
||||
|
||||
/**
|
||||
* Configuration descriptor list for a device implementing
|
||||
* CDC(Serial) + Audio(Speaker) composite driver.
|
||||
*/
|
||||
typedef struct _CdcAudspkdDriverConfigurationDescriptors {
|
||||
|
||||
/** Standard configuration descriptor. */
|
||||
USBConfigurationDescriptor configuration;
|
||||
|
||||
/* --- CDC 0 */
|
||||
/** IAD 0 */
|
||||
USBInterfaceAssociationDescriptor cdcIAD0;
|
||||
/** Communication interface descriptor */
|
||||
USBInterfaceDescriptor cdcCommunication0;
|
||||
/** CDC header functional descriptor. */
|
||||
CDCHeaderDescriptor cdcHeader0;
|
||||
/** CDC call management functional descriptor. */
|
||||
CDCCallManagementDescriptor cdcCallManagement0;
|
||||
/** CDC abstract control management functional descriptor. */
|
||||
CDCAbstractControlManagementDescriptor cdcAbstractControlManagement0;
|
||||
/** CDC union functional descriptor (with one slave interface). */
|
||||
CDCUnionDescriptor cdcUnion0;
|
||||
/** Notification endpoint descriptor. */
|
||||
USBEndpointDescriptor cdcNotification0;
|
||||
/** Data interface descriptor. */
|
||||
USBInterfaceDescriptor cdcData0;
|
||||
/** Data OUT endpoint descriptor. */
|
||||
USBEndpointDescriptor cdcDataOut0;
|
||||
/** Data IN endpoint descriptor. */
|
||||
USBEndpointDescriptor cdcDataIn0;
|
||||
|
||||
/* --- AUDIO (AC) */
|
||||
/** IAD 1*/
|
||||
USBInterfaceAssociationDescriptor audIAD;
|
||||
/** Audio control interface.*/
|
||||
USBInterfaceDescriptor audInterface;
|
||||
/** Descriptors for the audio control interface.*/
|
||||
AUDDSpeakerAcDescriptors audControl;
|
||||
/* -- AUDIO out (AS) */
|
||||
/** Streaming out interface descriptor (with no endpoint, required).*/
|
||||
USBInterfaceDescriptor audStreamingOutNoIsochronous;
|
||||
/** Streaming out interface descriptor.*/
|
||||
USBInterfaceDescriptor audStreamingOut;
|
||||
/** Audio class descriptor for the streaming out interface.*/
|
||||
AUDStreamingInterfaceDescriptor audStreamingOutClass;
|
||||
/** Stream format descriptor.*/
|
||||
AUDFormatTypeOneDescriptor1 audStreamingOutFormatType;
|
||||
/** Streaming out endpoint descriptor.*/
|
||||
AUDEndpointDescriptor audStreamingOutEndpoint;
|
||||
/** Audio class descriptor for the streaming out endpoint.*/
|
||||
AUDDataEndpointDescriptor audStreamingOutDataEndpoint;
|
||||
|
||||
} __attribute__ ((__packed__)) CdcAudspkdDriverConfigurationDescriptors;
|
||||
|
||||
/**
|
||||
* Configuration descriptor list for a device implementing
|
||||
* CDC(Serial) + Audio(SpeakerPhone) composite driver.
|
||||
*/
|
||||
typedef struct _CdcAuddDriverConfigurationDescriptors {
|
||||
|
||||
/** Standard configuration descriptor. */
|
||||
USBConfigurationDescriptor configuration;
|
||||
|
||||
/* --- CDC 0 */
|
||||
/** IAD 0 */
|
||||
USBInterfaceAssociationDescriptor cdcIAD0;
|
||||
/** Communication interface descriptor */
|
||||
USBInterfaceDescriptor cdcCommunication0;
|
||||
/** CDC header functional descriptor. */
|
||||
CDCHeaderDescriptor cdcHeader0;
|
||||
/** CDC call management functional descriptor. */
|
||||
CDCCallManagementDescriptor cdcCallManagement0;
|
||||
/** CDC abstract control management functional descriptor. */
|
||||
CDCAbstractControlManagementDescriptor cdcAbstractControlManagement0;
|
||||
/** CDC union functional descriptor (with one slave interface). */
|
||||
CDCUnionDescriptor cdcUnion0;
|
||||
/** Notification endpoint descriptor. */
|
||||
USBEndpointDescriptor cdcNotification0;
|
||||
/** Data interface descriptor. */
|
||||
USBInterfaceDescriptor cdcData0;
|
||||
/** Data OUT endpoint descriptor. */
|
||||
USBEndpointDescriptor cdcDataOut0;
|
||||
/** Data IN endpoint descriptor. */
|
||||
USBEndpointDescriptor cdcDataIn0;
|
||||
|
||||
/* --- AUDIO (AC) */
|
||||
/** IAD 1*/
|
||||
USBInterfaceAssociationDescriptor audIAD;
|
||||
/** Audio control interface.*/
|
||||
USBInterfaceDescriptor audInterface;
|
||||
/** Descriptors for the audio control interface.*/
|
||||
AUDDSpeakerPhoneAcDescriptors audControl;
|
||||
/* -- AUDIO out (AS) */
|
||||
/** Streaming out interface descriptor (with no endpoint, required).*/
|
||||
USBInterfaceDescriptor audStreamingOutNoIsochronous;
|
||||
/** Streaming out interface descriptor.*/
|
||||
USBInterfaceDescriptor audStreamingOut;
|
||||
/** Audio class descriptor for the streaming out interface.*/
|
||||
AUDStreamingInterfaceDescriptor audStreamingOutClass;
|
||||
/** Stream format descriptor.*/
|
||||
AUDFormatTypeOneDescriptor1 audStreamingOutFormatType;
|
||||
/** Streaming out endpoint descriptor.*/
|
||||
AUDEndpointDescriptor audStreamingOutEndpoint;
|
||||
/** Audio class descriptor for the streaming out endpoint.*/
|
||||
AUDDataEndpointDescriptor audStreamingOutDataEndpoint;
|
||||
/*- AUDIO IN */
|
||||
/** Streaming in interface descriptor (with no endpoint, required). */
|
||||
USBInterfaceDescriptor streamingInNoIsochronous;
|
||||
/** Streaming in interface descriptor. */
|
||||
USBInterfaceDescriptor streamingIn;
|
||||
/** Audio class descriptor for the streaming in interface. */
|
||||
AUDStreamingInterfaceDescriptor streamingInClass;
|
||||
/** Stream format descriptor. */
|
||||
AUDFormatTypeOneDescriptor1 streamingInFormatType;
|
||||
/** Streaming in endpoint descriptor. */
|
||||
AUDEndpointDescriptor streamingInEndpoint;
|
||||
/** Audio class descriptor for the streaming in endpoint. */
|
||||
AUDDataEndpointDescriptor streamingInDataEndpoint;
|
||||
|
||||
} __attribute__ ((__packed__)) CdcAuddDriverConfigurationDescriptors;
|
||||
|
||||
#pragma pack()
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
* Exported functions
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
extern void CDCAUDDDriver_Initialize(const USBDDriverDescriptors * pDescriptors);
|
||||
extern void CDCAUDDDriver_ConfigurationChangedHandler(uint8_t cfgnum);
|
||||
extern void CDCAUDDDriver_InterfaceSettingChangedHandler(
|
||||
uint8_t interface, uint8_t setting);
|
||||
extern void CDCAUDDDriver_RequestHandler(const USBGenericRequest *request);
|
||||
|
||||
/**@}*/
|
||||
#endif //#ifndef CDCHIDDDRIVER_H
|
||||
|
||||
@@ -0,0 +1,106 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2008, Atmel Corporation
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the disclaimer below.
|
||||
*
|
||||
* Atmel's name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
*
|
||||
* Single CDC Serial Port Function for USB device & composite driver.
|
||||
*/
|
||||
|
||||
#ifndef CDCDSERIAL_H
|
||||
#define CDCDSERIAL_H
|
||||
|
||||
/** \addtogroup usbd_cdc
|
||||
*@{
|
||||
*/
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Headers
|
||||
*------------------------------------------------------------------------------*/
|
||||
|
||||
/* These headers were introduced in C99
|
||||
by working group ISO/IEC JTC1/SC22/WG14. */
|
||||
#include <stdint.h>
|
||||
|
||||
#include <USBRequests.h>
|
||||
|
||||
#include <USBDDriver.h>
|
||||
#include <CDCDSerialPort.h>
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Definitions
|
||||
*------------------------------------------------------------------------------*/
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Types
|
||||
*------------------------------------------------------------------------------*/
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Exported functions
|
||||
*------------------------------------------------------------------------------*/
|
||||
|
||||
extern void CDCDSerial_Initialize(
|
||||
USBDDriver * pUsbd, uint8_t bInterfaceNb);
|
||||
|
||||
extern uint32_t CDCDSerial_RequestHandler(
|
||||
const USBGenericRequest *request);
|
||||
|
||||
extern void CDCDSerial_ConfigureFunction(
|
||||
USBGenericDescriptor * pDescriptors, uint16_t wLength);
|
||||
|
||||
extern uint32_t CDCDSerial_Write(
|
||||
void *data,
|
||||
uint32_t size,
|
||||
TransferCallback callback,
|
||||
void *argument);
|
||||
|
||||
extern uint32_t CDCDSerial_Read(
|
||||
void *data,
|
||||
uint32_t size,
|
||||
TransferCallback callback,
|
||||
void *argument);
|
||||
|
||||
extern void CDCDSerial_GetLineCoding(CDCLineCoding * pLineCoding);
|
||||
|
||||
extern uint8_t CDCDSerial_GetControlLineState(void);
|
||||
|
||||
extern uint16_t CDCDSerial_GetSerialState(void);
|
||||
|
||||
extern void CDCDSerial_SetSerialState(uint16_t serialState);
|
||||
|
||||
extern uint8_t CDCDSerial_LineCodingIsToChange(
|
||||
CDCLineCoding * pLineCoding);
|
||||
|
||||
extern void CDCDSerial_ControlLineStateChanged(
|
||||
uint8_t DTR,uint8_t RTS);
|
||||
|
||||
/**@}*/
|
||||
|
||||
#endif /*#ifndef CDCSERIAL_H*/
|
||||
|
||||
@@ -0,0 +1,249 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2008, Atmel Corporation
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the disclaimer below.
|
||||
*
|
||||
* Atmel's name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
*
|
||||
* \section Purpose
|
||||
*
|
||||
* Definition of a class for implementing a USB device CDC serial driver.
|
||||
*
|
||||
* \section Usage
|
||||
*
|
||||
* -# Re-implement the USBDCallbacks_RequestReceived method to pass
|
||||
* received requests to CDCDSerialDriver_RequestHandler. *This is
|
||||
* automatically done unless the NOAUTOCALLBACK symbol is defined*.
|
||||
* -# Initialize the CDC serial and USB drivers using
|
||||
* CDCDSerialDriver_Initialize.
|
||||
* -# Logically connect the device to the host using USBD_Connect.
|
||||
* -# Send serial data to the USB host using CDCDSerialDriver_Write.
|
||||
* -# Receive serial data from the USB host using CDCDSerialDriver_Read.
|
||||
*/
|
||||
|
||||
#ifndef CDCDSERIALDRIVER_H
|
||||
#define CDCDSERIALDRIVER_H
|
||||
|
||||
/** \addtogroup usbd_cdc
|
||||
*@{
|
||||
*/
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Headers
|
||||
*------------------------------------------------------------------------------*/
|
||||
|
||||
/* These headers were introduced in C99
|
||||
by working group ISO/IEC JTC1/SC22/WG14. */
|
||||
#include <stdint.h>
|
||||
|
||||
#include <USBRequests.h>
|
||||
#include <CDCRequests.h>
|
||||
#include <CDCDescriptors.h>
|
||||
#include <CDCNotifications.h>
|
||||
|
||||
#include <CDCDSerial.h>
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Definitions
|
||||
*------------------------------------------------------------------------------*/
|
||||
|
||||
/** \addtogroup usbd_cdc_if USB Device CDC Serial Interface IDs
|
||||
* @{
|
||||
*/
|
||||
/** Communication Class Interface ID */
|
||||
#define CDCDSerialDriver_CC_INTERFACE 0
|
||||
/** Data Class Interface ID */
|
||||
#define CDCDSerialDriver_DC_INTERFACE 1
|
||||
/** @}*/
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Types
|
||||
*------------------------------------------------------------------------------*/
|
||||
#pragma pack(1)
|
||||
#if defined ( __CC_ARM ) /* Keil ¦ÌVision 4 */
|
||||
#elif defined ( __ICCARM__ ) /* IAR Ewarm */
|
||||
#define __attribute__(...)
|
||||
#define __packed__ packed
|
||||
#elif defined ( __GNUC__ ) /* GCC CS3 */
|
||||
#define __packed__ aligned(1)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \typedef CDCDSerialDriverConfigurationDescriptors
|
||||
* \brief Configuration descriptor list for a device implementing a
|
||||
* CDC serial driver.
|
||||
*/
|
||||
typedef struct _CDCDSerialDriverConfigurationDescriptors {
|
||||
|
||||
/** Standard configuration descriptor. */
|
||||
USBConfigurationDescriptor configuration;
|
||||
/** Communication interface descriptor. */
|
||||
USBInterfaceDescriptor communication;
|
||||
/** CDC header functional descriptor. */
|
||||
CDCHeaderDescriptor header;
|
||||
/** CDC call management functional descriptor. */
|
||||
CDCCallManagementDescriptor callManagement;
|
||||
/** CDC abstract control management functional descriptor. */
|
||||
CDCAbstractControlManagementDescriptor abstractControlManagement;
|
||||
/** CDC union functional descriptor (with one slave interface). */
|
||||
CDCUnionDescriptor union1;
|
||||
/** Notification endpoint descriptor. */
|
||||
USBEndpointDescriptor notification;
|
||||
/** Data interface descriptor. */
|
||||
USBInterfaceDescriptor data;
|
||||
/** Data OUT endpoint descriptor. */
|
||||
USBEndpointDescriptor dataOut;
|
||||
/** Data IN endpoint descriptor. */
|
||||
USBEndpointDescriptor dataIn;
|
||||
|
||||
} __attribute__ ((__packed__)) CDCDSerialDriverConfigurationDescriptors;
|
||||
|
||||
/**
|
||||
* \typedef CDCDSerialDriverConfigurationDescriptorsOTG
|
||||
* \brief Configuration descriptor list for a device implementing a
|
||||
* CDC serial OTG driver.
|
||||
*/
|
||||
typedef struct _CDCDSerialDriverConfigurationDescriptorsOTG {
|
||||
|
||||
/** Standard configuration descriptor. */
|
||||
USBConfigurationDescriptor configuration;
|
||||
/* OTG descriptor */
|
||||
USBOtgDescriptor otgDescriptor;
|
||||
/** Communication interface descriptor. */
|
||||
USBInterfaceDescriptor communication;
|
||||
/** CDC header functional descriptor. */
|
||||
CDCHeaderDescriptor header;
|
||||
/** CDC call management functional descriptor. */
|
||||
CDCCallManagementDescriptor callManagement;
|
||||
/** CDC abstract control management functional descriptor. */
|
||||
CDCAbstractControlManagementDescriptor abstractControlManagement;
|
||||
/** CDC union functional descriptor (with one slave interface). */
|
||||
CDCUnionDescriptor union1;
|
||||
/** Notification endpoint descriptor. */
|
||||
USBEndpointDescriptor notification;
|
||||
/** Data interface descriptor. */
|
||||
USBInterfaceDescriptor data;
|
||||
/** Data OUT endpoint descriptor. */
|
||||
USBEndpointDescriptor dataOut;
|
||||
/** Data IN endpoint descriptor. */
|
||||
USBEndpointDescriptor dataIn;
|
||||
|
||||
} __attribute__ ((__packed__)) CDCDSerialDriverConfigurationDescriptorsOTG;
|
||||
|
||||
#pragma pack()
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Exported functions
|
||||
*------------------------------------------------------------------------------*/
|
||||
|
||||
extern void CDCDSerialDriver_Initialize(
|
||||
const USBDDriverDescriptors *pDescriptors);
|
||||
|
||||
extern void CDCDSerialDriver_ConfigurationChangedHandler(uint8_t cfgnum);
|
||||
|
||||
extern void CDCDSerialDriver_RequestHandler(
|
||||
const USBGenericRequest *request);
|
||||
|
||||
/**
|
||||
* Sends a data buffer through the virtual COM port created by the CDC
|
||||
* device serial driver. This function behaves exactly like USBD_Write.
|
||||
* \param data Pointer to the data buffer to send.
|
||||
* \param size Size of the data buffer in bytes.
|
||||
* \param callback Optional callback function to invoke when the transfer
|
||||
* finishes.
|
||||
* \param argument Optional argument to the callback function.
|
||||
* \return USBD_STATUS_SUCCESS if the read operation has been started normally;
|
||||
* otherwise, the corresponding error code.
|
||||
*/
|
||||
static inline uint32_t CDCDSerialDriver_Write(
|
||||
void *data,
|
||||
uint32_t size,
|
||||
TransferCallback callback,
|
||||
void *argument)
|
||||
{
|
||||
return CDCDSerial_Write(data, size, callback, argument);
|
||||
}
|
||||
|
||||
/**
|
||||
* Receives data from the host through the virtual COM port created by
|
||||
* the CDC device serial driver. This function behaves like USBD_Read.
|
||||
* \param data Pointer to the data buffer to put received data.
|
||||
* \param size Size of the data buffer in bytes.
|
||||
* \param callback Optional callback function to invoke when the transfer
|
||||
* finishes.
|
||||
* \param argument Optional argument to the callback function.
|
||||
* \return USBD_STATUS_SUCCESS if the read operation has been started normally;
|
||||
* otherwise, the corresponding error code.
|
||||
*/
|
||||
static inline uint32_t CDCDSerialDriver_Read(
|
||||
void *data,
|
||||
uint32_t size,
|
||||
TransferCallback callback,
|
||||
void *argument)
|
||||
{
|
||||
return CDCDSerial_Read(data, size, callback, argument);
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy current line coding settings to pointered space.
|
||||
* \param pLineCoding Pointer to CDCLineCoding instance.
|
||||
*/
|
||||
static inline void CDCDSerialDriver_GetLineCoding(CDCLineCoding * pLineCoding)
|
||||
{
|
||||
CDCDSerial_GetLineCoding(pLineCoding);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current control line state of the RS-232 line.
|
||||
*/
|
||||
static inline uint8_t CDCDSerialDriver_GetControlLineState(void)
|
||||
{
|
||||
return CDCDSerial_GetControlLineState();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current status of the RS-232 line.
|
||||
*/
|
||||
static inline uint16_t CDCDSerialDriver_GetSerialState(void)
|
||||
{
|
||||
return CDCDSerial_GetSerialState();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the current serial state of the device to the given value.
|
||||
* \param serialState New device state.
|
||||
*/
|
||||
static inline void CDCDSerialDriver_SetSerialState(uint16_t serialState)
|
||||
{
|
||||
CDCDSerial_SetSerialState(serialState);
|
||||
}
|
||||
|
||||
/**@}*/
|
||||
|
||||
#endif /*#ifndef CDCSERIALDRIVER_H*/
|
||||
|
||||
@@ -0,0 +1,167 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2010, Atmel Corporation
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the disclaimer below.
|
||||
*
|
||||
* Atmel's name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* Definition of a class for implementing a USB device
|
||||
* CDC serial port function.
|
||||
*/
|
||||
|
||||
#ifndef _CDCDSERIALPORT_H_
|
||||
#define _CDCDSERIALPORT_H_
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Headers
|
||||
*------------------------------------------------------------------------------*/
|
||||
|
||||
/* These headers were introduced in C99
|
||||
by working group ISO/IEC JTC1/SC22/WG14. */
|
||||
#include <stdint.h>
|
||||
|
||||
#include <USBRequests.h>
|
||||
#include <CDCRequests.h>
|
||||
#include <CDCNotifications.h>
|
||||
#include "USBD.h"
|
||||
#include <USBDDriver.h>
|
||||
/** \addtogroup usbd_cdc
|
||||
*@{
|
||||
*/
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Defines
|
||||
*------------------------------------------------------------------------------*/
|
||||
|
||||
/** \addtogroup usbd_cdc_serial_desc USB Device Serial Port Descriptor Values
|
||||
* @{
|
||||
*/
|
||||
/** Default CDC interrupt endpoints max packat size (8). */
|
||||
#define CDCDSerialPort_INTERRUPT_MAXPACKETSIZE 8
|
||||
/** Default CDC interrupt endpoint polling rate of High Speed (16ms). */
|
||||
#define CDCDSerialPort_INTERRUPT_INTERVAL_HS 8
|
||||
/** Default CDC interrupt endpoint polling rate of Full Speed (16ms). */
|
||||
#define CDCDSerialPort_INTERRUPT_INTERVAL_FS 16
|
||||
/** Default CDC bulk endpoints max packat size (512, for HS actually). */
|
||||
#define CDCDSerialPort_BULK_MAXPACKETSIZE_HS 512
|
||||
/** Default CDC bulk endpoints max packat size (64, for FS actually). */
|
||||
#define CDCDSerialPort_BULK_MAXPACKETSIZE_FS 64
|
||||
/** @}*/
|
||||
|
||||
/** \addtogroup usbd_cdc_serial_events USB Device Serial Port Events
|
||||
* @{
|
||||
*/
|
||||
/** SetControlLineState event, value is changed */
|
||||
#define CDCDSerialPortEvent_SETCONTROLLINESTATE 0
|
||||
/** SetLineCoding event, value is to changed according to return value */
|
||||
#define CDCDSerialPortEvent_SETLINECODING 1
|
||||
/** @}*/
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Types
|
||||
*------------------------------------------------------------------------------*/
|
||||
|
||||
/** Callback function for serial port events */
|
||||
typedef uint32_t (*CDCDSerialPortEventHandler)(uint32_t dwEvent,
|
||||
uint32_t dwParam,
|
||||
void * pArguments);
|
||||
|
||||
/**
|
||||
* Struct for USB CDC virtual COM serial port function.
|
||||
*/
|
||||
typedef struct _CDCDSerialPort {
|
||||
/** USB Driver for the %device */
|
||||
USBDDriver *pUsbd;
|
||||
/** Callback for serial port events */
|
||||
CDCDSerialPortEventHandler fEventHandler;
|
||||
/** Callback arguments */
|
||||
void *pArg;
|
||||
/** USB starting interface index */
|
||||
uint8_t bInterfaceNdx;
|
||||
/** USB number of interfaces */
|
||||
uint8_t bNumInterface;
|
||||
/** USB interrupt IN endpoint address */
|
||||
uint8_t bIntInPIPE;
|
||||
/** USB bulk IN endpoint address */
|
||||
uint8_t bBulkInPIPE;
|
||||
/** USB bulk OUT endpoint address */
|
||||
uint8_t bBulkOutPIPE;
|
||||
|
||||
/** Serial port ControlLineState */
|
||||
uint8_t bControlLineState;
|
||||
/** Serial port SerialState */
|
||||
uint16_t wSerialState;
|
||||
/** Serial port linecoding */
|
||||
CDCLineCoding lineCoding;
|
||||
|
||||
uint8_t bReserved;
|
||||
} CDCDSerialPort;
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Functions
|
||||
*------------------------------------------------------------------------------*/
|
||||
|
||||
extern void CDCDSerialPort_Initialize(CDCDSerialPort *pCdcd,
|
||||
USBDDriver *pUsbd,
|
||||
CDCDSerialPortEventHandler fCallback,
|
||||
void *pArg,
|
||||
uint8_t firstInterface,
|
||||
uint8_t numInterface);
|
||||
|
||||
extern USBGenericDescriptor * CDCDSerialPort_ParseInterfaces(
|
||||
CDCDSerialPort * pCdcd,
|
||||
USBGenericDescriptor * pDescriptors, uint32_t dwLength);
|
||||
|
||||
extern uint32_t CDCDSerialPort_RequestHandler(
|
||||
CDCDSerialPort *pCdcd,
|
||||
const USBGenericRequest *pRequest);
|
||||
|
||||
extern uint32_t CDCDSerialPort_Write(
|
||||
const CDCDSerialPort *pCdcd,
|
||||
void *pData, uint32_t dwSize,
|
||||
TransferCallback fCallback, void* pArg);
|
||||
|
||||
extern uint32_t CDCDSerialPort_Read(
|
||||
const CDCDSerialPort *pCdcd,
|
||||
void *pData, uint32_t dwSize,
|
||||
TransferCallback fCallback, void* pArg);
|
||||
|
||||
extern uint16_t CDCDSerialPort_GetSerialState(
|
||||
const CDCDSerialPort *pCdcd);
|
||||
|
||||
extern void CDCDSerialPort_SetSerialState(
|
||||
CDCDSerialPort *pCdcd,
|
||||
uint16_t wSerialState);
|
||||
|
||||
extern uint8_t CDCDSerialPort_GetControlLineState(
|
||||
const CDCDSerialPort * pCdcd);
|
||||
|
||||
extern void CDCDSerialPort_GetLineCoding(
|
||||
const CDCDSerialPort * pCdcd,
|
||||
CDCLineCoding * pLineCoding);
|
||||
|
||||
/**@}*/
|
||||
#endif /* #ifndef _CDCDSERIALPORT_H_ */
|
||||
@@ -0,0 +1,275 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2010, Atmel Corporation
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the disclaimer below.
|
||||
*
|
||||
* Atmel's name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/** \file
|
||||
*
|
||||
* Definitions and classes for USB CDC class descriptors.
|
||||
*/
|
||||
|
||||
#ifndef _CDCDESCRIPTORS_H_
|
||||
#define _CDCDESCRIPTORS_H_
|
||||
/** \addtogroup usb_cdc
|
||||
*@{
|
||||
*/
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Includes
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Definitions
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/** \addtogroup usb_cdc_ver USB CDC Specification Release Numbers
|
||||
* @{
|
||||
* This section list the CDC Spec. Release Numbers.
|
||||
* - \ref CDCGenericDescriptor_CDC1_10
|
||||
*/
|
||||
|
||||
/** Identify CDC specification version 1.10. */
|
||||
#define CDCGenericDescriptor_CDC1_10 0x0110
|
||||
/** @}*/
|
||||
|
||||
/** \addtogroup usb_cdc_desc_type CDC Descriptro Types
|
||||
* @{
|
||||
* This section lists CDC descriptor types.
|
||||
* - \ref CDCGenericDescriptor_INTERFACE
|
||||
* - \ref CDCGenericDescriptor_ENDPOINT
|
||||
*/
|
||||
/**Indicates that a CDC descriptor applies to an interface. */
|
||||
#define CDCGenericDescriptor_INTERFACE 0x24
|
||||
/** Indicates that a CDC descriptor applies to an endpoint. */
|
||||
#define CDCGenericDescriptor_ENDPOINT 0x25
|
||||
/** @}*/
|
||||
|
||||
/** \addtogroup usb_cdc_desc_subtype CDC Descriptor Subtypes
|
||||
* @{
|
||||
* This section lists CDC descriptor sub types
|
||||
* - \ref CDCGenericDescriptor_HEADER
|
||||
* - \ref CDCGenericDescriptor_CALLMANAGEMENT
|
||||
* - \ref CDCGenericDescriptor_ABSTRACTCONTROLMANAGEMENT
|
||||
* - \ref CDCGenericDescriptor_UNION
|
||||
*/
|
||||
|
||||
/** Header functional descriptor subtype. */
|
||||
#define CDCGenericDescriptor_HEADER 0x00
|
||||
/** Call management functional descriptor subtype. */
|
||||
#define CDCGenericDescriptor_CALLMANAGEMENT 0x01
|
||||
/** Abstract control management descriptor subtype. */
|
||||
#define CDCGenericDescriptor_ABSTRACTCONTROLMANAGEMENT 0x02
|
||||
/** Union descriptor subtype. */
|
||||
#define CDCGenericDescriptor_UNION 0x06
|
||||
/** @}*/
|
||||
|
||||
/** \addtogroup usb_cdc_descriptor USB CDC Device Descriptor Values
|
||||
* @{
|
||||
* This section lists the values for CDC Device Descriptor.
|
||||
* - \ref CDCDeviceDescriptor_CLASS
|
||||
* - \ref CDCDeviceDescriptor_SUBCLASS
|
||||
* - \ref CDCDeviceDescriptor_PROTOCOL
|
||||
*/
|
||||
/** Device class code when using the CDC class. */
|
||||
#define CDCDeviceDescriptor_CLASS 0x02
|
||||
/** Device subclass code when using the CDC class. */
|
||||
#define CDCDeviceDescriptor_SUBCLASS 0x00
|
||||
/** Device protocol code when using the CDC class. */
|
||||
#define CDCDeviceDescriptor_PROTOCOL 0x00
|
||||
/** @}*/
|
||||
|
||||
/** \addtogroup usb_cdc_if_desc USB CDC Communication Interface Descriptor
|
||||
* @{
|
||||
* This section lists the values for CDC Communication Interface Descriptor.
|
||||
* - \ref CDCCommunicationInterfaceDescriptor_CLASS
|
||||
* - \ref CDCCommunicationInterfaceDescriptor_ABSTRACTCONTROLMODEL
|
||||
* - \ref CDCCommunicationInterfaceDescriptor_NOPROTOCOL
|
||||
*/
|
||||
/** Interface class code for a CDC communication class interface. */
|
||||
#define CDCCommunicationInterfaceDescriptor_CLASS 0x02
|
||||
/** Interface subclass code for an Abstract Control Model interface descriptor.
|
||||
*/
|
||||
#define CDCCommunicationInterfaceDescriptor_ABSTRACTCONTROLMODEL 0x02
|
||||
/** Interface protocol code when a CDC communication interface does not
|
||||
implemenent any particular protocol. */
|
||||
#define CDCCommunicationInterfaceDescriptor_NOPROTOCOL 0x00
|
||||
/** @}*/
|
||||
|
||||
/** \addtogroup usb_cdc_data_if USB CDC Data Interface Values
|
||||
* @{
|
||||
* This section lists the values for CDC Data Interface Descriptor.
|
||||
* - \ref CDCDataInterfaceDescriptor_CLASS
|
||||
* - \ref CDCDataInterfaceDescriptor_SUBCLASS
|
||||
* - \ref CDCDataInterfaceDescriptor_NOPROTOCOL
|
||||
*/
|
||||
|
||||
/** Interface class code for a data class interface. */
|
||||
#define CDCDataInterfaceDescriptor_CLASS 0x0A
|
||||
/** Interface subclass code for a data class interface. */
|
||||
#define CDCDataInterfaceDescriptor_SUBCLASS 0x00
|
||||
/** Protocol code for a data class interface which does not implement any
|
||||
particular protocol. */
|
||||
#define CDCDataInterfaceDescriptor_NOPROTOCOL 0x00
|
||||
/** @}*/
|
||||
|
||||
/** \addtogroup usb_cdc_cb_man_desc USB CDC CallManagement Capabilities
|
||||
* @{
|
||||
* This section lists CDC CallManagement Capabilities.
|
||||
* - \ref CDCCallManagementDescriptor_SELFCALLMANAGEMENT
|
||||
* - \ref CDCCallManagementDescriptor_DATACALLMANAGEMENT
|
||||
*/
|
||||
/** Device handles call management itself. */
|
||||
#define CDCCallManagementDescriptor_SELFCALLMANAGEMENT (1 << 0)
|
||||
/** Device can exchange call management information over a Data class interface.
|
||||
*/
|
||||
#define CDCCallManagementDescriptor_DATACALLMANAGEMENT (1 << 1)
|
||||
/** @}*/
|
||||
|
||||
/** \addtogroup usb_cdc_acm USB CDC ACM Capabilities
|
||||
* @{
|
||||
*
|
||||
* This section lists the capabilities of the CDC ACM.
|
||||
* - \ref CDCAbstractControlManagementDescriptor_COMMFEATURE
|
||||
* - \ref CDCAbstractControlManagementDescriptor_LINE
|
||||
* - \ref CDCAbstractControlManagementDescriptor_SENDBREAK
|
||||
* - \ref CDCAbstractControlManagementDescriptor_NETWORKCONNECTION
|
||||
*/
|
||||
|
||||
/** Device supports the request combination of SetCommFeature, ClearCommFeature
|
||||
and GetCommFeature. */
|
||||
#define CDCAbstractControlManagementDescriptor_COMMFEATURE (1 << 0)
|
||||
/** Device supports the request combination of SetLineCoding, GetLineCoding and
|
||||
SetControlLineState. */
|
||||
#define CDCAbstractControlManagementDescriptor_LINE (1 << 1)
|
||||
/** Device supports the SendBreak request. */
|
||||
#define CDCAbstractControlManagementDescriptor_SENDBREAK (1 << 2)
|
||||
/** Device supports the NetworkConnection notification. */
|
||||
#define CDCAbstractControlManagementDescriptor_NETWORKCONNECTION (1 << 3)
|
||||
/** @}*/
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Types
|
||||
*----------------------------------------------------------------------------*/
|
||||
#pragma pack(1)
|
||||
#if defined ( __CC_ARM ) /* Keil ¦ÌVision 4 */
|
||||
#elif defined ( __ICCARM__ ) /* IAR Ewarm */
|
||||
#define __attribute__(...)
|
||||
#define __packed__ packed
|
||||
#elif defined ( __GNUC__ ) /* GCC CS3 */
|
||||
#define __packed__ aligned(1)
|
||||
#endif
|
||||
/**
|
||||
* \typedef CDCHeaderDescriptor
|
||||
* \brief Marks the beginning of the concatenated set of functional descriptors
|
||||
* for the interface.
|
||||
*/
|
||||
typedef struct _CDCHeaderDescriptor {
|
||||
|
||||
/** Size of this descriptor in bytes. */
|
||||
uint8_t bFunctionLength;
|
||||
/** Descriptor type . */
|
||||
uint8_t bDescriptorType;
|
||||
/** Descriptor sub-type . */
|
||||
uint8_t bDescriptorSubtype;
|
||||
/** USB CDC specification release number. */
|
||||
uint16_t bcdCDC;
|
||||
|
||||
} __attribute__ ((__packed__)) CDCHeaderDescriptor; /* GCC */
|
||||
|
||||
/**
|
||||
* \typedef CDCUnionDescriptor
|
||||
* \brief Describes the relationship between a group of interfaces that can
|
||||
* be considered to form a functional unit.
|
||||
*/
|
||||
typedef struct _CDCUnionDescriptor {
|
||||
|
||||
/** Size of the descriptor in bytes. */
|
||||
uint8_t bFunctionLength;
|
||||
/** Descriptor type . */
|
||||
uint8_t bDescriptorType;
|
||||
/** Descriptor subtype . */
|
||||
uint8_t bDescriptorSubtype;
|
||||
/** Number of the master interface for this union. */
|
||||
uint8_t bMasterInterface;
|
||||
/** Number of the first slave interface for this union. */
|
||||
uint8_t bSlaveInterface0;
|
||||
|
||||
} __attribute__ ((__packed__)) CDCUnionDescriptor; /* GCC */
|
||||
|
||||
/**
|
||||
* \typedef CDCCallManagementDescriptor
|
||||
* \brief Describes the processing of calls for the communication class
|
||||
* interface.
|
||||
*/
|
||||
typedef struct _CDCCallManagementDescriptor {
|
||||
|
||||
/** Size of this descriptor in bytes. */
|
||||
uint8_t bFunctionLength;
|
||||
/** Descriptor type . */
|
||||
uint8_t bDescriptorType;
|
||||
/** Descriptor sub-type . */
|
||||
uint8_t bDescriptorSubtype;
|
||||
/** Configuration capabilities
|
||||
\sa usb_cdc_cb_man_desc CDC CallManagement Capabilities. */
|
||||
uint8_t bmCapabilities;
|
||||
/** Interface number of the data class interface used for call management
|
||||
(optional). */
|
||||
uint8_t bDataInterface;
|
||||
|
||||
} __attribute__ ((__packed__)) CDCCallManagementDescriptor; /* GCC */
|
||||
|
||||
/**
|
||||
* \typedef CDCAbstractControlManagementDescriptor
|
||||
* \brief Describes the command supported by the communication interface class
|
||||
* with the Abstract Control Model subclass code.
|
||||
*/
|
||||
typedef struct _CDCAbstractControlManagementDescriptor {
|
||||
|
||||
/** Size of this descriptor in bytes. */
|
||||
uint8_t bFunctionLength;
|
||||
/** Descriptor type . */
|
||||
uint8_t bDescriptorType;
|
||||
/** Descriptor subtype . */
|
||||
uint8_t bDescriptorSubtype;
|
||||
/** Configuration capabilities.
|
||||
\sa usb_cdc_acm CDC ACM Capabilities. */
|
||||
uint8_t bmCapabilities;
|
||||
|
||||
} __attribute__ ((__packed__)) CDCAbstractControlManagementDescriptor; /* GCC */
|
||||
|
||||
#pragma pack()
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Functions
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
/**@}*/
|
||||
#endif /* #ifndef _CDCDESCRIPTORS_H_ */
|
||||
|
||||
@@ -0,0 +1,152 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2008, Atmel Corporation
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the disclaimer below.
|
||||
*
|
||||
* Atmel's name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
*
|
||||
* \section Purpose
|
||||
*
|
||||
* Definitions and methods for USB composite device implement.
|
||||
*
|
||||
* \section Usage
|
||||
*
|
||||
* -# Initialize USB function specified driver ( for MSD currently )
|
||||
* - MSDDFunctionDriver_Initialize()
|
||||
*
|
||||
* -# Initialize USB composite driver and USB driver
|
||||
* - CDCHIDDDriver_Initialize()
|
||||
*
|
||||
* -# Handle and dispach USB requests
|
||||
* - CDCHIDDDriver_RequestHandler()
|
||||
*
|
||||
* -# Try starting a remote wake-up sequence
|
||||
* - CDCHIDDDriver_RemoteWakeUp()
|
||||
*/
|
||||
|
||||
#ifndef CDCHIDDDRIVER_H
|
||||
#define CDCHIDDDRIVER_H
|
||||
/** \addtogroup usbd_composite_cdchid
|
||||
*@{
|
||||
*/
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
* Headers
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#include <USBRequests.h>
|
||||
#include <CDCDescriptors.h>
|
||||
#include <HIDDescriptors.h>
|
||||
#include "USBD.h"
|
||||
#include <USBDDriver.h>
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
* Definitions
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
/** \addtogroup usbd_cdc_hid_desc USB CDC(Serial) + HID(Kbd) Descriptors define
|
||||
* @{
|
||||
*/
|
||||
/** Number of interfaces of the device */
|
||||
#define CDCHIDDDriverDescriptors_NUMINTERFACE 3
|
||||
/** Number of the CDC interface. */
|
||||
#define CDCHIDDDriverDescriptors_CDC_INTERFACE 0
|
||||
/** Number of the HID interface. */
|
||||
#define CDCHIDDDriverDescriptors_HID_INTERFACE 2
|
||||
/** @}*/
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
* Types
|
||||
*---------------------------------------------------------------------------*/
|
||||
#pragma pack(1)
|
||||
#if defined ( __CC_ARM ) /* Keil ¦ÌVision 4 */
|
||||
#elif defined ( __ICCARM__ ) /* IAR Ewarm */
|
||||
#define __attribute__(...)
|
||||
#define __packed__ packed
|
||||
#elif defined ( __GNUC__ ) /* GCC CS3 */
|
||||
#define __packed__ aligned(1)
|
||||
#endif
|
||||
/**
|
||||
* \typedef CdcHidDriverConfigurationDescriptors
|
||||
* \brief Configuration descriptor list for a device implementing a
|
||||
* composite driver.
|
||||
*/
|
||||
typedef struct _CdcHidDriverConfigurationDescriptors {
|
||||
|
||||
/** Standard configuration descriptor. */
|
||||
USBConfigurationDescriptor configuration;
|
||||
|
||||
/* --- CDC 0 */
|
||||
/** IAD 0 */
|
||||
USBInterfaceAssociationDescriptor cdcIAD0;
|
||||
/** Communication interface descriptor */
|
||||
USBInterfaceDescriptor cdcCommunication0;
|
||||
/** CDC header functional descriptor. */
|
||||
CDCHeaderDescriptor cdcHeader0;
|
||||
/** CDC call management functional descriptor. */
|
||||
CDCCallManagementDescriptor cdcCallManagement0;
|
||||
/** CDC abstract control management functional descriptor. */
|
||||
CDCAbstractControlManagementDescriptor cdcAbstractControlManagement0;
|
||||
/** CDC union functional descriptor (with one slave interface). */
|
||||
CDCUnionDescriptor cdcUnion0;
|
||||
/** Notification endpoint descriptor. */
|
||||
USBEndpointDescriptor cdcNotification0;
|
||||
/** Data interface descriptor. */
|
||||
USBInterfaceDescriptor cdcData0;
|
||||
/** Data OUT endpoint descriptor. */
|
||||
USBEndpointDescriptor cdcDataOut0;
|
||||
/** Data IN endpoint descriptor. */
|
||||
USBEndpointDescriptor cdcDataIn0;
|
||||
|
||||
/* --- HID */
|
||||
USBInterfaceDescriptor hidInterface;
|
||||
HIDDescriptor1 hid;
|
||||
USBEndpointDescriptor hidInterruptIn;
|
||||
USBEndpointDescriptor hidInterruptOut;
|
||||
|
||||
} __attribute__ ((__packed__)) CdcHidDriverConfigurationDescriptors;
|
||||
|
||||
#pragma pack()
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
* Exported functions
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
/* -CDCHID */
|
||||
extern void CDCHIDDDriver_Initialize(
|
||||
const USBDDriverDescriptors * pDescriptors);
|
||||
|
||||
extern void CDCHIDDDriver_ConfigurationChangedHandler(uint8_t cfgnum);
|
||||
|
||||
extern void CDCHIDDDriver_RequestHandler(const USBGenericRequest *request);
|
||||
|
||||
extern void CDCHIDDDriver_RemoteWakeUp(void);
|
||||
|
||||
/**@}*/
|
||||
#endif //#ifndef CDCHIDDDRIVER_H
|
||||
|
||||
@@ -0,0 +1,155 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2008, Atmel Corporation
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the disclaimer below.
|
||||
*
|
||||
* Atmel's name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
*
|
||||
* \section Purpose
|
||||
*
|
||||
* Definitions and methods for USB CDCMSD device implement.
|
||||
*
|
||||
* \section Usage
|
||||
*
|
||||
* -# Initialize USB function specified driver ( for MSD currently )
|
||||
* - MSDDFunctionDriver_Initialize
|
||||
*
|
||||
* -# Initialize USB CDCMSD driver and USB driver
|
||||
* - CDCMSDDDriver_Initialize
|
||||
*
|
||||
* -# Handle and dispach USB requests
|
||||
* - CDCMSDDDriver_RequestHandler
|
||||
*
|
||||
* -# Try starting a remote wake-up sequence
|
||||
* - CDCMSDDDriver_RemoteWakeUp
|
||||
*/
|
||||
|
||||
#ifndef CDCMSDDDRIVER_H
|
||||
#define CDCMSDDDRIVER_H
|
||||
/** \addtogroup usbd_composite_cdcmsd
|
||||
*@{
|
||||
*/
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
* Headers
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#include <USBRequests.h>
|
||||
#include <CDCDescriptors.h>
|
||||
#include <MSDescriptors.h>
|
||||
#include <MSDLun.h>
|
||||
#include "USBD.h"
|
||||
#include <USBDDriver.h>
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
* Consts
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
/** \addtogroup usbd_cdc_msd_desc USB CDC(Serial) + MS Descriptors define
|
||||
* @{
|
||||
*/
|
||||
/** Number of interfaces of the device */
|
||||
#define CDCMSDDriverDescriptors_NUMINTERFACE 3
|
||||
/** Number of the CDC interface. */
|
||||
#define CDCMSDDriverDescriptors_CDC_INTERFACE 0
|
||||
/** Number of the HID interface. */
|
||||
#define CDCMSDDriverDescriptors_MSD_INTERFACE 2
|
||||
/** @}*/
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
* Types
|
||||
*---------------------------------------------------------------------------*/
|
||||
#pragma pack(1)
|
||||
#if defined ( __CC_ARM ) /* Keil ¦ÌVision 4 */
|
||||
#elif defined ( __ICCARM__ ) /* IAR Ewarm */
|
||||
#define __attribute__(...)
|
||||
#define __packed__ packed
|
||||
#elif defined ( __GNUC__ ) /* GCC CS3 */
|
||||
#define __packed__ aligned(1)
|
||||
#endif
|
||||
/**
|
||||
* \typedef CDCMSDDriverConfigurationDescriptors
|
||||
* \brief Configuration descriptor list for a device implementing
|
||||
* a CDCMSD driver.
|
||||
*/
|
||||
typedef struct _CDCMSDDriverConfigurationDescriptors {
|
||||
|
||||
/** Standard configuration descriptor. */
|
||||
USBConfigurationDescriptor configuration;
|
||||
|
||||
/* --- CDC 0 */
|
||||
/** IAD 0 */
|
||||
USBInterfaceAssociationDescriptor cdcIAD0;
|
||||
/** Communication interface descriptor */
|
||||
USBInterfaceDescriptor cdcCommunication0;
|
||||
/** CDC header functional descriptor. */
|
||||
CDCHeaderDescriptor cdcHeader0;
|
||||
/** CDC call management functional descriptor. */
|
||||
CDCCallManagementDescriptor cdcCallManagement0;
|
||||
/** CDC abstract control management functional descriptor. */
|
||||
CDCAbstractControlManagementDescriptor cdcAbstractControlManagement0;
|
||||
/** CDC union functional descriptor (with one slave interface). */
|
||||
CDCUnionDescriptor cdcUnion0;
|
||||
/** Notification endpoint descriptor. */
|
||||
USBEndpointDescriptor cdcNotification0;
|
||||
/** Data interface descriptor. */
|
||||
USBInterfaceDescriptor cdcData0;
|
||||
/** Data OUT endpoint descriptor. */
|
||||
USBEndpointDescriptor cdcDataOut0;
|
||||
/** Data IN endpoint descriptor. */
|
||||
USBEndpointDescriptor cdcDataIn0;
|
||||
|
||||
/* --- MSD */
|
||||
/** Mass storage interface descriptor. */
|
||||
USBInterfaceDescriptor msdInterface;
|
||||
/** Bulk-out endpoint descriptor. */
|
||||
USBEndpointDescriptor msdBulkOut;
|
||||
/** Bulk-in endpoint descriptor. */
|
||||
USBEndpointDescriptor msdBulkIn;
|
||||
|
||||
} __attribute__ ((__packed__)) CDCMSDDriverConfigurationDescriptors;
|
||||
|
||||
#pragma pack()
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
* Exported functions
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
/* -CDCMSD */
|
||||
extern void CDCMSDDriver_Initialize(
|
||||
const USBDDriverDescriptors *pDescriptors,
|
||||
MSDLun *pLuns, unsigned char numLuns);
|
||||
|
||||
extern void CDCMSDDriver_ConfigurationChangedHandler(unsigned char cfgnum);
|
||||
|
||||
extern void CDCMSDDriver_RequestHandler(const USBGenericRequest *request);
|
||||
|
||||
/**@}*/
|
||||
#endif /* #ifndef CDCMSDDDRIVER_H */
|
||||
|
||||
@@ -0,0 +1,111 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2010, Atmel Corporation
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the disclaimer below.
|
||||
*
|
||||
* Atmel's name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* Definitions and methods for USB CDC Notifications.
|
||||
*/
|
||||
|
||||
#ifndef _CDCNOTIFICATIONS_H_
|
||||
#define _CDCNOTIFICATIONS_H_
|
||||
/** \addtogroup usb_cdc
|
||||
*@{
|
||||
*/
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Includes
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Definitions
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/** \addtogroup cdc_serial_states CDC SerialState bits
|
||||
* @{
|
||||
* This page lists the bit map for CDC Serial States.
|
||||
*
|
||||
* - \ref CDCSerialState_RXDRIVER
|
||||
* - \ref CDCSerialState_TXCARRIER
|
||||
* - \ref CDCSerialState_BREAK
|
||||
* - \ref CDCSerialState_RINGSIGNAL
|
||||
* - \ref CDCSerialState_FRAMING
|
||||
* - \ref CDCSerialState_PARITY
|
||||
* - \ref CDCSerialState_OVERRUN
|
||||
*/
|
||||
|
||||
/** Indicates the receiver carrier signal is present */
|
||||
#define CDCSerialState_RXDRIVER (1 << 0)
|
||||
/** Indicates the transmission carrier signal is present */
|
||||
#define CDCSerialState_TXCARRIER (1 << 1)
|
||||
/** Indicates a break has been detected */
|
||||
#define CDCSerialState_BREAK (1 << 2)
|
||||
/** Indicates a ring signal has been detected */
|
||||
#define CDCSerialState_RINGSIGNAL (1 << 3)
|
||||
/** Indicates a framing error has occured */
|
||||
#define CDCSerialState_FRAMING (1 << 4)
|
||||
/** Indicates a parity error has occured */
|
||||
#define CDCSerialState_PARITY (1 << 5)
|
||||
/** Indicates a data overrun error has occured */
|
||||
#define CDCSerialState_OVERRUN (1 << 6)
|
||||
/** @}*/
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Types
|
||||
*----------------------------------------------------------------------------*/
|
||||
#pragma pack(1)
|
||||
#if defined ( __CC_ARM ) /* Keil ¦ÌVision 4 */
|
||||
#elif defined ( __ICCARM__ ) /* IAR Ewarm */
|
||||
#define __attribute__(...)
|
||||
#define __packed__ packed
|
||||
#elif defined ( __GNUC__ ) /* GCC CS3 */
|
||||
#define __packed__ aligned(1)
|
||||
#endif
|
||||
/** USB CDC SerialState struct (bitmap) */
|
||||
typedef struct _CDCSerialState {
|
||||
uint16_t bRxCarrier:1, /**< State of receive carrier detection (V2.4 signal
|
||||
109 and RS-232 signal DCD) */
|
||||
bTxCarrier:1, /**< State of transmission carrier */
|
||||
bBreak:1, /**< State of break detection */
|
||||
bRingSignal:1, /**< State of ring signal */
|
||||
bFraming:1, /**< Framing error */
|
||||
bParity:1, /**< Parity error */
|
||||
bOverRun:1, /**< Received data discarded due to overrun error */
|
||||
reserved:9; /**< Reserved */
|
||||
} __attribute__ ((__packed__)) CDCSerialState;
|
||||
|
||||
#pragma pack()
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Functions
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/**@}*/
|
||||
#endif /* #ifndef _CDCNOTIFICATIONS_H_ */
|
||||
|
||||
@@ -0,0 +1,183 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2010, Atmel Corporation
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the disclaimer below.
|
||||
*
|
||||
* Atmel's name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/** \file
|
||||
*
|
||||
* Definitions and classes for USB CDC class requests
|
||||
* (mostly for ACM).
|
||||
*
|
||||
* \section CDCLineCoding
|
||||
*
|
||||
* -# Initialize a CDCLineCoding instance using CDCLineCoding_Initialize.
|
||||
* -# Send a CDCLineCoding object to the host in response to a GetLineCoding
|
||||
* request.
|
||||
* -# Receive a CDCLineCoding object from the host after a SetLineCoding
|
||||
* request.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _CDCREQUESTS_H_
|
||||
#define _CDCREQUESTS_H_
|
||||
/** \addtogroup usb_cdc
|
||||
*@{
|
||||
*/
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Includes
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <USBRequests.h>
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Definitions
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/** \addtogroup usb_cdc_request USB CDC Request Codes
|
||||
* @{
|
||||
* This section lists USB CDC Request Codes.
|
||||
* - \ref CDCGenericRequest_SETLINECODING
|
||||
* - \ref CDCGenericRequest_GETLINECODING
|
||||
* - \ref CDCGenericRequest_SETCONTROLLINESTATE
|
||||
*/
|
||||
|
||||
/** SetLineCoding request code. */
|
||||
#define CDCGenericRequest_SETLINECODING 0x20
|
||||
/** GetLineCoding request code. */
|
||||
#define CDCGenericRequest_GETLINECODING 0x21
|
||||
/** SetControlLineState request code. */
|
||||
#define CDCGenericRequest_SETCONTROLLINESTATE 0x22
|
||||
/** @}*/
|
||||
|
||||
/** \addtogroup usb_cdc_ctrl_line_state USB CDC ControlLineState bitmap
|
||||
* @{
|
||||
* This section lists CDC ControlLineState bitmap.
|
||||
* - \ref CDCControlLineState_DTR, CDCControlLineState_DTE_PRESENT
|
||||
* - \ref CDCControlLineState_RTS, CDCControlLineState_CARRIER_ON
|
||||
*/
|
||||
/** Indicates to DCE if DTE is present or not. */
|
||||
#define CDCControlLineState_DTE_PRESENT (1 << 0)
|
||||
/** RS232 signal DTR: Data Terminal Ready. */
|
||||
#define CDCControlLineState_DTR (1 << 0)
|
||||
/** Carrier control for half duplex modems. */
|
||||
#define CDCControlLineState_CARRIER_ON (1 << 1)
|
||||
/** RS232 signal RTS: Request to send. */
|
||||
#define CDCControlLineState_RTS (1 << 1)
|
||||
/** @}*/
|
||||
|
||||
/** \addtogroup usb_cdc_stop USB CDC LineCoding StopBits
|
||||
* @{
|
||||
* This section lists Stop Bits for CDC Line Coding.
|
||||
* - \ref CDCLineCoding_ONESTOPBIT
|
||||
* - \ref CDCLineCoding_ONE5STOPBIT
|
||||
* - \ref CDCLineCoding_TWOSTOPBITS
|
||||
*/
|
||||
/** The transmission protocol uses one stop bit. */
|
||||
#define CDCLineCoding_ONESTOPBIT 0
|
||||
/** The transmission protocol uses 1.5 stop bit. */
|
||||
#define CDCLineCoding_ONE5STOPBIT 1
|
||||
/** The transmissin protocol uses two stop bits. */
|
||||
#define CDCLineCoding_TWOSTOPBITS 2
|
||||
/** @}*/
|
||||
|
||||
/** \addtogroup usb_cdc_parity USB CDC LineCoding ParityCheckings
|
||||
* @{
|
||||
* This section lists Parity checkings for CDC Line Coding.
|
||||
* - \ref CDCLineCoding_NOPARITY
|
||||
* - \ref CDCLineCoding_ODDPARITY
|
||||
* - \ref CDCLineCoding_EVENPARITY
|
||||
* - \ref CDCLineCoding_MARKPARITY
|
||||
* - \ref CDCLineCoding_SPACEPARITY
|
||||
*/
|
||||
/** No parity checking. */
|
||||
#define CDCLineCoding_NOPARITY 0
|
||||
/** Odd parity checking. */
|
||||
#define CDCLineCoding_ODDPARITY 1
|
||||
/** Even parity checking. */
|
||||
#define CDCLineCoding_EVENPARITY 2
|
||||
/** Mark parity checking. */
|
||||
#define CDCLineCoding_MARKPARITY 3
|
||||
/** Space parity checking. */
|
||||
#define CDCLineCoding_SPACEPARITY 4
|
||||
/** @}*/
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Types
|
||||
*----------------------------------------------------------------------------*/
|
||||
#pragma pack(1)
|
||||
#if defined ( __CC_ARM ) /* Keil ¦ÌVision 4 */
|
||||
#elif defined ( __ICCARM__ ) /* IAR Ewarm */
|
||||
#define __attribute__(...)
|
||||
#define __packed__ packed
|
||||
#elif defined ( __GNUC__ ) /* GCC CS3 */
|
||||
#define __packed__ aligned(1)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \typedef CDCLineCoding
|
||||
* \brief Format of the data returned when a GetLineCoding request is received.
|
||||
*/
|
||||
typedef struct _CDCLineCoding {
|
||||
|
||||
/** Data terminal rate in bits per second. */
|
||||
uint32_t dwDTERate;
|
||||
/** Number of stop bits.
|
||||
\sa usb_cdc_stop CDC LineCoding StopBits. */
|
||||
uint8_t bCharFormat;
|
||||
/** Type of parity checking used.
|
||||
\sa usb_cdc_parity CDC LineCoding ParityCheckings. */
|
||||
uint8_t bParityType;
|
||||
/** Number of data bits (5, 6, 7, 8 or 16). */
|
||||
uint8_t bDataBits;
|
||||
|
||||
} __attribute__ ((__packed__)) CDCLineCoding; /* GCC */
|
||||
|
||||
#pragma pack()
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Functions
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
extern uint8_t CDCSetControlLineStateRequest_IsDtePresent(
|
||||
const USBGenericRequest *request);
|
||||
|
||||
extern uint8_t CDCSetControlLineStateRequest_ActivateCarrier(
|
||||
const USBGenericRequest *request);
|
||||
|
||||
extern void CDCLineCoding_Initialize(CDCLineCoding *lineCoding,
|
||||
uint32_t bitrate,
|
||||
uint8_t stopbits,
|
||||
uint8_t parity,
|
||||
uint8_t databits);
|
||||
|
||||
|
||||
/**@}*/
|
||||
#endif /* #define _CDCREQUESTS_H_ */
|
||||
|
||||
@@ -0,0 +1,157 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2008, Atmel Corporation
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the disclaimer below.
|
||||
*
|
||||
* Atmel's name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
*
|
||||
* \section Purpose
|
||||
*
|
||||
* Definitions and methods for USB composite device implement.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef DUALCDCDDRIVER_H
|
||||
#define DUALCDCDDRIVER_H
|
||||
/** \addtogroup usbd_composite_cdccdc
|
||||
*@{
|
||||
*/
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
* Headers
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#include <USBRequests.h>
|
||||
#include <CDCDescriptors.h>
|
||||
|
||||
#include "USBD.h"
|
||||
#include <CDCDSerialPort.h>
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
* Defines
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
/** \addtogroup usbd_composite_cdccdc_desc
|
||||
* The driver uses these interface numbers in configuration descriptor.
|
||||
* @{
|
||||
*/
|
||||
/** Number of interfaces of the device */
|
||||
#define DUALCDCDDriverDescriptors_NUMINTERFACE 4
|
||||
/** Number of the CDC0 interface. */
|
||||
#define DUALCDCDDriverDescriptors_INTERFACENUM0 0
|
||||
/** Number of the CDC1 interface. */
|
||||
#define DUALCDCDDriverDescriptors_INTERFACENUM1 2
|
||||
/** @}*/
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
* Types
|
||||
*---------------------------------------------------------------------------*/
|
||||
#pragma pack(1)
|
||||
#if defined ( __CC_ARM ) /* Keil ¦ÌVision 4 */
|
||||
#elif defined ( __ICCARM__ ) /* IAR Ewarm */
|
||||
#define __attribute__(...)
|
||||
#define __packed__ packed
|
||||
#elif defined ( __GNUC__ ) /* GCC CS3 */
|
||||
#define __packed__ aligned(1)
|
||||
#endif
|
||||
/**
|
||||
* \typedef DualCdcDriverConfigurationDescriptors
|
||||
* \brief Configuration descriptor list for a device implementing a
|
||||
* dual CDC serial composite driver.
|
||||
*/
|
||||
typedef struct _DualCdcDriverConfigurationDescriptors {
|
||||
|
||||
/** Standard configuration descriptor. */
|
||||
USBConfigurationDescriptor configuration;
|
||||
|
||||
/* --- CDC 0 */
|
||||
/** IAD 0 */
|
||||
USBInterfaceAssociationDescriptor cdcIAD0;
|
||||
/** Communication interface descriptor */
|
||||
USBInterfaceDescriptor cdcCommunication0;
|
||||
/** CDC header functional descriptor. */
|
||||
CDCHeaderDescriptor cdcHeader0;
|
||||
/** CDC call management functional descriptor. */
|
||||
CDCCallManagementDescriptor cdcCallManagement0;
|
||||
/** CDC abstract control management functional descriptor. */
|
||||
CDCAbstractControlManagementDescriptor cdcAbstractControlManagement0;
|
||||
/** CDC union functional descriptor (with one slave interface). */
|
||||
CDCUnionDescriptor cdcUnion0;
|
||||
/** Notification endpoint descriptor. */
|
||||
USBEndpointDescriptor cdcNotification0;
|
||||
/** Data interface descriptor. */
|
||||
USBInterfaceDescriptor cdcData0;
|
||||
/** Data OUT endpoint descriptor. */
|
||||
USBEndpointDescriptor cdcDataOut0;
|
||||
/** Data IN endpoint descriptor. */
|
||||
USBEndpointDescriptor cdcDataIn0;
|
||||
|
||||
/* --- CDC 1 */
|
||||
/** IAD 1 */
|
||||
USBInterfaceAssociationDescriptor cdcIAD1;
|
||||
/** Communication interface descriptor */
|
||||
USBInterfaceDescriptor cdcCommunication1;
|
||||
/** CDC header functional descriptor. */
|
||||
CDCHeaderDescriptor cdcHeader1;
|
||||
/** CDC call management functional descriptor. */
|
||||
CDCCallManagementDescriptor cdcCallManagement1;
|
||||
/** CDC abstract control management functional descriptor. */
|
||||
CDCAbstractControlManagementDescriptor cdcAbstractControlManagement1;
|
||||
/** CDC union functional descriptor (with one slave interface). */
|
||||
CDCUnionDescriptor cdcUnion1;
|
||||
/** Notification endpoint descriptor. */
|
||||
USBEndpointDescriptor cdcNotification1;
|
||||
/** Data interface descriptor. */
|
||||
USBInterfaceDescriptor cdcData1;
|
||||
/** Data OUT endpoint descriptor. */
|
||||
USBEndpointDescriptor cdcDataOut1;
|
||||
/** Data IN endpoint descriptor. */
|
||||
USBEndpointDescriptor cdcDataIn1;
|
||||
|
||||
} __attribute__ ((__packed__)) DualCdcDriverConfigurationDescriptors;
|
||||
|
||||
#pragma pack()
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
* Exported functions
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
/* -DUALCDC */
|
||||
extern void DUALCDCDDriver_Initialize(
|
||||
const USBDDriverDescriptors* pDescriptors);
|
||||
|
||||
extern void DUALCDCDDriver_ConfigurationChangeHandler(uint8_t cfgnum);
|
||||
|
||||
extern void DUALCDCDDriver_RequestHandler(const USBGenericRequest *request);
|
||||
|
||||
extern CDCDSerialPort* DUALCDCDDriver_GetSerialPort(uint32_t port);
|
||||
|
||||
/**@}*/
|
||||
#endif /* #ifndef DUALCDCDDRIVER_H */
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,118 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2008, Atmel Corporation
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the disclaimer below.
|
||||
*
|
||||
* Atmel's name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* \section Purpose
|
||||
*
|
||||
* SCSI commands implementation.
|
||||
*
|
||||
* section Usage
|
||||
*
|
||||
* -# After a CBW is received from host, use SBC_GetCommandInformation to check
|
||||
* if the command is supported, and get the command length and type
|
||||
* information before processing it.
|
||||
* -# Then SBC_ProcessCommand can be used to handle a valid command, to
|
||||
* perform the command operations.
|
||||
* -# SBC_UpdateSenseData is used to update the sense data that will be sent
|
||||
* to host.
|
||||
*/
|
||||
|
||||
#ifndef SBCMETHODS_H
|
||||
#define SBCMETHODS_H
|
||||
|
||||
/** \addtogroup usbd_msd
|
||||
*@{
|
||||
*/
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Headers
|
||||
*------------------------------------------------------------------------------*/
|
||||
|
||||
#include "SBC.h"
|
||||
#include "MSDLun.h"
|
||||
#include "MSDDStateMachine.h"
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Definitions
|
||||
*------------------------------------------------------------------------------*/
|
||||
|
||||
/** \addtogroup usbd_sbc_command_state SBC Command States
|
||||
* @{
|
||||
* This page lists the possible states of a SBC command.
|
||||
*
|
||||
* \section States
|
||||
* - SBC_STATE_READ
|
||||
* - SBC_STATE_WAIT_READ
|
||||
* - SBC_STATE_WRITE
|
||||
* - SBC_STATE_WAIT_WRITE
|
||||
* - SBC_STATE_NEXT_BLOCK
|
||||
*/
|
||||
|
||||
/** Start of reading bulk data */
|
||||
#define SBC_STATE_READ 0x01
|
||||
/** Waiting for the bulk data reading complete */
|
||||
#define SBC_STATE_WAIT_READ 0x02
|
||||
/** Read error state */
|
||||
#define SBC_STATE_READ_ERROR 0x03
|
||||
/** Start next read block */
|
||||
#define SBC_STATE_NEXT_READ 0x04
|
||||
/** Start writing bulk data to host */
|
||||
#define SBC_STATE_WRITE 0x05
|
||||
/** Waiting for the bulk data sending complete */
|
||||
#define SBC_STATE_WAIT_WRITE 0x06
|
||||
/** Write error state */
|
||||
#define SBC_STATE_WRITE_ERROR 0x07
|
||||
/** Start next write block */
|
||||
#define SBC_STATE_NEXT_WRITE 0x08
|
||||
/** Start next command block */
|
||||
#define SBC_STATE_NEXT_BLOCK 0x09
|
||||
/** @}*/
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Exported functions
|
||||
*------------------------------------------------------------------------------*/
|
||||
|
||||
void SBC_UpdateSenseData(SBCRequestSenseData *requestSenseData,
|
||||
unsigned char senseKey,
|
||||
unsigned char additionalSenseCode,
|
||||
unsigned char additionalSenseCodeQualifier);
|
||||
|
||||
unsigned char SBC_GetCommandInformation(void *command,
|
||||
unsigned int *length,
|
||||
unsigned char *type,
|
||||
MSDLun *lun);
|
||||
|
||||
unsigned char SBC_ProcessCommand(MSDLun *lun,
|
||||
MSDCommandState *commandState);
|
||||
|
||||
/**@}*/
|
||||
|
||||
#endif /*#ifndef SBCMETHODS_H */
|
||||
|
||||
|
||||
@@ -0,0 +1,278 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2008, Atmel Corporation
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the disclaimer below.
|
||||
*
|
||||
* Atmel's name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
*
|
||||
* \section Purpose
|
||||
*
|
||||
* Collection of methods for using the USB device controller on AT91
|
||||
* microcontrollers.
|
||||
*
|
||||
* \section Usage
|
||||
*
|
||||
* Please refer to the corresponding application note.
|
||||
* - \ref usbd_framework AT91 USB device framework
|
||||
* - \ref usbd_api USBD API
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef USBD_H
|
||||
#define USBD_H
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Headers
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
#include "USBDescriptors.h"
|
||||
#include "USBRequests.h"
|
||||
|
||||
#include "USBLib_Types.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Definitions
|
||||
*------------------------------------------------------------------------------*/
|
||||
|
||||
/* Define attribute */
|
||||
#if defined ( __CC_ARM ) /* Keil ¦ÌVision 4 */
|
||||
#define WEAK __attribute__ ((weak))
|
||||
#elif defined ( __ICCARM__ ) /* IAR Ewarm 5.41+ */
|
||||
#define WEAK __weak
|
||||
#elif defined ( __GNUC__ ) /* GCC CS3 2009q3-68 */
|
||||
#define WEAK __attribute__ ((weak))
|
||||
#endif
|
||||
|
||||
/* Define NO_INIT attribute */
|
||||
#if defined ( __CC_ARM )
|
||||
#define NO_INIT
|
||||
#elif defined ( __ICCARM__ )
|
||||
#define NO_INIT __no_init
|
||||
#elif defined ( __GNUC__ )
|
||||
#define NO_INIT
|
||||
#endif
|
||||
|
||||
|
||||
/** \addtogroup usbd_interface
|
||||
*@{*/
|
||||
|
||||
/**
|
||||
* \addtogroup usbd_rc USB device API return codes
|
||||
* @{
|
||||
* This section lists the return codes for the USB device driver API
|
||||
* - \ref USBD_STATUS_SUCCESS
|
||||
* - \ref USBD_STATUS_LOCKED
|
||||
* - \ref USBD_STATUS_ABORTED
|
||||
* - \ref USBD_STATUS_RESET
|
||||
*/
|
||||
|
||||
/** Indicates the operation was successful. */
|
||||
#define USBD_STATUS_SUCCESS USBRC_SUCCESS
|
||||
/** Endpoint/device is already busy. */
|
||||
#define USBD_STATUS_LOCKED USBRC_BUSY
|
||||
/** Operation has been aborted (error or stall). */
|
||||
#define USBD_STATUS_ABORTED USBRC_ABORTED
|
||||
/** Operation has been canceled (by user). */
|
||||
#define USBD_STATUS_CANCELED USBRC_CANCELED
|
||||
/** Operation has been aborted because the device init/reset/un-configure. */
|
||||
#define USBD_STATUS_RESET USBRC_RESET
|
||||
/** Part ot operation successfully done. */
|
||||
#define USBD_STATUS_PARTIAL_DONE USBRC_PARTIAL_DONE
|
||||
/** Operation failed because parameter error */
|
||||
#define USBD_STATUS_INVALID_PARAMETER USBRC_PARAM_ERR
|
||||
/** Operation failed because in unexpected state */
|
||||
#define USBD_STATUS_WRONG_STATE USBRC_STATE_ERR
|
||||
/** Operation failed because SW not supported */
|
||||
#define USBD_STATUS_SW_NOT_SUPPORTED USBRC_SW_NOT_SUPPORTED
|
||||
/** Operation failed because HW not supported */
|
||||
#define USBD_STATUS_HW_NOT_SUPPORTED USBRC_HW_NOT_SUPPORTED
|
||||
/** @}*/
|
||||
|
||||
/** \addtogroup usbd_states USB device states
|
||||
* @{
|
||||
* This section lists the device states of the USB device driver.
|
||||
* - \ref USBD_STATE_SUSPENDED
|
||||
* - \ref USBD_STATE_ATTACHED
|
||||
* - \ref USBD_STATE_POWERED
|
||||
* - \ref USBD_STATE_DEFAULT
|
||||
* - \ref USBD_STATE_ADDRESS
|
||||
* - \ref USBD_STATE_CONFIGURED
|
||||
*/
|
||||
|
||||
/** The device is currently suspended. */
|
||||
#define USBD_STATE_SUSPENDED 0
|
||||
/** USB cable is plugged into the device. */
|
||||
#define USBD_STATE_ATTACHED 1
|
||||
/** Host is providing +5V through the USB cable. */
|
||||
#define USBD_STATE_POWERED 2
|
||||
/** Device has been reset. */
|
||||
#define USBD_STATE_DEFAULT 3
|
||||
/** The device has been given an address on the bus. */
|
||||
#define USBD_STATE_ADDRESS 4
|
||||
/** A valid configuration has been selected. */
|
||||
#define USBD_STATE_CONFIGURED 5
|
||||
/** @}*/
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Types
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* \brief Buffer struct used for multi-buffer-listed transfer.
|
||||
*
|
||||
* The driver can process 255 bytes of buffers or buffer list window.
|
||||
*/
|
||||
typedef struct _USBDTransferBuffer {
|
||||
/** Pointer to frame buffer */
|
||||
uint8_t * pBuffer;
|
||||
/** Size of the frame (up to 64K-1) */
|
||||
uint16_t size;
|
||||
/** Bytes transferred */
|
||||
uint16_t transferred;
|
||||
/** Bytes in FIFO */
|
||||
uint16_t buffered;
|
||||
/** Bytes remaining */
|
||||
uint16_t remaining;
|
||||
} USBDTransferBuffer;
|
||||
|
||||
#pragma pack(1)
|
||||
#if defined ( __CC_ARM ) /* Keil ¦ÌVision 4 */
|
||||
#elif defined ( __ICCARM__ ) /* IAR Ewarm 5.41+ */
|
||||
#define __attribute__(...)
|
||||
#elif defined ( __GNUC__ ) /* GCC CS3 2009q3-68 */
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \brief Struct used for USBD DMA Link List Transfer Descriptor, must be 16-bytes
|
||||
* aligned.
|
||||
*
|
||||
* (For USB, DMA transfer is linked to EPs and FIFO address is EP defined)
|
||||
*/
|
||||
typedef struct _USBDDmaDescriptor {
|
||||
/** Pointer to Next Descriptor */
|
||||
void* pNxtDesc;
|
||||
/** Pointer to data buffer address */
|
||||
void* pDataAddr;
|
||||
/** DMA Control setting register value */
|
||||
uint32_t ctrlSettings:8, /** Control settings */
|
||||
reserved:8, /** Not used */
|
||||
bufferLength:16; /** Length of buffer */
|
||||
/** Loaded to DMA register, OK to modify */
|
||||
uint32_t used;
|
||||
} __attribute__((aligned(16))) USBDDmaDescriptor;
|
||||
|
||||
#pragma pack()
|
||||
|
||||
/**
|
||||
* Callback used by transfer functions (USBD_Read & USBD_Write) to notify
|
||||
* that a transaction is complete.
|
||||
*/
|
||||
typedef void (*TransferCallback)(void *pArg,
|
||||
uint8_t status,
|
||||
uint32_t transferred,
|
||||
uint32_t remaining);
|
||||
|
||||
/**
|
||||
* Callback used by MBL transfer functions (USBD_Read & USBD_Write) to notify
|
||||
* that a transaction is complete.
|
||||
* \param pArg Pointer to callback arguments.
|
||||
* \param status USBD status.
|
||||
*/
|
||||
typedef void (*MblTransferCallback)(void *pArg,
|
||||
uint8_t status);
|
||||
|
||||
/**@}*/
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Exported functions
|
||||
*------------------------------------------------------------------------------*/
|
||||
|
||||
//extern void USBD_IrqHandler(void);
|
||||
|
||||
extern void USBD_Init(void);
|
||||
|
||||
extern void USBD_ConfigureSpeed(uint8_t forceFS);
|
||||
|
||||
extern void USBD_Connect(void);
|
||||
|
||||
extern void USBD_Disconnect(void);
|
||||
|
||||
extern uint8_t USBD_Write(
|
||||
uint8_t bEndpoint,
|
||||
const void *pData,
|
||||
uint32_t size,
|
||||
TransferCallback callback,
|
||||
void *pArg);
|
||||
|
||||
extern uint8_t USBD_Read(
|
||||
uint8_t bEndpoint,
|
||||
void *pData,
|
||||
uint32_t dLength,
|
||||
TransferCallback fCallback,
|
||||
void *pArg);
|
||||
|
||||
extern uint8_t USBD_Stall(uint8_t bEndpoint);
|
||||
|
||||
extern void USBD_Halt(uint8_t bEndpoint);
|
||||
|
||||
extern void USBD_Unhalt(uint8_t bEndpoint);
|
||||
|
||||
extern void USBD_ConfigureEndpoint(const USBEndpointDescriptor *pDescriptor);
|
||||
|
||||
extern uint8_t USBD_IsHalted(uint8_t bEndpoint);
|
||||
|
||||
extern void USBD_RemoteWakeUp(void);
|
||||
|
||||
extern void USBD_SetAddress(uint8_t address);
|
||||
|
||||
extern void USBD_SetConfiguration(uint8_t cfgnum);
|
||||
|
||||
extern uint8_t USBD_GetState(void);
|
||||
|
||||
extern uint8_t USBD_IsHighSpeed(void);
|
||||
|
||||
extern void USBD_Test(uint8_t bIndex);
|
||||
|
||||
extern void USBD_SuspendHandler(void);
|
||||
extern void USBD_ResumeHandler(void);
|
||||
extern void USBD_ResetHandler(void);
|
||||
extern void USBD_RequestHandler(uint8_t bEndpoint,
|
||||
const USBGenericRequest * pRequest);
|
||||
|
||||
|
||||
extern void USBDCallbacks_Initialized(void);
|
||||
extern void USBDCallbacks_Reset(void);
|
||||
extern void USBDCallbacks_Suspended(void);
|
||||
extern void USBDCallbacks_Resumed(void);
|
||||
extern void USBDCallbacks_RequestReceived(const USBGenericRequest *request);
|
||||
|
||||
#endif /*#ifndef USBD_H*/
|
||||
|
||||
@@ -0,0 +1,149 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2008, Atmel Corporation
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the disclaimer below.
|
||||
*
|
||||
* Atmel's name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
*
|
||||
* \section Purpose
|
||||
*
|
||||
* USB Device Driver class definition.
|
||||
*
|
||||
* \section Usage
|
||||
*
|
||||
* -# Instanciate a USBDDriver object and initialize it using
|
||||
* USBDDriver_Initialize.
|
||||
* -# When a USB SETUP request is received, forward it to the standard
|
||||
* driver using USBDDriver_RequestHandler.
|
||||
* -# Check the Remote Wakeup setting via USBDDriver_IsRemoteWakeUpEnabled.
|
||||
*/
|
||||
|
||||
#ifndef USBDDRIVER_H
|
||||
#define USBDDRIVER_H
|
||||
|
||||
/** \addtogroup usbd_interface
|
||||
*@{
|
||||
*/
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Headers
|
||||
*------------------------------------------------------------------------------*/
|
||||
|
||||
/* These headers were introduced in C99 by working group
|
||||
* ISO/IEC JTC1/SC22/WG14.
|
||||
*/
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <USBRequests.h>
|
||||
#include <USBDescriptors.h>
|
||||
#include <USBLib_Types.h>
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Types
|
||||
*------------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* \typedef USBDDriverDescriptors
|
||||
* \brief List of all descriptors used by a USB device driver. Each descriptor
|
||||
* can be provided in two versions: full-speed and high-speed. Devices
|
||||
* which are not high-speed capable do not need to provided high-speed
|
||||
* descriptors and the full-speed qualifier & other speed descriptors.
|
||||
*/
|
||||
typedef struct _USBDDriverDescriptors {
|
||||
|
||||
/** Pointer to the full-speed device descriptor */
|
||||
const USBDeviceDescriptor *pFsDevice;
|
||||
/** Pointer to the full-speed configuration descriptor */
|
||||
const USBConfigurationDescriptor *pFsConfiguration;
|
||||
/** Pointer to the full-speed qualifier descriptor */
|
||||
const USBDeviceQualifierDescriptor *pFsQualifier;
|
||||
/** Pointer to the full-speed other speed configuration descriptor */
|
||||
const USBConfigurationDescriptor *pFsOtherSpeed;
|
||||
/** Pointer to the high-speed device descriptor */
|
||||
const USBDeviceDescriptor *pHsDevice;
|
||||
/** Pointer to the high-speed configuration descriptor */
|
||||
const USBConfigurationDescriptor *pHsConfiguration;
|
||||
/** Pointer to the high-speed qualifier descriptor */
|
||||
const USBDeviceQualifierDescriptor *pHsQualifier;
|
||||
/** Pointer to the high-speed other speed configuration descriptor */
|
||||
const USBConfigurationDescriptor *pHsOtherSpeed;
|
||||
/** Pointer to the list of string descriptors */
|
||||
const uint8_t **pStrings;
|
||||
/** Number of string descriptors in list */
|
||||
uint8_t numStrings;
|
||||
|
||||
} USBDDriverDescriptors;
|
||||
|
||||
/**
|
||||
* \typedef USBDDriver
|
||||
* \brief USB device driver structure, holding a list of descriptors identifying
|
||||
* the device as well as the driver current state.
|
||||
*/
|
||||
typedef struct _USBDDriver {
|
||||
|
||||
/** List of descriptors used by the device. */
|
||||
const USBDDriverDescriptors *pDescriptors;
|
||||
/** Current setting for each interface. */
|
||||
uint8_t *pInterfaces;
|
||||
/** Current configuration number (0 -> device is not configured). */
|
||||
uint8_t cfgnum;
|
||||
/** Indicates if remote wake up has been enabled by the host. */
|
||||
uint8_t isRemoteWakeUpEnabled;
|
||||
/** Features supported by OTG */
|
||||
uint8_t otg_features_supported;
|
||||
} USBDDriver;
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Exported functions
|
||||
*------------------------------------------------------------------------------*/
|
||||
|
||||
extern USBDDriver *USBD_GetDriver(void);
|
||||
extern void USBDDriver_Initialize(
|
||||
USBDDriver *pDriver,
|
||||
const USBDDriverDescriptors *pDescriptors,
|
||||
uint8_t *pInterfaces);
|
||||
extern USBConfigurationDescriptor* USBDDriver_GetCfgDescriptors(
|
||||
USBDDriver * pDriver,
|
||||
uint8_t cfgNum);
|
||||
extern void USBDDriver_RequestHandler(
|
||||
USBDDriver *pDriver,
|
||||
const USBGenericRequest *pRequest);
|
||||
extern uint8_t USBDDriver_IsRemoteWakeUpEnabled(const USBDDriver *pDriver);
|
||||
extern uint8_t USBDDriver_returnOTGFeatures(const USBDDriver *pDriver);
|
||||
extern void USBDDriver_clearOTGFeatures(USBDDriver *pDriver);
|
||||
|
||||
extern void USBDDriverCallbacks_ConfigurationChanged(uint8_t cfgnum);
|
||||
extern void USBDDriverCallbacks_InterfaceSettingChanged(uint8_t interface,
|
||||
uint8_t setting);
|
||||
|
||||
/**@}*/
|
||||
|
||||
#endif /*#ifndef USBDDRIVER_H*/
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user