Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:22:44

0001 /* ---------------------------------------------------------------------------- */
0002 /*                  Atmel Microcontroller Software Support                      */
0003 /*                       SAM Software Package License                           */
0004 /* ---------------------------------------------------------------------------- */
0005 /* Copyright (c) 2015, Atmel Corporation                                        */
0006 /*                                                                              */
0007 /* All rights reserved.                                                         */
0008 /*                                                                              */
0009 /* Redistribution and use in source and binary forms, with or without           */
0010 /* modification, are permitted provided that the following condition is met:    */
0011 /*                                                                              */
0012 /* - Redistributions of source code must retain the above copyright notice,     */
0013 /* this list of conditions and the disclaimer below.                            */
0014 /*                                                                              */
0015 /* Atmel's name may not be used to endorse or promote products derived from     */
0016 /* this software without specific prior written permission.                     */
0017 /*                                                                              */
0018 /* DISCLAIMER:  THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR   */
0019 /* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF */
0020 /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE   */
0021 /* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,      */
0022 /* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
0023 /* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,  */
0024 /* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF    */
0025 /* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING         */
0026 /* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, */
0027 /* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.                           */
0028 /* ---------------------------------------------------------------------------- */
0029 
0030 /**
0031  *  \file
0032  *
0033  *  \section Purpose
0034  *
0035  *  Interface for configuring and using Timer Counter (TC) peripherals.
0036  *
0037  *  \section Usage
0038  *  -# Optionally, use TC_FindMckDivisor() to let the program find the best
0039  *     TCCLKS field value automatically.
0040  *  -# Configure a Timer Counter in the desired mode using TC_Configure().
0041  *  -# Start or stop the timer clock using TC_Start() and TC_Stop().
0042  */
0043 
0044 #ifndef _MCAN_CONFIG_
0045 #define _MCAN_CONFIG_
0046 
0047 /*------------------------------------------------------------------------------
0048  *         Headers
0049  *------------------------------------------------------------------------------*/
0050 
0051 
0052 /*------------------------------------------------------------------------------
0053  *         Global functions
0054  *------------------------------------------------------------------------------*/
0055 
0056 #ifdef __cplusplus
0057 extern "C" {
0058 #endif
0059 
0060 /* Programmable Clock Source for Baud Rate is Common To Both MCAN Controllers */
0061 #define MCAN_PROG_CLK_PRESCALER       1   /* /1 to /256 */
0062 // select one of the following for the programmable clock source
0063 //#define MCAN_PROG_CLK_SELECT          PMC_PCK_CSS_SLOW_CLK
0064 //#define MCAN_PROG_CLK_SELECT          PMC_PCK_CSS_MAIN_CLK
0065 //#define MCAN_PROG_CLK_SELECT          PMC_PCK_CSS_PLLA_CLK
0066 //#define MCAN_PROG_CLK_SELECT          PMC_PCK_CSS_UPLL_CLK
0067 #define MCAN_PROG_CLK_SELECT          PMC_PCK_CSS_MCK
0068 #define MCAN_PROG_CLK_FREQ_HZ \
0069     ((float) 150000000 / (float) MCAN_PROG_CLK_PRESCALER)
0070 
0071 #define MCAN0_BIT_RATE_BPS            500000
0072 #define MCAN0_PROP_SEG                2
0073 #define MCAN0_PHASE_SEG1              11
0074 #define MCAN0_PHASE_SEG2              11
0075 #define MCAN0_SYNC_JUMP               4
0076 
0077 #define MCAN0_FAST_BIT_RATE_BPS       2000000
0078 #define MCAN0_FAST_PROP_SEG           2
0079 #define MCAN0_FAST_PHASE_SEG1         4
0080 #define MCAN0_FAST_PHASE_SEG2         4
0081 #define MCAN0_FAST_SYNC_JUMP          2
0082 
0083 #define MCAN0_NMBR_STD_FLTS           8  /* 128 max filters */
0084 #define MCAN0_NMBR_EXT_FLTS           8  /* 64 max filters */
0085 #define MCAN0_NMBR_RX_FIFO0_ELMTS     0  /* # of elements, 64 elements max */
0086 #define MCAN0_NMBR_RX_FIFO1_ELMTS     0  /* # of elements, 64 elements max */
0087 #define MCAN0_NMBR_RX_DED_BUF_ELMTS   16 /* # of elements, 64 elements max */
0088 #define MCAN0_NMBR_TX_EVT_FIFO_ELMTS  0  /* # of elements, 32 elements max */
0089 #define MCAN0_NMBR_TX_DED_BUF_ELMTS   4  /* # of elements, 32 elements max */
0090 #define MCAN0_NMBR_TX_FIFO_Q_ELMTS    0  /* # of elements, 32 elements max */
0091 #define MCAN0_RX_FIFO0_ELMT_SZ        8  /* 8, 12, 16, 20, 24, 32, 48, 64 bytes */
0092 #define MCAN0_RX_FIFO1_ELMT_SZ        8  /* 8, 12, 16, 20, 24, 32, 48, 64 bytes */
0093 #define MCAN0_RX_BUF_ELMT_SZ          8  /* 8, 12, 16, 20, 24, 32, 48, 64 bytes */
0094 #define MCAN0_TX_BUF_ELMT_SZ          8  /* 8, 12, 16, 20, 24, 32, 48, 64 bytes */
0095 
0096 #define MCAN1_BIT_RATE_BPS            500000
0097 #define MCAN1_PROP_SEG                2
0098 #define MCAN1_PHASE_SEG1              11
0099 #define MCAN1_PHASE_SEG2              11
0100 #define MCAN1_SYNC_JUMP               4
0101 
0102 #define MCAN1_FAST_BIT_RATE_BPS       2000000
0103 #define MCAN1_FAST_PROP_SEG           2
0104 #define MCAN1_FAST_PHASE_SEG1         4
0105 #define MCAN1_FAST_PHASE_SEG2         4
0106 #define MCAN1_FAST_SYNC_JUMP          2
0107 
0108 #define MCAN1_NMBR_STD_FLTS           8   /* 128 max filters */
0109 #define MCAN1_NMBR_EXT_FLTS           8   /* 64 max filters */
0110 #define MCAN1_NMBR_RX_FIFO0_ELMTS     12  /* # of elements, 64 elements max */
0111 #define MCAN1_NMBR_RX_FIFO1_ELMTS     0   /* # of elements, 64 elements max */
0112 #define MCAN1_NMBR_RX_DED_BUF_ELMTS   4   /* # of elements, 64 elements max */
0113 #define MCAN1_NMBR_TX_EVT_FIFO_ELMTS  0   /* # of elements, 32 elements max */
0114 #define MCAN1_NMBR_TX_DED_BUF_ELMTS   4   /* # of elements, 32 elements max */
0115 #define MCAN1_NMBR_TX_FIFO_Q_ELMTS    4   /* # of elements, 32 elements max */
0116 #define MCAN1_RX_FIFO0_ELMT_SZ        8   /* 8, 12, 16, 20, 24, 32, 48, 64 bytes */
0117 #define MCAN1_RX_FIFO1_ELMT_SZ        8   /* 8, 12, 16, 20, 24, 32, 48, 64 bytes */
0118 #define MCAN1_RX_BUF_ELMT_SZ          64  /* 8, 12, 16, 20, 24, 32, 48, 64 bytes */
0119 #define MCAN1_TX_BUF_ELMT_SZ          32  /* 8, 12, 16, 20, 24, 32, 48, 64 bytes */
0120 
0121 #ifdef __cplusplus
0122 }
0123 #endif
0124 
0125 #endif /* #ifndef _MCAN_CONFIG_ */
0126