1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-23 14:58:09 +00:00
trezor-firmware/micropython/extmod/modtrezormsg/modtrezormsg-stmhal.h

38 lines
835 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-02-16 13:12:32 +00:00
#include "touch.h"
2016-09-23 09:27:26 +00:00
extern struct _USBD_HandleTypeDef hUSBDDevice;
extern uint8_t USBD_HID_SendReport(struct _USBD_HandleTypeDef *pdev, uint8_t *report, uint16_t len);
extern int USBD_HID_Rx(uint8_t *buf, uint32_t len, uint32_t timeout);
2016-04-29 01:15:18 +00:00
void msg_init(void)
{
2017-02-16 13:12:32 +00:00
touch_init();
2016-04-29 01:15:18 +00:00
}
ssize_t msg_recv(uint8_t *iface, uint8_t *buf, size_t len)
2016-04-29 01:15:18 +00:00
{
*iface = 0; // TODO: return proper interface
2016-09-23 09:27:26 +00:00
return USBD_HID_Rx(buf, len, 1);
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
{
(void)iface; // TODO: ignore interface for now
if (len > 0) {
USBD_HID_SendReport(&hUSBDDevice, (uint8_t *)buf, len);
}
2016-09-23 09:27:26 +00:00
return len;
2016-04-29 01:15:18 +00:00
}
2017-02-22 14:19:25 +00:00
uint32_t msg_poll_touch(void)
2016-04-29 01:15:18 +00:00
{
2017-02-22 14:19:25 +00:00
return touch_read();
2016-04-29 01:15:18 +00:00
}