Commit d326e6e4 authored by Matthias Wenzl's avatar Matthias Wenzl
Browse files

removed callback API, added mailbox API

parent fc4d6ee2
......@@ -51,7 +51,7 @@ int CAN_RegisterMsgObj(int index, int objId, CAN_Msg *txmsg, uint32_t msgType) {
int CAN_AlterRxCallback(int index, CAN_RxCallback callback) {
int CAN_GetMbHandle(int index, void **mb) {
......@@ -51,7 +51,7 @@ typedef struct CANTiva_HWAttrs{
typedef struct CANTiva_Object{
bool isOpen;//!< Check if device has been opened
CAN_Stats stats;//!< Statistics block of this device
volatile CAN_RxCallback rxCb; //!< Pointer to message received complete callback
Mailbox_Handle canMb;//!< Mailbox Handle
......@@ -94,14 +94,16 @@ int canTivaClose(CAN_Handle handle);
int canTivaRegisterMsgObject(CAN_Handle handle,uint32_t objId, CAN_Msg *msg, uint32_t msgType);
/*! \brief Initialize, but do not start all available CAN devices
/*! \brief Retreive MailBox handle set up during CAN device initialization
* \param handle Pointer to CAN_Config structure
* \param callback pointer to user supplied function that must be called upon reception of a frame has been completed
* \param Address of pointer to MailBox
* \return CAN_SUCCESS on success, negative value otherwise
int canTivaAlterRxCallback(CAN_Handle handle, CAN_RxCallback callback);
int canTivaGetMbHandle (CAN_Handle handle, void **mb);
/*! \brief Get pointer to statistics block
......@@ -127,5 +129,5 @@ void CANIntHandler(UArg uarg);
void CANBusOffSwiHandler(UArg arg0, UArg arg1);
#endif /*ENABLE_CAN*/
#endif /*CANTIVA_H_*/
......@@ -18,19 +18,22 @@
/*! CAN HAL function returns successfully */
#define CAN_SUCCESS (0)
/*! CAN generic error */
#define CAN_ERROR (-1)
/*! CAN handle is null */
#define CAN_HANDLE_IS_NULL (-1)
/*! CAN_Handle is null */
#define CAN_HANDLE_IS_NULL (-2)
/*! CAN HAL device already opened*/
#define CAN_IS_OPEN (-3)
/*! CAN device is already open */
#define CAN_IS_OPEN (-2)
/*! CAN device is already closed */
#define CAN_IS_CLOSED (-3)
/*! Invalid device identifier */
/*! Wrong parameter value has been passed to a function */
#define CAN_PARAM_ERROR (-5)
/*! CAN HAL device is already closed */
#define CAN_IS_CLOSED (-4)
/*! Specified CAN HAL device is invalid */
/*! \brief Statistic block for a CAN module; Stores transmission, reception and error counters of a CAN module
......@@ -64,7 +67,7 @@ typedef int (*FxnCANOpen) (CAN_Handle handle);
typedef int (*FxnCANClose) (CAN_Handle handle);
typedef int (*FxnCANGetStats) (CAN_Handle handle, CAN_Stats *stats);
typedef int (*FxnCANRegisterMsgObject) (CAN_Handle handle, uint32_t objId, CAN_Msg *msg, uint32_t msgType);
typedef int (*FxnCANAlterRxCallback) (CAN_Handle handle, CAN_RxCallback callback);
typedef int (*FxnCANGetMbHandle) (CAN_Handle handle, void **mb);
/*! \brief Function pointer table connecting HAL functions with CAN device object
......@@ -74,7 +77,7 @@ typedef struct CAN_FxnTable{
FxnCANClose canClose;
FxnCANGetStats canGetStats;
FxnCANRegisterMsgObject canRegMsgObject;
FxnCANAlterRxCallback canAlterCb;
FxnCANGetMbHandle canGetMbHandle;
/*! \brief Representation of an abstract CAN device in memory
......@@ -85,6 +88,15 @@ typedef struct CAN_Config{
void const *hwAttrs; //!< Pointer to a structure holding the device specific hardware parameters, such as base address, interrupt number,...
/*! Maximum can payload length */
/*! \brief Representation of a received can message in memory*/
typedef struct CAN_RxMsg {
uint32_t id;//!< Message id
uint32_t len;//!< Actually received bytes
uint8_t payload[MAX_CAN_PAYLOAD_LEN];//!< Worst case message length for standard CAN.
/*! \brief Initialize, but do not start all available CAN devices
......@@ -131,11 +143,12 @@ int CAN_RegisterMsgObj(int index, int objId, CAN_Msg *msg, uint32_t msgType);
* Call hw specific function to receiver callback through CAN_config structure
* \param index Specified CAN module
* \param callback Callback function triggered upon reception completion
* \param mb Pointer to a MailBox pointer that is set up during CAN device initialization
* \return negative value in case something went wrong, otherwise CAN_SUCCESS
int CAN_AlterRxCallback(int index, CAN_RxCallback callback);
int CAN_GetMbHandle(int index, void **mb);
/*! \brief Get reference to statistics object of CAN device
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment