example of i2c slave device supporting block transfers

Dependencies:   lib_i2c_slave_block

Tested on nucleo board as slave. Use with i2c_master_block_example on raspberry pi as master.

Master I2C write will print on serial terminal 115200. User button will raise an irq; the RPi test program will service the interrupt.

See lib_i2c_slave_block for explanation of code.

Committer:
Wayne Roberts
Date:
Fri Jan 18 14:36:09 2019 -0800
Revision:
0:3ccfaf358115
Child:
2:d7e05c75f240
initial commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Wayne Roberts 0:3ccfaf358115 1
Wayne Roberts 0:3ccfaf358115 2 #define CMD_TEST3 0x00
Wayne Roberts 0:3ccfaf358115 3 #define CMD_TEST12 0x01
Wayne Roberts 0:3ccfaf358115 4 #define CMD_TEST32 0x02
Wayne Roberts 0:3ccfaf358115 5 #define CMD_IRQ 0x03
Wayne Roberts 0:3ccfaf358115 6
Wayne Roberts 0:3ccfaf358115 7 typedef union {
Wayne Roberts 0:3ccfaf358115 8 struct __attribute__((packed)) {
Wayne Roberts 0:3ccfaf358115 9 struct {
Wayne Roberts 0:3ccfaf358115 10 uint8_t button : 1; // 0
Wayne Roberts 0:3ccfaf358115 11 uint8_t xyz : 1; // 1
Wayne Roberts 0:3ccfaf358115 12 uint8_t res : 6; // 2,3,4,5,6,7
Wayne Roberts 0:3ccfaf358115 13 } flags;
Wayne Roberts 0:3ccfaf358115 14 uint8_t cnt; // if flags.button
Wayne Roberts 0:3ccfaf358115 15 uint8_t a;
Wayne Roberts 0:3ccfaf358115 16 int8_t b;
Wayne Roberts 0:3ccfaf358115 17 int8_t c;
Wayne Roberts 0:3ccfaf358115 18 } fields;
Wayne Roberts 0:3ccfaf358115 19 uint8_t buf[5];
Wayne Roberts 0:3ccfaf358115 20 } irq_t;
Wayne Roberts 0:3ccfaf358115 21
Wayne Roberts 0:3ccfaf358115 22 extern const uint8_t cmd_to_length[];