implemented more console / usb handling
still untested, probably doesn't work ... but there's hope
This commit is contained in:
@@ -49,24 +49,45 @@ void EP1_IN_Callback (void)
|
||||
*/
|
||||
void EP2_OUT_Callback (void)
|
||||
{
|
||||
uint32_t len;
|
||||
len = GetEPRxCount( EP2_OUT & 0x7F );
|
||||
PMAToUserBufferCopy( &CDC_Tx_Buf[ ( Cdc.Tx_LoadNum * DEF_USB_FS_PACK_LEN ) ], GetEPRxAddr( EP2_OUT & 0x7F ), len );
|
||||
Cdc.Tx_PackLen[ Cdc.Tx_LoadNum ] = len;
|
||||
Cdc.Tx_LoadNum++;
|
||||
if( Cdc.Tx_LoadNum >= DEF_CDC_TX_BUF_NUM_MAX )
|
||||
{
|
||||
Cdc.Tx_LoadNum = 0x00;
|
||||
}
|
||||
Cdc.Tx_RemainNum++;
|
||||
uint16_t cnt;
|
||||
uint16_t remain;
|
||||
uint8_t dat[DEF_USB_FS_PACKET_LEN];
|
||||
uint8_t *buf = dat;
|
||||
|
||||
if( Cdc.Tx_RemainNum >= ( DEF_CDC_TX_BUF_NUM_MAX - 2 ) )
|
||||
{
|
||||
Cdc.USB_Down_StopFlag = 0x01;
|
||||
|
||||
// receive data
|
||||
cnt = GetEPRxCount(EP2_OUT & 0x7F);
|
||||
PMAToUserBufferCopy(buf, GetEPRxAddr(EP2_OUT & 0x7F), cnt);
|
||||
|
||||
// copy data to buffer
|
||||
// note: this is slower, but we are using circular buffer,
|
||||
// so this is easier without seriously reworking code
|
||||
remain = cnt;
|
||||
|
||||
if (cnt >= DEF_CDC_FROM_HOST_BUF_LEN - Cdc.from_host_ptr) {
|
||||
// if we've got too much data, then copy what will fit to end of buffer
|
||||
remain = DEF_CDC_FROM_HOST_BUF_LEN - Cdc.from_host_ptr;
|
||||
memcpy(cdc_from + Cdc.from_host_ptr, buf, remain);
|
||||
|
||||
// set pointers
|
||||
Cdc.from_host_ptr = 0;
|
||||
|
||||
buf += remain;
|
||||
remain = cnt - remain;
|
||||
}
|
||||
|
||||
// fill the buffer
|
||||
memcpy(cdc_from + Cdc.from_host_ptr, buf, remain);
|
||||
|
||||
// todo: handle not overflowing
|
||||
/*
|
||||
if( Cdc.Tx_RemainNum >= ( DEF_CDC_TX_BUF_NUM_MAX - 2 ) ) {
|
||||
Cdc.usb_from_host_stop_flag = 1;
|
||||
}
|
||||
else
|
||||
*/
|
||||
{
|
||||
SetEPRxValid( ENDP2 );
|
||||
SetEPRxValid(ENDP2);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,7 +102,7 @@ void EP2_OUT_Callback (void)
|
||||
void EP3_IN_Callback (void)
|
||||
{
|
||||
USBD_Endp3_Busy = 0;
|
||||
Cdc.USB_Up_IngFlag = 0x00;
|
||||
Cdc.usb_send_host_flag = 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -392,7 +392,7 @@ uint8_t *USB_CDC_GetLineCoding( uint16_t Length )
|
||||
return( NULL );
|
||||
}
|
||||
|
||||
return (uint8_t *)&Cdc.Com_Cfg[ 0 ];
|
||||
return (uint8_t *)&Cdc.cdc_cfg[ 0 ];
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
@@ -410,7 +410,7 @@ uint8_t *USB_CDC_SetLineCoding( uint16_t Length )
|
||||
pInformation->Ctrl_Info.Usb_wLength = 7;
|
||||
return( NULL );
|
||||
}
|
||||
return(uint8_t *)&Cdc.Com_Cfg[ 0 ];
|
||||
return(uint8_t *)&Cdc.cdc_cfg[ 0 ];
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ typedef enum _DEVICE_STATE
|
||||
|
||||
|
||||
|
||||
extern __IO uint32_t bDeviceState; /* USB device status */
|
||||
extern __IO uint32_t bDeviceState; /* USB device status */
|
||||
extern __IO uint8_t fSuspendEnabled; /* true when suspend is possible */
|
||||
|
||||
|
||||
|
||||
@@ -9,7 +9,10 @@
|
||||
* Attention: This software (modified or not) and binary are used for
|
||||
* microcontroller manufactured by Nanjing Qinheng Microelectronics.
|
||||
*******************************************************************************/
|
||||
#include "../../driver/inc/usb_lib.h"
|
||||
|
||||
#include "usb_lib.h"
|
||||
|
||||
|
||||
|
||||
/* Global define */
|
||||
#define ValBit(VAR,Place) (VAR & (1 << Place))
|
||||
|
||||
@@ -9,7 +9,10 @@
|
||||
* Attention: This software (modified or not) and binary are used for
|
||||
* microcontroller manufactured by Nanjing Qinheng Microelectronics.
|
||||
*******************************************************************************/
|
||||
#include "../../driver/inc/usb_lib.h"
|
||||
|
||||
#include "usb_lib.h"
|
||||
|
||||
|
||||
|
||||
/* Private variables */
|
||||
__IO uint16_t SaveRState;
|
||||
@@ -123,11 +126,3 @@ void CTR_HP(void)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -9,7 +9,9 @@
|
||||
* Attention: This software (modified or not) and binary are used for
|
||||
* microcontroller manufactured by Nanjing Qinheng Microelectronics.
|
||||
*******************************************************************************/
|
||||
#include "../../driver/inc/usb_lib.h"
|
||||
|
||||
#include "usb_lib.h"
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
@@ -67,8 +69,3 @@ void PMAToUserBufferCopy(uint8_t *pbUsrBuf, uint16_t wPMABufAddr, uint16_t wNByt
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -9,7 +9,10 @@
|
||||
* Attention: This software (modified or not) and binary are used for
|
||||
* microcontroller manufactured by Nanjing Qinheng Microelectronics.
|
||||
*******************************************************************************/
|
||||
#include "../../driver/inc/usb_lib.h"
|
||||
|
||||
#include "usb_lib.h"
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
* @fn SetCNTR.
|
||||
|
||||
@@ -10,7 +10,9 @@
|
||||
* Attention: This software (modified or not) and binary are used for
|
||||
* microcontroller manufactured by Nanjing Qinheng Microelectronics.
|
||||
*******************************************************************************/
|
||||
#include "../../driver/inc/usb_lib.h"
|
||||
|
||||
#include "usb_lib.h"
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
@@ -70,8 +72,3 @@ uint32_t USB_SIL_Read(uint8_t bEpAddr, uint8_t* pBufferPointer)
|
||||
return DataLength;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user