Send custom structure over i2c

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Send custom structure over i2c

581件の閲覧回数
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 返答(返信)

500件の閲覧回数
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 件の賞賛

500件の閲覧回数
rudasi
Contributor I

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

0 件の賞賛