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

28 lines
510 B
C
Raw Normal View History

2016-10-11 12:05:55 +00:00
/*
* Copyright (c) Pavol Rusnak, SatoshiLabs
*
* Licensed under TREZOR License
* see LICENSE file for details
*/
2017-03-30 20:06:59 +00:00
#include "usb.h"
2016-04-29 01:15:18 +00:00
void msg_init(void)
{
}
ssize_t msg_recv(uint8_t *iface, uint8_t *buf, size_t len)
2016-04-29 01:15:18 +00:00
{
2017-03-30 20:06:59 +00:00
int i = usb_hid_read_select(1); // 1ms timeout
if (i < 0) {
return 0;
}
*iface = i;
return usb_hid_read(i, buf, len);
2016-04-29 01:15:18 +00:00
}
ssize_t msg_send(uint8_t iface, const uint8_t *buf, size_t len)
2016-04-29 01:15:18 +00:00
{
2017-03-30 20:06:59 +00:00
return usb_hid_write_blocking(iface, buf, len, 1); // 1ms timeout
2016-04-29 01:15:18 +00:00
}