//! enable and initialize the software uart void uartswInit(void) { // initialize the buffers uartswInitBuffers(); // initialize the ports sbi(UARTSW_TX_DDR, UARTSW_TX_PIN); cbi(UARTSW_RX_DDR, UARTSW_RX_PIN); cbi(UARTSW_RX_PORT, UARTSW_RX_PIN); // initialize baud rate uartswSetBaudRate(9600); // setup the transmitter UartswTxBusy = FALSE; // disable OC2 interrupt cbi(TIMSK, OCIE2); // attach TxBit service routine to OC2 timerAttach(TIMER2OUTCOMPARE_INT, uartswTxBitService); // setup the receiver UartswRxBusy = FALSE; // disable OC0 interrupt cbi(TIMSK, OCIE0); // attach RxBit service routine to OC0 timerAttach(TIMER0OUTCOMPARE_INT, uartswRxBitService); // INT2 trigger on rising edge sbi(EICRA, ISC20); // enable INT2 interrupt sbi(EIMSK, INT2); // turn on interrupts sei(); }
//! enable and initialize the software uart void uartswInit(void) { // initialize the buffers uartswInitBuffers(); // initialize the ports sbi(UARTSW_TX_DDR, UARTSW_TX_PIN); cbi(UARTSW_RX_DDR, UARTSW_RX_PIN); cbi(UARTSW_RX_PORT, UARTSW_RX_PIN); // initialize baud rate uartswSetBaudRate(9600); // setup the transmitter UartswTxBusy = FALSE; // disable OC1A interrupt cbi(TIMSK, OCIE1A); // attach TxBit service routine to OC1A timerAttach(TIMER1OUTCOMPAREA_INT, uartswTxBitService); // setup the receiver UartswRxBusy = FALSE; // disable OC1B interrupt cbi(TIMSK, OCIE1B); // attach RxBit service routine to OC1B timerAttach(TIMER1OUTCOMPAREB_INT, uartswRxBitService); // attach RxBit service routine to ICP timerAttach(TIMER1INPUTCAPTURE_INT, uartswRxBitService); // trigger on rising edge sbi(TCCR1B, ICES1); // enable ICP interrupt sbi(TIMSK, TICIE1); // turn on interrupts sei(); }
// enable and initialize the software uart void uartswInit(void) { // initialize the buffers uartswInitBuffers(); // initialize the ports sbi(UARTSW_TX_DDR, UARTSW_TX_PIN); #ifdef UARTSW_INVERT cbi(UARTSW_TX_PORT, UARTSW_TX_PIN); #else sbi(UARTSW_TX_PORT, UARTSW_TX_PIN); #endif cbi(UARTSW_RX_DDR, UARTSW_RX_PIN); #ifdef UARTSW_INVERT cbi(UARTSW_RX_PORT, UARTSW_RX_PIN); #else sbi(UARTSW_RX_PORT, UARTSW_RX_PIN); #endif // initialize baud rate uartswSetBaudRate(9600); // setup the transmitter UartswTxBusy = FALSE; // disable OC0A interrupt cbi(TIMSK0, OCIE0A); // attach TxBit service routine to OC0A timerAttach(TIMER0OUTCOMPAREA_INT, uartswTxBitService); // setup the receiver UartswRxBusy = FALSE; // disable 0C0B interrupt cbi(TIMSK0, OCIE0B); // attach RxBit service routine to OC0B timerAttach(TIMER0OUTCOMPAREB_INT, uartswRxBitService); // INT1 trigger on rising/falling edge #ifdef UARTSW_INVERT sbi(EICRA, ISC11); sbi(EICRA, ISC10); #else sbi(EICRA, ISC11); cbi(EICRA, ISC10); #endif // enable INT1 interrupt sbi(EIMSK, INT1); // turn on interrupts sei(); }
//! enable and initialize the software uart void uartswInit(void) { // initialize the buffers uartswInitBuffers(); // initialize the ports sbi(UARTSW_TX_DDR, UARTSW_TX_PIN); #ifdef UARTSW_INVERT cbi(UARTSW_TX_PORT, UARTSW_TX_PIN); #else sbi(UARTSW_TX_PORT, UARTSW_TX_PIN); #endif cbi(UARTSW_RX_DDR, UARTSW_RX_PIN); cbi(UARTSW_RX_PORT, UARTSW_RX_PIN); // initialize baud rate uartswSetBaudRate(9600); // setup the transmitter UartswTxBusy = FALSE; // disable OC2 interrupt cbi(TIMSK0, OCIE2A); // attach TxBit service routine to OC2 timerAttach(TIMER2OUTCOMPARE_INT, uartswTxBitService); // setup the receiver UartswRxBusy = FALSE; // disable OC0 interrupt cbi(TIMSK0, OCIE0A); // attach RxBit service routine to OC0 timerAttach(OCIE0A, uartswRxBitService); // INT2 trigger on rising/falling edge #ifdef UARTSW_INVERT sbi(MCUCR, ISC11); // rising edge #else cbi(MCUCR, ISC11); // falling edge #endif // enable INT2 interrupt sbi(PCMSK0, PCINT2); // turn on interrupts sei(); }