All pastes #222526 Raw Edit

Mine

public text v1 · immutable
#222526 ·published 2006-10-26 11:01 UTC
rendered paste body
void uart_putc(char c) {

  if (UART_TX_OK && (tx_wr == tx_rd)) {

    UDR = c;

  } else {

    while (TX_INCR(tx_wr, 1) == tx_rd) ;

    tx_buf[tx_wr] = c;

    tx_wr = TX_INCR(tx_wr, 1);

  }

}



void uart_init(void) {

  tx_wr = tx_rd = 0;

  

  /* set baudrate */

  //UBRRL = (((F_CPU) / (16 * MIDI_BAUD)) - 1);

  //UBRRL = 51;       // 9600 @ 8mhz

  UBRRL = 15;       // 31250kbps @ 8mhz

	/* enable TX, interrupts */

  UCSRB = _BV(TXEN) | _BV(TXCIE);

  /* enable 2x mode */

  //UCSRA = _BV(U2X);



  sei();

}