|
правда тормозится немного при опросе флага.
#if __VER__ < 200
void interrupt [UART0TX_VECTOR] write_to_uart( void )
#else
#pragma vector=UART0TX_VECTOR
__interrupt void write_to_uart( void )
#endif
{
if (tx_chars <= 0) /* If tx buffer empty, turn */
{
IE1 &= ~UTXIE0;
IFG1 |= UTXIFG0;
while (!(UTCTL0 & TXEPT));
P3OUT &= ~0x08; // P4.0 disable externat transmitter
return;
}
TXBUF0 = tx_queue[tx_out++] ;
if (tx_out == TX_QUEUE_SIZE)
tx_out = 0;
tx_chars--;
}
void
putc( char c)
{
while (!(tx_chars < TX_QUEUE_SIZE)) ; /* Wait for non-full buffer */
IE1 &= ~UTXIE0; /* Interrupts off */
tx_queue[tx_in++] = c; /* Stuff character in queue */
if (tx_in == TX_QUEUE_SIZE) tx_in = 0; /* Wrap index if needed */
tx_chars++; /* Number of char's in queue */
P3OUT |= 0x08; // P4.0 enable externat transmitter
IE1 |= UTXIE0; /* Enable UART tx interrupt */
}
E-mail: info@telesys.ru