RTEMS 7.0-rc1
Loading...
Searching...
No Matches
can-defs.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_TIMER_DEFS_H
23#define LPC176X_TIMER_DEFS_H
24
25#include <bsp/common-types.h>
26#include <bsp/can.h>
27
28/* CAN ACCEPTANCE FILTER */
29#define CAN_ACCEPT_BASE_ADDR 0x4003C000
30
31#define CAN_DRIVER_IS_MINOR_VALID( minor ) ( minor < CAN_DEVICES_NUMBER )
32#define CAN_DEFAULT_BAUD_RATE 1000000u
33#define CAN_DEFAULT_INTERRUPT_CONFIGURATION 0
34
35#define MAX_NUMBER_OF_CAN_BITS 25u
36#define MIN_NUMBER_OF_CAN_BITS 4u
37#define CAN_BRP_EXTRA_BIT 1u
38#define CAN_TSEG_EXTRA_BITS 3u
39#define MAX_TSEG1_TSEG2_BITS 22u
40
41#define CAN_GSR_RBS_MASK 1u
42#define CAN_CMR_RRB_MASK 4u
43
44#define CAN_MAXIMUM_DATA_SIZE 8u
45#define CAN10_MAXIMUM_ID 0x7FFu
46
50typedef enum {
51 CAN_TSEG1,
52 CAN_TSEG2,
53 CAN_NUMBER_OF_TSEG,
55
56#define CAN_BTR_TSEG1_SHIFT 16u
57#define CAN_BTR_TSEG2_SHIFT 20u
58#define CAN_BTR_SJW_SHIFT 14u
59#define CAN_BTR_BRP_SHIFT 0u
60
61#define CAN_BTR_TSEG1_MASK 0x000F0000U
62#define CAN_BTR_TSEG2_MASK 0x00700000U
63#define CAN_BTR_SJW_MASK 0x0000C000U
64#define CAN_BTR_BRP_MASK 0x000003FFU
65
66#define WRONG_BTR_VALUE 0xFFFFFFFF
67
71typedef enum {
72 CAN_TRANSMIT1,
73 CAN_TRANSMIT2,
74 CAN_TRANSMIT3,
75 CAN_NUMBER_OF_TRANSMIT_BUFFERS
77
82typedef struct {
83 uint32_t can_status_mask;
84 uint32_t not_cc_cmr_value;
86
88typedef struct {
89 volatile uint32_t MOD;
90 volatile uint32_t CMR;
91 volatile uint32_t GSR;
92 volatile uint32_t ICR;
93 volatile uint32_t IER;
94 volatile uint32_t BTR;
95 volatile uint32_t EWL;
96 volatile uint32_t SR;
97 volatile registers_can_message receive;
98 volatile registers_can_message transmit[ CAN_NUMBER_OF_TRANSMIT_BUFFERS ];
100
104typedef enum {
105 CAN_TX_PIN,
106 CAN_RX_PIN,
107 NUMBER_OF_CAN_PINS
109
113typedef struct {
114 can_device *const device;
115 const lpc176x_module module;
116 const uint32_t pconp_pin;
117 const uint32_t pins[ NUMBER_OF_CAN_PINS ];
118 const lpc176x_pin_function pinfunction;
120
122typedef struct {
123 volatile uint32_t TX_SR;
124 volatile uint32_t RX_SR;
125 volatile uint32_t MSR;
127
129typedef struct {
130 volatile uint32_t AFMR;
131 volatile uint32_t SFF_SA;
132 volatile uint32_t SFF_GRP_SA;
133 volatile uint32_t EFF_SA;
134 volatile uint32_t EFF_GRP_SA;
135 volatile uint32_t EOT;
136 volatile uint32_t LUT_ERR_ADR;
137 volatile uint32_t LUT_ERR;
138 volatile uint32_t FCANIE;
139 volatile uint32_t FCANIC0;
140 volatile uint32_t FCANIC1;
142
146typedef enum {
147 CANStandard = 0,
148 CANExtended = 1,
149 CANAny = 2
150} can_format;
151
155typedef enum {
156 CANData = 0,
157 CANRemote = 1
158} can_type;
159
160#define CAN_INTERRUPT_TYPE_MASK 0x1ffu
161
165typedef lpc176x_can_isr lpc176x_can_isr_vector[ CAN_IRQ_NUMBER ];
166
167#define CAN_MOD_RM 0x00000001U
168
169#define CAN_ACCF_AFMR_ACCOF 0x00000001U
170#define CAN_ACCF_AFMR_ACCBP 0x00000002U
171#define CAN_ACCF_AFMR_EFCAN 0x00000004U
172
173#define CAN_IER_RIE 0x000000001U
174#define CAN_IER_TIE1 0x000000002U
175#define CAN_IER_EIE 0x000000004U
176#define CAN_IER_DOIE 0x000000008U
177#define CAN_IER_WUIE 0x000000010U
178#define CAN_IER_EPIEX 0x000000020U
179#define CAN_IER_ALIEX 0x000000040U
180#define CAN_IER_BEIEX 0x000000080U
181#define CAN_IER_IDIEX 0x000000100U
182#define CAN_IER_TIE2 0x000000200U
183#define CAN_IER_TIE3 0x000000400U
184
185#endif /*LPC176X_TIMER_DEFS_H*/
CAN controller for the mbed lpc1768 board.
void(* lpc176x_can_isr)(lpc176x_can_number number)
An isr for a CAN interrupt.
Definition: can.h:94
can_pin_number
A TX or RX pin for each CAN device .
Definition: can-defs.h:104
lpc176x_can_isr lpc176x_can_isr_vector[CAN_IRQ_NUMBER]
The vector with all the callbacks for the CAN isr.
Definition: can-defs.h:165
can_type
The types of message.
Definition: can-defs.h:155
can_format
The possible CAN formats for a message.
Definition: can-defs.h:146
can_transmit_number
The transmit buffers of the CAN device.
Definition: can-defs.h:71
can_tseg_number
The Time segments of a CAN bit.
Definition: can-defs.h:50
Definitions types used by some devices in common.
lpc176x_module
lpc176x module representation.
Definition: common-types.h:46
#define MSR
Modem Status Register.
Definition: uart.h:93
lpc176x_pin_function
Defines the functions according to the pin.
Definition: io-defs.h:70
Represents the acceptance filter registers.
Definition: can-defs.h:129
Represents the CAN centralized registers.
Definition: can-defs.h:122
Represents the CAN controller registers.
Definition: can-defs.h:88
A driver entry for each low level device.
Definition: can-defs.h:113
The CAN status and control masks to send a message for each transmit buffer.
Definition: can-defs.h:82
A CAN message represented for the registers of the device.
Definition: can.h:45