CAN CoreX 2.3.1
Table-driven CAN, CAN FD, ISO-TP, network simulation, and bus monitoring library
Loading...
Searching...
No Matches
can_corex.h File Reference

Core CAN CoreX public API. More...

#include <limits.h>
#include <stdint.h>
#include "can_corex_bus.h"

Go to the source code of this file.

Data Structures

struct  CCX_GlobalStats_t
 Global statistics for CAN instance. More...
struct  CCX_message_t
 Structure representing a CAN message. More...
struct  CCX_RX_table_t
 CAN RX table entry structure. More...
struct  CCX_TX_table_t
 CAN TX table entry structure. More...
struct  CCX_instance_t

Macros

#define CCX_VERSION_MAJOR   2
#define CCX_VERSION_MINOR   3
#define CCX_VERSION_PATCH   1
#define CCX_VERSION_STRING   "2.3.1"
#define CCX_TICK_FROM_FUNC   0
 Enables system tick retrieval via a function call.
#define CCX_HR_TICK_FROM_FUNC   0
 Enables high-resolution tick retrieval via a function call.
#define CCX_RX_BUFFER_SIZE   48
 Size of the CAN receive buffer.
#define CCX_TX_BUFFER_SIZE   48
 Size of the CAN transmit buffer.
#define CCX_ENABLE_CANFD   1
 Enables CAN FD support (64-byte payload, BRS, ESI, FDF).
#define CCX_DLC_ANY   16
 Special DLC value for wildcard matching in RX table.
#define CCX_RX_HASH_SIZE   64
 Size of the hash table for RX message lookup (used when CCX_RX_SEARCH_HASH is defined).
#define CCX_TIME_BASE_SCALAR   uint32_t
#define CCX_MAX_TIMEOUT   UINT32_MAX
#define CCX_HR_TIME_BASE_SCALAR   uint16_t
#define CCX_HR_MAX_TIMEOUT   UINT16_MAX
#define CCX_INTERNAL_MS_FROM_US_CEIL(us)
#define CCX_HR_TIME(us)
#define CCX_GetPrimaryTick()
#define CCX_GetHighResTick()

Typedefs

typedef volatile uint32_t CCX_TIME_t
typedef volatile uint16_t CCX_HR_TIME_t
typedef struct CCX_instance_t CCX_instance_t

Enumerations

enum  CCX_BusIsFree_t { CCX_BUS_BUSY = 0 , CCX_BUS_FREE }
 Enumeration indicating the status of the CAN bus. More...
enum  CCX_ide_t { CCX_ID_STANDARD = 0 , CCX_ID_EXTENDED = 1 }
 CAN identifier type (standard 11-bit or extended 29-bit). More...
enum  CCX_frame_format_t { CCX_FRAME_FORMAT_CLASSIC = 0 , CCX_FRAME_FORMAT_FD = 1 , CCX_FRAME_FORMAT_FD_BRS = 2 }
 CAN frame format selection. More...
enum  CCX_MsgRegStatus_t { CCX_MSG_UNREG , CCX_MSG_REG }
enum  CCX_Status_t {
  CCX_OK = 0 , CCX_NULL_PTR , CCX_WRONG_ARG , CCX_BUS_TOO_BUSY ,
  CCX_MISSING_TIMEBASE
}
enum  CCX_FD_DLC_t {
  CCX_FD_DLC_0B = 0 , CCX_FD_DLC_1B = 1 , CCX_FD_DLC_2B = 2 , CCX_FD_DLC_3B = 3 ,
  CCX_FD_DLC_4B = 4 , CCX_FD_DLC_5B = 5 , CCX_FD_DLC_6B = 6 , CCX_FD_DLC_7B = 7 ,
  CCX_FD_DLC_8B = 8 , CCX_FD_DLC_12B = 9 , CCX_FD_DLC_16B = 10 , CCX_FD_DLC_20B = 11 ,
  CCX_FD_DLC_24B = 12 , CCX_FD_DLC_32B = 13 , CCX_FD_DLC_48B = 14 , CCX_FD_DLC_64B = 15
}
 Named CAN FD DLC values. More...

Functions

CCX_Status_t CCX_RX_PushMsg (CCX_instance_t *Instance, const CCX_message_t *msg)
CCX_Status_t CCX_TX_PushMsg (CCX_instance_t *Instance, const CCX_message_t *msg)
uint16_t CCX_RX_GetDepth (const CCX_instance_t *Instance)
uint16_t CCX_TX_GetDepth (const CCX_instance_t *Instance)
uint16_t CCX_RX_GetFree (const CCX_instance_t *Instance)
uint16_t CCX_TX_GetFree (const CCX_instance_t *Instance)
void CCX_FlushRx (CCX_instance_t *Instance)
void CCX_FlushTx (CCX_instance_t *Instance)
void CCX_Flush (CCX_instance_t *Instance)
void CCX_Reset (CCX_instance_t *Instance)
CCX_Status_t CCX_Poll (CCX_instance_t *Instance)
CCX_Status_t CCX_Init (CCX_instance_t *Instance, CCX_RX_table_t *CCX_RX_table, CCX_TX_table_t *CCX_TX_table, uint16_t RxTableSize, uint16_t TxTableSize, void(*SendFunction)(const CCX_instance_t *Instance, const CCX_message_t *msg), CCX_BusIsFree_t(*BusCheck)(const CCX_instance_t *Instance), void(*ParserUnregMsg)(const CCX_instance_t *Instance, CCX_message_t *Msg))
void CCX_tick_variable_register (CCX_TIME_t *Variable)
 Registers the system tick source variable.
void CCX_high_res_tick_variable_register (CCX_HR_TIME_t *Variable)
uint8_t CCX_IsPrimaryTickRegistered (void)
uint8_t CCX_IsHighResTickRegistered (void)
const CCX_GlobalStats_tCCX_GetGlobalStats (const CCX_instance_t *Instance)
 Get global statistics.
void CCX_ResetGlobalStats (CCX_instance_t *Instance)
 Reset global statistics.
void CCX_OnMessageTransmitted (CCX_instance_t *Instance, const CCX_message_t *msg)
 Notify library that a message was successfully transmitted.
void CCX_RX_RebuildHash (CCX_instance_t *Instance)
 Rebuild hash table for RX message lookup.
uint8_t CCX_FD_LenToDLC (uint8_t len)
 Convert byte length to the smallest valid CAN FD DLC.

Variables

CCX_TIME_t * CCX_tick
CCX_HR_TIME_t * CCX_high_res_tick
const uint8_t CCX_FD_DLC_TO_LEN [16]
 DLC-to-payload-length lookup table: index 0-15, values {0,1,2,3,4,5,6,7,8,12,16,20,24,32,48,64}.

Detailed Description

Core CAN CoreX public API.