Skip to content

Commit

Permalink
Add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
MCUdude committed Nov 13, 2023
1 parent f6380af commit 3dfa0cf
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/avrpart.c
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,6 @@ void avr_mem_display(const char *prefix, FILE *f, const AVRMEM *m,
const char *table_padding = "-------------------------------";
static int m_char_max[4] = {0};


if (m == NULL) {
for (LNODEID ln=lfirst(p->mem); ln; ln=lnext(ln)) {
m = ldata(ln);
Expand Down Expand Up @@ -534,6 +533,7 @@ void avr_mem_display(const char *prefix, FILE *f, const AVRMEM *m,
}
m_char_max[3] += strlen("0x");

// Print memory table header
if(p->prog_modes & (PM_PDI | PM_UPDI)) {
fprintf(f,
"\n%s| %-*s %-*s %-*s %*s |\n"
Expand Down Expand Up @@ -569,11 +569,10 @@ void avr_mem_display(const char *prefix, FILE *f, const AVRMEM *m,
prev_mem_offset = m->offset;
prev_mem_size = m->size;

// Workaround to get the 0x prefix where it should be
int m_offset = m->offset;
int m_offset_cnt = 0;
int m_offset_digits = 0;

// Workaround to get the 0x prefix where it should be
do {
m_offset /= 16;
++m_offset_cnt;
Expand All @@ -587,6 +586,7 @@ void avr_mem_display(const char *prefix, FILE *f, const AVRMEM *m,
char d[256];
sprintf(d,"%s%s%s", m->desc, a? "/": "", m_desc_a);

// Print memory table content
if(p->prog_modes & (PM_PDI | PM_UPDI)) {
fprintf(f, "%s| %-*s %*d %*d %*s0x%x |\n",
prefix,
Expand All @@ -612,6 +612,7 @@ static int avr_variants_display(const char *prefix, FILE *f, const AVRPART *p) {
int var_tok_len[5] = {0};

if(lsize(p->variants)) {
// Split variants strings into tokens and find their strlen
for(LNODEID ln=lfirst(p->variants); ln; ln=lnext(ln)) {
sscanf(ldata(ln), "%49[^:]: %49[^,], Fmax=%49[^,], T=[%49[^]]], Vcc=[%49[^]]]",
var_tok[0], var_tok[1], var_tok[2], var_tok[3], var_tok[4]);
Expand All @@ -623,6 +624,7 @@ static int avr_variants_display(const char *prefix, FILE *f, const AVRPART *p) {
}
}

// Print variants table header
fprintf(f,
"\n%s| %-*s %-*s %-*s %-*s %-*s |\n"
"%s|-%*.*s--%*.*s--%*.*s--%*.*s--%*.*s-|\n",
Expand All @@ -639,6 +641,7 @@ static int avr_variants_display(const char *prefix, FILE *f, const AVRPART *p) {
var_tok_len[3]+2, var_tok_len[3]+2, table_padding,
var_tok_len[4]+2, var_tok_len[4]+2, table_padding);

// Print variants table content
for(LNODEID ln=lfirst(p->variants); ln; ln=lnext(ln)) {
sscanf(ldata(ln), "%49[^:]: %49[^,], Fmax=%49[^,], T=[%49[^]]], Vcc=[%49[^]]]",
var_tok[0], var_tok[1], var_tok[2], var_tok[3], var_tok[4]);
Expand Down

0 comments on commit 3dfa0cf

Please sign in to comment.