@@ -25,6 +25,15 @@
/* USER CODE BEGIN INCLUDE */
uint8_t* CDC_RX_BUFFER = NULL ;
uint16_t CDC_RX_LEN = 0;
/*
* PSTN v1.20, § 6.3.12 SetControlLineState
*
* wValue:
* D0 DTR
* D1 RTS
*/
static uint16_t line_status;
/* USER CODE END INCLUDE */
/* Private typedef -----------------------------------------------------------*/
@@ -184,6 +193,10 @@ static int8_t CDC_DeInit_FS(void)
static int8_t CDC_Control_FS(uint8_t cmd, uint8_t* pbuf, uint16_t length)
{
/* USER CODE BEGIN 5 */
USBD_SetupReqTypedef *req;
req = (USBD_SetupReqTypedef *)pbuf;
switch(cmd)
{
case CDC_SEND_ENCAPSULATED_COMMAND:
@@ -232,7 +245,7 @@ static int8_t CDC_Control_FS(uint8_t cmd, uint8_t* pbuf, uint16_t length)
break;
case CDC_SET_CONTROL_LINE_STATE:
line_status = req->wValue;
break;
case CDC_SEND_BREAK:
@@ -300,23 +313,16 @@ uint8_t CDC_Transmit_FS(uint8_t* Buf, uint16_t Len)
/* USER CODE BEGIN PRIVATE_FUNCTIONS_IMPLEMENTATION */
#include <stdarg.h>
uint16_t vcp_status( USBD_SetupReqTypedef *req){
if(req->bRequest ==CDC_SET_CONTROL_LINE_STATE){
if(req->wValue){
return 1;
}
}
return 0;
uint16_t vcp_status(){
return line_status & 0x1;
}
void usb_printf(const char *format, ...)
int
usb_write(void *cookie, const char *buf, int length)
{
va_list args;
uint32_t length;
va_start(args, format);
length = vsnprintf((char *)UserTxBufferFS, APP_TX_DATA_SIZE, (char *)format, args);
va_end(args);
length = MIN(length, APP_TX_DATA_SIZE);
memcpy((char *)UserTxBufferFS, buf, length);
for (;;) {
if (CDC_Transmit_FS(UserTxBufferFS, length) == USBD_BUSY) {
HAL_Delay(1);
@@ -324,6 +330,8 @@ void usb_printf(const char *format, ...)
}
break;
}
return length;
}
/* USER CODE END PRIVATE_FUNCTIONS_IMPLEMENTATION */