Clear Filters
Clear Filters

How to represent struct pointer in Simulink ???

3 views (last 30 days)
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;
}

Answers (0)

Categories

Find more on Simulink Environment Customization in Help Center and File Exchange

Products


Release

R2015a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!