aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/Thermo_K/MCP9600.c
blob: 4c1c7f01910d693bffa2cf515c96a19ff8f9eebb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/*
 * MCP9600.c
 *
 *  Created on: Jul 11, 2018
 *      Author: avi
 */

//https://github.com/MikroElektronika/HEXIWEAR/blob/master/SW/Click%20Examples%20mikroC/examples/Thermo_K/HEXIWEAR_THERMO_K_Click.c


#include "MCP9600.h"

char tmp_data[10];
/*
float Read_Temperature()
{

  float Temperature;



  tmp_data[0] = MCP9600_TH;                                                     // Thermocouple Temperature register



  I2C_Start();                                                                  // Issue I2C start signal

  I2C_Write( MCP9600_I2C_ADDR, tmp_data, 1, END_MODE_RESTART );                 // Send byte (tmp_data[0])

  Delay_us( 50 );                                                               // delay 50 us

  I2C_Read( MCP9600_I2C_ADDR, tmp_data, 2, END_MODE_STOP );                     // Read thermocouple temperature and store it in tmp_data



  if( (tmp_data[0] & 0x80) == 0x80 )

  {                                             // TA < 0�C

    tmp_data[0] = tmp_data[0] & 0x7F;                                           // Clear SIGN

    Temperature = 1024 - ( tmp_data[0] * 16 + tmp_data[1] / 16 );

  }

  else                                                                          // TA > 0�C

    Temperature = ( tmp_data[0] * 16 + (float)tmp_data[1] / 16 );               // Temperature = Ambient Temperature (�C)



  return Temperature;                                                           // Return Thermocouple temperature data

}
*/