Send custom structure over i2c

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

Send custom structure over i2c

593 次查看
rudasi
Contributor I

I am trying to send a custom structure over i2c to a kinetis board which is acting as a slave with an interrupt triggering a callback in this scenario. I am able to run the example code which has a uint8_t buffer but I am not sure how to send a custom structure with different data types over. 

 

Any example code out there?

标签 (1)
标记 (2)
0 项奖励
2 回复数

512 次查看
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi, Rahul,

If you need complicated structure, I think you can use sprintf() function to output all variable to a buffer with char type, it is okay. If you want to output a structure, I think you can use union type structure.

typedef struct str_union

{

char array[];

union

{

}

}

Hope it can help you

BR

XiangJun Rong

0 项奖励

512 次查看
rudasi
Contributor I

Figured it out by just type casting the data to my structure. 

0 项奖励