RTEMS
6.3
Toggle main menu visibility
Loading...
Searching...
No Matches
bsps
arm
lpc176x
include
bsp
can.h
Go to the documentation of this file.
1
8
9
/*
10
* Copyright (c) 2014 Taller Technologies.
11
*
12
* @author Diaz Marcos (marcos.diaz@tallertechnologies.com)
13
* @author Daniel Chicco (daniel.chicco@tallertechnologies.com)
14
*
15
* The license and distribution terms for this file may be
16
* found in the file LICENSE in this distribution or at
17
* http://www.rtems.org/license/LICENSE.
18
*/
19
20
#ifndef LPC176X_CAN_H
21
#define LPC176X_CAN_H
22
23
#include <bsp.h>
24
#include <bsp/io.h>
25
#include <
bsp/lpc176x.h
>
26
27
#ifdef __cplusplus
28
extern
"C"
{
29
#endif
/* __cplusplus */
30
34
typedef
enum
{
35
CAN_0,
36
CAN_1,
37
CAN_DEVICES_NUMBER
38
}
lpc176x_can_number
;
39
43
typedef
struct
{
44
uint32_t info;
45
uint32_t id;
46
uint32_t data_a;
47
uint32_t data_b;
48
}
registers_can_message
;
49
53
typedef
struct
{
54
unsigned
int
reserved1 : 16;
55
unsigned
int
dlc : 4;
/* Bits 16..19: DLC - Data Length Counter*/
56
unsigned
int
reserved0 : 10;
57
unsigned
int
rtr : 1;
/* Bit 30: Set if this is a RTR message*/
58
unsigned
int
type : 1;
/* Bit 31: Set if this is a 29-bit ID message*/
59
unsigned
int
id;
/* CAN Message ID (11-bit or 29-bit)*/
60
unsigned
char
data[ 8 ];
/* CAN Message Data Bytes 0-7*/
61
}
low_level_can_message
;
62
66
typedef
union
{
67
low_level_can_message
low_level;
68
registers_can_message
registers;
69
}
can_message
;
70
74
typedef
enum
{
75
IRQ_RX = 0,
76
IRQ_TX,
77
IRQ_ERROR,
78
IRQ_OVERRUN,
79
IRQ_WAKEUP,
80
IRQ_PASSIVE,
81
IRQ_ARB,
82
IRQ_BUS,
83
IRQ_READY,
84
CAN_IRQ_NUMBER
85
}
can_irq_type
;
86
92
typedef
void (*
lpc176x_can_isr
) (
lpc176x_can_number
number );
93
97
typedef
unsigned
int
can_freq
;
98
109
rtems_status_code
can_open
(
lpc176x_can_number
minor,
can_freq
freq );
110
117
rtems_status_code
can_close
(
lpc176x_can_number
minor );
118
126
rtems_status_code
can_read
(
127
const
lpc176x_can_number
minor,
128
can_message
*
message
129
);
130
138
rtems_status_code
can_write
(
139
const
lpc176x_can_number
minor,
140
const
can_message
*
const
message
141
);
142
152
rtems_status_code
can_register_isr
(
153
const
lpc176x_can_number
number,
154
const
can_irq_type
type,
155
const
lpc176x_can_isr
isr
156
);
157
168
rtems_status_code
create_can_message
(
169
can_message
*
const
msg
,
170
const
int
_id,
171
const
char
*
const
_data,
172
const
char
_len
173
);
174
175
#ifdef __cplusplus
176
}
177
#endif
/* __cplusplus */
178
179
#endif
/* ifndef LPC176X_CAN_H */
can_close
rtems_status_code can_close(const lpc176x_can_number minor)
Closes the passed CAN device and shut it down.
Definition
can.c:81
can_read
rtems_status_code can_read(const lpc176x_can_number minor, can_message *message)
Reads the CAN device.
Definition
can.c:415
can_open
rtems_status_code can_open(const lpc176x_can_number minor, can_freq freq)
Opens CAN device.
Definition
can.c:332
can_write
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:458
can_register_isr
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:506
create_can_message
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:523
can_irq_type
can_irq_type
The possible interrupt sources for CAN.
Definition
can.h:74
lpc176x_can_isr
void(*) lpc176x_can_isr(lpc176x_can_number number)
An isr for a CAN interrupt.
Definition
can.h:92
lpc176x_can_number
lpc176x_can_number
The CAN devices of the board.
Definition
can.h:34
can_freq
unsigned int can_freq
A CAN frequency value.
Definition
can.h:97
rtems_status_code
rtems_status_code
This enumeration provides status codes for directives of the Classic API.
Definition
status.h:85
lpc176x.h
Specific register definitions according to lpc176x family boards.
low_level_can_message
A CAN message represented with each logical parts.
Definition
can.h:53
message
Definition
media-server.c:46
msg
Definition
b1553brm.c:94
registers_can_message
A CAN message represented for the registers of the device.
Definition
can.h:43
can_message
A CAN message represented of both forms.
Definition
can.h:66
Generated by
1.18.0