sja1000_error_register.c
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$
28  */
29 // ----------------------------------------------------------------------------
30 
31 #include "sja1000_private.h"
32 #ifdef SUPPORT_FOR_SJA1000__
33 
34 // ----------------------------------------------------------------------------
35 
36 can_error_register_t sja1000_read_error_register(void)
37 {
39 
40  error.tx = sja1000_read(TXERR);
41  error.rx = sja1000_read(RXERR);
42 
43  return error;
44 }
45 
46 // ----------------------------------------------------------------------------
47 // check for bus-off-status
48 
49 bool sja1000_check_bus_off(void)
50 {
51  return (sja1000_read(SR) & (1<<BS));
52 }
53 
54 // ----------------------------------------------------------------------------
55 void sja1000_reset_bus_off(void)
56 {
57  uint8_t status = sja1000_read(SR) & (1<<BS);
58  sja1000_write(SR, status & ~(1<<BS));
59 }
60 
61 #endif // SUPPORT_FOR_SJA1000__
SR
#define SR
Definition: sja1000_defs.h:45
pyuavcan_v0.dsdl.parser.error
def error(fmt, *args)
Definition: parser.py:722
uavcan::uint8_t
std::uint8_t uint8_t
Definition: std.hpp:24
TXERR
#define TXERR
Definition: mcp2515_defs.h:271
BS
#define BS
Bitdefinition von SR.
Definition: sja1000_defs.h:125
RXERR
#define RXERR
Definition: sja1000_defs.h:58
sja1000_private.h
SJA1000 Interface.
can_error_register_t
Inhalt der Fehler-Register.
Definition: can.h:257


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