-
Notifications
You must be signed in to change notification settings - Fork 0
/
CAN.h
49 lines (39 loc) · 1.85 KB
/
CAN.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/*----------------------------------------------------------------------------
* Name: CAN.h
* Purpose: CAN interface for STM32
* Version: V1.00
*----------------------------------------------------------------------------
* This file is part of the uVision/ARM development tools.
* This software may only be used under the terms of a valid, current,
* end user licence from KEIL for a compatible version of KEIL software
* development tools. Nothing else gives you the right to use this software.
*
* Copyright (c) 2005-2007 Keil Software. All rights reserved.
*----------------------------------------------------------------------------*/
#ifndef _CAN_H_
#define _CAN_H_
#define STANDARD_FORMAT 0
#define EXTENDED_FORMAT 1
#define DATA_FRAME 0
#define REMOTE_FRAME 1
typedef struct {
unsigned int id; // 29 bit identifier
unsigned char data[8]; // Data field
unsigned char len; // Length of data field in bytes
unsigned char format; // 0 - STANDARD, 1- EXTENDED IDENTIFIER
unsigned char type; // 0 - DATA FRAME, 1 - REMOTE FRAME
} CAN_msg;
/* Functions defined in module CAN.c */
void CAN_setup (void);
void CAN_init (void);
void CAN_start (void);
void CAN_waitReady (void);
void CAN_wrMsg (CAN_msg *msg);
void CAN_rdMsg (CAN_msg *msg);
void CAN_wrFilter (unsigned int id, unsigned char filter_type);
void CAN_testmode (unsigned int testmode);
extern CAN_msg CAN_TxMsg; // CAN messge for sending
extern CAN_msg CAN_RxMsg; // CAN message for receiving
extern unsigned int CAN_TxRdy; // CAN HW ready to transmit a message
extern unsigned int CAN_RxRdy; // CAN HW received a message
#endif // _CAN_H_