Moved remotely

git-svn-id: file:///srv/dev-disk-by-uuid-17e88007-4d0c-45e0-8757-cacfcc458630/repositories/svn/Diplomarbeit@113 9fe90eed-be63-e94b-8204-d34ff4c2ff93
This commit is contained in:
Matthias
2009-01-12 08:38:14 +00:00
parent 4e45654a5f
commit 6cc948eef8
204 changed files with 0 additions and 0 deletions
+400
View File
@@ -0,0 +1,400 @@
/******************************************************************************
*
* $RCSfile: $
* $Revision: $
*
* This module provides the interface definitions for for uart.c
* Copyright 2004, R O SoftWare
* No guarantees, warrantees, or promises, implied or otherwise.
* May be used for hobby or commercial purposes provided copyright
* notice remains intact.
*
*****************************************************************************/
#ifndef INC_UART_H
#define INC_UART_H
#include "sys_config.h"
#include "app_types.h"
#include "LPC_REGS.h"
///////////////////////////////////////////////////////////////////////////////
// code is optimized for power of 2 buffer sizes (16, 32, 64, 128, ...)
// NOTE: the buffers are only used if the respective interrupt mode is
// enabled
#define UART0_RX_BUFFER_SIZE 256 // UART0 receive buffer size
#define UART0_TX_BUFFER_SIZE 256 // UART0 transmit buffer size
#define UART1_RX_BUFFER_SIZE 128 // UART1 receive buffer size
#define UART1_TX_BUFFER_SIZE 256 // UART1 transmit buffer size
///////////////////////////////////////////////////////////////////////////////
// use the following macros to determine the 'baud' parameter values
// for uart0Init() and uart1Init()
// CAUTION - 'baud' SHOULD ALWAYS BE A CONSTANT or
// a lot of code will be generated.
#define UART_PCLK_DIV (2) // PCLKSEL0 is changed to div 2 is changed for UART for supporting 115k
#define UART_BAUD(baud) (uint16_t)(((CCLK / UART_PCLK_DIV) / ((baud) * 16.0)) + 0.5)
///////////////////////////////////////////////////////////////////////////////
// Definitions for typical UART 'baud' settings
#define B1200 UART_BAUD(1200)
#define B2400 UART_BAUD(2400)
#define B4800 UART_BAUD(4800)
#define B9600 UART_BAUD(9600)
#define B19200 UART_BAUD(19200)
#define B38400 UART_BAUD(38400)
#define B57600 UART_BAUD(57600)
#define B115200 UART_BAUD(115200)
///////////////////////////////////////////////////////////////////////////////
// Definitions for typical UART 'mode' settings
#define UART_8N1 (uint8_t)(ULCR_CHAR_8 + ULCR_PAR_NO + ULCR_STOP_1)
#define UART_7N1 (uint8_t)(ULCR_CHAR_7 + ULCR_PAR_NO + ULCR_STOP_1)
#define UART_8N2 (uint8_t)(ULCR_CHAR_8 + ULCR_PAR_NO + ULCR_STOP_2)
#define UART_7N2 (uint8_t)(ULCR_CHAR_7 + ULCR_PAR_NO + ULCR_STOP_2)
#define UART_8E1 (uint8_t)(ULCR_CHAR_8 + ULCR_PAR_EVEN + ULCR_STOP_1)
#define UART_7E1 (uint8_t)(ULCR_CHAR_7 + ULCR_PAR_EVEN + ULCR_STOP_1)
#define UART_8E2 (uint8_t)(ULCR_CHAR_8 + ULCR_PAR_EVEN + ULCR_STOP_2)
#define UART_7E2 (uint8_t)(ULCR_CHAR_7 + ULCR_PAR_EVEN + ULCR_STOP_2)
#define UART_8O1 (uint8_t)(ULCR_CHAR_8 + ULCR_PAR_ODD + ULCR_STOP_1)
#define UART_7O1 (uint8_t)(ULCR_CHAR_7 + ULCR_PAR_ODD + ULCR_STOP_1)
#define UART_8O2 (uint8_t)(ULCR_CHAR_8 + ULCR_PAR_ODD + ULCR_STOP_2)
#define UART_7O2 (uint8_t)(ULCR_CHAR_7 + ULCR_PAR_ODD + ULCR_STOP_2)
///////////////////////////////////////////////////////////////////////////////
// Definitions for typical UART 'fmode' settings
#define UART_FIFO_OFF (0x00)
#define UART_FIFO_1 (uint8_t)(UFCR_FIFO_ENABLE + UFCR_FIFO_TRIG1)
#define UART_FIFO_4 (uint8_t)(UFCR_FIFO_ENABLE + UFCR_FIFO_TRIG4)
#define UART_FIFO_8 (uint8_t)(UFCR_FIFO_ENABLE + UFCR_FIFO_TRIG8)
#define UART_FIFO_14 (uint8_t)(UFCR_FIFO_ENABLE + UFCR_FIFO_TRIG14)
///////////////////////////////////////////////////////////////////////////////
/******************************************************************************
*
* Function Name: uart0Init()
*
* Description:
* This function initializes the UART for async mode
*
* Calling Sequence:
* baudrate divisor - use UART0_BAUD macro
* mode - see typical modes (above)
* fmode - see typical fmodes (above)
*
* Returns:
* void
*
* NOTE: uart0Init(UART_BAUD(9600), UART_8N1, UART_FIFO_8);
*
*****************************************************************************/
void uart0Init(uint16_t baud, uint8_t mode, uint8_t fmode);
/******************************************************************************
*
* Function Name: uart0Putch()
*
* Description:
* This function puts a character into the UART output queue for
* transmission.
*
* Calling Sequence:
* character to be transmitted
*
* Returns:
* ch on success, -1 on error (queue full)
*
*****************************************************************************/
int uart0Putch(int ch);
// same but blocking when no space available (mthomas)
int uart0Putch_block(int ch);
/******************************************************************************
*
* Function Name: uart0Space()
*
* Description:
* This function gets the available space in the transmit queue
*
* Calling Sequence:
* void
*
* Returns:
* available space in the transmit queue
*
*****************************************************************************/
uint16_t uart0Space(void);
/******************************************************************************
*
* Function Name: uart0Puts()
*
* Description:
* This function writes a NULL terminated 'string' to the UART output
* queue, returning a pointer to the next character to be written.
*
* Calling Sequence:
* address of the string
*
* Returns:
* a pointer to the next character to be written
* (\0 if full string is written)
*
*****************************************************************************/
const char *uart0Puts(const char *string);
// same but blocking when no space available (mthomas)
const char *uart0Puts_block(const char *string);
/******************************************************************************
*
* Function Name: uart0Write()
*
* Description:
* This function writes 'count' characters from 'buffer' to the UART
* output queue.
*
* Calling Sequence:
*
*
* Returns:
* 0 on success, -1 if insufficient room, -2 on error
* NOTE: if insufficient room, no characters are written.
*
*****************************************************************************/
int uart0Write(const char *buffer, uint16_t count);
/******************************************************************************
*
* Function Name: uart0TxEmpty()
*
* Description:
* This function returns the status of the UART transmit data
* registers.
*
* Calling Sequence:
* void
*
* Returns:
* FALSE - either the tx holding or shift register is not empty
* !FALSE - if both the tx holding & shift registers are empty
*
*****************************************************************************/
int uart0TxEmpty(void);
/******************************************************************************
*
* Function Name: uart0RxEmpty()
*
* Description:
* This function checks the imput buffers
*
* Calling Sequence:
* void
*
* Returns:
* FALSE - either the tx holding or shift register is not empty
* !FALSE - if both the tx holding & shift registers are empty
*
*****************************************************************************/
int uart0RxEmpty(void);
/******************************************************************************
*
* Function Name: uart0TxFlush()
*
* Description:
* This function removes all characters from the UART transmit queue
* (without transmitting them).
*
* Calling Sequence:
* void
*
* Returns:
* void
*
*****************************************************************************/
void uart0TxFlush(void);
/******************************************************************************
*
* Function Name: uart0Getch()
*
* Description:
* This function gets a character from the UART receive queue
*
* Calling Sequence:
* void
*
* Returns:
* character on success, -1 if no character is available
*
*****************************************************************************/
int uart0Getch(void);
/******************************************************************************
*
* Function Name: uart1Init()
*
* Description:
* This function initializes the UART for async mode
*
* Calling Sequence:
* baudrate divisor - use UART_BAUD macro
* mode - see typical modes (above)
* fmode - see typical fmodes (above)
*
* Returns:
* void
*
* NOTE: uart1Init(UART_BAUD(9600), UART_8N1, UART_FIFO_8);
*
*****************************************************************************/
void uart1Init(uint16_t baud, uint8_t mode, uint8_t fmode);
/******************************************************************************
*
* Function Name: uart1Putch()
*
* Description:
* This function puts a character into the UART output queue for
* transmission.
*
* Calling Sequence:
* character to be transmitted
*
* Returns:
* ch on success, -1 on error (queue full)
*
*****************************************************************************/
int uart1Putch(int ch);
// same but blocking when no space available (mthomas)
int uart1Putch_block(int ch);
/******************************************************************************
*
* Function Name: uart1Space()
*
* Description:
* This function gets the available space in the transmit queue
*
* Calling Sequence:
* void
*
* Returns:
* available space in the transmit queue
*
*****************************************************************************/
uint16_t uart1Space(void);
/******************************************************************************
*
* Function Name: uart1Puts()
*
* Description:
* This function writes a NULL terminated 'string' to the UART output
* queue, returning a pointer to the next character to be written.
*
* Calling Sequence:
* address of the string
*
* Returns:
* a pointer to the next character to be written
* (\0 if full string is written)
*
*****************************************************************************/
const char *uart1Puts(const char *string);
// same but blocking when no space available (mthomas)
const char *uart1Puts_block(const char *string);
/******************************************************************************
*
* Function Name: uart1Write()
*
* Description:
* This function writes 'count' characters from 'buffer' to the UART
* output queue.
*
* Calling Sequence:
*
*
* Returns:
* 0 on success, -1 if insufficient room, -2 on error
* NOTE: if insufficient room, no characters are written.
*
*****************************************************************************/
int uart1Write(const char *buffer, uint16_t count);
/******************************************************************************
*
* Function Name: uart1TxEmpty()
*
* Description:
* This function returns the status of the UART transmit data
* registers.
*
* Calling Sequence:
* void
*
* Returns:
* FALSE - either the tx holding or shift register is not empty
* !FALSE - if both the tx holding & shift registers are empty
*
*****************************************************************************/
int uart1TxEmpty(void);
/******************************************************************************
*
* Function Name: uart1RxEmpty()
*
* Description:
* This function checks the imput buffers
*
* Calling Sequence:
* void
*
* Returns:
* FALSE - either the tx holding or shift register is not empty
* !FALSE - if both the tx holding & shift registers are empty
*
*****************************************************************************/
int uart1RxEmpty(void);
/******************************************************************************
*
* Function Name: uart1TxFlush()
*
* Description:
* This function removes all characters from the UART transmit queue
* (without transmitting them).
*
* Calling Sequence:
* void
*
* Returns:
* void
*
*****************************************************************************/
void uart1TxFlush(void);
/******************************************************************************
*
* Function Name: uart1Getch()
*
* Description:
* This function gets a character from the UART receive queue
*
* Calling Sequence:
* void
*
* Returns:
* character on success, -1 if no character is available
*
*****************************************************************************/
int uart1Getch(void);
#endif