1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-17 03:48:09 +00:00
trezor-firmware/micropython/extmod/modtrezormsg/modtrezormsg-stm32.h

28 lines
510 B
C

/*
* 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
}