avr_lin_t *p = (avr_lin_t*) param;
if (p->r_linbtr != p->ldisr.reg || p->r_linbtr != p->lbt.reg) { // sanity check
- printf("Error: LDISR and LBT[x] register different!\n");
+ AVR_LOG(avr, LOG_ERROR, "LIN: LDISR and LBT[x] register different!\n");
return;
}
- printf("LIN addr[%04x] = %02x\n", addr, v);
+ AVR_LOG(avr, LOG_TRACE, "LIN: addr[%04x] = %02x\n", addr, v);
if (addr == p->ldisr.reg) {
if (avr_regbit_get(avr, p->lena)) {
- printf("Warning: LENA bit set on changing LBTR\n");
+ AVR_LOG(avr, LOG_WARNING, "LIN: LENA bit set on changing LBTR\n");
return;
}
if ((v >> p->ldisr.bit) & p->ldisr.mask) {
uint8_t lbt = (v >> p->lbt.bit) & p->lbt.mask;
uint8_t ov = v;
v = (1 << p->ldisr.bit) | (lbt << p->lbt.bit);
- printf("LIN: v=%02x -> LBT = %02x -> LINBT = %02x\n", ov, lbt, v);
+ AVR_LOG(avr, LOG_TRACE, "LIN: v=%02x -> LBT = %02x -> LINBT = %02x\n", ov, lbt, v);
} else {
v = 0x20;
}
uint32_t lbt = avr_regbit_get(avr, p->lbt);
uint32_t lbrr = (avr->data[p->r_linbrrh] << 8) | avr->data[p->r_linbrrl];
- printf("LIN-UART LBT/LBRR to %04x/%04x\n", lbt, lbrr);
+ AVR_LOG(avr, LOG_TRACE, "LIN: UART LBT/LBRR to %04x/%04x\n", lbt, lbrr);
uint32_t baud = avr->frequency / (lbt * (lbrr + 1));
uint32_t word_size = 1 /*start*/+ 8 /*data bits*/+ 1 /*parity*/+ 1 /*stop*/;
- printf("LIN-UART configured to %04x/%04x = %d bps, 8 data 1 stop\n", lbt,
+ AVR_LOG(avr, LOG_TRACE, "LIN: UART configured to %04x/%04x = %d bps, 8 data 1 stop\n", lbt,
lbrr, baud);
p->uart.usec_per_byte = 1000000 / (baud / word_size);
- printf("Roughly %d usec per bytes\n", (int) p->uart.usec_per_byte);
+ AVR_LOG(avr, LOG_TRACE, "LIN: Roughly %d usec per bytes\n", (int) p->uart.usec_per_byte);
}
static void
avr_lin_reset(
avr_io_t *port)
{
- printf("LIN-UART: reset\n");
avr_lin_t *p = (avr_lin_t*) port;
avr_t * avr = p->io.avr;
+ AVR_LOG(avr, LOG_TRACE, "LIN: UART: reset\n");
+
p->uart.io.reset(&p->uart.io);
avr->data[p->r_linbtr] = 0x20;
}