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 14:02:18 +00:00
|
|
|
|
2016-04-29 01:15:18 +00:00
|
|
|
void msg_init(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-10-11 11:13:14 +00:00
|
|
|
ssize_t msg_recv(uint8_t *iface, uint8_t *buf, size_t len)
|
2016-04-29 01:15:18 +00:00
|
|
|
{
|
2017-05-31 16:39:37 +00:00
|
|
|
int i = usb_hid_read_select(0);
|
2017-03-30 20:06:59 +00:00
|
|
|
if (i < 0) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
*iface = i;
|
|
|
|
return usb_hid_read(i, buf, len);
|
2016-04-29 01:15:18 +00:00
|
|
|
}
|
|
|
|
|
2016-10-11 11:13:14 +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
|
|
|
}
|