TCAN4550  1p2
TCAN4550.h
Go to the documentation of this file.
1 /*
2 * TCAN4550.h
3 * Description: This file contains TCAN4550 functions, and relies on the TCAN4x5x_SPI abstraction functions
4 *
5 * Created on: Oct 1, 2017
6 * Author: Texas Instruments
7 *
8 *
9 * Copyright (c) 2017 Texas Instruments Incorporated. All rights reserved.
10 * Software License Agreement
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
14 * are met:
15 *
16 * Redistributions of source code must retain the above copyright
17 * notice, this list of conditions and the following disclaimer.
18 *
19 * Redistributions in binary form must reproduce the above copyright
20 * notice, this list of conditions and the following disclaimer in the
21 * documentation and/or other materials provided with the
22 * distribution.
23 *
24 * Neither the name of Texas Instruments Incorporated nor the names of
25 * its contributors may be used to endorse or promote products derived
26 * from this software without specific prior written permission.
27 *
28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
31 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
32 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
33 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
34 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
35 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
36 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
38 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39 */
40 #ifndef TCAN4550_H_
41 #define TCAN4550_H_
42 #include "TCAN4x5x_SPI.h"
43 #include "TCAN4x5x_Reg.h"
44 #include "TCAN4x5x_Data_Structs.h"
45 
47 #define TCAN4x5x_MCAN_CACHE_CONFIGURATION
48 
50 #define TCAN4x5x_MCAN_VERIFY_CONFIGURATION_WRITES
51 
53 #define TCAN4x5x_DEVICE_VERIFY_CONFIGURATION_WRITES
54 
55 
56 // Defines for caching the configuration values to save on reads and writes
57 #ifdef TCAN4x5x_MCAN_CACHE_CONFIGURATION
58 #define TCAN4x5x_MCAN_CACHE_SIDFC 0
59 #define TCAN4x5x_MCAN_CACHE_XIDFC 1
60 #define TCAN4x5x_MCAN_CACHE_RXF0C 2
61 #define TCAN4x5x_MCAN_CACHE_RXF1C 3
62 #define TCAN4x5x_MCAN_CACHE_RXBC 4
63 #define TCAN4x5x_MCAN_CACHE_TXEFC 5
64 #define TCAN4x5x_MCAN_CACHE_TXBC 6
65 #define TCAN4x5x_MCAN_CACHE_RXESC 7
66 #define TCAN4x5x_MCAN_CACHE_TXESC 8
67 #endif
68 
73 
74 
75 
76 // ~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*
77 // MCAN Device Functions
78 // ~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*
92 
93 
94 extern bool TCAN4x5x_MRAM_Configure(TCAN4x5x_MRAM_Config *MRAMConfig);
95 extern void TCAN4x5x_MRAM_Clear(void);
98 extern void TCAN4x5x_MCAN_ClearInterruptsAll(void);
101 extern uint8_t TCAN4x5x_MCAN_ReadNextFIFO(TCAN4x5x_MCAN_FIFO_Enum FIFODefine, TCAN4x5x_MCAN_RX_Header *header, uint8_t dataPayload[]);
102 extern uint8_t TCAN4x5x_MCAN_ReadRXBuffer(uint8_t bufIndex, TCAN4x5x_MCAN_RX_Header *header, uint8_t dataPayload[]);
103 extern uint32_t TCAN4x5x_MCAN_WriteTXBuffer(uint8_t bufIndex, TCAN4x5x_MCAN_TX_Header *header, uint8_t dataPayload[]);
104 extern bool TCAN4x5x_MCAN_TransmitBufferContents(uint8_t bufIndex);
105 extern bool TCAN4x5x_MCAN_WriteSIDFilter(uint8_t filterIndex, TCAN4x5x_MCAN_SID_Filter *filter);
106 extern bool TCAN4x5x_MCAN_ReadSIDFilter(uint8_t filterIndex, TCAN4x5x_MCAN_SID_Filter *filter);
107 extern bool TCAN4x5x_MCAN_WriteXIDFilter(uint8_t fifoIndex, TCAN4x5x_MCAN_XID_Filter *filter);
108 extern uint8_t TCAN4x5x_MCAN_DLCtoBytes(uint8_t inputDLC);
109 extern uint8_t TCAN4x5x_MCAN_TXRXESC_DataByteValue(uint8_t inputESCValue);
110 
111 
112 
113 
114 // ~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*
115 // Non-MCAN Device Functions
116 // ~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*
117 extern uint16_t TCAN4x5x_Device_ReadDeviceVersion(void);
122 extern void TCAN4x5x_Device_ClearInterruptsAll(void);
123 extern void TCAN4x5x_Device_ClearSPIERR(void);
126 extern bool TCAN4x5x_Device_SetMode(TCAN4x5x_Device_Mode_Enum modeDefine);
129 extern bool TCAN4x5x_Device_DisableTestMode(void);
131 
132 
133 extern bool TCAN4x5x_WDT_Configure(TCAN4x5x_WDT_Timer_Enum WDTtimeout);
135 extern bool TCAN4x5x_WDT_Enable(void);
136 extern bool TCAN4x5x_WDT_Disable(void);
137 extern void TCAN4x5x_WDT_Reset(void);
138 
139 
140 #endif
void TCAN4x5x_MCAN_ConfigureInterruptEnable(TCAN4x5x_MCAN_Interrupt_Enable *ie)
Configures the MCAN interrupt enable register.
Definition: TCAN4550.c:1429
TCAN4x5x_Device_Mode_Enum
Definition: TCAN4550.h:72
uint8_t TCAN4x5x_MCAN_DLCtoBytes(uint8_t inputDLC)
Converts the CAN message DLC hex value to the number of bytes it corresponds to.
Definition: TCAN4550.c:1443
void TCAN4x5x_MCAN_ReadNominalTiming_Raw(TCAN4x5x_MCAN_Nominal_Timing_Raw *nomTiming)
Reads the MCAN nominal/arbitration time settings, using the raw MCAN timing struct.
Definition: TCAN4550.c:431
void TCAN4x5x_Device_ClearSPIERR(void)
Clears a SPIERR flag that may be set.
Definition: TCAN4550.c:1603
bool TCAN4x5x_MCAN_ConfigureNominalTiming_Raw(TCAN4x5x_MCAN_Nominal_Timing_Raw *nomTiming)
Writes the MCAN nominal timing settings, using the raw MCAN nominal timing struct.
Definition: TCAN4550.c:514
bool TCAN4x5x_MCAN_ConfigureCCCRRegister(TCAN4x5x_MCAN_CCCR_Config *cccr)
Configure the MCAN CCCR Register.
Definition: TCAN4550.c:150
Used to setup the timing parameters of the MCAN module This is the raw MCAN form of the struct which ...
Struct containing the device interrupt enable bit field.
bool TCAN4x5x_MRAM_Configure(TCAN4x5x_MRAM_Config *MRAMConfig)
Configures the MRAM registers.
Definition: TCAN4550.c:584
CAN message header for transmitted messages.
TCAN4x5x_MCAN_FIFO_Enum
Definition: TCAN4550.h:69
bool TCAN4x5x_MCAN_ConfigureNominalTiming_Simple(TCAN4x5x_MCAN_Nominal_Timing_Simple *nomTiming)
Writes the MCAN nominal timing settings, using the simple nominal timing struct.
Definition: TCAN4550.c:457
uint8_t TCAN4x5x_MCAN_TXRXESC_DataByteValue(uint8_t inputESCValue)
Converts the MCAN ESC (Element Size) value to number of bytes that it corresponds to...
Definition: TCAN4550.c:1465
bool TCAN4x5x_MCAN_EnableProtectedRegisters(void)
Enable Protected MCAN Registers.
Definition: TCAN4550.c:79
void TCAN4x5x_Device_ReadConfig(TCAN4x5x_DEV_CONFIG *devCfg)
Reads the device mode and pin register.
Definition: TCAN4550.c:1553
void TCAN4x5x_Device_ClearInterruptsAll(void)
Clear all device interrupts.
Definition: TCAN4550.c:1593
bool TCAN4x5x_MCAN_TransmitBufferContents(uint8_t bufIndex)
Transmit TX buffer contents of the specified tx buffer.
Definition: TCAN4550.c:1173
bool TCAN4x5x_MCAN_WriteSIDFilter(uint8_t filterIndex, TCAN4x5x_MCAN_SID_Filter *filter)
Write MCAN Standard ID filter into MRAM.
Definition: TCAN4550.c:1199
bool TCAN4x5x_MCAN_ConfigureGlobalFilter(TCAN4x5x_MCAN_Global_Filter_Configuration *gfc)
Configures the MCAN global filter configuration register, using the passed Global Filter Configuratio...
Definition: TCAN4550.c:547
void TCAN4x5x_Device_ReadInterrupts(TCAN4x5x_Device_Interrupts *ir)
Read the device interrupts.
Definition: TCAN4550.c:1567
Struct containing the register values for the Global Filter Configuration Register.
Used to setup the nominal timing parameters of the MCAN module This is the raw MCAN form of the struc...
bool TCAN4x5x_Device_SetMode(TCAN4x5x_Device_Mode_Enum modeDefine)
Sets the TCAN4x5x device mode.
Definition: TCAN4550.c:1657
bool TCAN4x5x_WDT_Enable(void)
Enable the watchdog timer.
Definition: TCAN4550.c:1887
void TCAN4x5x_MCAN_ReadNominalTiming_Simple(TCAN4x5x_MCAN_Nominal_Timing_Simple *nomTiming)
Reads the MCAN nominal/arbitration time settings, using the simple timing struct. ...
Definition: TCAN4550.c:410
bool TCAN4x5x_MCAN_WriteXIDFilter(uint8_t fifoIndex, TCAN4x5x_MCAN_XID_Filter *filter)
Write MCAN Extended ID filter into MRAM.
Definition: TCAN4550.c:1277
void TCAN4x5x_MCAN_ClearInterrupts(TCAN4x5x_MCAN_Interrupts *ir)
Clear the MCAN interrupts.
Definition: TCAN4550.c:1388
bool TCAN4x5x_MCAN_ConfigureDataTiming_Raw(TCAN4x5x_MCAN_Data_Timing_Raw *dataTiming)
Writes the MCAN data time settings, using the raw MCAN data timing struct.
Definition: TCAN4550.c:352
TCAN4x5x_WDT_Timer_Enum
Definition: TCAN4550.h:70
uint32_t TCAN4x5x_MCAN_WriteTXBuffer(uint8_t bufIndex, TCAN4x5x_MCAN_TX_Header *header, uint8_t dataPayload[])
Write CAN message to the specified TX buffer.
Definition: TCAN4550.c:1064
bool TCAN4x5x_WDT_Disable(void)
Disable the watchdog timer.
Definition: TCAN4550.c:1908
void TCAN4x5x_MCAN_ReadInterruptEnable(TCAN4x5x_MCAN_Interrupt_Enable *ie)
Read the MCAN interrupt enable register.
Definition: TCAN4550.c:1414
Standard ID filter struct.
void TCAN4x5x_Device_ClearInterrupts(TCAN4x5x_Device_Interrupts *ir)
Clear the device interrupts.
Definition: TCAN4550.c:1581
void TCAN4x5x_WDT_Reset(void)
Reset the watchdog timer.
Definition: TCAN4550.c:1927
TCAN4x5x_Device_Mode_Enum TCAN4x5x_Device_ReadMode(void)
Reads the TCAN4x5x device mode.
Definition: TCAN4550.c:1698
bool TCAN4x5x_MCAN_DisableProtectedRegisters(void)
Disable Protected MCAN Registers.
Definition: TCAN4550.c:113
bool TCAN4x5x_MCAN_ReadSIDFilter(uint8_t filterIndex, TCAN4x5x_MCAN_SID_Filter *filter)
Read a MCAN Standard ID filter from MRAM.
Definition: TCAN4550.c:1241
bool TCAN4x5x_Device_ConfigureInterruptEnable(TCAN4x5x_Device_Interrupt_Enable *ie)
Configures the device interrupt enable register.
Definition: TCAN4550.c:1633
Defines the number of MRAM elements and the size of the elements.
Struct containing the MCAN interrupt enable bit field.
struct containing the bit fields of the MCAN CCCR register
Used to setup the data timing parameters of the MCAN module This is a simplified struct, requiring only the prescaler value (1:x), number of time quanta before and after the sample point.
void TCAN4x5x_MCAN_ReadCCCRRegister(TCAN4x5x_MCAN_CCCR_Config *cccrConfig)
Read the MCAN CCCR configuration register.
Definition: TCAN4550.c:200
void TCAN4x5x_MCAN_ReadInterrupts(TCAN4x5x_MCAN_Interrupts *ir)
Read the MCAN interrupts.
Definition: TCAN4550.c:1374
Struct containing the device interrupt bit field.
TCAN4x5x_Device_Test_Mode_Enum TCAN4x5x_Device_ReadTestMode(void)
Reads the TCAN4x5x device test mode.
Definition: TCAN4550.c:1788
TCAN4x5x_Device_Test_Mode_Enum
Definition: TCAN4550.h:71
uint8_t TCAN4x5x_MCAN_ReadNextFIFO(TCAN4x5x_MCAN_FIFO_Enum FIFODefine, TCAN4x5x_MCAN_RX_Header *header, uint8_t dataPayload[])
Read the next MCAN FIFO element.
Definition: TCAN4550.c:828
bool TCAN4x5x_WDT_Configure(TCAN4x5x_WDT_Timer_Enum WDTtimeout)
Configure the watchdog.
Definition: TCAN4550.c:1814
void TCAN4x5x_MCAN_ClearInterruptsAll(void)
Clear all MCAN interrupts.
Definition: TCAN4550.c:1400
Extended ID filter struct.
void TCAN4x5x_Device_ReadInterruptEnable(TCAN4x5x_Device_Interrupt_Enable *ie)
Read the device interrupt enable register.
Definition: TCAN4550.c:1617
void TCAN4x5x_MCAN_ReadDataTimingFD_Raw(TCAN4x5x_MCAN_Data_Timing_Raw *dataTiming)
Reads the MCAN data time settings, using the raw MCAN struct.
Definition: TCAN4550.c:239
bool TCAN4x5x_MCAN_ConfigureDataTiming_Simple(TCAN4x5x_MCAN_Data_Timing_Simple *dataTiming)
Writes the MCAN data time settings, using the simple data timing struct.
Definition: TCAN4550.c:277
void TCAN4x5x_MRAM_Clear(void)
Clear (Zero-fill) the contents of MRAM.
Definition: TCAN4550.c:796
void TCAN4x5x_MCAN_ReadDataTimingFD_Simple(TCAN4x5x_MCAN_Data_Timing_Simple *dataTiming)
Reads the MCAN data time settings, using the simple struct.
Definition: TCAN4550.c:217
bool TCAN4x5x_Device_Configure(TCAN4x5x_DEV_CONFIG *devCfg)
Configures the device mode and pin register.
Definition: TCAN4550.c:1505
Struct containing the MCAN interrupt bit field.
uint16_t TCAN4x5x_Device_ReadDeviceVersion(void)
Read the TCAN4x5x device version register.
Definition: TCAN4550.c:1485
bool TCAN4x5x_Device_EnableTestMode(TCAN4x5x_Device_Test_Mode_Enum modeDefine)
Sets the TCAN4x5x device test mode.
Definition: TCAN4550.c:1728
uint8_t TCAN4x5x_MCAN_ReadRXBuffer(uint8_t bufIndex, TCAN4x5x_MCAN_RX_Header *header, uint8_t dataPayload[])
Read the specified RX buffer element.
Definition: TCAN4550.c:964
bool TCAN4x5x_Device_DisableTestMode(void)
Disables the TCAN4x5x device test mode.
Definition: TCAN4550.c:1767
Used to setup the nominal timing parameters of the MCAN module This is a simplified struct...
TCAN4x5x_WDT_Timer_Enum TCAN4x5x_WDT_Read(void)
Read the watchdog configuration.
Definition: TCAN4550.c:1857