16FXlib
can.h
Go to the documentation of this file.
1 
2 //*****************************************************************************
3 // Author : Christian Illy
4 // Created : 04.05.2009
5 // Revised : 05.07.2009
6 // Version : 0.1
7 // Target MCU : Fujitsu MB96300 series
8 //
9 // This program is free software: you can redistribute it and/or modify
10 // it under the terms of the GNU General Public License as published by
11 // the Free Software Foundation, either version 3 of the License, or
12 // (at your option) any later version.
13 //
14 // This program is distributed in the hope that it will be useful,
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 // GNU General Public License for more details.
18 //
19 // You should have received a copy of the GNU General Public License
20 // along with this program. If not, see <http://www.gnu.org/licenses/>.
21 //
28 //*****************************************************************************
30 
31 
32 #ifndef CAN_H_
33 #define CAN_H_
34 
35 #include "../inttypes.h"
36 #include "can.cfg.h"
37 
50 uint8_t can_init(uint8_t prescaler, uint8_t propSeg, uint8_t phSeg1, uint8_t phSeg2,
51  uint8_t jumpWidth, uint8_t interrupts);
52 
63 uint8_t can_config_buffer(uint8_t buffer, uint32_t id, uint8_t options, uint8_t maskOptions,
64  uint32_t idMask);
65 
74 
84 
92 
101 
111 int8_t can_buffer_getData(uint8_t buffer, uint8_t* data, uint32_t* id);
112 
113 
120 
124 #define ID_TO_STDFRAME(id) ((id & 0x000007FFL) << 18)
125 
129 #define ID_TO_EXTFRAME(id) (id & 0x1FFFFFFFL)
130 
134 #define STDFRAME_TO_ID(reg) (((reg & 0x1FFFFFFFL) >> 18) & 0x000007FFL)
135 
139 #define EXTFRAME_TO_ID(reg) (reg & 0x1FFFFFFFL)
140 
141 
142 
151 
155 #define CAN_BAUD_50K 14, 8, 6, 5, 1
156 
160 #define CAN_BAUD_125K 7, 7, 4, 4, 1
161 
165 #define CAN_BAUD_1000K 1, 7, 3, 3, 1
166 
168 
169 
170 
176 
181 #define CAN_BUF_OPT_ENABLED (_BV(0))
182 
188 #define CAN_BUF_OPT_TRANSMIT (_BV(1))
189 
194 #define CAN_BUF_OPT_EXTENDED (_BV(2))
195 
200 #define CAN_BUF_OPT_RX_INTERRUPT (_BV(4))
201 
206 #define CAN_BUF_OPT_TX_INTERRUPT (_BV(5))
207 
209 
210 
217 
223 #define CAN_BUF_MASK_USE (_BV(0))
224 
230 #define CAN_BUF_MASK_EXTENDED (_BV(1))
231 
237 #define CAN_BUF_MASK_DIRECTION (_BV(2))
238 
240 
241 
242 #endif /* CAN_H_ */
243 
unsigned long uint32_t
Definition: inttypes.h:60
uint8_t can_config_buffer(uint8_t buffer, uint32_t id, uint8_t options, uint8_t maskOptions, uint32_t idMask)
Definition: can.c:80
unsigned char uint8_t
Definition: inttypes.h:35
uint8_t can_set_buffer_autoreply(uint8_t buffer, uint8_t enable)
Definition: can.c:136
char int8_t
Definition: inttypes.h:45
uint8_t can_set_buffer_data(uint8_t buffer, uint8_t *data, uint8_t len)
Definition: can.c:158
int8_t can_buffer_getData(uint8_t buffer, uint8_t *data, uint32_t *id)
Definition: can.c:219
uint8_t can_init(uint8_t prescaler, uint8_t propSeg, uint8_t phSeg1, uint8_t phSeg2, uint8_t jumpWidth, uint8_t interrupts)
Definition: can.c:37
uint8_t can_buffer_newData(uint8_t buffer)
Definition: can.c:203
uint8_t can_send_buffer(uint8_t buffer)
Definition: can.c:184