37.
38. IIC_Send_Byte(reg);
39. IIC_Wait_Ack();
40.
41. temp = (u8)(data>>8);
42. IIC_Send_Byte(temp);
43. IIC_Wait_Ack();
44.
45. temp = (u8)(data&0x00FF);
46. IIC_Send_Byte(temp);
47. IIC_Wait_Ack();
48.
49. IIC_Stop();
50. }
51.
52. //
读取
53. u16 INA226_ReadData(u8 addr)
54. {
55. u16 temp=0;
56. IIC_Start();
57.
58. IIC_Send_Byte(addr+1);
59. IIC_Wait_Ack();
60.
61. temp = IIC_Read_Byte(1);
62. temp<<=8;
63. temp |= IIC_Read_Byte(0);
64.
65. IIC_Stop();
66. return temp;
67. }
68. /*
69. u8 INA226_AlertAddr()
70. {
71. u8 temp;
72. IIC_Start();
73.
74. IIC_Send_Byte(INA226_GETALADDR);
75. IIC_Wait_Ack();
76.
77. temp = IIC_Read_Byte(1);
78.
79. IIC_Stop();
80. return temp;
81. }
82. */
83.
84. //1mA/bit
85. u16 INA226_GetShunt_Current(u8 addr)
评论2
最新资源