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 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Simulink Environment Customization 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!