simplify code

This commit is contained in:
XIVN1987
2023-01-08 20:58:13 +08:00
parent 7d3e19af69
commit d84b28f1d9
12 changed files with 129 additions and 393 deletions
+1 -1
View File
@@ -226,7 +226,7 @@
<Group>
<GroupName>APP</GroupName>
<tvExp>0</tvExp>
<tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel>
<RteFlg>0</RteFlg>
+4 -4
View File
@@ -9,7 +9,6 @@
static usb_setup_type Setup;
static uint8_t hid_rx_buff[64];
uint8_t cdc_rx_buff[64];
/**
@@ -37,7 +36,7 @@ static usb_sts_type class_init_handler(void *udev)
usbd_ept_open(usbd, CDC_BULK_IN_EP, EPT_BULK_TYPE, CDC_BULK_IN_SZ);
usbd_ept_open(usbd, CDC_BULK_OUT_EP, EPT_BULK_TYPE, CDC_BULK_OUT_SZ);
usbd_ept_recv(usbd, CDC_BULK_OUT_EP, cdc_rx_buff, CDC_BULK_OUT_SZ);
usbd_ept_recv(usbd, CDC_BULK_OUT_EP, (uint8_t *)Vcom.out_buff, CDC_BULK_OUT_SZ);
return USB_OK;
}
@@ -182,7 +181,7 @@ static usb_sts_type class_in_handler(void *udev, uint8_t ept_num)
break;
case CDC_BULK_IN_EP:
VCOM_InComplete();
Vcom.in_ready = 1;
break;
}
@@ -212,7 +211,8 @@ static usb_sts_type class_out_handler(void *udev, uint8_t ept_num)
break;
case CDC_BULK_OUT_EP:
VCOM_GetOutData(cdc_rx_buff, recv_len);
Vcom.out_bytes = recv_len;
Vcom.out_ready = 1;
break;
}
+2 -18
View File
@@ -116,21 +116,6 @@ void USART2_IRQHandler(void)
}
void VCOM_InComplete(void)
{
Vcom.in_ready = 1;
}
void VCOM_GetOutData(uint8_t * buf, uint32_t len)
{
Vcom.out_pbuf = buf;
Vcom.out_bytes = len;
Vcom.out_ready = 1;
}
extern otg_core_type Otg;
void VCOM_TransferData(void)
@@ -175,7 +160,7 @@ void VCOM_TransferData(void)
{
for(int i = 0; i < Vcom.out_bytes; i++)
{
Vcom.tx_buff[Vcom.tx_wrptr++] = Vcom.out_pbuf[i];
Vcom.tx_buff[Vcom.tx_wrptr++] = Vcom.out_buff[i];
if(Vcom.tx_wrptr >= TX_BUFF_SIZE)
Vcom.tx_wrptr = 0;
}
@@ -187,8 +172,7 @@ void VCOM_TransferData(void)
Vcom.out_ready = 0;
/* Ready for next BULK OUT */
extern uint8_t cdc_rx_buff[64];
usbd_ept_recv(&Otg.dev, CDC_BULK_OUT_EP, cdc_rx_buff, CDC_BULK_OUT_SZ);
usbd_ept_recv(&Otg.dev, CDC_BULK_OUT_EP, (uint8_t *)Vcom.out_buff, CDC_BULK_OUT_SZ);
}
if((Vcom.tx_bytes) && (USART2->ctrl1_bit.tdbeien == 0))
+1 -5
View File
@@ -20,7 +20,7 @@ typedef struct {
uint8_t in_buff[64] __attribute__((aligned(4)));
uint16_t in_bytes;
uint16_t in_ready;
uint8_t *out_pbuf;
uint8_t out_buff[64];
uint16_t out_bytes;
uint16_t out_ready;
} VCOM;
@@ -43,8 +43,4 @@ void VCOM_TransferData(void);
void VCOM_LineCoding(VCOM_LINE_CODING * LineCfgx);
void VCOM_InComplete(void);
void VCOM_GetOutData(uint8_t * buf, uint32_t len);
#endif // __VCOM_SERIAL_H__