OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [freertos-6.1.1/] [Demo/] [Common/] [drivers/] [ST/] [STM32F10xFWLib/] [inc/] [stm32f10x_can.h] - Blame information for rev 615

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 608 jeremybenn
/******************** (C) COPYRIGHT 2007 STMicroelectronics ********************
2
* File Name          : stm32f10x_can.h
3
* Author             : MCD Application Team
4
* Date First Issued  : 09/29/2006
5
* Description        : This file contains all the functions prototypes for the
6
*                      CAN firmware library.
7
********************************************************************************
8
* History:
9
* 04/02/2007: V0.2
10
* 02/05/2007: V0.1
11
* 09/29/2006: V0.01
12
********************************************************************************
13
* THE PRESENT SOFTWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
14
* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
15
* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
16
* INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
17
* CONTENT OF SUCH SOFTWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
18
* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
19
*******************************************************************************/
20
 
21
/* Define to prevent recursive inclusion -------------------------------------*/
22
#ifndef __STM32F10x_CAN_H
23
#define __STM32F10x_CAN_H
24
 
25
/* Includes ------------------------------------------------------------------*/
26
#include "stm32f10x_map.h"
27
 
28
/* Exported types ------------------------------------------------------------*/
29
/* CAN init structure definition */
30
typedef struct
31
{
32
  FunctionalState CAN_TTCM;
33
  FunctionalState CAN_ABOM;
34
  FunctionalState CAN_AWUM;
35
  FunctionalState CAN_NART;
36
  FunctionalState CAN_RFLM;
37
  FunctionalState CAN_TXFP;
38
  u8 CAN_Mode;
39
  u8 CAN_SJW;
40
  u8 CAN_BS1;
41
  u8 CAN_BS2;
42
  u8 CAN_Clock;
43
  u16 CAN_Prescaler;
44
} CAN_InitTypeDef;
45
 
46
/* CAN filter init structure definition */
47
typedef struct
48
{
49
  u8 CAN_FilterNumber;
50
  u8 CAN_FilterMode;
51
  u8 CAN_FilterScale;
52
  u16 CAN_FilterIdHigh;
53
  u16 CAN_FilterIdLow;
54
  u16 CAN_FilterMaskIdHigh;
55
  u16 CAN_FilterMaskIdLow;
56
  u16 CAN_FilterFIFOAssignment;
57
  FunctionalState CAN_FilterActivation;
58
} CAN_FilterInitTypeDef;
59
 
60
/* CAN Tx message structure definition */
61
typedef struct
62
{
63
  u32 StdId;
64
  u32 ExtId;
65
  u8 IDE;
66
  u8 RTR;
67
  u8 DLC;
68
  u8 Data[8];
69
} CanTxMsg;
70
 
71
/* CAN Rx message structure definition */
72
typedef struct
73
{
74
  u32 StdId;
75
  u32 ExtId;
76
  u8 IDE;
77
  u8 RTR;
78
  u8 DLC;
79
  u8 Data[8];
80
  u8 FMI;
81
} CanRxMsg;
82
 
83
/* Exported constants --------------------------------------------------------*/
84
 
85
/* CAN sleep constants */
86
#define CANINITFAILED              ((u8)0x00) /* CAN initialization failed */
87
#define CANINITOK                  ((u8)0x01) /* CAN initialization failed */
88
 
89
/* CAN operating mode */
90
#define CAN_Mode_Normal             ((u8)0x00)  /* normal mode */
91
#define CAN_Mode_LoopBack           ((u8)0x01)  /* loopback mode */
92
#define CAN_Mode_Silent             ((u8)0x02)  /* silent mode */
93
#define CAN_Mode_Silent_LoopBack    ((u8)0x03)  /* loopback combined with silent mode */
94
 
95
#define IS_CAN_MODE(MODE) ((MODE == CAN_Mode_Normal) || (MODE == CAN_Mode_LoopBack)|| \
96
                           (MODE == CAN_Mode_Silent) || (MODE == CAN_Mode_Silent_LoopBack))
97
 
98
/* CAN synchronisation jump width */
99
#define CAN_SJW_0tq                 ((u8)0x00)  /* 0 time quantum */
100
#define CAN_SJW_1tq                 ((u8)0x01)  /* 1 time quantum */
101
#define CAN_SJW_2tq                 ((u8)0x02)  /* 2 time quantum */
102
#define CAN_SJW_3tq                 ((u8)0x03)  /* 3 time quantum */
103
 
104
#define IS_CAN_SJW(SJW) ((SJW == CAN_SJW_0tq) || (SJW == CAN_SJW_1tq)|| \
105
                         (SJW == CAN_SJW_2tq) || (SJW == CAN_SJW_3tq))
106
 
107
/* time quantum in bit segment 1 */
108
#define CAN_BS1_1tq                 ((u8)0x00)  /* 1 time quantum */
109
#define CAN_BS1_2tq                 ((u8)0x01)  /* 2 time quantum */
110
#define CAN_BS1_3tq                 ((u8)0x02)  /* 3 time quantum */
111
#define CAN_BS1_4tq                 ((u8)0x03)  /* 4 time quantum */
112
#define CAN_BS1_5tq                 ((u8)0x04)  /* 5 time quantum */
113
#define CAN_BS1_6tq                 ((u8)0x05)  /* 6 time quantum */
114
#define CAN_BS1_7tq                 ((u8)0x06)  /* 7 time quantum */
115
#define CAN_BS1_8tq                 ((u8)0x07)  /* 8 time quantum */
116
#define CAN_BS1_9tq                 ((u8)0x08)  /* 9 time quantum */
117
#define CAN_BS1_10tq                ((u8)0x09)  /* 10 time quantum */
118
#define CAN_BS1_11tq                ((u8)0x0A)  /* 11 time quantum */
119
#define CAN_BS1_12tq                ((u8)0x0B)  /* 12 time quantum */
120
#define CAN_BS1_13tq                ((u8)0x0C)  /* 13 time quantum */
121
#define CAN_BS1_14tq                ((u8)0x0D)  /* 14 time quantum */
122
#define CAN_BS1_15tq                ((u8)0x0E)  /* 15 time quantum */
123
#define CAN_BS1_16tq                ((u8)0x0F)  /* 16 time quantum */
124
 
125
#define IS_CAN_BS1(BS1) (BS1 <= CAN_BS1_16tq)
126
 
127
/* time quantum in bit segment 2 */
128
#define CAN_BS2_1tq                 ((u8)0x00)  /* 1 time quantum */
129
#define CAN_BS2_2tq                 ((u8)0x01)  /* 2 time quantum */
130
#define CAN_BS2_3tq                 ((u8)0x02)  /* 3 time quantum */
131
#define CAN_BS2_4tq                 ((u8)0x03)  /* 4 time quantum */
132
#define CAN_BS2_5tq                 ((u8)0x04)  /* 5 time quantum */
133
#define CAN_BS2_6tq                 ((u8)0x05)  /* 6 time quantum */
134
#define CAN_BS2_7tq                 ((u8)0x06)  /* 7 time quantum */
135
#define CAN_BS2_8tq                 ((u8)0x07)  /* 8 time quantum */
136
 
137
#define IS_CAN_BS2(BS2) (BS2 <= CAN_BS2_8tq)
138
 
139
/* CAN clock selected */
140
#define CAN_Clock_8MHz              ((u8)0x00)  /* 8MHz XTAL clock selected */
141
#define CAN_Clock_APB               ((u8)0x01)  /* APB clock selected */
142
 
143
#define IS_CAN_CLOCK(CLOCK) ((CLOCK == CAN_Clock_8MHz) || (CLOCK == CAN_Clock_APB))
144
 
145
/* CAN clock prescaler */
146
#define IS_CAN_PRESCALER(PRESCALER) ((PRESCALER >= 1) && (PRESCALER <= 1024))
147
 
148
/* CAN filter number */
149
#define IS_CAN_FILTER_NUMBER(NUMBER) (NUMBER <= 13)
150
 
151
/* CAN filter mode */
152
#define CAN_FilterMode_IdMask       ((u8)0x00)  /* id/mask mode */
153
#define CAN_FilterMode_IdList       ((u8)0x01)  /* identifier list mode */
154
 
155
#define IS_CAN_FILTER_MODE(MODE) ((MODE == CAN_FilterMode_IdMask) || \
156
                                       (MODE == CAN_FilterMode_IdList))
157
 
158
/* CAN filter scale */
159
#define CAN_FilterScale_16bit       ((u8)0x00) /* 16-bit filter scale */
160
#define CAN_FilterScale_32bit       ((u8)0x01) /* 2-bit filter scale */
161
 
162
#define IS_CAN_FILTER_SCALE(SCALE) ((SCALE == CAN_FilterScale_16bit) || \
163
                                         (SCALE == CAN_FilterScale_32bit))
164
 
165
/* CAN filter FIFO assignation */
166
#define CAN_FilterFIFO0             ((u8)0x00)  /* Filter FIFO 0 assignment for filter x */
167
#define CAN_FilterFIFO1             ((u8)0x01)  /* Filter FIFO 1 assignment for filter x */
168
 
169
#define IS_CAN_FILTER_FIFO(FIFO) ((FIFO == CAN_FilterFIFO0) || \
170
                                       (FIFO == CAN_FilterFIFO1))
171
 
172
/* CAN Tx */
173
#define IS_CAN_TRANSMITMAILBOX(TRANSMITMAILBOX) (TRANSMITMAILBOX <= ((u8)0x02))
174
#define IS_CAN_STDID(STDID)   (STDID <= ((u32)0x7FF))
175
#define IS_CAN_EXTID(EXTID)   (EXTID <= ((u32)0x3FFFF))
176
#define IS_CAN_DLC(DLC)       (DLC <= ((u8)0x08))
177
 
178
/* CAN identifier type */
179
#define CAN_ID_STD                 ((u32)0x00000000)  /* Standard Id */
180
#define CAN_ID_EXT                 ((u32)0x00000004)  /* Extended Id */
181
 
182
#define IS_CAN_IDTYPE(IDTYPE) ((IDTYPE == CAN_ID_STD) || (IDTYPE == CAN_ID_EXT))
183
 
184
/* CAN remote transmission request */
185
#define CAN_RTR_DATA                ((u32)0x00000000)  /* Data frame */
186
#define CAN_RTR_REMOTE              ((u32)0x00000002)  /* Remote frame */
187
 
188
#define IS_CAN_RTR(RTR) ((RTR == CAN_RTR_DATA) || (RTR == CAN_RTR_REMOTE))
189
 
190
/* CAN transmit constants */
191
#define CANTXFAILED                 ((u8)0x00) /* CAN transmission failed */
192
#define CANTXOK                     ((u8)0x01) /* CAN transmission succeeded */
193
#define CANTXPENDING                ((u8)0x02) /* CAN transmission pending */
194
#define CAN_NO_MB                   ((u8)0x04) /* CAN cell did not provide an empty mailbox */
195
 
196
/* CAN receive FIFO number constants */
197
#define CAN_FIFO0                 ((u8)0x00) /* CAN FIFO0 used to receive */
198
#define CAN_FIFO1                 ((u8)0x01) /* CAN FIFO1 used to receive */
199
 
200
#define IS_CAN_FIFO(FIFO) ((FIFO == CAN_FIFO0) || (FIFO == CAN_FIFO1))
201
 
202
/* CAN sleep constants */
203
#define CANSLEEPFAILED              ((u8)0x00) /* CAN did not enter the sleep mode */
204
#define CANSLEEPOK                  ((u8)0x01) /* CAN entered the sleep mode */
205
 
206
/* CAN wake up constants */
207
#define CANWAKEUPFAILED             ((u8)0x00) /* CAN did not leave the sleep mode */
208
#define CANWAKEUPOK                 ((u8)0x01) /* CAN leaved the sleep mode */
209
 
210
/* CAN flags */
211
#define CAN_FLAG_EWG                ((u32)0x00000001) /* Error Warning Flag */
212
#define CAN_FLAG_EPV                ((u32)0x00000002) /* Error Passive Flag */
213
#define CAN_FLAG_BOF                ((u32)0x00000004) /* Bus-Off Flag */
214
 
215
#define IS_CAN_FLAG(FLAG) ((FLAG == CAN_FLAG_EWG) || (FLAG == CAN_FLAG_EPV) ||\
216
                           (FLAG == CAN_FLAG_BOF))
217
 
218
/* CAN interrupts */
219
#define CAN_IT_RQCP0                ((u8)0x05) /* Request completed mailbox 0 */
220
#define CAN_IT_RQCP1                ((u8)0x06) /* Request completed mailbox 1 */
221
#define CAN_IT_RQCP2                ((u8)0x07) /* Request completed mailbox 2 */
222
#define CAN_IT_TME                  ((u32)0x00000001) /* Transmit mailbox empty */
223
#define CAN_IT_FMP0                 ((u32)0x00000002) /* FIFO 0 message pending */
224
#define CAN_IT_FF0                  ((u32)0x00000004) /* FIFO 0 full */
225
#define CAN_IT_FOV0                 ((u32)0x00000008) /* FIFO 0 overrun */
226
#define CAN_IT_FMP1                 ((u32)0x00000010) /* FIFO 1 message pending */
227
#define CAN_IT_FF1                  ((u32)0x00000020) /* FIFO 1 full */
228
#define CAN_IT_FOV1                 ((u32)0x00000040) /* FIFO 1 overrun */
229
#define CAN_IT_EWG                  ((u32)0x00000100) /* Error warning */
230
#define CAN_IT_EPV                  ((u32)0x00000200) /* Error passive */
231
#define CAN_IT_BOF                  ((u32)0x00000400) /* Bus-off */
232
#define CAN_IT_LEC                  ((u32)0x00000800) /* Last error code */
233
#define CAN_IT_ERR                  ((u32)0x00008000) /* Error */
234
#define CAN_IT_WKU                  ((u32)0x00010000) /* Wake-up */
235
#define CAN_IT_SLK                  ((u32)0x00020000) /* Sleep */
236
 
237
#define IS_CAN_IT(IT) ((IT == CAN_IT_RQCP0) || (IT == CAN_IT_RQCP1) ||\
238
                       (IT == CAN_IT_RQCP2) || (IT == CAN_IT_TME)   ||\
239
                       (IT == CAN_IT_FMP0)  || (IT == CAN_IT_FF0)   ||\
240
                       (IT == CAN_IT_FOV0)  || (IT == CAN_IT_FMP1)  ||\
241
                       (IT == CAN_IT_FF1)   || (IT == CAN_IT_FOV1)  ||\
242
                       (IT == CAN_IT_EWG)   || (IT == CAN_IT_EPV)   ||\
243
                       (IT == CAN_IT_BOF)   || (IT == CAN_IT_LEC)   ||\
244
                       (IT == CAN_IT_ERR)   || (IT == CAN_IT_WKU)   ||\
245
                       (IT == CAN_IT_SLK))
246
 
247
/* Exported macro ------------------------------------------------------------*/
248
/* Exported function protypes ----------------------------------------------- */
249
void CAN_DeInit(void);
250
u8 CAN_Init(CAN_InitTypeDef* CAN_InitStruct);
251
void CAN_FilterInit(CAN_FilterInitTypeDef* CAN_FilterInitStruct);
252
void CAN_StructInit(CAN_InitTypeDef* CAN_InitStruct);
253
void CAN_ITConfig(u32 CAN_IT, FunctionalState NewState);
254
u8 CAN_Transmit(CanTxMsg* TxMessage);
255
u32 CAN_TransmitStatus(u8 TransmitMailbox);
256
void CAN_CancelTransmit(u8 Mailbox);
257
void CAN_FIFORelease(u8 FIFONumber);
258
u8 CAN_MessagePending(u8 FIFONumber);
259
void CAN_Receive(u8 FIFONumber, CanRxMsg* RxMessage);
260
u8 CAN_Sleep(void);
261
u8 CAN_WakeUp(void);
262
FlagStatus CAN_GetFlagStatus(u32 CAN_FLAG);
263
void CAN_ClearFlag(u32 CAN_FLAG);
264
ITStatus CAN_GetITStatus(u32 CAN_IT);
265
void CAN_ClearITPendingBit(u32 CAN_IT);
266
 
267
#endif /* __STM32F10x_CAN_H */
268
 
269
/******************* (C) COPYRIGHT 2007 STMicroelectronics *****END OF FILE****/

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.