请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
器件型号:TPS92682-Q1 主题中讨论的其他器件:TPS92518-Q1、 TPS92518
大家好、
客户请求一个示例通信代码来控制三个产品。
您可以共享示例代码吗?
TPS92518-Q1、TPS92682-Q1、TPS92682-Q1
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
大家好、
客户请求一个示例通信代码来控制三个产品。
您可以共享示例代码吗?
TPS92518-Q1、TPS92682-Q1、TPS92682-Q1
问题 TPS92518和 TPS92682中仅列出2个器件。
如需518、请通过以下链接查看数据表第8.6节。
对于682、请使用此示例说明如何构建帧。
Uint16 assembleSPICmd_682(Uint16 write, Uint16 address, Uint8 data)
{
Uint16 assembledCmd = 0; // Build this to shift through parity calculation
Uint16 parity = 0; // Parity bit calculated here
Uint16 packet = 0; // This will be what we send
if(write)
{
assembledCmd |= 0x8000; // Set CMD = 1
}
assembledCmd |= (((address << 9) & 0x7E00) | (Uint16)(data & 0x00FF));
packet = assembledCmd;
// Calculate parity
while(assembledCmd > 0)
{
// Count the number of 1s in the LSb
if(assembledCmd & 0x0001)
{
parity++;
}
// Shift right
assembledCmd >>= 1;
}
// If the LSb is a 0 (even # of 1s), we need to add the odd parity bit
if(!(parity & 0x0001))
{
packet |= (1 << 8);
}
return(packet);
}