[processor-sdk/performance-audio-sr.git] / pdk_k2g_1_0_1 / packages / ti / board / diag / dcan / src / evmk2g_dcan_frame.h
1 /*
2 * Copyright (C) 2005 Marc Kleine-Budde, Pengutronix
3 * Copyright (C) 2006 Andrey Volkov, Varma Electronics
4 * Copyright (C) 2008-2009 Wolfgang Grandegger <wg@grandegger.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the version 2 of the GNU General Public License
8 * as published by the Free Software Foundation
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
20 /**
21 * \file evmc66x_dcan_frame.h
22 *
23 * \brief This file consists of macro definitions and function prototypes
24 * used in dcan_frame.c file.
25 *
26 */
28 #ifndef _EVMC66X_DCAN_FRAME_H_
29 #define _EVMC66X_DCAN_FRAME_H_
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
35 /******************************************************************************
36 ** MACRO DEFINITIONS
37 ******************************************************************************/
38 /*
39 ** These macros can be used as 'flag' present in the 'can_frame' structure.
40 */
41 #define CAN_DATA_FRAME (0x00000001u)
42 #define CAN_EXT_FRAME (0x00000004u)
43 #define CAN_MSG_DIR_TX (0x00000010u)
44 #define CAN_MSG_DIR_RX (0x00000020u)
46 /* Total No. of message objects available in the DCAN message RAM */
47 #define CAN_NUM_OF_MSG_OBJS (64u)
49 /* Macros used by CANBitTimeCalculator */
50 #define CAN_CALC_MAX_ERROR (50u)
51 #define BIT_RATE_ERR_WARN (2u)
52 #define BIT_RATE_ERR_MAX (1u)
53 #define EXTRACT_BRPE_VAL (0x3C0u)
54 #define NO_BIT_RATE_ERR (3u)
55 #define BRPE_SHIFT (10u)
57 /******************************************************************************/
58 /* STRUCTURE DECLARATIONS */
59 /******************************************************************************/
60 /*
61 ** Structure which will hold information related to a CANframe which will be
62 ** stored in a message object.
63 */
64 typedef struct _can_frame{
65 unsigned int flag;
66 unsigned int id;
67 unsigned int dlc;
68 unsigned int msk;
69 unsigned int *data;
70 }can_frame;
72 /*
73 ** Structure used by the CAN Bit time calculator. Will hold values related to
74 ** bit-time configuration.
75 */
76 struct _dcan_bittiming{
77 unsigned int bitRate; /* Bit-rate in bits/second */
78 unsigned int samplePnt; /* Sample point in one-tenth of a percent */
79 unsigned long tq; /* Time quanta (tq) in nanoseconds */
80 unsigned int propSeg; /* Propagation segment in tq */
81 unsigned int phaseSeg1; /* Phase buffer segment 1 in tq */
82 unsigned int phaseSeg2; /* Phase buffer segment 2 in tq */
83 unsigned int sjw; /* Synchronisation jump width in tq */
84 unsigned int brp; /* Bit-rate prescaler */
85 };
87 /*
88 ** Structure used by the CAN Bit time calculator. Will hold values related to
89 ** bit-time configuration.
90 */
91 struct _dcan_hw_params{
92 unsigned int tseg1Min; /* Time segement 1 = prop_seg + phase_seg1 */
93 unsigned int tseg1Max;
94 unsigned int tseg2Min; /* Time segement 2 = phase_seg2 */
95 unsigned int tseg2Max;
96 unsigned int sjwMax; /* Synchronisation jump width */
97 unsigned int brpMin; /* Bit-rate prescaler */
98 unsigned int brpMax;
99 unsigned int brpInc;
100 };
102 /******************************************************************************
103 ** FUNCTION PROTOTYPES
104 ******************************************************************************/
105 extern void CANMsgObjectConfig(unsigned int baseAdd, can_frame* canPtr);
106 extern unsigned int CANTxObjectConfig(unsigned int baseAdd, can_frame* canPtr);
107 extern unsigned int CANRxObjectConfig(unsigned int baseAdd, can_frame* canPtr);
108 extern void CANClrIntPndStat(unsigned int baseAdd, unsigned int msgNum,
109 unsigned int ifReg);
110 extern void CANValidateMsgObject(unsigned int baseAdd, unsigned int msgNum,
111 unsigned int ifReg);
112 extern void CANInValidateMsgObject(unsigned int baseAdd, unsigned int msgNum,
113 unsigned int ifReg);
114 extern void CANReadMsgObjData(unsigned int baseAdd, unsigned int msgNum,
115 unsigned int* data, unsigned int ifReg);
116 extern void CANTxIntDisable(unsigned int baseAdd, unsigned int msgNum,
117 unsigned int ifReg);
118 extern void CANRxIntDisable(unsigned int baseAdd, unsigned int msgNum,
119 unsigned int ifReg);
120 extern void CANUpdateDataBytes(unsigned int baseAdd, unsigned int* dataPtr,
121 unsigned int msgNum, unsigned int ifReg);
122 /* Bit timing calculation functions */
123 extern int canUpdatSamPt(const struct _dcan_hw_params *ptr,
124 int sampl_pt, int tseg, int *tseg1, int *tseg2);
125 extern unsigned int CANbitTimeCalculator(struct _dcan_hw_params *btc,
126 struct _dcan_bittiming *bt,
127 unsigned int clkFreq);
128 extern unsigned int CANSetBitTiming(unsigned int baseAdd, unsigned int clkFreq,
129 unsigned int bitRate);
131 #ifdef __cplusplus
132 }
133 #endif
135 #endif /* _EVMC66X_DCAN_FRAME_H_ */
137 /*************************** END OF FILE **************************************/