USB-BDI
Defines | Functions | Variables
M:/USB-BDI/USB-BDI/Firmware/MPC555-USB-BDI/include/uart.h File Reference

headerfile for uart.c More...

#include "fx2regs.h"

Go to the source code of this file.

Defines

#define usbOutBufferUart   EP4FIFOBUF
#define usbInBufferUart   EP8FIFOBUF
#define NUMBER_OF_STD_VALUES   7
#define UART_BUF_LEN   512
#define Uart0Insert(char)
#define Uart0TriggerSend()

Functions

void initUART ()
 initialize uart0
void changeBaudRate (unsigned long bitRate)
 changes the BaudeRate

Variables

__xdata volatile unsigned char uart0OutBuffer [UART_BUF_LEN]
__xdata volatile unsigned char uart0InBuffer [UART_BUF_LEN]
volatile unsigned short uart0OutBufferStart
volatile unsigned short uart0OutBufferEnd
volatile unsigned short uart0InBufferStart
volatile unsigned short uart0InBufferEnd
unsigned short uart0InBufferLen

Detailed Description

headerfile for uart.c

Author:
Schlaepfer Stephan
Version:
1.0
Date:
24.10.2006

Definition in file uart.h.


Define Documentation

#define NUMBER_OF_STD_VALUES   7

number of std values

Definition at line 37 of file uart.h.

#define Uart0Insert (   char)
Value:
{\
        uart0InBuffer[uart0InBufferEnd] = char;\
        uart0InBufferEnd = (uart0InBufferEnd + 1) % UART_BUF_LEN;\
        /* used to overwrite the oldest char if buffer full*/\
        if (uart0InBufferEnd == uart0InBufferStart) {\
                uart0InBufferStart = (uart0InBufferStart + 1) % UART_BUF_LEN;\
        }\
}

puts a char into the buffer

Definition at line 53 of file uart.h.

#define Uart0TriggerSend ( )
Value:
{\
        uart0InBufferLen = ((uart0InBufferEnd - uart0InBufferStart) + UART_BUF_LEN) % UART_BUF_LEN;\
        if (uart0InBufferLen > 0) {\
                SBUF0 = uart0InBuffer[uart0InBufferStart];\
                uart0InBufferStart = (uart0InBufferStart + 1) % UART_BUF_LEN;\
        }\
}

triggers sending a message

Definition at line 63 of file uart.h.

#define UART_BUF_LEN   512

usb buffer length

Definition at line 41 of file uart.h.

#define usbInBufferUart   EP8FIFOBUF

usb in buffer for uart0

Definition at line 35 of file uart.h.

#define usbOutBufferUart   EP4FIFOBUF

usb out buffer for uart0

Definition at line 33 of file uart.h.


Function Documentation

void changeBaudRate ( unsigned long  bitRate)

changes the BaudeRate

Parameters:
bitRatenew bit Rate

Bit rate = 12Mhz/16/(255-TH1) Default value is 9600 baud/sec NOTE: the bit rate is rounded for example if you chose 350000 than TH1 = 255-750000/bitRate is set to 252 and thus the rate is 750000/(255-252) = 375000. the same happens in the MPC555 for these reason there are sometimes rates which don't match. the higher the rates the higher is the probability that this effect takes place

Definition at line 135 of file uart.c.

void initUART ( )

initialize uart0

initialization for uart1 is commented out

Definition at line 93 of file uart.c.


Variable Documentation

__xdata volatile unsigned char uart0InBuffer[UART_BUF_LEN]

uart0 in buffer

Definition at line 44 of file uart.c.

volatile unsigned short uart0InBufferEnd

uart0 in buffer end "pointer"

Definition at line 40 of file uart.c.

unsigned short uart0InBufferLen

uart0 buffer length

Definition at line 30 of file dispatch.c.

volatile unsigned short uart0InBufferStart

uart0 in buffer start "pointer"

Definition at line 38 of file uart.c.

__xdata volatile unsigned char uart0OutBuffer[UART_BUF_LEN]

uart0 out buffer

Definition at line 42 of file uart.c.

volatile unsigned short uart0OutBufferEnd

uart0 out buffer end "pointer"

Definition at line 36 of file uart.c.

volatile unsigned short uart0OutBufferStart

uart0 out buffer start "pointer"

Definition at line 34 of file uart.c.

 All Files Functions Variables Defines