HPM SDK
HPMicro Software Development Kit
hpm_mcan_soc.h File Reference
#include <stdint.h>
#include "hpm_mcan_regs.h"
#include "hpm_soc.h"
#include "hpm_soc_feature.h"

Go to the source code of this file.

Data Structures

struct  mcan_msg_buf_attr_t
 The Attribute of Message Attribute. More...
 

Macros

#define MCAN_SOC_TSU_SRC_TWO_STAGES   (1U)
 
#define HPM_MCAN_EXT_TBSEL_NUM   (4U)
 
#define HPM_MCAN_TBSEL_BASE   (0xF02FF000UL)
 
#define HPM_MCAN_TBSEL   (*(volatile uint32_t *)HPM_MCAN_TBSEL_BASE)
 
#define HPM_MCAN_TBSEL_BITWIDTH   (6U)
 
#define HPM_MCAN_TBSEL_MASK   ((1UL << HPM_MCAN_TBSEL_BITWIDTH) - 1UL)
 
#define HPM_MCAN_TBSEL0_SHIFT   (8U)
 
#define MCAN_MSG_BUF_BASE_VALID_START   (0xF0400000UL) /* This is the start address of AHB_RAM */
 
#define MCAN_MSG_BUG_SIZE_MAX   (32UL * 1024UL) /* This is the total size of AHB_RAM */
 
#define MCAN_MSG_BUF_BASE_VALID_END   (MCAN_MSG_BUF_BASE_VALID_START + MCAN_MSG_BUG_SIZE_MAX)
 
#define MCAN_MSG_BUF_ALIGNMENT_SIZE   (4U)
 
#define MCAN_MSG_BUF_SIZE_IN_WORDS   (640U)
 MCAN MSG BUF base address (AHB_RAM) More...
 
#define MCAN_IP_SLOT_SIZE   (0x4000U)
 
#define MCAN_TSU_EXT_TIMEBASE_SRC_MIN   (0U)
 TSU External Timebase Sources. More...
 
#define MCAN_TSU_EXT_TIMEBASE_SRC_TBSEL_0   (MCAN_TSU_EXT_TIMEBASE_SRC_MIN)
 
#define MCAN_TSU_EXT_TIMEBASE_SRC_TBSEL_1   (1U)
 
#define MCAN_TSU_EXT_TIMEBASE_SRC_TBSEL_2   (2U)
 
#define MCAN_TSU_EXT_TIMEBASE_SRC_TBSEL_3   (3U)
 
#define MCAN_TSU_EXT_TIMEBASE_SRC_MAX   (MCAN_TSU_EXT_TIMEBASE_SRC_TBSEL_3)
 
#define MCAN_TSU_TBSEL_PTPC0   (0x20)
 MCAN TSU timebase option for each External Timebase. More...
 
#define MCAN_TSU_TBSEL_MCAN0   (0x00)
 
#define MCAN_TSU_TBSEL_MCAN1   (0x01)
 
#define MCAN_TSU_TBSEL_MCAN2   (0x02)
 
#define MCAN_TSU_TBSEL_MCAN3   (0x03)
 
#define MCAN_TSU_TBSEL_MCAN4   (0x04)
 
#define MCAN_TSU_TBSEL_MCAN5   (0x05)
 
#define MCAN_TSU_TBSEL_MCAN6   (0x06)
 
#define MCAN_TSU_TBSEL_MCAN7   (0x07)
 

Functions

static uint32_t mcan_get_instance_from_base (MCAN_Type *base)
 Get the MCAN instance index from base address. More...
 
static void mcan_set_tsu_ext_timebase_src (MCAN_Type *ptr, uint8_t src)
 Set External Timebase Source for MCAN TSU. More...
 
static void mcan_set_tsu_tbsel_option (MCAN_Type *ptr, uint8_t ext_tbsel, uint8_t tbsel_option)
 Set the Source for specified external timebase. More...
 
static void mcan_enable_standby_pin (MCAN_Type *ptr)
 Enable Standby Pin for MCAN. More...
 
static void mcan_disable_standby_pin (MCAN_Type *ptr)
 Disable Standby pin for MCAN. More...
 
static hpm_stat_t mcan_set_msg_buf_attr (MCAN_Type *ptr, const mcan_msg_buf_attr_t *attr)
 Set the attribute of the Message Buffer for specified MCAN. More...
 
static uint32_t mcan_get_ram_base (MCAN_Type *ptr)
 Get RAM base for MCAN. More...
 
static uint32_t mcan_get_ram_offset (MCAN_Type *ptr)
 Get the MCAN RAM offset in the dedicated/shared RAM for. More...
 
static uint32_t mcan_get_ram_size (MCAN_Type *ptr)
 Get MCAN RAM size. More...
 

Variables

mcan_msg_buf_attr_t mcan_soc_msg_buf_attr [(8U)]
 

Macro Definition Documentation

◆ HPM_MCAN_EXT_TBSEL_NUM

#define HPM_MCAN_EXT_TBSEL_NUM   (4U)

◆ HPM_MCAN_TBSEL

#define HPM_MCAN_TBSEL   (*(volatile uint32_t *)HPM_MCAN_TBSEL_BASE)

◆ HPM_MCAN_TBSEL0_SHIFT

#define HPM_MCAN_TBSEL0_SHIFT   (8U)

◆ HPM_MCAN_TBSEL_BASE

#define HPM_MCAN_TBSEL_BASE   (0xF02FF000UL)

◆ HPM_MCAN_TBSEL_BITWIDTH

#define HPM_MCAN_TBSEL_BITWIDTH   (6U)

◆ HPM_MCAN_TBSEL_MASK

#define HPM_MCAN_TBSEL_MASK   ((1UL << HPM_MCAN_TBSEL_BITWIDTH) - 1UL)

◆ MCAN_IP_SLOT_SIZE

#define MCAN_IP_SLOT_SIZE   (0x4000U)

◆ MCAN_MSG_BUF_ALIGNMENT_SIZE

#define MCAN_MSG_BUF_ALIGNMENT_SIZE   (4U)

◆ MCAN_MSG_BUF_BASE_VALID_END

#define MCAN_MSG_BUF_BASE_VALID_END   (MCAN_MSG_BUF_BASE_VALID_START + MCAN_MSG_BUG_SIZE_MAX)

◆ MCAN_MSG_BUF_BASE_VALID_START

#define MCAN_MSG_BUF_BASE_VALID_START   (0xF0400000UL) /* This is the start address of AHB_RAM */

◆ MCAN_MSG_BUF_SIZE_IN_WORDS

#define MCAN_MSG_BUF_SIZE_IN_WORDS   (640U)

MCAN MSG BUF base address (AHB_RAM)

Default Message Buffer Size in this driver

◆ MCAN_MSG_BUG_SIZE_MAX

#define MCAN_MSG_BUG_SIZE_MAX   (32UL * 1024UL) /* This is the total size of AHB_RAM */

◆ MCAN_SOC_TSU_SRC_TWO_STAGES

#define MCAN_SOC_TSU_SRC_TWO_STAGES   (1U)

◆ MCAN_TSU_EXT_TIMEBASE_SRC_MAX

#define MCAN_TSU_EXT_TIMEBASE_SRC_MAX   (MCAN_TSU_EXT_TIMEBASE_SRC_TBSEL_3)

◆ MCAN_TSU_EXT_TIMEBASE_SRC_MIN

#define MCAN_TSU_EXT_TIMEBASE_SRC_MIN   (0U)

TSU External Timebase Sources.

◆ MCAN_TSU_EXT_TIMEBASE_SRC_TBSEL_0

#define MCAN_TSU_EXT_TIMEBASE_SRC_TBSEL_0   (MCAN_TSU_EXT_TIMEBASE_SRC_MIN)

◆ MCAN_TSU_EXT_TIMEBASE_SRC_TBSEL_1

#define MCAN_TSU_EXT_TIMEBASE_SRC_TBSEL_1   (1U)

◆ MCAN_TSU_EXT_TIMEBASE_SRC_TBSEL_2

#define MCAN_TSU_EXT_TIMEBASE_SRC_TBSEL_2   (2U)

◆ MCAN_TSU_EXT_TIMEBASE_SRC_TBSEL_3

#define MCAN_TSU_EXT_TIMEBASE_SRC_TBSEL_3   (3U)

◆ MCAN_TSU_TBSEL_MCAN0

#define MCAN_TSU_TBSEL_MCAN0   (0x00)

◆ MCAN_TSU_TBSEL_MCAN1

#define MCAN_TSU_TBSEL_MCAN1   (0x01)

◆ MCAN_TSU_TBSEL_MCAN2

#define MCAN_TSU_TBSEL_MCAN2   (0x02)

◆ MCAN_TSU_TBSEL_MCAN3

#define MCAN_TSU_TBSEL_MCAN3   (0x03)

◆ MCAN_TSU_TBSEL_MCAN4

#define MCAN_TSU_TBSEL_MCAN4   (0x04)

◆ MCAN_TSU_TBSEL_MCAN5

#define MCAN_TSU_TBSEL_MCAN5   (0x05)

◆ MCAN_TSU_TBSEL_MCAN6

#define MCAN_TSU_TBSEL_MCAN6   (0x06)

◆ MCAN_TSU_TBSEL_MCAN7

#define MCAN_TSU_TBSEL_MCAN7   (0x07)

◆ MCAN_TSU_TBSEL_PTPC0

#define MCAN_TSU_TBSEL_PTPC0   (0x20)

MCAN TSU timebase option for each External Timebase.

Function Documentation

◆ mcan_disable_standby_pin()

static void mcan_disable_standby_pin ( MCAN_Type ptr)
inlinestatic

Disable Standby pin for MCAN.

Parameters
[in]ptrMCAN base

◆ mcan_enable_standby_pin()

static void mcan_enable_standby_pin ( MCAN_Type ptr)
inlinestatic

Enable Standby Pin for MCAN.

Parameters
[in]ptrMCAN base

◆ mcan_get_instance_from_base()

static uint32_t mcan_get_instance_from_base ( MCAN_Type base)
inlinestatic

Get the MCAN instance index from base address.

Parameters
[in]baseMCAN base
Returns
MCAN instance index

◆ mcan_get_ram_base()

static uint32_t mcan_get_ram_base ( MCAN_Type ptr)
inlinestatic

Get RAM base for MCAN.

Parameters
[in]ptrMCAN base
Returns
RAM base for MCAN

◆ mcan_get_ram_offset()

static uint32_t mcan_get_ram_offset ( MCAN_Type ptr)
inlinestatic

Get the MCAN RAM offset in the dedicated/shared RAM for.

Parameters
[in]ptrMCAN base
Returns
RAM offset for MCAN

◆ mcan_get_ram_size()

static uint32_t mcan_get_ram_size ( MCAN_Type ptr)
inlinestatic

Get MCAN RAM size.

Parameters
[in]ptrMCAN base
Returns
RAM size in bytes

◆ mcan_set_msg_buf_attr()

static hpm_stat_t mcan_set_msg_buf_attr ( MCAN_Type ptr,
const mcan_msg_buf_attr_t attr 
)
inlinestatic

Set the attribute of the Message Buffer for specified MCAN.

Parameters
[in]ptrMCAN base
[in]attrThe attribute of message buffer
Return values
status_successNo error occurred
status_invalid_argumentInvalid argument was detected

◆ mcan_set_tsu_ext_timebase_src()

static void mcan_set_tsu_ext_timebase_src ( MCAN_Type ptr,
uint8_t  src 
)
inlinestatic

Set External Timebase Source for MCAN TSU.

Parameters
[in]ptrMCAN base
[in]srcExternal Timebase source

◆ mcan_set_tsu_tbsel_option()

static void mcan_set_tsu_tbsel_option ( MCAN_Type ptr,
uint8_t  ext_tbsel,
uint8_t  tbsel_option 
)
inlinestatic

Set the Source for specified external timebase.

Parameters
[in]ptrMCAN base
[in]ext_tbselExternal TBSEL index
[in]tbsel_optionTimebase source selection

Variable Documentation

◆ mcan_soc_msg_buf_attr

mcan_msg_buf_attr_t mcan_soc_msg_buf_attr[(8U)]
extern