-
Notifications
You must be signed in to change notification settings - Fork 0
/
UCint.c
36 lines (33 loc) · 976 Bytes
/
UCint.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <msp430.h>
#include <ctl_api.h>
#include <UCA1_uart.h>
//buffers for USB UART
struct Tx UCA1_TxBuf;
struct Rx UCA1_RxBuf;
//UART TX ISR called to transmit UART data
void UC1_TX(void) __ctl_interrupt[USCIAB1TX_VECTOR]{
unsigned char flags=UC1IFG&(UC1IE);
//=============[UART Transmit Handler]===============
if(flags&UCA1TXIFG){
unsigned char c;
if (ctl_byte_queue_receive_nb(&UCA1_TxBuf.queue,&c)==0){
//buffer empty disable TX
UCA1_TxBuf.done=1;
UC1IFG&=~UCA1TXIFG;
}else{
//send char to UART
UCA1TXBUF=c;
}
}
}
// receive UART ISR
void UC1_rx(void) __ctl_interrupt[USCIAB1RX_VECTOR]{
unsigned char flags=UC1IFG&(UC1IE);
//==============[UART Receive Handler]==========================
if(flags&UCA1RXIFG){
//read a byte from UART
unsigned char c=UCA1RXBUF;
//put byte in queue, if no room too darn bad
ctl_byte_queue_post_nb(&UCA1_RxBuf.queue,c);
}
}