Skip to content

Commit

Permalink
Fix snprintf bugs in MAX32665 ADC example
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacob-Scheiffler committed Oct 6, 2023
1 parent e74f371 commit 2e9223d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions Examples/MAX32665/ADC/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,20 +146,20 @@ int main(void)
overflow[3] = (MXC_ADC_GetData(&adc_val[3]) == E_OVERFLOW ? 1 : 0);

/* Display results on OLED display, display asterisk if overflow */
snprintf((char *)fmtstr, sizeof((char *)fmtstr), "0: 0x%04x%s 2: 0x%04x%s", adc_val[0],
snprintf((char *)fmtstr, sizeof(fmtstr), "0: 0x%04x%s 2: 0x%04x%s", adc_val[0],
overflow[0] ? "*" : " ", adc_val[2], overflow[2] ? "*" : " ");
printf("%s\n", fmtstr);

snprintf((char *)fmtstr, sizeof((char *)fmtstr), "1: 0x%04x%s 3: 0x%04x%s", adc_val[1],
snprintf((char *)fmtstr, sizeof(fmtstr), "1: 0x%04x%s 3: 0x%04x%s", adc_val[1],
overflow[1] ? "*" : " ", adc_val[3], overflow[3] ? "*" : " ");
printf("%s\n", fmtstr);
/* Determine if programmable limits on AIN1 were exceeded */
if (MXC_ADC_GetFlags() & (MXC_F_ADC_INTR_LO_LIMIT_IF | MXC_F_ADC_INTR_HI_LIMIT_IF)) {
snprintf((char *)fmtstr, sizeof((char *)fmtstr), " %s Limit on AIN0 ",
snprintf((char *)fmtstr, sizeof(fmtstr), " %s Limit on AIN0 ",
(MXC_ADC_GetFlags() & MXC_F_ADC_INTR_LO_LIMIT_IF) ? "Low" : "High");
MXC_ADC_ClearFlags(MXC_F_ADC_INTR_LO_LIMIT_IF | MXC_F_ADC_INTR_HI_LIMIT_IF);
} else {
snprintf((char *)fmtstr, sizeof((char *)fmtstr), " ");
snprintf((char *)fmtstr, sizeof(fmtstr), " ");
}
printf("%s\n", fmtstr);

Expand Down

0 comments on commit 2e9223d

Please sign in to comment.