1 /* -------------------------------- Arctic Core ------------------------------
2 * Arctic Core - the open source AUTOSAR platform http://arccore.com
4 * Copyright (C) 2009 ArcCore AB <contact@arccore.com>
6 * This source code is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 as published by the
8 * Free Software Foundation; See <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * -------------------------------- Arctic Core ------------------------------*/
26 #define CAN_VENDOR_ID 1
\r
27 #define CAN_MODULE_ID MODULE_ID_CAN
\r
28 #define CAN_AR_MAJOR_VERSION 2
\r
29 #define CAN_AR_MINOR_VERSION 2
\r
30 #define CAN_AR_PATCH_VERSION 2
32 #define CAN_SW_MAJOR_VERSION 1
\r
33 #define CAN_SW_MINOR_VERSION 0
\r
34 #define CAN_SW_PATCH_VERSION 0
\r
36 #define CAN_E_PARAM_POINTER 0x01
\r
37 #define CAN_E_PARAM_HANDLE 0x02
\r
38 #define CAN_E_PARAM_DLC 0x03
\r
39 #define CAN_E_PARAM_CONTROLLER 0x04
\r
40 // API service used without initialization
\r
41 #define CAN_E_UNINIT 0x05
\r
42 // Init transition for current mode
\r
43 #define CAN_E_TRANSITION 0x06
\r
46 #include "Std_Types.h"
\r
47 #include "CanIf_Types.h"
\r
48 #include "ComStack_Types.h"
\r
52 uint32 txSuccessCnt;
\r
53 uint32 rxSuccessCnt;
\r
57 uint32 fifoOverflow;
\r
59 } Can_Arc_StatisticsType;
\r
62 // uint16: if only Standard IDs are used
\r
63 // uint32: if also Extended IDs are used
\r
64 typedef uint32 Can_IdType;
\r
66 /* Good things to know
\r
72 typedef struct Can_PduType_s {
\r
73 // the CAN ID, 29 or 11-bit
\r
75 // Length, max 8 bytes
\r
79 // private data for CanIf,just save and use for callback
\r
80 PduIdType swPduHandle;
\r
89 } Can_StateTransitionType;
\r
95 // CAN_WAKEUP, // Removed in 3.0
\r
98 /* Error from CAN controller */
\r
100 volatile uint32_t R;
\r
102 volatile uint32_t:24;
\r
103 volatile uint32_t BIT1ERR:1;
\r
104 volatile uint32_t BIT0ERR:1;
\r
105 volatile uint32_t ACKERR:1;
\r
106 volatile uint32_t CRCERR:1;
\r
107 volatile uint32_t FRMERR:1;
\r
108 volatile uint32_t STFERR:1;
\r
109 volatile uint32_t TXWRN:1;
\r
110 volatile uint32_t RXWRN:1;
\r
112 } Can_Arc_ErrorType;
\r
114 // Each controller has 32 hth's, so the division of 32 will give the
\r
116 #define GET_CANCONTROLLER(a) (a / HTH_DIVIDER)
\r
118 #include "Can_Cfg.h"
\r
120 void Can_Init( const Can_ConfigType *Config );
\r
123 #if ( CAN_VERSION_INFO_API == STD_ON )
\r
124 #define Can_GetVersionInfo(_vi) STD_GET_VERSION_INFO(_vi,CAN)
\r
127 void Can_InitController( uint8 controller, const Can_ControllerConfigType *config);
\r
128 Can_ReturnType Can_SetControllerMode( uint8 Controller, Can_StateTransitionType transition );
\r
129 void Can_DisableControllerInterrupts( uint8 controller );
\r
130 void Can_EnableControllerInterrupts( uint8 controller );
\r
131 // Hth - for Flexcan, the hardware message box number... .We don't care
\r
134 Can_ReturnType Can_Write( Can_Arc_HTHType hth, Can_PduType *pduInfo );
\r
136 void Can_Cbk_CheckWakeup( uint8 controller );
\r
137 void Can_MainFunction_Write( void );
\r
138 void Can_MainFunction_Read( void );
\r
139 void Can_MainFunction_BusOff( void );
\r
140 void Can_MainFunction_Wakeup( void );
\r
142 void Can_Arc_GetStatistics( uint8 controller, Can_Arc_StatisticsType * stat);
\r