source: rtems/bsps/arm/atsam/include/libchip/include/mcan.h @ d8de6b9

5
Last change on this file since d8de6b9 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 100644
File size: 8.6 KB
Line 
1/* ---------------------------------------------------------------------------- */
2/*                  Atmel Microcontroller Software Support                      */
3/*                       SAM Software Package License                           */
4/* ---------------------------------------------------------------------------- */
5/* Copyright (c) 2015, Atmel Corporation                                        */
6/*                                                                              */
7/* All rights reserved.                                                         */
8/*                                                                              */
9/* Redistribution and use in source and binary forms, with or without           */
10/* modification, are permitted provided that the following condition is met:    */
11/*                                                                              */
12/* - Redistributions of source code must retain the above copyright notice,     */
13/* this list of conditions and the disclaimer below.                            */
14/*                                                                              */
15/* Atmel's name may not be used to endorse or promote products derived from     */
16/* this software without specific prior written permission.                     */
17/*                                                                              */
18/* DISCLAIMER:  THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR   */
19/* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF */
20/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE   */
21/* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,      */
22/* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
23/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,  */
24/* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF    */
25/* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING         */
26/* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, */
27/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.                           */
28/* ---------------------------------------------------------------------------- */
29
30/**
31 *  \file
32 *
33 *  \section Purpose
34 *
35 *  Interface for configuring and using Timer Counter (TC) peripherals.
36 *
37 *  \section Usage
38 *  -# Optionally, use TC_FindMckDivisor() to let the program find the best
39 *     TCCLKS field value automatically.
40 *  -# Configure a Timer Counter in the desired mode using TC_Configure().
41 *  -# Start or stop the timer clock using TC_Start() and TC_Stop().
42 */
43
44#ifndef _MCAN_
45#define _MCAN_
46
47/*------------------------------------------------------------------------------
48 *         Headers
49 *------------------------------------------------------------------------------*/
50
51#include "chip.h"
52
53#include <stdint.h>
54
55/*------------------------------------------------------------------------------
56 *         Global functions
57 *------------------------------------------------------------------------------*/
58
59#ifdef __cplusplus
60extern "C" {
61#endif
62
63typedef enum {
64        CAN_STD_ID = 0,
65        CAN_EXT_ID = 1
66} MCan_IdType;
67
68typedef enum {
69        CAN_DLC_0 = 0,
70        CAN_DLC_1 = 1,
71        CAN_DLC_2 = 2,
72        CAN_DLC_3 = 3,
73        CAN_DLC_4 = 4,
74        CAN_DLC_5 = 5,
75        CAN_DLC_6 = 6,
76        CAN_DLC_7 = 7,
77        CAN_DLC_8 = 8,
78        CAN_DLC_12 = 9,
79        CAN_DLC_16 = 10,
80        CAN_DLC_20 = 11,
81        CAN_DLC_24 = 12,
82        CAN_DLC_32 = 13,
83        CAN_DLC_48 = 14,
84        CAN_DLC_64 = 15
85} MCan_DlcType;
86
87typedef enum {
88        CAN_FIFO_0 = 0,
89        CAN_FIFO_1 = 1
90} MCan_FifoType;
91
92typedef enum {
93        CAN_INTR_LINE_0 = 0,
94        CAN_INTR_LINE_1 = 1
95} MCan_IntrLineType;
96
97typedef struct MailboxInfoTag {
98        uint32_t   id;
99        uint32_t   length;
100        uint32_t   timestamp;
101} MailboxInfoType;
102
103
104typedef struct MailBox8Tag {
105        MailboxInfoType info;
106        uint8_t         data[8];
107} Mailbox8Type;
108
109typedef struct MailBox12Tag {
110        MailboxInfoType info;
111        uint8_t         data[12];
112} Mailbox12Type;
113
114typedef struct MailBox16Tag {
115        MailboxInfoType info;
116        uint8_t         data[16];
117} Mailbox16Type;
118
119typedef struct MailBox20Tag {
120        MailboxInfoType info;
121        uint8_t         data[20];
122} Mailbox20Type;
123
124typedef struct MailBox24Tag {
125        MailboxInfoType info;
126        uint8_t         data[24];
127} Mailbox24Type;
128
129typedef struct MailBox32Tag {
130        MailboxInfoType info;
131        uint8_t         data[32];
132} Mailbox32ype;
133
134typedef struct MailBox48Tag {
135        MailboxInfoType info;
136        uint8_t         data[48];
137} Mailbox48Type;
138
139typedef struct MailBox64Tag {
140        MailboxInfoType info;
141        uint8_t         data[64];
142} Mailbox64Type;
143
144
145
146typedef struct MCan_MsgRamPntrsTag {
147        uint32_t *pStdFilts;
148        uint32_t *pExtFilts;
149        uint32_t *pRxFifo0;
150        uint32_t *pRxFifo1;
151        uint32_t *pRxDedBuf;
152        uint32_t *pTxEvtFifo;
153        uint32_t *pTxDedBuf;
154        uint32_t *pTxFifoQ;
155} MCan_MsgRamPntrs;
156
157typedef struct MCan_ConfigTag {
158        Mcan             *pMCan;
159        uint32_t          bitTiming;
160        uint32_t          fastBitTiming;
161        uint32_t          nmbrStdFilts;
162        uint32_t          nmbrExtFilts;
163        uint32_t          nmbrFifo0Elmts;
164        uint32_t          nmbrFifo1Elmts;
165        uint32_t          nmbrRxDedBufElmts;
166        uint32_t          nmbrTxEvtFifoElmts;
167        uint32_t          nmbrTxDedBufElmts;
168        uint32_t          nmbrTxFifoQElmts;
169        uint32_t          rxFifo0ElmtSize;
170        uint32_t          rxFifo1ElmtSize;
171        uint32_t          rxBufElmtSize;
172        // Element sizes and data sizes (encoded element size)
173        uint32_t          txBufElmtSize;
174        // Element size and data size (encoded element size)
175        MCan_MsgRamPntrs  msgRam;
176} MCan_ConfigType;
177
178extern const MCan_ConfigType mcan0Config;
179extern const MCan_ConfigType mcan1Config;
180
181__STATIC_INLINE uint32_t MCAN_IsTxComplete(
182        const MCan_ConfigType *mcanConfig)
183{
184        Mcan *mcan = mcanConfig->pMCan;
185        return (mcan->MCAN_IR & MCAN_IR_TC);
186}
187
188__STATIC_INLINE void MCAN_ClearTxComplete(
189        const MCan_ConfigType *mcanConfig)
190{
191        Mcan *mcan = mcanConfig->pMCan;
192        mcan->MCAN_IR = MCAN_IR_TC;
193}
194
195__STATIC_INLINE uint32_t MCAN_IsMessageStoredToRxDedBuffer(
196        const MCan_ConfigType *mcanConfig)
197{
198        Mcan *mcan = mcanConfig->pMCan;
199
200        return (mcan->MCAN_IR & MCAN_IR_DRX);
201}
202
203__STATIC_INLINE void MCAN_ClearMessageStoredToRxBuffer(
204        const MCan_ConfigType *mcanConfig)
205{
206        Mcan *mcan = mcanConfig->pMCan;
207        mcan->MCAN_IR = MCAN_IR_DRX;
208}
209
210__STATIC_INLINE uint32_t MCAN_IsMessageStoredToRxFifo0(
211        const MCan_ConfigType *mcanConfig)
212{
213        Mcan *mcan = mcanConfig->pMCan;
214        return (mcan->MCAN_IR & MCAN_IR_RF0N);
215}
216
217__STATIC_INLINE void MCAN_ClearMessageStoredToRxFifo0(
218        const MCan_ConfigType *mcanConfig)
219{
220        Mcan *mcan = mcanConfig->pMCan;
221        mcan->MCAN_IR = MCAN_IR_RF0N;
222}
223
224__STATIC_INLINE uint32_t MCAN_IsMessageStoredToRxFifo1(
225        const MCan_ConfigType *mcanConfig)
226{
227        Mcan *mcan = mcanConfig->pMCan;
228        return (mcan->MCAN_IR & MCAN_IR_RF1N);
229}
230
231__STATIC_INLINE void MCAN_ClearMessageStoredToRxFifo1(
232        const MCan_ConfigType *mcanConfig)
233{
234        Mcan *mcan = mcanConfig->pMCan;
235        mcan->MCAN_IR = MCAN_IR_RF1N;
236}
237
238void MCAN_Init(
239        const MCan_ConfigType *mcanConfig);
240
241void MCAN_InitFdEnable(
242        const MCan_ConfigType *mcanConfig);
243
244void MCAN_InitFdBitRateSwitchEnable(
245        const MCan_ConfigType *mcanConfig);
246
247void MCAN_InitTxQueue(
248        const MCan_ConfigType *mcanConfig);
249
250void MCAN_InitLoopback(
251        const MCan_ConfigType *mcanConfig);
252
253void MCAN_Enable(
254        const MCan_ConfigType *mcanConfig);
255
256void MCAN_RequestIso11898_1(
257        const MCan_ConfigType *mcanConfig);
258
259void MCAN_RequestFd(
260        const MCan_ConfigType *mcanConfig);
261
262void MCAN_RequestFdBitRateSwitch(
263        const MCan_ConfigType *mcanConfig);
264
265void MCAN_LoopbackOn(
266        const MCan_ConfigType *mcanConfig);
267
268void MCAN_LoopbackOff(
269        const MCan_ConfigType *mcanConfig);
270
271void MCAN_IEnableMessageStoredToRxDedBuffer(
272        const MCan_ConfigType *mcanConfig,
273        MCan_IntrLineType line);
274
275uint8_t   *MCAN_ConfigTxDedBuffer(
276        const MCan_ConfigType *mcanConfig,
277        uint8_t buffer,
278        uint32_t id,
279        MCan_IdType idType,
280        MCan_DlcType dlc);
281
282void MCAN_SendTxDedBuffer(
283        const MCan_ConfigType *mcanConfig,
284        uint8_t buffer);
285
286uint32_t MCAN_AddToTxFifoQ(
287        const MCan_ConfigType *mcanConfig,
288        uint32_t id, MCan_IdType idType,
289        MCan_DlcType dlc, uint8_t *data);
290
291uint8_t MCAN_IsBufferTxd(
292        const MCan_ConfigType *mcanConfig,
293        uint8_t buffer);
294
295void MCAN_ConfigRxBufferFilter(
296        const MCan_ConfigType *mcanConfig,
297        uint32_t buffer,
298        uint32_t filter,
299        uint32_t id,
300        MCan_IdType idType);
301
302void MCAN_ConfigRxClassicFilter(
303        const MCan_ConfigType *mcanConfig,
304        MCan_FifoType fifo,
305        uint8_t filter,
306        uint32_t id,
307        MCan_IdType idType,
308        uint32_t mask);
309
310uint8_t MCAN_IsNewDataInRxDedBuffer(
311        const MCan_ConfigType *mcanConfig,
312        uint8_t buffer);
313
314void MCAN_GetRxDedBuffer(
315        const MCan_ConfigType *mcanConfig,
316        uint8_t buffer,
317        Mailbox64Type *pRxMailbox);
318
319uint32_t MCAN_GetRxFifoBuffer(
320        const MCan_ConfigType *mcanConfig,
321        MCan_FifoType fifo,
322        Mailbox64Type *pRxMailbox);
323
324#ifdef __cplusplus
325}
326#endif
327
328#endif /* #ifndef _MCAN_ */
329
Note: See TracBrowser for help on using the repository browser.