1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-01 11:58:28 +00:00

move initialization of I2C1 to msg_init()

This commit is contained in:
Pavol Rusnak 2016-09-26 15:46:16 +02:00
parent ae65b8c17f
commit db6673b50e
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D
2 changed files with 11 additions and 1 deletions

View File

@ -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 int USBD_HID_Rx(uint8_t *buf, uint32_t len, uint32_t timeout);
extern I2C_HandleTypeDef I2CHandle1; 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); 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) 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) ssize_t msg_recv(uint8_t *iface, uint8_t *buf, size_t len)

View File

@ -4,4 +4,3 @@ if sys.platform in ['trezor', 'pyboard']: # stmhal
import pyb import pyb
# hid=(subclass, protocol, max_packet_len, polling_interval, report_desc) # 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.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)