1function tplg_write(fn, blob8, name, comment) 2 3if nargin < 4 4 comment = 'Exported Control Bytes'; 5end 6 7%% Pad blob length to multiple of four bytes 8n_orig = length(blob8); 9n_new = ceil(n_orig/4)*4; 10blob8_new = zeros(1, n_new); 11blob8_new(1:n_orig) = blob8; 12 13%% Write blob 14fh = fopen(fn, 'w'); 15nl = 8; 16fprintf(fh, '# %s %s\n', comment, date()); 17fprintf(fh, 'CONTROLBYTES_PRIV(%s_priv,\n', name); 18fprintf(fh, '` bytes "'); 19for i = 1:nl:n_new 20 if i > 1 21 fprintf(fh, '` '); 22 end 23 for j = 0:nl-1 24 n = i + j; 25 if n < n_new 26 fprintf(fh, '0x%02x,', blob8_new(n)); 27 end 28 if n == n_new 29 fprintf(fh, '0x%02x"', blob8_new(n)); 30 end 31 end 32 fprintf(fh, '''\n'); 33end 34fprintf(fh, ')\n'); 35fclose(fh); 36 37end 38