2016-10-11 12:05:55 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) Pavol Rusnak, SatoshiLabs
|
|
|
|
*
|
|
|
|
* Licensed under TREZOR License
|
|
|
|
* see LICENSE file for details
|
|
|
|
*/
|
|
|
|
|
2017-03-24 15:38:46 +00:00
|
|
|
extern int usb_hid_read_blocking(uint8_t iface_num, uint8_t *buf, uint32_t len, uint32_t timeout);
|
|
|
|
extern int usb_hid_write_blocking(uint8_t iface_num, const uint8_t *buf, uint32_t len, uint32_t timeout);
|
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
|
|
|
{
|
2016-10-11 11:13:14 +00:00
|
|
|
*iface = 0; // TODO: return proper interface
|
2017-03-24 15:38:46 +00:00
|
|
|
return usb_hid_read_blocking(0x00, buf, len, 1);
|
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
|
|
|
{
|
2016-10-11 11:13:14 +00:00
|
|
|
(void)iface; // TODO: ignore interface for now
|
2016-10-04 16:53:32 +00:00
|
|
|
if (len > 0) {
|
2017-03-24 15:38:46 +00:00
|
|
|
usb_hid_write_blocking(0x00, buf, len, 1);
|
2016-10-04 16:53:32 +00:00
|
|
|
}
|
2016-09-23 09:27:26 +00:00
|
|
|
return len;
|
2016-04-29 01:15:18 +00:00
|
|
|
}
|