HI.
I met a question here. In the function Onboard_SendKeys( uint8 keys , uint8 state) , It defines a pointer which is called the msgPtr . The msgPtr is a type of keyChange_t . It is a struct which contains osal_event_hdr_t * hdr , uint8 state and uint8 keys . You can get it understood with the follows.
/****************definiton of keyChange_t*******************/
typedef struct
{
osal_event_hdr_t hdr;
uint8 state; // shift
uint8 keys; // keys
} keyChange_t;
/**************definition of keyChange_t ends **************/
OKay, let us go on. The function osal_msg_send (registeredKeyTaskID , (uint8 *) msgPtr ) appears . // the msgPtr is the type of the keyChange_t .
The process of the osal_msg_send , it invokes a new function OSAL_MSG_ID . Then the problem that I can not understand is just as the follows.
/*********************question begins**************************/
#define OSAL_MSG_NEXT(msg_ptr) ((osal_msg_hdr_t *) (msg_ptr) - 1)->next
#define OSAL_MSG_Q_INIT(q_ptr) *(q_ptr) = NULL
#define OSAL_MSG_Q_EMPTY(q_ptr) (*(q_ptr) == NULL)
#define OSAL_MSG_Q_HEAD(q_ptr) (*(q_ptr))
#define OSAL_MSG_LEN(msg_ptr) ((osal_msg_hdr_t *) (msg_ptr) - 1)->len
#define OSAL_MSG_ID(msg_ptr) ((osal_msg_hdr_t *) (msg_ptr) - 1)->dest_id
/*******************question ends*****************************/
Qian
How can I change the msg_ptr into a type of osal_msg_hdr_t ? The msg_ptr is the type of keyChange_t .
/************the type of osal_msg_hdr_t******************/
typedef struct
{
void *next;
uint16 len;
uint8 dest_id;
} osal_msg_hdr_t;
/***************************************************************/
Would you help me?
I am looking forward to your answer ..
Brs,