mirror of
https://github.com/tillitis/tillitis-key1.git
synced 2025-03-26 00:28:15 -04:00
ch552: Add functionality to dynamically control USB endpoints
- Make it possible to enable and disable endpoints on demand - Add internal FPGA<->CH552 communication channel (IO_CH552) - Reorder IO endpoint numbering - Rename endpoint from TKEYCTRL to DEBUG and update related variables - Rename endpoint from HID to FIDO and update related variables
This commit is contained in:
parent
1ed8398700
commit
d080dedca0
@ -62,11 +62,11 @@ Mode Protocol. It is used in both directions.
|
||||
|
||||
The different endpoints:
|
||||
|
||||
| *Name* | *Value* | *Comment* |
|
||||
|--------|---------|---------------------------------------------------------------------|
|
||||
| CTRL | 0x20 | A USB HID special debug pipe. Useful for debug prints. |
|
||||
| CDC | 0x40 | USB CDC-ACM, a serial port on the client. |
|
||||
| HID | 0x80 | A USB HID security token device, useful for FIDO-type applications. |
|
||||
| *Name* | *Value* | *Comment* |
|
||||
|--------|---------|----------------------------------------------------------------------|
|
||||
| DEBUG | 0x20 | A USB HID special debug pipe. Useful for debug prints. |
|
||||
| CDC | 0x40 | USB CDC-ACM, a serial port on the client. |
|
||||
| FIDO | 0x80 | A USB FIDO security token device, useful for FIDO-type applications. |
|
||||
|
||||
On top of the USB Mode Protocol is [the TKey Framing
|
||||
Protocol](https://dev.tillitis.se/protocol/) which is described in the
|
||||
|
@ -53,8 +53,8 @@ if __name__ == "__main__":
|
||||
"SerialDesc": "68de5d27-e223-4874-bc76-a54d6e84068f",
|
||||
"CdcCtrlInterfaceDesc": "CDC-Ctrl",
|
||||
"CdcDataInterfaceDesc": "CDC-Data",
|
||||
"FidoHidInterfaceDesc": "FIDO-HID",
|
||||
"TkeyCtrlInterfaceDesc": "TKEY-Ctrl"
|
||||
"FidoInterfaceDesc": "FIDO",
|
||||
"DebugInterfaceDesc": "DEBUG"
|
||||
}
|
||||
|
||||
with open('inc/usb_strings.h', 'w') as f:
|
||||
|
@ -195,8 +195,8 @@ Header file for CH554 microcontrollers.
|
||||
#define USB_IDX_SERIAL_STR 0x03
|
||||
#define USB_IDX_INTERFACE_CDC_CTRL_STR 0x04
|
||||
#define USB_IDX_INTERFACE_CDC_DATA_STR 0x05
|
||||
#define USB_IDX_INTERFACE_FIDO_HID_STR 0x06
|
||||
#define USB_IDX_INTERFACE_TKEY_CTRL_STR 0x07
|
||||
#define USB_IDX_INTERFACE_FIDO_STR 0x06
|
||||
#define USB_IDX_INTERFACE_DEBUG_STR 0x07
|
||||
#endif
|
||||
|
||||
#ifndef USB_DEVICE_ADDR
|
||||
|
14
hw/usb_interface/ch552_fw/inc/io.h
Normal file
14
hw/usb_interface/ch552_fw/inc/io.h
Normal file
@ -0,0 +1,14 @@
|
||||
#ifndef __IO_H__
|
||||
#define __IO_H__
|
||||
|
||||
enum ioend {
|
||||
IO_NONE = 0x00, // No endpoint
|
||||
IO_UART = 0x01, // Only destination, raw UART access
|
||||
IO_QEMU = 0x02, // Only destination, QEMU debug port
|
||||
IO_CH552 = 0x10, // Internal CH552 control port
|
||||
IO_DEBUG = 0x20, // HID debug port
|
||||
IO_CDC = 0x40, // CDC "serial port"
|
||||
IO_FIDO = 0x80, // FIDO security token port
|
||||
};
|
||||
|
||||
#endif
|
@ -1,14 +1,14 @@
|
||||
#ifndef __MAIN_H__
|
||||
#define __MAIN_H__
|
||||
|
||||
#define USE_DEBUG_PRINT /* Enable to print debug messages */
|
||||
#define DEBUG_PRINT_SW /* Enable to print debug messages via FPGA */
|
||||
//#define DEBUG_PRINT_HW /* Enable to print debug messages via UART0 */
|
||||
//#define USE_DEBUG_PRINT /* Enable to print debug messages */
|
||||
//#define DEBUG_PRINT_SW /* Enable to print debug messages via FPGA */
|
||||
//#define DEBUG_PRINT_HW /* Enable to print debug messages via UART0 */
|
||||
|
||||
#define USE_NUM_U8
|
||||
//#define USE_NUM_U32
|
||||
|
||||
//#define DEBUG_SETUP /* Enable to debug USB setup flow (printStrSetup,printNumU8HexSetup) */
|
||||
//#define DEBUG_SETUP /* Enable to debug USB setup flow (printStrSetup,printNumU8HexSetup) */
|
||||
|
||||
#define USE_NUM_U8HEX
|
||||
#define USE_NUM_U16HEX
|
||||
|
@ -46,19 +46,17 @@ unsigned char FLASH CdcDataInterfaceDesc[] = { // "CDC-Data"
|
||||
'D', 0, 'a', 0, 't', 0, 'a', 0,
|
||||
};
|
||||
|
||||
unsigned char FLASH FidoHidInterfaceDesc[] = { // "FIDO-HID"
|
||||
18, // Length of this descriptor (in bytes)
|
||||
unsigned char FLASH FidoInterfaceDesc[] = { // "FIDO"
|
||||
10, // Length of this descriptor (in bytes)
|
||||
0x03, // Descriptor type (String)
|
||||
'F', 0, 'I', 0, 'D', 0, 'O', 0,
|
||||
'-', 0, 'H', 0, 'I', 0, 'D', 0,
|
||||
};
|
||||
|
||||
unsigned char FLASH TkeyCtrlInterfaceDesc[] = { // "TKEY-Ctrl"
|
||||
20, // Length of this descriptor (in bytes)
|
||||
unsigned char FLASH DebugInterfaceDesc[] = { // "DEBUG"
|
||||
12, // Length of this descriptor (in bytes)
|
||||
0x03, // Descriptor type (String)
|
||||
'T', 0, 'K', 0, 'E', 0, 'Y', 0,
|
||||
'-', 0, 'C', 0, 't', 0, 'r', 0,
|
||||
'l', 0,
|
||||
'D', 0, 'E', 0, 'B', 0, 'U', 0,
|
||||
'G', 0,
|
||||
};
|
||||
|
||||
#endif
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -2,13 +2,12 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "debug.h"
|
||||
#include "io.h"
|
||||
#include "lib.h"
|
||||
#include "main.h"
|
||||
#include "mem.h"
|
||||
#include "print.h"
|
||||
|
||||
#define MODE_CH552 0x10
|
||||
|
||||
void printStr(uint8_t *str)
|
||||
{
|
||||
#ifdef USE_DEBUG_PRINT
|
||||
@ -19,7 +18,7 @@ void printStr(uint8_t *str)
|
||||
}
|
||||
#elif defined(DEBUG_PRINT_SW)
|
||||
uint32_t str_len = strlen(str);
|
||||
CH554UART1SendByte(MODE_CH552);
|
||||
CH554UART1SendByte(IO_CH552);
|
||||
CH554UART1SendByte(str_len);
|
||||
CH554UART1SendBuffer(str, str_len);
|
||||
#endif
|
||||
@ -34,7 +33,7 @@ void printChar(uint8_t c)
|
||||
#if defined(DEBUG_PRINT_HW)
|
||||
CH554UART0SendByte(c);
|
||||
#elif defined(DEBUG_PRINT_SW)
|
||||
CH554UART1SendByte(MODE_CH552);
|
||||
CH554UART1SendByte(IO_CH552);
|
||||
CH554UART1SendByte(1);
|
||||
CH554UART1SendByte(c);
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user