mirror of
https://github.com/tillitis/tillitis-key1.git
synced 2025-08-08 14:42:19 -04:00
tkey-libs: Import tag fw-3 of tkey-libs
- Use tag fw-3 from https://github.com/tillitis/tkey-libs/
This commit is contained in:
parent
d0c049cdba
commit
81f3195592
19 changed files with 861 additions and 79 deletions
|
@ -80,9 +80,9 @@ static void write_with_header(enum ioend dest, const uint8_t *buf,
|
|||
//
|
||||
// - IO_CDC: Through the UART for the CDC endpoint, with header.
|
||||
//
|
||||
// - IO_HID: Through the UART for the HID endpoint, with header.
|
||||
// - IO_FIDO: Through the UART for the FIDO endpoint, with header.
|
||||
//
|
||||
// - IO_TKEYCTRL: Through the UART for the debug HID endpoint, with
|
||||
// - IO_DEBUG: Through the UART for the DEBUG HID endpoint, with
|
||||
// header.
|
||||
void write(enum ioend dest, const uint8_t *buf, size_t nbytes)
|
||||
{
|
||||
|
@ -194,18 +194,18 @@ static int discard(size_t nbytes)
|
|||
//
|
||||
// Use like this:
|
||||
//
|
||||
// readselect(IO_CDC|IO_HID, &endpoint, &len)
|
||||
// readselect(IO_CDC|IO_FIDO, &endpoint, &len)
|
||||
//
|
||||
// to wait for some data from either the CDC or the HID endpoint.
|
||||
// to wait for some data from either the CDC or the FIDO endpoint.
|
||||
//
|
||||
// NOTE WELL: You need to call readselect() first, before doing any
|
||||
// calls to read().
|
||||
//
|
||||
// Only endpoints available for read are:
|
||||
//
|
||||
// - IO_TKEYCTRL
|
||||
// - IO_DEBUG
|
||||
// - IO_CDC
|
||||
// - IO_HID
|
||||
// - IO_FIDO
|
||||
//
|
||||
// If you need blocking low-level UART reads, use uart_read() instead.
|
||||
//
|
||||
|
@ -215,7 +215,7 @@ static int discard(size_t nbytes)
|
|||
// Returns non-zero on error.
|
||||
int readselect(int bitmask, enum ioend *endpoint, uint8_t *len)
|
||||
{
|
||||
if (bitmask & IO_UART || bitmask & IO_QEMU) {
|
||||
if ((bitmask & IO_UART) || (bitmask & IO_QEMU)) {
|
||||
// Not possible to use readselect() on these
|
||||
// endpoints.
|
||||
return -1;
|
||||
|
@ -348,3 +348,27 @@ void hexdump(enum ioend dest, void *buf, int len)
|
|||
write(dest, rowbuf, rowpos);
|
||||
}
|
||||
}
|
||||
|
||||
// Configure USB endpoints that should be enabled/disabled
|
||||
//
|
||||
// Allowed options are:
|
||||
// - IO_FIDO
|
||||
// - IO_DEBUG
|
||||
//
|
||||
// The following are always enabled:
|
||||
// - IO_CDC
|
||||
// - IO_CH552
|
||||
//
|
||||
// Use like this:
|
||||
//
|
||||
// config_endpoints(IO_FIDO|IO_DEBUG)
|
||||
//
|
||||
void config_endpoints(enum ioend endpoints)
|
||||
{
|
||||
uint8_t cmdbuf[2] = {0};
|
||||
|
||||
cmdbuf[0] = SET_ENDPOINTS;
|
||||
cmdbuf[1] = endpoints;
|
||||
|
||||
write(IO_CH552, cmdbuf, 2);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue