ESOS32
ESOSOn32-bitProcessors
Files | Data Structures | Macros | Enumerations | Enumerator | Functions | Variables
ESOS_Task_ECAN_Service

Files

file  esos_hwxxxx_ecan.c
 Template for creating hardware-specific support for the ESOS32 Controller Area Network (CAN) service.
 
file  esos_ecan.h
 
file  esos_hwxxx_ecan.h
 This file contains routines which define, configure and allow use of Controller Area Network (CAN) service on the target hardware (hwxxxx)
 

Data Structures

struct  client_t
 

Macros

#define MAX_CANFACTORY_CLIENTS   32
 
#define DEFAULT_MSG_ID   0x7a0
 
#define DEBUG_MODE   ESOS_USER_FLAG_F
 
#define ENABLE_DEBUG_MODE()   esos_SetUserFlag(DEBUG_MODE)
 
#define DISABLE_DEBUG_MODE()   esos_ClearUserFlag(DEBUG_MODE)
 
#define CHECK_DEBUG_MODE_ENABLED()   esos_IsUserFlagSet(DEBUG_MODE)
 
#define TRUE   1
 
#define FALSE   0
 
#define ESOS_ECAN_SEND(u16_can_id, pu8_msg, u8_len)
 
#define __ESOS_ECAN_HW_NUM_TX_BUFS   1
 
#define __ESOS_ECAN_HW_NUM_BUFS   8
 
#define __ESOS_ECAN_HW_ARE_MESSAGES_WAITING()   ( _DMA1IF )
 
#define __ESOS_ECAN_HW_GET_BUFFER_ID()   ( C1FIFO & 0x1F )
 
#define __ESOS_ECAN_HW_TX_IN_PROGRESS()   ( C1TR01CONbits.TXREQ0 )
 

Enumerations

enum  maskcontrol_t { MASKCONTROL_FIELD_NONZERO, MASKCONTROL_EQUAL }
 

Functions

__eds__ ECANMSG __esos_ecan_msgBuf[__ESOS_ECAN_HW_NUM_BUFS] __attribute__ ((space(dma), aligned(__ESOS_ECAN_HW_NUM_BUFS *16), eds))
 
void __esos_ecan_hw_config_ecan (void)
 
void __esos_ecan_hw_config_dma_tx (void)
 
void __esos_ecan_hw_config_dma_rx (void)
 
void __esos_ecan_hw_mark_message_received (uint16_t u16_rx_buff_id)
 
void __esos_ecan_hw_format_and_send (ECANMSG *p_temp_Msg, uint16_t u16_can_id, uint8_t u8_payload_len)
 
void esos_ecan_canfactory_subscribe (ESOS_TASK_HANDLE pst_Task, uint16_t u16_can_id, uint16_t u16_mask, maskcontrol_t m_mask_control)
 
void esos_ecan_canfactory_unsubscribe (uint8_t(*pst_Task)(ESOS_TASK_HANDLE), uint16_t u16_can_id, uint16_t u16_mask, maskcontrol_t m_mask_control)
 
BOOL esos_ecan_mask_check (uint16_t u16_subscribed, uint16_t u16_recieved, uint16_t u16_mask)
 
 ESOS_USER_TASK (CANFactory)
 
void __esos_ecan_hw_config_baud (void)
 
void __esos_ecan_hw_config_rxFilter ()
 

Variables

uint16_t client_t::u16_canID
 
uint16_t client_t::u16_idMask
 
maskcontrol_t client_t::m_idMaskControl
 
uint8_t(* client_t::pf_task )(ESOS_TASK_HANDLE pst_Task)
 

Detailed Description

Macro Definition Documentation

◆ ESOS_ECAN_SEND

#define ESOS_ECAN_SEND (   u16_can_id,
  pu8_msg,
  u8_len 
)
Value:
{ \
do { \
ESOS_TASK_HANDLE __esos_ecan_hTask; \
MAILMESSAGE __esos_ecan_mailMsg; \
uint8_t __esos_mail_msgBuf[ sizeof( uint16_t ) + 8 * sizeof( uint8_t ) ]; \
__esos_ecan_hTask = esos_GetTaskHandle( CANFactory ); \
if ( ESOS_TASK_MAILBOX_GOT_AT_LEAST_DATA_BYTES( __esos_ecan_hTask, __MAIL_MSG_HEADER_LEN + sizeof( uint8_t ) * u8_len + sizeof( uint16_t ) ) ) { \
*( ( uint16_t* ) &__esos_mail_msgBuf[0] ) = u16_can_id; \
memcpy( &__esos_mail_msgBuf[ sizeof( uint16_t ) ], pu8_msg, u8_len ); \
ESOS_TASK_MAKE_MSG_AUINT8 ( __esos_ecan_mailMsg, __esos_mail_msgBuf, sizeof( uint8_t ) * u8_len + sizeof( uint16_t ) ); \
ESOS_TASK_SEND_MESSAGE( __esos_ecan_hTask, &__esos_ecan_mailMsg ); \
} \
} while ( 0 ); \
}

esos_ecan_send():

Send a message using the CANFactory user task.

u16_can_id: CAN ID to be attached to the message. This should follow the assumed convention of your system. For embedded systems at MSU, this should be populated with the appropriate data from the supplied header file. pu8_msg: Pointer to the byte that is the beginning of u8_len bytes of sequential data to be sent. u8_len: Length of message pointed to by pu8_msg in bytes.

Definition at line 86 of file esos_ecan.h.

Function Documentation

◆ esos_ecan_canfactory_subscribe()

void esos_ecan_canfactory_subscribe ( ESOS_TASK_HANDLE  pst_Task,
uint16_t  u16_can_id,
uint16_t  u16_mask,
maskcontrol_t  m_mask_control 
)

esos_ecan_canfactory_subscribe():

Enroll a task/mask combination in the CANFactory system.

pst_Task: ESOS user task to be subscribed in the CANFactory. This is the task that is responsible for receiving relevant messages through the ESOS mail system. u16_can_id: CAN ID of the specified task pointed to by pst_Task. u16_mask: Mask to be used in accordance to the convention specified by m_mask_control. m_mask_control: Can be either value of the enumeration maskcontrol_t as shown below. MASKCONTROL_FIELD_NONZERO: u16_mask represents a mask that covers all message headers to which pst_Task should listen. If a message header has a bit lifted underneath the mask, the message will be sent to the pst_Task mailbox. MASKCONTROL_EQUAL: u16_mask represents a mask that is the exact message header to which pst_Task should listen. If a message header does not match this mask exactly, it will not be sent to the pst_Task mailbox.

◆ esos_ecan_canfactory_unsubscribe()

void esos_ecan_canfactory_unsubscribe ( uint8_t(*)(ESOS_TASK_HANDLE pst_Task,
uint16_t  u16_can_id,
uint16_t  u16_mask,
maskcontrol_t  m_mask_control 
)

esos_ecan_canfactory_unsubscribe():

Unsubscribe a task/mask combination in the CANFactory system.

pst_Task: Task handle of the task that should be removed from CANFactory's data structure. u16_can_id: CAN ID of the task that should be removed from CANFactory's data structure. u16_mask: Mask of the task/mask combination that should be removed from the CANFactory's data structure. m_mask_control: Mask control specifier of the task/mask combination that should be removed from the CANFactory's data structure.

◆ esos_ecan_mask_check()

BOOL esos_ecan_mask_check ( uint16_t  u16_subscribed,
uint16_t  u16_recieved,
uint16_t  u16_mask 
)

esos_ecan_mask_check():

Check subscribed messages against recieved messages according to the mask.

u16_subscribed: ID of the subscribed task.

u16_recieved: CAN ID of the message recieved.

u16_mask: Mask ID to be checked against.

◆ ESOS_USER_TASK()

ESOS_USER_TASK ( CANFactory  )

CANFactory user task:

Handles the management of the ECAN peripheral so that the API can be used.

Note: the user should register this task from user_init in addition to using the API in this file.

esos_GetTaskHandle
ESOS_TASK_HANDLE esos_GetTaskHandle(uint8_t(*taskname)(ESOS_TASK_HANDLE pstTask))
Definition: esos.c:259
ESOS_TASK_MAILBOX_GOT_AT_LEAST_DATA_BYTES
#define ESOS_TASK_MAILBOX_GOT_AT_LEAST_DATA_BYTES(pstTask, x)
Definition: esos_mail.h:214