В нижеприведенном коде не могу понять зачем нужно:
Код
char i = 16;
и
Код
while (i && txout)
? Какой логический смысл в этом?
Код
//uart1.c
#include <LPC214x.H>
#define Fosc 12000000
#define Fpclk 60000000
unsigned int txin; // Next In Index
unsigned int txout; // Next Out Index
unsigned char *txbuf; // pointer to Tx buffer
__irq void U1_Isr(void)
{
char i = 16;
if ((U1IIR & 0x0F) == 2) // THRE Interrupt ? когда передающий буфер пуст
{
while (i && txout)
{
U1THR = txbuf[txin++];
txout --;
i --;
}
}
VICVectAddr = 0; // Acknowledge Interrupt
}
void UART1_Send(unsigned char *buf, unsigned int len)
{
char i = 16;
if (txout == 0) // previous message send ?
{
txbuf = buf; // copy buffer pointer
txout = len;
txin = 0;
while (i && txout)
{
U1THR = txbuf[txin++];
txout --;
i --;
}
}
}
Спасибо.
Живи днем так, чтобы ночью ты спал спокойно.