1#Diagram demonstrating how to build a command link for an I2C master to read n bytes from a slave 2 3blockdiag i2c-command-link-master-read { 4 # global properties 5 span_width = 5; 6 span_height = 5; 7 node_height = 25; 8 default_group_color = lightgrey; 9 class spacer [shape=none, width=10]; 10 class cmdlink [colwidth=2, width=180]; 11 class cjoint [shape=none, width=40]; 12 13 # all the rows 14 0 -- a0 -- f0 [style=none]; 15 1 -- a1 -- b1 -- c1 -- d1 -- e1 -- f1 -- g1 -- h1 -- i1 -- j1 [style=none]; 16 2 -- a2 -- b2 -- c2 -- d2 -- e2 -- f2 -- g2 -- h2 -- i2 [style=none]; 17 3 -- a3 -- d3 -- f3 -- h3 [style=none]; 18 4 -- a4 [style=none]; 19 5 -- a5 [style=none]; 20 6 -- a6 -- c6 [style=none]; 21 7 -- a7 -- c7 -- d7 [style=none]; 22 8 -- a8 -- c8 -- f8 [style=none]; 23 9 -- a9 -- c9 -- h9 [style=none]; 24 10 -- a10 -- c10 -- j10 [style=none]; 25 11 -- a11 [style=none]; 26 12 -- a12 [style=none]; 27 28 # separator row 29 3, a3, d3, f3, h3 [shape=none, height=5]; 30 31 # tuning node properties and connections 32 0 [class=spacer]; a0 [shape=none, colwidth=5]; f0 [shape=note, colwidth=2]; 33 1 [class=spacer]; a1 [shape=none]; b1; c1 [width=40]; e1 [shape=none, width=30]; f1 [shape=none]; g1 [width=30]; h1 [shape=none]; i1 [width=30]; j1 [width=40]; 34 2 [class=spacer]; a2 [shape=none]; b2; c2 [class=cjoint]; d2 [shape=none]; e2 [width=30]; g2 [shape=none, width=30]; i2 [shape=none, width=30]; 35 3 [class=spacer]; a3 [shape=none, colwidth=3]; d3 [colwidth=2]; f3 [colwidth=2]; h3 [colwidth=2]; 36 4 [class=spacer]; a4 [class=cmdlink] 37 5 [class=spacer]; a5 [class=cmdlink]; 38 6 [class=spacer]; a6 [class=cmdlink]; c6 [class=cjoint]; a6 -- c6 [style=solid]; c6 -- c2 -> c1 [folded]; 39 7 [class=spacer]; a7 [class=cmdlink]; c7 [class=cjoint]; d7 [shape=none, colwidth=2]; a7 -- c7 -- d7 [style=solid]; d7 -> d3 [folded]; 40 8 [class=spacer]; a8 [class=cmdlink]; c8 [class=cjoint, colwidth=3]; f8 [shape=none, colwidth=2]; a8 -- c8 -- f8 [style=solid]; f8 -> f3 [folded]; 41 9 [class=spacer]; a9 [class=cmdlink]; c9 [class=cjoint, colwidth=5]; h9 [shape=none, colwidth=2]; a9 -- c9 -- h9 [style=solid]; h9 -> h3 [folded]; 42 10 [class=spacer]; a10 [class=cmdlink]; c10 [class=cjoint, colwidth=7]; j10 [shape=none, width=40]; a10 -- c10 -- j10 [style=solid]; j10 -> j1 [folded]; 43 11 [class=spacer]; a11 [class=cmdlink]; 44 12 [class=spacer]; a12 [class=cmdlink]; 45 46 # labels 47 f0 [label="Data (n-1) times", shape=note, color=yellow]; 48 b1 [label=Master, shape=note, color=lightyellow]; c1 [label=START]; d1 [label="Slave Address"]; g1 [label=ACK]; i1 [label=NAK]; j1 [label=STOP]; 49 b2 [label=Slave, shape=note, color=lightyellow]; e2 [label=ACK]; f2 [label=Data]; h2 [label=Data]; 50 a4 [shape=note, label=Commands, color=yellow]; 51 a5 [label="cmd = i2c_cmd_link_create()", numbered = 1]; 52 a6 [label="i2c_master_start(cmd)", numbered = 2]; 53 a7 [label="i2c_master_write_byte(cmd, Address, ACK)", numbered = 3]; 54 a8 [label="i2c_master_read(Data, n-1, ACK)", numbered = 4]; 55 a9 [label="i2c_master_read(Data, 1, NAK)", numbered = 5]; 56 a10 [label="i2c_master_stop(cmd)", numbered = 6]; 57 a11 [label="i2c_master_cmd_begin(I2c_port, cmd, wait)", numbered = 7]; 58 a12 [label="i2c_cmd_link_delete(cmd)", numbered = 8]; 59 60 # Slave Address 61 group { d1; e1; } 62 group { d2; e2; d3; } 63 64 # Data x (n - 1) times 65 group { f1; g1;} 66 group { f2; g2; f3; } 67 68 # Data 69 group { h1; i1; } 70 group { h2; i2; h3; } 71} 72