source: rtems/bsps/arm/lpc176x/include/bsp/can.h @ 9964895

5
Last change on this file since 9964895 was 2afb22b, checked in by Chris Johns <chrisj@…>, on 12/23/17 at 07:18:56

Remove make preinstall

A speciality of the RTEMS build system was the make preinstall step. It
copied header files from arbitrary locations into the build tree. The
header files were included via the -Bsome/build/tree/path GCC command
line option.

This has at least seven problems:

  • The make preinstall step itself needs time and disk space.
  • Errors in header files show up in the build tree copy. This makes it hard for editors to open the right file to fix the error.
  • There is no clear relationship between source and build tree header files. This makes an audit of the build process difficult.
  • The visibility of all header files in the build tree makes it difficult to enforce API barriers. For example it is discouraged to use BSP-specifics in the cpukit.
  • An introduction of a new build system is difficult.
  • Include paths specified by the -B option are system headers. This may suppress warnings.
  • The parallel build had sporadic failures on some hosts.

This patch removes the make preinstall step. All installed header
files are moved to dedicated include directories in the source tree.
Let @RTEMS_CPU@ be the target architecture, e.g. arm, powerpc, sparc,
etc. Let @RTEMS_BSP_FAMILIY@ be a BSP family base directory, e.g.
erc32, imx, qoriq, etc.

The new cpukit include directories are:

  • cpukit/include
  • cpukit/score/cpu/@RTEMS_CPU@/include
  • cpukit/libnetworking

The new BSP include directories are:

  • bsps/include
  • bsps/@RTEMS_CPU@/include
  • bsps/@RTEMS_CPU@/@RTEMS_BSP_FAMILIY@/include

There are build tree include directories for generated files.

The include directory order favours the most general header file, e.g.
it is not possible to override general header files via the include path
order.

The "bootstrap -p" option was removed. The new "bootstrap -H" option
should be used to regenerate the "headers.am" files.

Update #3254.

  • Property mode set to 100755
File size: 4.2 KB
Line 
1/**
2 * @file can.h
3 *
4 * @ingroup lpc176x
5 *
6 * @brief CAN controller for the mbed lpc1768 board.
7 */
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
28extern "C" {
29#endif /* __cplusplus */
30
31/**
32 * @brief The CAN devices of the board.
33 */
34typedef enum {
35  CAN_0,
36  CAN_1,
37  CAN_DEVICES_NUMBER
38} lpc176x_can_number;
39
40/**
41 * @brief  A CAN message represented for the registers of the device.
42 */
43typedef struct {
44  uint32_t info;
45  uint32_t id;
46  uint32_t data_a;
47  uint32_t data_b;
48} registers_can_message;
49
50/**
51 * @brief A CAN message represented with each logical parts
52 */
53typedef 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
63/**
64 * @brief A CAN message represented of both forms.
65 */
66typedef union {
67  low_level_can_message low_level;
68  registers_can_message registers;
69} can_message;
70
71/**
72 * @brief The possible interrupt sources for CAN.
73 */
74typedef 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
87/**
88 * @brief An isr for a CAN interrupt
89 *
90 * @param number The CAN which rised the interrupt.
91 */
92typedef void (*lpc176x_can_isr) ( lpc176x_can_number number );
93
94/**
95 * @brief A CAN frequency value
96 */
97typedef unsigned int can_freq;
98
99/**
100 * @brief Opens CAN device.
101 * @details It enables the module and gives it a clock, sets the pins,
102 * disables the interrupts, sets the frequency and bypasses
103 * the acceptance filter.
104 *
105 * @param  minor The device to open.
106 * @param freq The desired frequency.
107 * @return RTEMS_SUCCESFUL on success.
108 */
109rtems_status_code can_open( lpc176x_can_number minor, can_freq freq );
110
111/**
112 * @brief Closes the passed CAN device and shut it down.
113 *
114 * @param minor The device to close.
115 * @return RTEMS_SUCCESSFUL  if ok, RTEMS_INVALID_NUMBER for a bad parameter.
116 */
117rtems_status_code can_close( lpc176x_can_number minor );
118
119/**
120 * @brief Reads the CAN device.
121 *
122 * @param minor The CAN device to read.
123 * @param message The read message.
124 * @return RTEMS_SUCCESSFUL if read ok, RTEMS_IO_ERROR otherwise.
125 */
126rtems_status_code can_read(
127  const lpc176x_can_number minor,
128  can_message             *message
129);
130
131/**
132 * @brief Writes the passed CAN message into the selected CAN device.
133 *
134 * @param minor The device to write.
135 * @param message The message to write.
136 * @return RTEMS_SUCCESFUL if write ok. RTEMS_IO_ERROR otherwise.
137 */
138rtems_status_code can_write(
139  const lpc176x_can_number minor,
140  const can_message *const message
141);
142
143/**
144 * @brief Registers an isr in the driver vector, and enables the interrupt
145*  in the device.
146 *
147 * @param number The CAN device to set
148 * @param type The interrupt type.
149 * @param isr The isr to register.
150 * @return RTEMS_SUCCESSFUL if ok RTEMS_INVALID_NUMBER otherwise.
151 */
152rtems_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
158/**
159 * @brief Creates a CAN message.
160 * @details [long description]
161 *
162 * @param msg The created message.
163 * @param _id The can id for the message.
164 * @param _data The data of the message.
165 * @param _len The length of the message.
166 * @return RTEMS_SUCCESFUL if created, RTEMS_INVALID_NUMBER otherwise.
167 */
168rtems_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 */
Note: See TracBrowser for help on using the repository browser.