Function Pointer in C Struct
7 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I have a struct in custom C code that I included in my state_flow simulation:
typedef struct __UART_Message_Queue{
Queue_Lock lock;
int8_t queue_front;
int8_t queue_back;
uint32_t message_queue[16];
Queue_Status (* queue_push)(struct __UART_Message_Queue * queue, uint16_t header, uint16_t message);
uint32_t (* queue_pop)(struct __UART_Message_Queue * queue);
Queue_Status (* queue_status)(struct __UART_Message_Queue * queue);
}UART_Message_Queue;
and a function that I like to point to:
Queue_Status __queue_push(UART_Message_Queue* queue, uint16_t header, uint16_t message){
if(queue->queue_status(queue)==QUEUE_FULL){
return QUEUE_FULL;
}
else{
queue->queue_back = (queue->queue_back + 1) % 16;
queue->message_queue[queue->queue_back] = (((uint32_t)header)<<16U) + (uint32_t)message;
return QUEUE_NOT_FULL;
}
}
In my stateflow diagram, I assign:
UART_Message_Queue uart_queue;
uart_queue.queue_push = &__queue_push;
then when I call the "uart_queue.queue_push" function I get an error that the function is unresolved, but if I call the "__queue_push" everything is fine.
Has anybody faced this situation before?
0 Commenti
Risposte (0)
Vedere anche
Categorie
Scopri di più su Simulink Functions in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!