What do I misunderstand about processing pointers ?
I have CAN1_msg_t buffer with in/out pointers
I want to set pCAN1RxMsg pointer to eq. c1rxbuf->buf[0] in my CAN1GetPtr() function.
struct CAN1_msg_t {
uint8_t flags;
uint32_t id;
uint8_t data[8];
};
struct can1_buf_st
{
unsigned int in; // In Index
unsigned int out; // Out Index
struct CAN1_msg_t buf[100]; // Buffer
};
int CAN1GetPtr(struct CAN1_msg_t *pcan)
{
struct can1_buf_st *p = &c1rxbuf;
pcan = &(p->buf[p->out++]);
return 1;
}
static struct can1_buf_st c1rxbuf = { 0, 0, };
void main()
{
struct CAN1_msg_t *pCAN1RxMsg;
if(CAN1GetPtr(pCAN1RxMsg)) {
if((*pCAN1RxMsg).id == 0x100) {
(...)
}
}
}