2025-02-15 11:05:28 -05:00

103 lines
3.1 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 INTERNAL_UART_H
#define INTERNAL_UART_H
/* ************************************************************************** */
/* Includes */
/* ************************************************************************** */
/* Defines */
#define INTERNAL_UART_BUFFER_DEPTH 1//4//16 //JFM 2012-08-27
#define USE_TX_INTERNAL_BUFFER
#define INTERNAL_UART1_TX_PIN_DIR TRISFbits.TRISF3
#define INTERNAL_UART1_TX_PIN LATFbits.LATF3
#define INTERNAL_UART2_TX_PIN_DIR TRISFbits.TRISF5
#define INTERNAL_UART2_TX_PIN LATFbits.LATF5
#define INTERNAL_UART5_TX_PIN_DIR TRISBbits.TRISB14
#define INTERNAL_UART5_TX_PIN LATBbits.LATB14
/* ************************************************************************** */
/* Type definitions */
typedef enum
{
INTERNAL_UART_PORT_1,
INTERNAL_UART_PORT_2,
INTERNAL_UART_PORT_5,
MAX_INTERNAL_UART_PORT
}eInternalUartPorts;
typedef enum
{
INT_UART_NO_PARITY,
INT_UART_EVEN_PARITY,
INT_UART_ODD_PARITY
}eIntUartParity;
typedef enum
{
INT_UART_ONE_STOP_BIT,
INT_UART_TWO_STOP_BITS
}eIntUartStopBits;
typedef enum
{
INT_UART_INTERRUPT_OFF,
INT_UART_INTERRUPT_ON
}eIntUartInterruptOnOff;
typedef struct
{
char *pcTxDataPtr;
char acIntUartTxFIFO[INTERNAL_UART_BUFFER_DEPTH];
int iNbFIFOPendingBytes;
int iTxDataSize;
int iTxDataCounter;
int iIsBusy;
int iIsOpened;
int iUartHandle;
}stInternalUartData;
/* ************************************************************************** */
/* Prototypes */
void InternalUartInit(void);
int OpenInternalPort(int p_iUartPort,int p_iUartHandle,char *p_pcHeadPtr, char *p_pcTailPtr, int p_iBaudRate, int p_iNbStopBits, int p_iParityEnable);
int SendInternalUartData(char *p_pcDataBuf, int p_iDataSize, int p_iUartPort, char *p_pcSourceBufferHead, char *p_pcSourceBufferTail);
int SetIntalUartInterrupts(int p_iUartPort, int p_iRxInterrupt,int p_iTxInterrupt);
int SendInternalUartDataBlocking(char *p_pcDataBuf, int p_iDataSize, int p_iUartPort);
void TickInternalUart(void);
void ResetUart1(void);
void ResetUart2(void);
void ResetUart5(void);
#endif
//EOF