/*! * \brief Initialize debug device 2. * * \return Always 0. */ static int DebugInit(NUTDEVICE * dev) { #if NUT_DEV_DEBUG_PINS /* Disable GPIO on UART tx/rx pins. */ outr(NUT_DEV_DEBUG_PDR, NUT_DEV_DEBUG_PINS); #endif /* Reset UART. */ outr(DBGU_CR, US_RSTRX | US_RSTTX | US_RXDIS | US_TXDIS); /* Disable all UART interrupts. */ outr(DBGU_IDR, 0xFFFFFFFF); #if NUT_DEV_DEBUG_SPEED /* Set UART baud rate generator register. */ outr(DBGU_BRGR, At91BaudRateDiv(NUT_DEV_DEBUG_SPEED)); #endif /* Set UART mode to 8 data bits, no parity and 1 stop bit. */ outr(DBGU_MR, US_CHMODE_NORMAL | US_CHRL_8 | US_PAR_NO | US_NBSTOP_1); /* Enable UART transmitter and optionally the receiver. */ outr(DBGU_CR, NUT_DEV_DEBUG_ENA); return 0; }
/*! * \brief Handle I/O controls for debug device 2. * * The debug device supports UART_SETSPEED only. * * \return 0 on success, -1 otherwise. */ int At91DevDebugIOCtl(NUTDEVICE * dev, int req, void *conf) { if(req == UART_SETSPEED) { outr(dev->dev_base + US_BRGR_OFF, At91BaudRateDiv(*((uint32_t *)conf))); return 0; } return -1; }