You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

56 lines
3.9 KiB

1 year ago
#ifndef USART1_H_
#define USART1_H_
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
#include <inttypes.h>
#include "Common/IDIBUS_DEFS.h"
#include <avr/io.h>
#include <avr/interrupt.h>
#include "USART_COM.h"
//#include <avr/pgmspace.h>
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
volatile USART_HANDLER_TYPE USART1STR; //Do not remove volatile!!!
//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
#define USART1_BUF_SIZE IDIMMES_MAX_MES_SIZE + 1 // Buffer size
volatile uint8_t USART1_RX_BUF[USART1_BUF_SIZE]; // RX buffer
volatile uint8_t USART1_TX_BUF[USART1_BUF_SIZE]; // TX buffer
void USART1_Init(void);
//inline void USART1_IRQN_HANDLER(void);
//inline void USART1_RX_TIMER_HANDLER(void);
void USART1_SendTxBuf(uint16_t Count);
//uint8_t USART1_IsNewRxMessage(void);
//uint8_t USART1_IsRxError(void);
//uint16_t USART1_getRxBufSize(void);
//uint8_t *USART1_getRxBuf(void);
//uint8_t *USART1_getTxBuf(void);
void USART1_RxTransferRestart(void);
//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
void USART1_copyRxBuf(uint8_t *Dst, uint16_t StartPos, uint16_t Count);
//#define USART1_copyRxBuf(Dst,StartPos,Count) _memcopy(&USART1_RX_BUF[StartPos],Dst,Count);
// void USART1_copyRxBuf(uint8_t *Dst, uint16_t StartPos, uint16_t Count) { _memcopy(&USART1_RX_BUF[StartPos], Dst,Count); }
//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
uint8_t USART1_IsTxActive(void);
//#define USART1_IsTxActive() (USART1STR.TxComplete == 1 ? 0 : 1)
//uint8_t USART1_IsTxActive(void){
// if (USART1STR.TxComplete) return 0;
// else return 1;
//}
//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
#define USART1_IsNewRxMessage() USART1STR.RxComplete
//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
#define USART1_IsRxError() USART1STR.RxError
//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
#define USART1_getRxBufSize() USART1STR.RxBufCount
//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
#define USART1_getRxBuf() &USART1_RX_BUF[0]
//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
#define USART1_getTxBuf() &USART1_TX_BUF[0]
//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
void USART1_SetIdiBusBoudrate(enum IDIBUS_SERIAL_BAUDRATE BoudrateCode);
//void USART1_RxAlarmFrameStart(void);
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
#endif /* USART1_H_ */