How to represent struct pointer in Simulink ???
3 views (last 30 days)
Show older comments
Following is example about header and source file which used structure pointer . I used the bus for structure type, but I don't know represent in func function.
Can you show me the way ???
Header file (.h)
typedef struct newStructType{
uint16_t a;
void* pVal;
subStructType * ptr;
uint8_t type;
}newStructType;
typedef struct subStructType{
unsigned char a1 : 1;
unsigned char b1 : 1;
}subStructType;
Source file (.c)
newStructType* const PtrTable[];
uint32_t func(uint16_t var)
{
newStructType* temp = NULL;
if(var > 100)
{
temp = (newStructType*)PtrTable[var-100];
}
switch(temp->type)
{
case 1:
Ret = (uint32_t)(*(uint8_t*)(temp->pVal));
break;
case 2:
Ret = (uint32_t)(*(uint16_t*)(temp->pVal));
break;
default:
break;
}
return Ret;
}
0 Comments
Answers (0)
See Also
Categories
Find more on Simulink Environment Customization in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!