RTEMS 7.0-rc1
Loading...
Searching...
No Matches
can.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: GPL-2.0+-with-RTEMS-exception */
2
11/*
12 * Copyright (c) 2014 Taller Technologies.
13 *
14 * @author Diaz Marcos (marcos.diaz@tallertechnologies.com)
15 * @author Daniel Chicco (daniel.chicco@tallertechnologies.com)
16 *
17 * The license and distribution terms for this file may be
18 * found in the file LICENSE in this distribution or at
19 * http://www.rtems.org/license/LICENSE.
20 */
21
22#ifndef LPC176X_CAN_H
23#define LPC176X_CAN_H
24
25#include <bsp.h>
26#include <bsp/io.h>
27#include <bsp/lpc176x.h>
28
29#ifdef __cplusplus
30extern "C" {
31#endif /* __cplusplus */
32
36typedef enum {
37 CAN_0,
38 CAN_1,
39 CAN_DEVICES_NUMBER
41
45typedef struct {
46 uint32_t info;
47 uint32_t id;
48 uint32_t data_a;
49 uint32_t data_b;
51
55typedef struct {
56 unsigned int reserved1 : 16;
57 unsigned int dlc : 4; /* Bits 16..19: DLC - Data Length Counter*/
58 unsigned int reserved0 : 10;
59 unsigned int rtr : 1; /* Bit 30: Set if this is a RTR message*/
60 unsigned int type : 1; /* Bit 31: Set if this is a 29-bit ID message*/
61 unsigned int id; /* CAN Message ID (11-bit or 29-bit)*/
62 unsigned char data[ 8 ]; /* CAN Message Data Bytes 0-7*/
64
68typedef union {
69 low_level_can_message low_level;
70 registers_can_message registers;
72
76typedef enum {
77 IRQ_RX = 0,
78 IRQ_TX,
79 IRQ_ERROR,
80 IRQ_OVERRUN,
81 IRQ_WAKEUP,
82 IRQ_PASSIVE,
83 IRQ_ARB,
84 IRQ_BUS,
85 IRQ_READY,
86 CAN_IRQ_NUMBER
88
94typedef void (*lpc176x_can_isr) ( lpc176x_can_number number );
95
99typedef unsigned int can_freq;
100
112
120
129 const lpc176x_can_number minor,
131);
132
141 const lpc176x_can_number minor,
142 const can_message *const message
143);
144
155 const lpc176x_can_number number,
156 const can_irq_type type,
157 const lpc176x_can_isr isr
158);
159
171 can_message *const msg,
172 const int _id,
173 const char *const _data,
174 const char _len
175);
176
177#ifdef __cplusplus
178}
179#endif /* __cplusplus */
180
181#endif /* ifndef LPC176X_CAN_H */
rtems_status_code can_close(lpc176x_can_number minor)
Closes the passed CAN device and shut it down.
Definition: can.c:83
can_irq_type
The possible interrupt sources for CAN.
Definition: can.h:76
rtems_status_code can_open(lpc176x_can_number minor, can_freq freq)
Opens CAN device.
Definition: can.c:334
void(* lpc176x_can_isr)(lpc176x_can_number number)
An isr for a CAN interrupt.
Definition: can.h:94
rtems_status_code can_register_isr(const lpc176x_can_number number, const can_irq_type type, const lpc176x_can_isr isr)
Registers an isr in the driver vector, and enables the interrupt in the device.
Definition: can.c:510
rtems_status_code create_can_message(can_message *const msg, const int _id, const char *const _data, const char _len)
Creates a CAN message.
Definition: can.c:527
lpc176x_can_number
The CAN devices of the board.
Definition: can.h:36
unsigned int can_freq
A CAN frequency value.
Definition: can.h:99
rtems_status_code can_read(const lpc176x_can_number minor, can_message *message)
Reads the CAN device.
Definition: can.c:419
rtems_status_code can_write(const lpc176x_can_number minor, const can_message *const message)
Writes the passed CAN message into the selected CAN device.
Definition: can.c:462
rtems_status_code
This enumeration provides status codes for directives of the Classic API.
Definition: status.h:85
Specific register definitions according to lpc176x family boards.
A CAN message represented with each logical parts.
Definition: can.h:55
Definition: media-server.c:46
Definition: b1553brm.c:94
A CAN message represented for the registers of the device.
Definition: can.h:45
A CAN message represented of both forms.
Definition: can.h:68