uart_int.c File Reference

Interrupt driven UART communications for better (less cpu time) over serial. More...

Go to the source code of this file.

Defines

#define INT_CTI   5
#define INT_RDA   2
#define INT_RLS   3
#define INT_THRE   1

Functions

__irq void uarti_isr (void)
void uarti_print_2float (float f1, float f2)
void uarti_print_float (float f)
void uarti_print_int (int i)
void uarti_print_int2 (int i1, int i2)
int uarti_tx_buf (char *buf, int buflen)
void uarti_tx_refill (void)
void uarti_tx_set_empty_callback (UARTI_CALLBACK_PTR callback)

Variables

static char * uarti_out_buf
static UARTI_CALLBACK_PTR uarti_out_callback
static volatile int uarti_out_len = 0
static volatile int uarti_out_next_idx = 0
static volatile int uarti_out_stall = 1
static char uarti_str [100]
static int uarti_strlen = 0

Detailed Description

Interrupt driven UART communications for better (less cpu time) over serial.

Example use:

  char string[50];
  int str_length = sprintf(string,"Hello World!!\n"); //fill the char buffer
  uarti_tx_buf(string, str_length); //send out string over uart

Example Hardware and Register setup for interrupt UART:

  // ***********************************************
  // UART Init Section
  // ***********************************************
  
  //Set P0.0 to TXD0 and P0.1 to RXD0 
  PINSEL0 &= ~(0xF);
  PINSEL0 |= 0x5;
  
  U0LCR = (1<<7);//DLAB = 1 to enable baud rate changes
  //Rate config from Jason for 115.2k, with 1+0.3 frac divider and pclk = 60MHz
  U0DLL = 25;
  U0DLM = 0;
  U0FDR = 3;//DIVADDVAL = 3
  U0FDR |= 10<<4;//MULTVAL = 10;
  //
  
  U0LCR = (0<<7)|(3<<0);//DLAB = 0 to disable baud rate changes, Wordsize = 3 for 8 bit words
  
  U0IER = (1<<1);//1: Enable THRE interrupt
  
  IO0DIR |= 1<<10; //Unassert SHDN_L on uart level shifter
  IO0SET = 1<<10;

Example Interrupt setup for the uart_isr:

  VICVectAddr8 = (unsigned long)uarti_isr;
  VICVectCntl8 = 0x20 | VIC_UART0; // Timer1 Interrupt 
  VICIntEnable = 1 << VIC_UART0;   // Enable Timer1 Interrupt
Author:
Tommy Craig
Date:
Summer 2009

Definition in file uart_int.c.

Generated on Tue Jun 29 16:36:15 2010 by  doxygen 1.6.3