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:
Mon Jan 21 18:09:05 2019 -0800
Revision:
2:d7e05c75f240
Parent:
0:3ccfaf358115
Child:
3:0288d257446a
add buffer for read/write integrity test

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 2:d7e05c75f240 6 #define CMD_BUFFER 0x04
Wayne Roberts 0:3ccfaf358115 7
Wayne Roberts 0:3ccfaf358115 8 typedef union {
Wayne Roberts 0:3ccfaf358115 9 struct __attribute__((packed)) {
Wayne Roberts 0:3ccfaf358115 10 struct {
Wayne Roberts 0:3ccfaf358115 11 uint8_t button : 1; // 0
Wayne Roberts 0:3ccfaf358115 12 uint8_t xyz : 1; // 1
Wayne Roberts 0:3ccfaf358115 13 uint8_t res : 6; // 2,3,4,5,6,7
Wayne Roberts 0:3ccfaf358115 14 } flags;
Wayne Roberts 0:3ccfaf358115 15 uint8_t cnt; // if flags.button
Wayne Roberts 0:3ccfaf358115 16 uint8_t a;
Wayne Roberts 0:3ccfaf358115 17 int8_t b;
Wayne Roberts 0:3ccfaf358115 18 int8_t c;
Wayne Roberts 0:3ccfaf358115 19 } fields;
Wayne Roberts 0:3ccfaf358115 20 uint8_t buf[5];
Wayne Roberts 0:3ccfaf358115 21 } irq_t;
Wayne Roberts 0:3ccfaf358115 22
Wayne Roberts 0:3ccfaf358115 23 extern const uint8_t cmd_to_length[];