105 lines
2.7 KiB
C
105 lines
2.7 KiB
C
/*******************************************************************************
|
|
* *
|
|
* Copyright 2010 Rheinmetall Canada Inc. *
|
|
* *
|
|
* No part of this document may be reproduced, stored in *
|
|
* a retrieval system, or transmitted, in any form or by any means, *
|
|
* electronic, mechanical, photocopying, recording, or otherwise, *
|
|
* without the prior written permission of Rheinmetall Canada Inc. *
|
|
* *
|
|
*******************************************************************************/
|
|
/*
|
|
Description:
|
|
This is a template file for standard C header file.
|
|
|
|
*/
|
|
|
|
/* ************************************************************************** */
|
|
/* ¤Revision:
|
|
000 20100616 JFM,
|
|
Original version.
|
|
|
|
### YYYYMMDD Initial, Bug Identification
|
|
Change description.
|
|
*/
|
|
|
|
#ifndef UART_H
|
|
#define UART_H
|
|
|
|
/* ************************************************************************** */
|
|
/* Defines */
|
|
#define UART_MAX_RX_BUFF_SIZE 1024
|
|
#define UART_MAX_TX_BUFF_SIZE 1024
|
|
|
|
//#define UART_SET_FLAG_ON_SEND
|
|
|
|
|
|
/* ************************************************************************** */
|
|
/* Type definitions */
|
|
//Handles to the Uart ports as mapped physically on the CU board.
|
|
//in comment is the physical port assigned to each handle
|
|
//
|
|
enum eUartHandles
|
|
{
|
|
//Uart 0 to 6 is mapped to P2 connector
|
|
UART_0, //(422)
|
|
UART_1, //(422)
|
|
UART_2, //(422)
|
|
UART_3, //(422)
|
|
UART_4, //(232)
|
|
UART_5, //(232)
|
|
|
|
MAX_UART_HANDLE
|
|
};
|
|
|
|
enum eUartStopBits
|
|
{
|
|
UART_ONE_STOP_BIT,
|
|
UART_ONE_HALF_STOP_BIT,
|
|
UART_TWO_STOP_BITS
|
|
};
|
|
enum eUartParity
|
|
{
|
|
UART_NO_PARITY,
|
|
UART_EVEN_PARITY,
|
|
UART_ODD_PARTIY
|
|
};
|
|
|
|
typedef struct
|
|
{
|
|
int iIsInternal;
|
|
int iPhysicalUartPort;
|
|
int iDataPending; //This flag is 0 when : TxPtr == RxPtr OR Uart is transmitting.
|
|
|
|
char acTxCircularBuffer[UART_MAX_TX_BUFF_SIZE];
|
|
char *pcTxInPtr;
|
|
char *pcTxOutPtr;
|
|
|
|
char acRxBuffer[UART_MAX_RX_BUFF_SIZE];
|
|
|
|
|
|
}stUartData;
|
|
|
|
enum eUartReturnValues
|
|
{
|
|
UART_OK = 1,
|
|
UART_PORT_BUSY,
|
|
UART_PORT_NOT_OPENED,
|
|
UART_BUFFER_FULL,
|
|
UART_INVALID_HANDLE,
|
|
UART_INVALID_PORT
|
|
};
|
|
|
|
/* ************************************************************************** */
|
|
/* Prototypes */
|
|
int UartTransmitData(int p_iUartHandle, char *p_pcBuffer, int p_iSize);
|
|
int UartReceiveData(int p_iUartHandle, char *p_pcBuffer, int p_iSize);
|
|
int DataSentNotification(int p_iUartHandle,int p_iDataSize);
|
|
void InitUart(void);
|
|
int UartOpenComPort(int p_iUartHandle, int p_iBaudRate, int p_iNbStopBits, int p_iParityEnable);
|
|
int UartTick(void);
|
|
|
|
#endif
|
|
//EOF
|
|
|