mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-25 17:09:44 +00:00
move initialization of I2C1 to msg_init()
This commit is contained in:
parent
ae65b8c17f
commit
db6673b50e
@ -3,10 +3,21 @@ extern uint8_t USBD_HID_SendReport(struct _USBD_HandleTypeDef *pdev, uint8_t *re
|
||||
extern int USBD_HID_Rx(uint8_t *buf, uint32_t len, uint32_t timeout);
|
||||
|
||||
extern I2C_HandleTypeDef I2CHandle1;
|
||||
extern void i2c_init(I2C_HandleTypeDef *i2c);
|
||||
extern HAL_StatusTypeDef HAL_I2C_Master_Receive(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size, uint32_t Timeout);
|
||||
|
||||
void msg_init(void)
|
||||
{
|
||||
I2C_InitTypeDef *init = &(I2CHandle1.Init);
|
||||
init->OwnAddress1 = 0xfe; // master
|
||||
init->ClockSpeed = 400000;
|
||||
init->DutyCycle = I2C_DUTYCYCLE_16_9;
|
||||
init->AddressingMode = I2C_ADDRESSINGMODE_7BIT;
|
||||
init->DualAddressMode = I2C_DUALADDRESS_DISABLED;
|
||||
init->GeneralCallMode = I2C_GENERALCALL_DISABLED;
|
||||
init->NoStretchMode = I2C_NOSTRETCH_DISABLED;
|
||||
init->OwnAddress2 = 0;
|
||||
i2c_init(&I2CHandle1);
|
||||
}
|
||||
|
||||
ssize_t msg_recv(uint8_t *iface, uint8_t *buf, size_t len)
|
||||
|
@ -4,4 +4,3 @@ if sys.platform in ['trezor', 'pyboard']: # stmhal
|
||||
import pyb
|
||||
# hid=(subclass, protocol, max_packet_len, polling_interval, report_desc)
|
||||
pyb.usb_mode('VCP+HID', vid=0x1209, pid=0x53C1, hid=(0, 0, 64, 1, b'\x06\x00\xff\x09\x01\xa1\x01\x09\x20\x15\x00\x26\xff\x00\x75\x08\x95\x40\x81\x02\x09\x21\x15\x00\x26\xff\x00\x75\x08\x95\x40\x91\x02\xc0'))
|
||||
pyb.I2C(1, pyb.I2C.MASTER)
|
||||
|
Loading…
Reference in New Issue
Block a user