Added functionality to send back linestate reports to host. This is currently not working correctly

pull/25/head
Simon Kueppers 2023-05-21 13:56:49 +02:00
rodzic 43cd92f3bb
commit 122c8dd21b
2 zmienionych plików z 39 dodań i 0 usunięć

Wyświetl plik

@ -251,3 +251,32 @@ void USB_SerialTask(void)
{
}
#include "device/usbd_pvt.h"
bool USB_SerialSendLineState(uint8_t lineState)
{
#if 0
/* TODO: This causes issues with the stack if its being called before CDC was initialized? Crashes on terminal connect */
uint8_t const rhport = 0;
static uint8_t notification[10] = {
/* bmRequestType */ 0xA1,
/* bNotification */ 0x20,
/* wValue */ 0x00, 0x00,
/* wIndex */ ITF_NUM_CDC_0, 0x00,
/* wLength */ 0x02, 0x00,
/* Data */ 0x00, 0x00
};
notification[8] = lineState;
notification[9] = 0x00;
// claim endpoint
TU_VERIFY( usbd_edpt_claim(rhport, EPNUM_CDC_0_NOTIF) );
return usbd_edpt_xfer(rhport, EPNUM_CDC_0_NOTIF, notification, sizeof(notification));
#else
return true;
#endif
}

Wyświetl plik

@ -1,6 +1,9 @@
#ifndef USB_SERIAL_H_
#define USB_SERIAL_H_
#include <stdint.h>
#include <stdbool.h>
#define USB_SERIAL_UART USART1
#define USB_SERIAL_UART_IRQ USART1_IRQHandler
#define USB_SERIAL_UART_PERIPHCLK RCC_PERIPHCLK_USART1
@ -10,7 +13,14 @@
#define USB_SERIAL_UART_PIN_TX GPIO_PIN_9
#define USB_SERIAL_UART_PIN_RX GPIO_PIN_10
#define USB_SERIAL_LINESTATE_DCD 0x01
#define USB_SERIAL_LINESTATE_DSR 0x02
#define USB_SERIAL_LINESTATE_BREAK 0x04
#define USB_SERIAL_LINESTATE_RI 0x08
void USB_SerialInit(void);
void USB_SerialTask(void);
bool USB_SerialSendLineState(uint8_t lineState);
#endif /* USB_SERIAL_H_ */