📄 uart.hu
字号:
/* $Header: O:\Pvcs\IBS_Software\06_Opel\src\uart.huv 1.5 20 Jul 2006 13:29:52 Zubrzycki_Michal $*/
/**********************************************************************
*
* Copyright 2004 Delphi Technologies, Inc., All Rights Reserved.
*
***********************************************************************
***********************************************************************
Title : uart.hu
Module Description : This file contains application specific header
information for Uart. It is included directly by
uart.h
Author : Guido Brunken
**********************************************************************/
/*---------------------------------------------------------------------
* Instructions for using this module if any:
*
*-------------------------------------------------------------------*/
/**********************************************************************
* Constant and Macro Definitions using #define
*********************************************************************/
#define UART_CONF_DESIP_OLD_STYLE_IS (false) /* Hisip */
#define UART_CONF_USE_BUFFERED_IO_IS (true) /* Hisip */
#define UART_CONF_USE_TX_INT_0_IS (true) /* TSI, DV*/
#define UART_CONF_USE_RX_INT_0_IS (true) /* TSI, DV*/
#define UART_CONF_USE_TX_INT_1_IS (false) // UART1 not used
#define UART_CONF_USE_RX_INT_1_IS (false) // UART1 not used
#define UART_CONF_USE_GET_ISR_STATE (false)
#define UART_CONF_SET_BAUDRATE_IS (false)
#define UART_CONF_SET_MODE_IS (false)
#define UART_CONF_USE_TX_INT_2_IS (true) // not used DV
#define UART_CONF_USE_RX_INT_2_IS (true) // not used DV
/* Do not change manually, derived from previous settings */
#if ( (UART_CONF_USE_TX_INT_0_IS) || (UART_CONF_USE_TX_INT_2_IS) )
#define UART_CONF_USE_TX_INTERRUPT_IS (true)
#else
#define UART_CONF_USE_TX_INTERRUPT_IS (false)
#endif
#if ( (UART_CONF_USE_RX_INT_0_IS) || (UART_CONF_USE_RX_INT_2_IS) )
#define UART_CONF_USE_RX_INTERRUPT_IS (true)
#else
#define UART_CONF_USE_RX_INTERRUPT_IS (false)
#endif
/* End of Do not change manually, derived from previous settings */
/* Consistency checks: */
#if (UART_CONF_DESIP_OLD_STYLE_IS) && (!UART_CONF_USE_BUFFERED_IO_IS)
#error "DESIP_OLD_STYLE needs BUFFERED_IO!"
#endif
#if 0 /*steven_yi : only for insight tools to parse this file*/
#if ( (UART_CONF_USE_TX_INT_0_IS) || (UART_CONF_USE_RX_INT_0_IS) \
|| (UART_CONF_USE_TX_INT_1_IS) || (UART_CONF_USE_RX_INT_1_IS) \
|| (UART_CONF_USE_TX_INT_2_IS) || (UART_CONF_USE_RX_INT_2_IS) ) \
&& (!UART_CONF_USE_BUFFERED_IO_IS)
#error "Interrupt-Handling needs BUFFERED_IO enabled!"
#endif
#if ( (UART_CONF_USE_TX_INT_0_IS) || (UART_CONF_USE_TX_INT_1_IS) || (UART_CONF_USE_TX_INT_2_IS) ) \
&& (!UART_CONF_USE_TX_INTERRUPT_IS)
#error "TX_INTERRUPT_IS must be set when using TX interupts!"
#endif
#if ( (UART_CONF_USE_RX_INT_0_IS) || (UART_CONF_USE_RX_INT_1_IS) || (UART_CONF_USE_RX_INT_2_IS) ) \
&& (!UART_CONF_USE_RX_INTERRUPT_IS)
#error "RX_INTERRUPT_IS must be set when using RX interupts!"
#endif
/* End of Consistency checks: */
#endif
#define UART_ERR_OVERFLOW (0x01)
#define UART_ERR_FRAME (0x02)
#define UART_ERR_PARITY (0x04)
#define UART_ERROR_MASK (UART_ERR_OVERFLOW | UART_ERR_FRAME | UART_ERR_PARITY)
/**********************************************************************
* Enumerations and Structures and Typedefs
*********************************************************************/
typedef enum Uart_Error_Enum_Tag
{
E_UART_NO_DEVICE = (-2),
E_UART_ERROR = (-1),
E_UART_OK = 0,
} Uart_Error_Enum_T;
typedef Uart_Error_Enum_T Uart_Ret_T;
typedef enum Uart_Rx_Func_Ret_Tag
{
UART_RX_DONE = 0,
UART_RX_CONTINUE,
UART_NUM_RX_RETURN_CODES
} Uart_Rx_Func_Ret_T;
typedef enum Uart_Isr_State_Tag
{
UART_ISR_OFF = 0,
UART_ISR_RX_ON = 1,
UART_ISR_TX_ON = 2,
UART_ISR_RX_TX_ON = 3,
UART_NUM_ISR_STATES
} Uart_Isr_State_T;
/* Device specific data structures to map UART registers: */
typedef uint32_t UART_Base_Address_T; /* machine dependent */
/* Each UART hardware channel has registers arranged like this (must match
* V850ES CPU hardware registers): */
typedef struct uart_reg_tag
{
uint8_t ctl0; // Control register 0
uint8_t ctl1; // Control register 1
uint8_t ctl2; // Control register 2
uint8_t opt0; // Option control register 0
uint8_t str; // Status register
uint8_t res; // Reserved for future use
const uint8_t rx; // Reception data register
uint8_t tx; // Transmission data register
} uart_reg_t;
typedef struct uart_reg_init_data_tag
{
UART_Base_Address_T base_address; // start address of UART registers
uint8_t ctl0; // Control register 0
uint8_t ctl1; // Control register 1
uint8_t ctl2; // Control register 2
uint8_t opt0; // Option control register 0
} uart_reg_init_data_t;
/* Add further baudrates here and add register settings in uart_baud_rate_init_table */
typedef enum UART_Baudrate_Tag
{
UART_BAUD_5 = 0,
UART_BAUD_200,
UART_BAUD_9600,
UART_BAUD_115K2,
UART_NUM_SUPPORTED_BAUDRATES
} UART_Baudrate_T;
typedef enum Uart_Devices_Enum_Tag
{
UART_DEVICE_0 = 0, // TSI
UART_DEVICE_1, // not used
UART_DEVICE_2, // not used
UART_NUM_HW_DEVICES, /* Num of UARTs supported by uP */
} Uart_Devices_Enum_T;
/*configure application UART ID*/
#define UART_DEVICE_TSI UART_DEVICE_0 // TSI
#define UART_DEVICE_NONE UART_DEVICE_2 //Not Used
#define UART_NUM_HW_DEVICES_USED 2
typedef enum Uart_Device_Config_Tag
{
UART_CONF_TSI = 0,
UART_CONF_NONE,
UART_NUM_DEVICE_CONFIGS
} Uart_Device_Config_T;
#if BLUETOOTH_IS
#define CXN_RTS_HIGH() BTp_RTS_CTRL(IO_OUT);\
BTpo_RTS_CTRL(1);
#define CXN_RTS_LOW() BTp_RTS_CTRL(IO_OUT);\
BTp_RTS_CTRL(0);
#define CXN_CTS_HIGH() BTp_CTS_CTRL(IO_OUT);\
BTpo_CTS_CTRL(1);
#define CXN_CTS_LOW() BTp_CTS_CTRL(IO_OUT);\
BTp_CTS_CTRL(0);
#endif
/**********************************************************************
* Global Variable extern Declarations
*********************************************************************/
/**********************************************************************
* Function Prototypes
*********************************************************************/
extern void UART_Set_Isr_State ( Uart_Devices_Enum_T device, Uart_Isr_State_T state );
#if UART_CONF_DESIP_OLD_STYLE_IS
extern int16_t Com_Get_Char(void);
extern int16_t Com_Put_Char( uint16_t data );
extern void Open_Com (void);
#endif // UART_CONF_DESIP_OLD_STYLE_IS
#if (BLUETOOTH_IS || (External_Bluetooth_IS && M12_NAV_MODEL_IS))
bool BT_Uart_Initilize(void);
#endif
#if BLUETOOTH_IS
extern void BT_RX_Data (uint8_t * rx_buffer);
#endif
#if UART_CONF_SET_BAUDRATE_IS
extern void UART_Set_Baudrate ( Uart_Devices_Enum_T device, UART_Baudrate_T baud );
#endif // #if UART_CONF_SET_BAUDRATE_IS
#if UART_CONF_SET_MODE_IS
extern void UART_Set_Mode( Uart_Devices_Enum_T device, uint_fast8_t mode );
#endif // #if UART_CONF_SET_MODE_IS
#if UART_CONF_USE_GET_ISR_STATE
extern Uart_Isr_State_T UART_Get_Isr_State ( Uart_Devices_Enum_T device );
#endif // #if UART_CONF_USE_GET_ISR_STATE
/*steven_yi for DVDX UART channel , need to modify later*/
extern UINT8 UART_Error_Register(Uart_Devices_Enum_T device);
extern UINT8 UART_Signal_Setup_Register(Uart_Devices_Enum_T device);
extern UINT8 UART_Rx_Buf_Input_Index(Uart_Devices_Enum_T device);
extern UINT8 UART_Get_Char_Offset(Uart_Devices_Enum_T device, UINT16 offset);
extern bool UART_Reset_Rx_Buf(Uart_Devices_Enum_T device);
extern void Configure_UART_For_Idle(Uart_Devices_Enum_T device);
#if (BLUETOOTH_IS || (External_Bluetooth_IS && M12_NAV_MODEL_IS))
extern void UART_Service_Write(Uart_Devices_Enum_T dev_index, uint8_t *buffer, uint16_t size);
#endif
#if BLUETOOTH_IS
extern bool BT_RecvBuffer_Is_Full();
extern bool BT_RecvBuffer_Is_Empty();
extern bool BT_New_Data();
extern bool BT_Get_Current_Inpx(Uart_Devices_Enum_T dev_index);
extern uint16_t UART_Service_Read(Uart_Devices_Enum_T dev_index,uint8_t *buffer, bool_t specific_size, uint16_t size);
extern uint8_t Uart_Check_Uart_Char(Uart_Devices_Enum_T dev_index, uint8_t offset);
#endif
extern void Set_New_Msg_From_SBX(void);
extern void TSI_UART_RX_ISR(void);
extern int8_t TSI_Get_Char (uint8_t data);
extern int8_t TSI_Put_Char ( uint8_t data );
/**********************************************************************
*
* REVISION RECORDS
*
*********************************************************************/
/**********************************************************************
* $Log: O:\Pvcs\IBS_Software\06_Opel\src\uart.huv $
*
* Rev 1.0 steven_yi
* initial modification for Chery Nav project
* Rev 1.5 20 Jul 2006 13:29:52 Zubrzycki_Michal
* - added missing ')' in conditional compilation directives
*
* Rev 1.4 Apr 26 2005 17:56:56 Stryj_Michael
* add compile switch KW82_USED_IS to device flags
*
* Rev 1.3 Apr 11 2005 18:05:14 Brunken_Guido
* + set UART_CONF_USE_STOP_IS to true
* - function used in KW82 module
*
* Rev 1.2 Mar 09 2005 18:49:44 Brunken_Guido
* + reworked module
* + added configuration switches for code size optimization
*
* Rev 1.1 Oct 11 2004 11:10:40 Brunken_Guido
* + reconfigured: HiSIP --> UART0
*
* Rev 1.0 Sep 30 2004 21:11:06 Brunken_Guido
* Initial revision.
*
*
*********************************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -