CLEON  Version 1
Cloud-Offloaded GPS Receiver
hal_uart.c
Go to the documentation of this file.
1 
7 #include "cleon_conf.h"
8 #include "app_define.h"
9 #include "sys_define.h"
10 #include "hal_define.h"
11 #include "fs_define.h"
12 
13 // Flags
14 extern bool bFLAG_USBFrameReceived;
15 
16 /*----------------------------------------------------------------------------*/
25 {
26  USB_PORT(SEL) |= BV(USB_TXD_PIN);
27  USB_PORT(SEL) |= BV(USB_RXD_PIN);
28 
29  // UART, which is used for USB, is set to 57600 bps
30  // (see, pp909 of 'MSP430x5xx and MSP430x6xx family user's guide')
31  UCA1CTL1 |= UCSWRST; // **Put state machine in reset**
32  UCA1CTL1 |= UCSSEL_2; // Set SMCLK as clock source
33  UCA1BRW = 208; // 12MHz 57600 bps (see User's Guide)
34  UCA1MCTL = UCBRS_2; // Modln UCBRSx=2, UCBRFx=0,
35 
36  UCA1CTL1 &= ~UCSWRST; // **Initialize USCI state machine**
37  UCA1IE |= UCRXIE; // Enable USCI_A1 RX interrupt
38 }
39 
40 //------------------------------------------------------------------------------
41 // USCI_A1 Interrupt Service Routine
42 //------------------------------------------------------------------------------
43 #pragma vector = USCI_A1_VECTOR
44 __interrupt void USCI_A1_VECTOR_ISR(void)
45 {
46  unsigned char ucRxData;
47  switch(__even_in_range(UCA1IV,12)){
48  case 0: break;
49  case 2:
50  ucRxData = UCA1RXBUF;
51  SYS_USB_ReceiveFrame(ucRxData);
52  // If a complete USB frame has received successfully, exit low-power-mode
54  __low_power_mode_off_on_exit();
55  }
56  break;
57  case 4: break;
58  case 6: break;
59  case 8: break;
60  case 10: break;
61  case 12: break;
62  default: break;
63  }
64 }