RTEMS 7.0-rc1
Loading...
Searching...
No Matches
Macros | Enumerations | Functions
ctucanfd.c File Reference

This source file contains the implementation of CTU CAN FD controller. More...

#include <stdatomic.h>
#include <stdint.h>
#include <stddef.h>
#include <errno.h>
#include <stdbool.h>
#include <endian.h>
#include <stdlib.h>
#include <string.h>
#include <rtems.h>
#include <rtems/malloc.h>
#include <rtems/score/basedefs.h>
#include <dev/can/can-devcommon.h>
#include <dev/can/can-helpers.h>
#include <dev/can/can.h>
#include <dev/can/ctucanfd.h>
#include "ctucanfd_kframe.h"
#include "ctucanfd_kregs.h"
#include "ctucanfd_txb.h"
#include "ctucanfd_internal.h"

Macros

#define CTUCANFD_ID   0xCAFD
 The magic number synthesized to the core. See 3.1.1 DEVICE_ID register description in CTU CAN FD Core Datasheet Documentation.
 
#define CTUCANFD_ID_MASK   0xFFFF
 
#define CTUCANFD_INIT_TXB_ORDER   0x76543210
 This defines initial transmit buffer order. Every 4 bits correspond to one buffer number. The buffer located on the least significant 4 bits has the highest priority.
 
#define CAN_CTUCANFD_TYPE   "ctucanfd"
 

Enumerations

enum  ctucanfd_txtb_status {
  TXT_NOT_EXIST = 0x0 , TXT_RDY = 0x1 , TXT_TRAN = 0x2 , TXT_ABTP = 0x3 ,
  TXT_TOK = 0x4 , TXT_ERR = 0x6 , TXT_ABT = 0x7 , TXT_ETY = 0x8
}
 
enum  ctucanfd_txtb_command { TXT_CMD_SET_EMPTY = 0x01 , TXT_CMD_SET_READY = 0x02 , TXT_CMD_SET_ABORT = 0x04 }
 

Functions

struct rtems_can_chiprtems_ctucanfd_initialize (uintptr_t addr, rtems_vector_number irq, rtems_task_priority worker_priority, unsigned int ntxbufs, rtems_option irq_option, unsigned long can_clk_rate)
 This function initializes the CTU CAN FD controller.
 

Detailed Description

This source file contains the implementation of CTU CAN FD controller.

Function Documentation

◆ rtems_ctucanfd_initialize()

struct rtems_can_chip * rtems_ctucanfd_initialize ( uintptr_t  addr,
rtems_vector_number  irq,
rtems_task_priority  worker_priority,
unsigned int  ntxbufs,
rtems_option  irq_option,
unsigned long  can_clk_rate 
)

This function initializes the CTU CAN FD controller.

This is an entry point for CTU CAN FD controller initialization. This function allocates generic CAN and CTU CAN FD related structures, sets default values and initializes the resources (interrupt handler, semaphore. worker thread).

Parameters
addrCTU CAN FD code base address.
irqInterrupt number
worker_priotiryThe priority of TX/RX worker thread
ntxbufsNumber of TX hardware buffers to be used. The function automatically limits the maximum HW buffers based on the used core. You can use RTEMS_CTUCANFD_NTXBUFS_MAX to setup maximum available buffers.
irq_optionRTEMS_INTERRUPT_SHARED or RTEMS_INTERRUPT_UNIQUE
can_clk_rateCAN clock rate.
Returns
Pointer to CAN chip structure on success, NULL otherwise.