You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
trezor-firmware/micropython/extmod/modtrezormsg/modtrezormsg-stmhal.h

28 lines
510 B

/*
* Copyright (c) Pavol Rusnak, SatoshiLabs
*
* Licensed under TREZOR License
* see LICENSE file for details
*/
#include "usb.h"
void msg_init(void)
{
}
ssize_t msg_recv(uint8_t *iface, uint8_t *buf, size_t len)
{
int i = usb_hid_read_select(1); // 1ms timeout
if (i < 0) {
return 0;
}
*iface = i;
return usb_hid_read(i, buf, len);
}
ssize_t msg_send(uint8_t iface, const uint8_t *buf, size_t len)
{
return usb_hid_write_blocking(iface, buf, len, 1); // 1ms timeout
}