can_private.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 /*
3  * Copyright (c) 2007 Fabian Greif, Roboterclub Aachen e.V.
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  * 1. Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in the
13  * documentation and/or other materials provided with the distribution.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18  * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
19  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25  * SUCH DAMAGE.
26  *
27  * $Id: can_private.h 8086 2009-07-14 14:08:25Z fabian $
28  */
29 // ----------------------------------------------------------------------------
30 
31 #ifndef CAN_PRIVATE_H
32 #define CAN_PRIVATE_H
33 
34 #include "can.h"
35 
36 #ifndef CAN_FORCE_TX_ORDER
37  #define CAN_FORCE_TX_ORDER 0
38 #endif
39 
40 // settings for buffered operation (only possible for the AT90CAN...)
41 #if !defined(CAN_TX_BUFFER_SIZE) || CAN_TX_BUFFER_SIZE == 0
42  #define CAN_TX_BUFFER_SIZE 0
43 
44  // forced order is only possible with buffered transmission
45  #undef CAN_FORCE_TX_ORDER
46  #define CAN_FORCE_TX_ORDER 0
47 #endif
48 
49 #ifndef CAN_RX_BUFFER_SIZE
50  #define CAN_RX_BUFFER_SIZE 0
51 #endif
52 
53 
54 #if defined(SUPPORT_MCP2515) && (SUPPORT_MCP2515 == 1)
55  #define BUILD_FOR_MCP2515 1
56 #else
57  #define BUILD_FOR_MCP2515 0
58 #endif
59 
60 #if defined(SUPPORT_AT90CAN) && (SUPPORT_AT90CAN == 1)
61  #define BUILD_FOR_AT90CAN 1
62 #else
63  #define BUILD_FOR_AT90CAN 0
64 #endif
65 
66 #if defined(SUPPORT_SJA1000) && (SUPPORT_SJA1000 == 1)
67  #define BUILD_FOR_SJA1000 1
68 #else
69  #define BUILD_FOR_SJA1000 0
70 #endif
71 
72 #if ((BUILD_FOR_MCP2515 + BUILD_FOR_AT90CAN + BUILD_FOR_SJA1000) <= 1)
73  #if (BUILD_FOR_MCP2515 == 1)
74 
75  #define mcp2515_init(...) can_init(__VA_ARGS__)
76  #define mcp2515_sleep(...) can_sleep(__VA_ARGS__)
77  #define mcp2515_wakeup(...) can_wakeup(__VA_ARGS__)
78  #define mcp2515_check_free_buffer(...) can_check_free_buffer(__VA_ARGS__)
79  #define mcp2515_check_message(...) can_check_message(__VA_ARGS__)
80  #define mcp2515_get_filter(...) can_get_filter(__VA_ARGS__)
81  #define mcp2515_static_filter(...) can_static_filter(__VA_ARGS__)
82  #define mcp2515_set_filter(...) can_set_filter(__VA_ARGS__)
83  #define mcp2515_get_message(...) can_get_message(__VA_ARGS__)
84  #define mcp2515_send_message(...) can_send_message(__VA_ARGS__)
85  #define mcp2515_read_error_register(...) can_read_error_register(__VA_ARGS__)
86  #define mcp2515_set_mode(...) can_set_mode(__VA_ARGS__)
87 
88  #elif (BUILD_FOR_AT90CAN == 1)
89 
90  #define at90can_init(...) can_init(__VA_ARGS__)
91  #define at90can_check_free_buffer(...) can_check_free_buffer(__VA_ARGS__)
92  #define at90can_check_message(...) can_check_message(__VA_ARGS__)
93  #define at90can_get_filter(...) can_get_filter(__VA_ARGS__)
94  #define at90can_set_filter(...) can_set_filter(__VA_ARGS__)
95  #define at90can_disable_filter(...) can_disable_filter(__VA_ARGS__)
96 
97  #if CAN_RX_BUFFER_SIZE == 0
98  #define at90can_get_message(...) can_get_message(__VA_ARGS__)
99  #else
100  #define at90can_get_buffered_message(...) can_get_message(__VA_ARGS__)
101  #endif
102 
103  #if CAN_TX_BUFFER_SIZE == 0
104  #define at90can_send_message(...) can_send_message(__VA_ARGS__)
105  #else
106  #define at90can_send_buffered_message(...) can_send_message(__VA_ARGS__)
107  #endif
108 
109  #define at90can_read_error_register(...) can_read_error_register(__VA_ARGS__)
110  #define at90can_set_mode(...) can_set_mode(__VA_ARGS__)
111 
112  #elif (BUILD_FOR_SJA1000 == 1)
113 
114  #define sja1000_init(...) can_init(__VA_ARGS__)
115  #define sja1000_check_free_buffer(...) can_check_free_buffer(__VA_ARGS__)
116  #define sja1000_check_message(...) can_check_message(__VA_ARGS__)
117  #define sja1000_disable_filter(...) can_disable_filter(__VA_ARGS__)
118  #define sja1000_get_message(...) can_get_message(__VA_ARGS__)
119  #define sja1000_send_message(...) can_send_message(__VA_ARGS__)
120  #define sja1000_read_error_register(...) can_read_error_register(__VA_ARGS__)
121  #define sja1000_check_bus_off(...) can_check_bus_off(__VA_ARGS__)
122  #define sja1000_reset_bus_off(...) can_reset_bus_off(__VA_ARGS__)
123  #define sja1000_set_mode(...) can_set_mode(__VA_ARGS__)
124 
125  #else
126 
127  #error No CAN-interface specified!
128 
129  #endif
130 #endif
131 
132 #ifndef CAN_INDICATE_TX_TRAFFIC_FUNCTION
133  #define CAN_INDICATE_TX_TRAFFIC_FUNCTION
134 #endif
135 
136 #ifndef CAN_INDICATE_RX_TRAFFIC_FUNCTION
137  #define CAN_INDICATE_RX_TRAFFIC_FUNCTION
138 #endif
139 
140 #ifdef CAN_DEBUG_LEVEL
141  #include <avr/pgmspace.h>
142  #include <stdio.h>
143 
144  #define DEBUG_INFO(format, ...) printf_P(PSTR(format), ##__VA_ARGS__)
145 #else
146  #define DEBUG_INFO(format, ...)
147 #endif
148 
149 
150 #endif // CAN_PRIVATE_H


uavcan_communicator
Author(s):
autogenerated on Fri Dec 13 2024 03:10:02