Has base BMU code but sends dummy temperature and voltage readings to test CAN

Dependencies:   CUER_CAN DS1820 LTC2943 LTC6804 mbed

Fork of BMS_BMUCore_Max by CUER

Committer:
lcockerton62
Date:
Fri Dec 30 16:01:59 2016 +0000
Revision:
1:51477fe4851b
Child:
12:fa9b1a459e47
Storing SOC in EEPROM, added temperature sensors code, changed some of the data structures, added to CAN messages, added basic error status

Who changed what in which revision?

UserRevisionLine numberNew contents of line
lcockerton62 1:51477fe4851b 1 /*
lcockerton62 1:51477fe4851b 2 * Code for identifying address and temperature of DS1820 1-Wire Thermometers by Maxim
lcockerton62 1:51477fe4851b 3 * Uses the DS1820 library written by Michael Hagberg and Fernando Caamaño, with some slight modifications
lcockerton62 1:51477fe4851b 4 * Currently tested using DS18S20 1-Wire Thermometers in an array, parasite power yet to be tested
lcockerton62 1:51477fe4851b 5 */
lcockerton62 1:51477fe4851b 6 #include "Temperature.h"
lcockerton62 1:51477fe4851b 7
lcockerton62 1:51477fe4851b 8 DS1820* probe[MAX_PROBES];
lcockerton62 1:51477fe4851b 9 int devices_found = 0;
lcockerton62 1:51477fe4851b 10
lcockerton62 1:51477fe4851b 11 void temperature_init()
lcockerton62 1:51477fe4851b 12 {
lcockerton62 1:51477fe4851b 13 int i;
lcockerton62 1:51477fe4851b 14 int address_byte_count;
lcockerton62 1:51477fe4851b 15 // Initialize the probe array to DS1820 objects
lcockerton62 1:51477fe4851b 16 for (i = 0; i < MAX_PROBES; i++)
lcockerton62 1:51477fe4851b 17 probe[i] = new DS1820(DATA_PIN, PARASITE_PIN);
lcockerton62 1:51477fe4851b 18 // Initialize global state variables
lcockerton62 1:51477fe4851b 19 probe[0]->search_ROM_setup();
lcockerton62 1:51477fe4851b 20 // Loop to find all devices on the data line
lcockerton62 1:51477fe4851b 21 while (probe[devices_found]->search_ROM() and devices_found<MAX_PROBES-1)
lcockerton62 1:51477fe4851b 22 devices_found++;
lcockerton62 1:51477fe4851b 23 // If maximum number of probes are found,
lcockerton62 1:51477fe4851b 24 // bump the counter to include the last array entry
lcockerton62 1:51477fe4851b 25 if (probe[devices_found]->ROM[0] != 0xFF)
lcockerton62 1:51477fe4851b 26 devices_found++;
lcockerton62 1:51477fe4851b 27
lcockerton62 1:51477fe4851b 28 if (devices_found==0)
lcockerton62 1:51477fe4851b 29 printf("No devices found");
lcockerton62 1:51477fe4851b 30 else {
lcockerton62 1:51477fe4851b 31 printf("\n%d device(s) found!\r\n\n" ,devices_found);
lcockerton62 1:51477fe4851b 32 for (i=0; i<devices_found; i++) {
lcockerton62 1:51477fe4851b 33 printf("Device %d address is: \r\n", i+1);
lcockerton62 1:51477fe4851b 34 for(address_byte_count=0; address_byte_count<8; address_byte_count++) {
lcockerton62 1:51477fe4851b 35 printf("0x%02x", probe[i]->ROM[address_byte_count]);
lcockerton62 1:51477fe4851b 36 if(address_byte_count == 7) printf("\r\n\n");
lcockerton62 1:51477fe4851b 37 else printf(", ");
lcockerton62 1:51477fe4851b 38 }
lcockerton62 1:51477fe4851b 39 }
lcockerton62 1:51477fe4851b 40 }
lcockerton62 1:51477fe4851b 41 }
lcockerton62 1:51477fe4851b 42