#Diagram demonstrating how to build a command link for an I2C master to read n bytes from a slave blockdiag i2c-command-link-master-read { # global properties span_width = 5; span_height = 5; node_height = 25; default_group_color = lightgrey; class spacer [shape=none, width=10]; class cmdlink [colwidth=2, width=180]; class cjoint [shape=none, width=40]; # all the rows 0 -- a0 -- f0 [style=none]; 1 -- a1 -- b1 -- c1 -- d1 -- e1 -- f1 -- g1 -- h1 -- i1 -- j1 [style=none]; 2 -- a2 -- b2 -- c2 -- d2 -- e2 -- f2 -- g2 -- h2 -- i2 [style=none]; 3 -- a3 -- d3 -- f3 -- h3 [style=none]; 4 -- a4 [style=none]; 5 -- a5 [style=none]; 6 -- a6 -- c6 [style=none]; 7 -- a7 -- c7 -- d7 [style=none]; 8 -- a8 -- c8 -- f8 [style=none]; 9 -- a9 -- c9 -- h9 [style=none]; 10 -- a10 -- c10 -- j10 [style=none]; 11 -- a11 [style=none]; 12 -- a12 [style=none]; # separator row 3, a3, d3, f3, h3 [shape=none, height=5]; # tuning node properties and connections 0 [class=spacer]; a0 [shape=none, colwidth=5]; f0 [shape=note, colwidth=2]; 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]; 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]; 3 [class=spacer]; a3 [shape=none, colwidth=3]; d3 [colwidth=2]; f3 [colwidth=2]; h3 [colwidth=2]; 4 [class=spacer]; a4 [class=cmdlink] 5 [class=spacer]; a5 [class=cmdlink]; 6 [class=spacer]; a6 [class=cmdlink]; c6 [class=cjoint]; a6 -- c6 [style=solid]; c6 -- c2 -> c1 [folded]; 7 [class=spacer]; a7 [class=cmdlink]; c7 [class=cjoint]; d7 [shape=none, colwidth=2]; a7 -- c7 -- d7 [style=solid]; d7 -> d3 [folded]; 8 [class=spacer]; a8 [class=cmdlink]; c8 [class=cjoint, colwidth=3]; f8 [shape=none, colwidth=2]; a8 -- c8 -- f8 [style=solid]; f8 -> f3 [folded]; 9 [class=spacer]; a9 [class=cmdlink]; c9 [class=cjoint, colwidth=5]; h9 [shape=none, colwidth=2]; a9 -- c9 -- h9 [style=solid]; h9 -> h3 [folded]; 10 [class=spacer]; a10 [class=cmdlink]; c10 [class=cjoint, colwidth=7]; j10 [shape=none, width=40]; a10 -- c10 -- j10 [style=solid]; j10 -> j1 [folded]; 11 [class=spacer]; a11 [class=cmdlink]; 12 [class=spacer]; a12 [class=cmdlink]; # labels f0 [label="Data (n-1) times", shape=note, color=yellow]; b1 [label=Master, shape=note, color=lightyellow]; c1 [label=START]; d1 [label="Slave Address"]; g1 [label=ACK]; i1 [label=NAK]; j1 [label=STOP]; b2 [label=Slave, shape=note, color=lightyellow]; e2 [label=ACK]; f2 [label=Data]; h2 [label=Data]; a4 [shape=note, label=Commands, color=yellow]; a5 [label="cmd = i2c_cmd_link_create()", numbered = 1]; a6 [label="i2c_master_start(cmd)", numbered = 2]; a7 [label="i2c_master_write_byte(cmd, Address, ACK)", numbered = 3]; a8 [label="i2c_master_read(Data, n-1, ACK)", numbered = 4]; a9 [label="i2c_master_read(Data, 1, NAK)", numbered = 5]; a10 [label="i2c_master_stop(cmd)", numbered = 6]; a11 [label="i2c_master_cmd_begin(I2c_port, cmd, wait)", numbered = 7]; a12 [label="i2c_cmd_link_delete(cmd)", numbered = 8]; # Slave Address group { d1; e1; } group { d2; e2; d3; } # Data x (n - 1) times group { f1; g1;} group { f2; g2; f3; } # Data group { h1; i1; } group { h2; i2; h3; } }