How to represent struct pointer in Simulink ???

3 次查看(过去 30 天)
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 个)

类别

Help CenterFile Exchange 中查找有关 Simulink Environment Customization 的更多信息

产品


版本

R2015a

Community Treasure Hunt

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

Start Hunting!

Translated by