33#include " unity.h"
44#include " utest.h"
55#include " rtos.h"
6- #include " TMP102 .h"
6+ #include " LM75B .h"
77#include < I2CEeprom.h>
88
99using namespace utest ::v1;
@@ -12,29 +12,33 @@ using namespace utest::v1;
1212
1313const char *convBool (bool value) { return value ? " true" : " false" ; }
1414
15- #define I2C_SENTINAL ' Z'
15+ #define I2C_SENTINAL ' Z' // TODO: make this a random letter or string
1616#define TMP102_ADDR 0x90
1717#define EEPROM_ADDR 0xA0
1818
1919// a test to see if the temperature can be read. A I2C failure returns a 0
2020void test_tmp102 (){
21- TMP102 temperature (I2C_SDA, I2C_SCL, TMP102_ADDR); // A0 pin is connected to ground
22- TEST_ASSERT (0 != temperature.read ());
21+ // TMP102 temperature(I2C_SDA, I2C_SCL, TMP102_ADDR); //A0 pin is connected to ground
22+ LM75B temperature (I2C_SDA, I2C_SCL);
23+ TEST_ASSERT_MESSAGE (0 != temperature.open ()," Failed to open sensor" );
24+ TEST_ASSERT_MESSAGE (NULL != temperature.temp ()," Invalid value NULL returned" );
25+ TEST_ASSERT_MESSAGE (50 > temperature.temp ()," Its too Hot (>10C), Faulty Sensor?" );
26+ TEST_ASSERT_MESSAGE (0 < temperature.temp ()," Its Too Cold (<0C), Faulty Sensor?" );
2327}
2428
2529// A test to write the EEprom
2630void test_eeprom_W (){
2731 I2CEeprom memory (I2C_SDA,I2C_SCL, EEPROM_ADDR, 32 , 0 );
28- TEST_ASSERT (memory.write (1 , I2C_SENTINAL) == 1 ); // check data was written
32+ TEST_ASSERT_MESSAGE (memory.write (1 , I2C_SENTINAL) == 1 , " data not written, error with EEPROM? " ); // check data was written
2933}
3034
3135
3236// A test to read the EEprom
3337void test_eeprom_R (){
3438 I2CEeprom memory (I2C_SDA,I2C_SCL, EEPROM_ADDR, 32 , 0 );
3539 char value = ' a' ;
36- TEST_ASSERT (memory.read (1 ,value) == 1 ); // check data was read
37- TEST_ASSERT (I2C_SENTINAL == value); // check data integrity
40+ TEST_ASSERT_MESSAGE (memory.read (1 ,value) == 1 , " data failed to be read correctly " ); // check data was read
41+ TEST_ASSERT_MESSAGE (I2C_SENTINAL == value, " data read does not match data written! bad EEPROM? " ); // check data integrity
3842}
3943
4044// A test to Write then read the eeprom
0 commit comments