Commit mthomas changes to GCC and port those changes to IAR
authorKevin Rosenberg <kevin@rosenberg.net>
Fri, 27 Jun 2008 01:04:50 +0000 (19:04 -0600)
committerKevin Rosenberg <kevin@rosenberg.net>
Fri, 27 Jun 2008 01:04:50 +0000 (19:04 -0600)
19 files changed:
BaseMegaFirmware/GCC/bc100_slave.c
BaseTinyFirmware/GCC/ADC.c
BaseTinyFirmware/GCC/LIIONspecs.h
BaseTinyFirmware/GCC/avr458/Makefile
BaseTinyFirmware/GCC/avr463/Makefile
BaseTinyFirmware/GCC/battery.c
BaseTinyFirmware/GCC/battery.h
BaseTinyFirmware/GCC/chargefunc.c
BaseTinyFirmware/GCC/statefunc.c
BaseTinyFirmware/GCC/statefunc.h
BaseTinyFirmware/GCC/structs.h
BaseTinyFirmware/IAR/ADC.c
BaseTinyFirmware/IAR/LIIONspecs.h
BaseTinyFirmware/IAR/battery.c
BaseTinyFirmware/IAR/battery.h
BaseTinyFirmware/IAR/statefunc.c
BaseTinyFirmware/IAR/statefunc.h
BaseTinyFirmware/IAR/structs.h
ChangeLog

index a03a33463f92d7dd22204b3449c2385398b8e458..2ff06a80fe495dae1e26872323defbeb7188d4a2 100644 (file)
@@ -96,6 +96,45 @@ uint8_t bc100_slave_test(void)
        }\r
        myprintf_P("average IBAT   %d [mA]\n", ADCS.avgIBAT);\r
 \r
        }\r
        myprintf_P("average IBAT   %d [mA]\n", ADCS.avgIBAT);\r
 \r
+       Batteries_t BattData;\r
+       myprintf_P("Current Battery:\n");\r
+       out = BC100_SLAVE_READ | BC100_SLAVE_SRAM | sizeof(BattData);\r
+       SPI_rw( out );\r
+       out = ADR_BATTDATA;\r
+       in = SPI_rw( out );\r
+       myprintf_P("In1 : 0x%02x (expected 0xcc)\n", in );\r
+       in = SPI_rw( dummy );\r
+       myprintf_P("In2 : 0x%02x (expected 0xbb)\n", in );\r
+       i = sizeof(BattData);\r
+       while ( i-- > 0 ) {\r
+               *( (unsigned char*)&BattData + i ) = SPI_rw(dummy);\r
+       }\r
+       if ( BattData.Present ) {\r
+               myprintf_P("Battery found\n");\r
+               if ( BattData.Charged ) {\r
+                       myprintf_P("- fully charged\n");\r
+               }\r
+               if ( BattData.Low ) {\r
+                       myprintf_P("- low voltage\n");\r
+               }\r
+               if ( BattData.Exhausted) {\r
+                       myprintf_P("- exhausted\n");\r
+               }\r
+               if ( BattData.HasRID) {\r
+                       myprintf_P("- has a ID-Resistor\n");\r
+               }\r
+               myprintf_P("Safety circuit ID    %d\n", BattData.Circuit );\r
+               myprintf_P("Tempearture          %d centi-degree C\n", BattData.Temperature );\r
+               myprintf_P("ADCSteps/half degree %d\n", BattData.ADCSteps);\r
+               myprintf_P("Capacity             %d mAh\n", BattData.Capacity);\r
+               myprintf_P("max. Current         %d mA\n", BattData.MaxCurrent);\r
+               myprintf_P("max. cut-off Time    %d min\n", BattData.MaxTime);\r
+               myprintf_P("min. cut-off Current %d mA\n", BattData.MinCurrent);\r
+       }\r
+       else {\r
+               myprintf_P("Battery not found\n");\r
+       }\r
+\r
        SPI_release();\r
 \r
        return err;\r
        SPI_release();\r
 \r
        return err;\r
index 50814ca6413782eef7d73523cbbf2e590c972910..3ed65b8b43c633d55f1bd4b8edf054bb9ba08569 100644 (file)
@@ -159,6 +159,7 @@ ISR(ADC_vect)
 \r
                        // Scale voltage according to jumper setting.\r
                        ADCS.VBAT = ScaleU(eeprom_read_byte(&VBAT_RANGE), (unsigned int)ADC); // ADC is a short.\r
 \r
                        // Scale voltage according to jumper setting.\r
                        ADCS.VBAT = ScaleU(eeprom_read_byte(&VBAT_RANGE), (unsigned int)ADC); // ADC is a short.\r
+                        __asm__ __volatile__ ("NOP"::);\r
                        Next=0x17;\r
 //                     Signed = TRUE;  // Next conversion is bipolar. Halves sensitivity!\r
                break;\r
                        Next=0x17;\r
 //                     Signed = TRUE;  // Next conversion is bipolar. Halves sensitivity!\r
                break;\r
index e662b1ef75dbe7a5a8614dbe45cc7f575e0bc933..5a30b35ace2a0ac01e69b806588acd12fdda1df7 100644 (file)
 #ifndef LIIONSPECS_H\r
 #define LIIONSPECS_H\r
 \r
 #ifndef LIIONSPECS_H\r
 #define LIIONSPECS_H\r
 \r
+/*\r
+ Information on Varta EasyPack 66590 711 099 collected by M. Thomas:\r
+\r
+ Connections:\r
+ Pad 1 - marked with + : Battery +\r
+ Pad 2 - not marked    : ID-Resistor (RID) to Pad 4, 3.9kOhm\r
+ Pad 3 - not marked    : NTC to Pad 4, 10kOhm B=3435K\r
+ Pad 4 - marked with - : Battery -\r
+ -> 1Wire not available\r
+\r
+ Capacity: nom. 550mAh (min. 520 mAh) at 0.2C from 4.2V to 3.0V\r
+ Nominal Voltage: 3.7V, Range: 2.75V - 4.2V\r
+ Charging Method: Constant Current + Constant Voltage\r
+  Charge Voltage: 4.2V\r
+  Initial charge Current: std. 260mA, rapid 520mA\r
+  Charging cut of either:\r
+  (a) at time: std. 5h, rapid 3h\r
+  (b) by min current of 10mA\r
+  Temparature 0 to 45degC\r
+ Discharge max. Current: 1040mA\r
+ Protection:\r
+  overcharge : 4.35V (resume at 4.0V)\r
+  discharge  : 2.2V\r
+  overcurrent: 3.0A\r
+\r
+ Additional from PoliFlex-Handbook:\r
+  - fast charging in termperatur-range 0 - 45degC\r
+  - max charge current 1C (=550mA here)\r
+  - max charge current has to be limited stricly to 4,2V +/- 50mV\r
+  - stop charge 3h after start of when current is <0.02C (=11mA here)\r
+*/\r
+\r
 \r
 //******************************************************************************\r
 // Cell limits\r
 //******************************************************************************\r
 // This is for common NiMH batteries.\r
 #define        CELL_VOLTAGE_SAFETY     0  /*!< \brief Buffer for unmatched batteries.\r
 \r
 //******************************************************************************\r
 // Cell limits\r
 //******************************************************************************\r
 // This is for common NiMH batteries.\r
 #define        CELL_VOLTAGE_SAFETY     0  /*!< \brief Buffer for unmatched batteries.\r
- * \r
+ *\r
  * If we are charging a multicell battery and the cells aren't matched, we\r
  * may risk overcharging at least one. Therefore, we may subtract this constant\r
  * per additional cell in battery to allow for a "buffer".\r
  * If we are charging a multicell battery and the cells aren't matched, we\r
  * may risk overcharging at least one. Therefore, we may subtract this constant\r
  * per additional cell in battery to allow for a "buffer".\r
 //! Charge voltage hysteresis, in mV.\r
 #define        BAT_VOLTAGE_HYST     10\r
 \r
 //! Charge voltage hysteresis, in mV.\r
 #define        BAT_VOLTAGE_HYST     10\r
 \r
-//! Maximum battery voltage, in mV. \r
+//! Maximum battery voltage, in mV.\r
 #define        BAT_VOLTAGE_MAX      (CELL_VOLTAGE_MAX * BAT_CELL_NUMBER) - \\r
                               ((BAT_CELL_NUMBER - 1) * CELL_VOLTAGE_SAFETY)\r
 \r
 #define        BAT_VOLTAGE_MAX      (CELL_VOLTAGE_MAX * BAT_CELL_NUMBER) - \\r
                               ((BAT_CELL_NUMBER - 1) * CELL_VOLTAGE_SAFETY)\r
 \r
index c2d1462e600dd9cc3cb6bdc05cac0465160bf532..844d3dbe9fff90082487d46fde6043fca7ed74e9 100644 (file)
@@ -15,6 +15,7 @@ COMMON = -mmcu=$(MCU)
 CFLAGS = $(COMMON)\r
 CFLAGS += -gdwarf-2 -std=gnu99 -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums\r
 CFLAGS += -Wall -Wstrict-prototypes -Wundef -Wa,-adhlns=./$(*F).lst\r
 CFLAGS = $(COMMON)\r
 CFLAGS += -gdwarf-2 -std=gnu99 -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums\r
 CFLAGS += -Wall -Wstrict-prototypes -Wundef -Wa,-adhlns=./$(*F).lst\r
+CFLAGS += -fno-inline-small-functions -fno-split-wide-types\r
 CFLAGS += -MMD -MP -MF dep/$(@F).d  \r
 CFLAGS += -DLIION\r
 \r
 CFLAGS += -MMD -MP -MF dep/$(@F).d  \r
 CFLAGS += -DLIION\r
 \r
index c2c00b08049f49e47896cbf5e25634144dca7adf..53aebb18583967fcb3b80b22fe903a03126b216e 100644 (file)
@@ -14,6 +14,7 @@ COMMON = -mmcu=$(MCU)
 ## Compile options common for all C compilation units.\r
 CFLAGS = $(COMMON)\r
 CFLAGS += -gdwarf-2 -std=gnu99 -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -ffunction-sections\r
 ## Compile options common for all C compilation units.\r
 CFLAGS = $(COMMON)\r
 CFLAGS += -gdwarf-2 -std=gnu99 -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -ffunction-sections\r
+CFLAGS += -fno-inline-small-functions -fno-split-wide-types\r
 CFLAGS += -Wall -Wstrict-prototypes -Wundef -Wa,-adhlns=./$(*F).lst\r
 CFLAGS += -MMD -MP -MF dep/$(@F).d  \r
 CFLAGS += -DNIMH\r
 CFLAGS += -Wall -Wstrict-prototypes -Wundef -Wa,-adhlns=./$(*F).lst\r
 CFLAGS += -MMD -MP -MF dep/$(@F).d  \r
 CFLAGS += -DNIMH\r
index b3617118cd562fd4f29df63ad09e3ec1bcfb9861..97c9f3bbce6ba8409460cc56e9483d385e1bf29b 100644 (file)
 \r
  *\r
  * \par Documentation\r
 \r
  *\r
  * \par Documentation\r
- *      For comprehensive code documentation, supported compilers, compiler \r
+ *      For comprehensive code documentation, supported compilers, compiler\r
  *      settings and supported devices see readme.html\r
  *\r
  * \author\r
  *      Atmel Corporation: http://www.atmel.com \n\r
  *      Support email: avr@atmel.com\r
  *\r
  *      settings and supported devices see readme.html\r
  *\r
  * \author\r
  *      Atmel Corporation: http://www.atmel.com \n\r
  *      Support email: avr@atmel.com\r
  *\r
- * \r
+ *\r
  * $Name$\r
  * $Revision: 2299 $\r
  * $RCSfile$\r
  * $Name$\r
  * $Revision: 2299 $\r
  * $RCSfile$\r
@@ -124,7 +124,7 @@ const NTC_Lookup_t NTC[NTC_TABLE_SIZE] = {
 };\r
 */\r
 \r
 };\r
 */\r
 \r
\r
+\r
 //******************************************************************************\r
 // Functions\r
 //******************************************************************************\r
 //******************************************************************************\r
 // Functions\r
 //******************************************************************************\r
@@ -132,7 +132,7 @@ const NTC_Lookup_t NTC[NTC_TABLE_SIZE] = {
  *\r
  * Stores current capacity, then attempts to refresh battery status.\n\r
  * If the refresh is successful, old capacity is compared with the new one.\r
  *\r
  * Stores current capacity, then attempts to refresh battery status.\n\r
  * If the refresh is successful, old capacity is compared with the new one.\r
- * \r
+ *\r
  * \retval FALSE Battery is disconnected, or capacity has changed.\r
  * \retval TRUE All OK.\r
  */\r
  * \retval FALSE Battery is disconnected, or capacity has changed.\r
  * \retval TRUE All OK.\r
  */\r
@@ -140,14 +140,14 @@ unsigned char BatteryCheck(void)
 {\r
        unsigned char success = TRUE;\r
        unsigned int  oldCapacity;\r
 {\r
        unsigned char success = TRUE;\r
        unsigned int  oldCapacity;\r
-       \r
+\r
        // Save to see if battery data has changed.\r
        // Save to see if battery data has changed.\r
-       oldCapacity = BattData.Capacity;  \r
-       \r
+       oldCapacity = BattData.Capacity;\r
+\r
        if (!BatteryStatusRefresh()) {\r
                success = FALSE;              // Battery not present or RID was invalid.\r
        }\r
        if (!BatteryStatusRefresh()) {\r
                success = FALSE;              // Battery not present or RID was invalid.\r
        }\r
-       \r
+\r
        if (oldCapacity != BattData.Capacity) {\r
                success = FALSE;              // Battery configuration has changed.\r
        }\r
        if (oldCapacity != BattData.Capacity) {\r
                success = FALSE;              // Battery configuration has changed.\r
        }\r
@@ -176,7 +176,7 @@ unsigned char BatteryStatusRefresh(void)
        unsigned char sreg_saved;\r
        unsigned int adcs_VBAT_tmp;\r
        signed int adcs_avgIBAT_tmp;\r
        unsigned char sreg_saved;\r
        unsigned int adcs_VBAT_tmp;\r
        signed int adcs_avgIBAT_tmp;\r
-       \r
+\r
        BattData.Present = FALSE;\r
        BattData.Charged = FALSE;\r
        BattData.Low = TRUE;\r
        BattData.Present = FALSE;\r
        BattData.Charged = FALSE;\r
        BattData.Low = TRUE;\r
@@ -208,7 +208,7 @@ unsigned char BatteryStatusRefresh(void)
 \r
        // If we are not charging, yet VBAT is above safe limit, battery is present.\r
        // If we are charging and there's a current flowing, the battery is present.\r
 \r
        // If we are not charging, yet VBAT is above safe limit, battery is present.\r
        // If we are charging and there's a current flowing, the battery is present.\r
-       \r
+\r
        /*! \todo If ABORT_IF_PWM_MAX is defined this last check battery presence\r
        * check is redundant since charging will be aborted due to low current at\r
        * max duty cycle. That is preferrable since the charge current reading is\r
        /*! \todo If ABORT_IF_PWM_MAX is defined this last check battery presence\r
        * check is redundant since charging will be aborted due to low current at\r
        * max duty cycle. That is preferrable since the charge current reading is\r
@@ -250,13 +250,13 @@ unsigned char BatteryDataRefresh(void)
        unsigned char offset;\r
        unsigned char i, crc, family, temp, page;\r
        unsigned char success;\r
        unsigned char offset;\r
        unsigned char i, crc, family, temp, page;\r
        unsigned char success;\r
-       \r
+\r
        // Look for EPROM and read 4 pages of 32 bytes each worth of data, if found.\r
        for (page = 0; page < 4; page++)        {\r
                success = FALSE;\r
        // Look for EPROM and read 4 pages of 32 bytes each worth of data, if found.\r
        for (page = 0; page < 4; page++)        {\r
                success = FALSE;\r
-       \r
+\r
                if (OWI_DetectPresence(OWIBUS) == OWIBUS) {\r
                if (OWI_DetectPresence(OWIBUS) == OWIBUS) {\r
-                       \r
+\r
                        // Presence detected, check type and CRC.\r
                        OWI_SendByte(OWI_ROM_READ, OWIBUS);\r
                        family = OWI_ReceiveByte(OWIBUS);\r
                        // Presence detected, check type and CRC.\r
                        OWI_SendByte(OWI_ROM_READ, OWIBUS);\r
                        family = OWI_ReceiveByte(OWIBUS);\r
@@ -286,14 +286,14 @@ unsigned char BatteryDataRefresh(void)
                                        // and writing it to EEPROM.\r
                                        if (OWI_ComputeCRC8(OWI_ReceiveByte(OWIBUS),crc) == 0) {\r
                                                crc = 0;\r
                                        // and writing it to EEPROM.\r
                                        if (OWI_ComputeCRC8(OWI_ReceiveByte(OWIBUS),crc) == 0) {\r
                                                crc = 0;\r
-                                               \r
+\r
                                                // Fill page with data.\r
                                                for (i=0; i<32; i++) {\r
                                                        temp = OWI_ReceiveByte(OWIBUS);\r
                                                        crc = OWI_ComputeCRC8(temp, crc);\r
                                                        eeprom_write_byte(&BattEEPROM[page][i], temp);\r
                                                }\r
                                                // Fill page with data.\r
                                                for (i=0; i<32; i++) {\r
                                                        temp = OWI_ReceiveByte(OWIBUS);\r
                                                        crc = OWI_ComputeCRC8(temp, crc);\r
                                                        eeprom_write_byte(&BattEEPROM[page][i], temp);\r
                                                }\r
-                                               \r
+\r
                                                if (OWI_ComputeCRC8(OWI_ReceiveByte(OWIBUS),crc) == 0) {\r
                                                                success = TRUE;  // Data read OK\r
                                                }\r
                                                if (OWI_ComputeCRC8(OWI_ReceiveByte(OWIBUS),crc) == 0) {\r
                                                                success = TRUE;  // Data read OK\r
                                                }\r
@@ -301,7 +301,7 @@ unsigned char BatteryDataRefresh(void)
                                        }\r
                                } else { // Wrong device type.\r
                                }\r
                                        }\r
                                } else { // Wrong device type.\r
                                }\r
-                       } else { // No device found.             \r
+                       } else { // No device found.\r
                        }\r
                } else { // No presence detected on one-wire bus.\r
                }\r
                        }\r
                } else { // No presence detected on one-wire bus.\r
                }\r
@@ -309,7 +309,10 @@ unsigned char BatteryDataRefresh(void)
          // Erase local EEPROM page if there were any errors during transfer.\r
                if (!success) {\r
                        for (i=0; i<32; i++) {\r
          // Erase local EEPROM page if there were any errors during transfer.\r
                if (!success) {\r
                        for (i=0; i<32; i++) {\r
-                               eeprom_write_byte(&BattEEPROM[page][i], 0);\r
+                          // mthomas: avoid unneeded writes\r
+                          if ( eeprom_read_byte( &BattEEPROM[page][i] ) != 0 ) {\r
+                            eeprom_write_byte(&BattEEPROM[page][i], 0);\r
+                          }\r
                        }\r
                }\r
        }\r
                        }\r
                }\r
        }\r
@@ -338,10 +341,10 @@ void EnableBattery(unsigned char bat)
        PORTB |= (1 << (PB4+bat));\r
 \r
        // Disconnect other battery.\r
        PORTB |= (1 << (PB4+bat));\r
 \r
        // Disconnect other battery.\r
-       PORTB &= ~(1<<(PB5-bat));     \r
+       PORTB &= ~(1<<(PB5-bat));\r
 \r
        do { // Let port switch settle.\r
 \r
        do { // Let port switch settle.\r
-       } while (Time_Left(TIMER_GEN));  \r
+       } while (Time_Left(TIMER_GEN));\r
 }\r
 \r
 \r
 }\r
 \r
 \r
@@ -352,7 +355,7 @@ void EnableBattery(unsigned char bat)
 void DisableBatteries(void)\r
 {\r
        // Turn off LEDs and disconnect batteries.\r
 void DisableBatteries(void)\r
 {\r
        // Turn off LEDs and disconnect batteries.\r
-       PORTB &= ~((1<<PB4)|(1<<PB5));  \r
+       PORTB &= ~((1<<PB4)|(1<<PB5));\r
 }\r
 \r
 \r
 }\r
 \r
 \r
@@ -370,7 +373,7 @@ unsigned char RIDLookUp (void)
        unsigned char i, found = FALSE;\r
        unsigned int adcs_rawRID_tmp;\r
        unsigned char sreg_saved;\r
        unsigned char i, found = FALSE;\r
        unsigned int adcs_rawRID_tmp;\r
        unsigned char sreg_saved;\r
-               \r
+\r
        // Lookup in the RID-table. If measured RID is within the limits\r
        // of an entry, those data are used, and TRUE is returned.\r
        for (i = 0 ; i < RID_TABLE_SIZE; i++) {\r
        // Lookup in the RID-table. If measured RID is within the limits\r
        // of an entry, those data are used, and TRUE is returned.\r
        for (i = 0 ; i < RID_TABLE_SIZE; i++) {\r
@@ -384,12 +387,12 @@ unsigned char RIDLookUp (void)
                                BattData.MaxCurrent = RID[i].Icharge;\r
                                BattData.MaxTime = RID[i].tCutOff;\r
                                BattData.MinCurrent = RID[i].ICutOff;\r
                                BattData.MaxCurrent = RID[i].Icharge;\r
                                BattData.MaxTime = RID[i].tCutOff;\r
                                BattData.MinCurrent = RID[i].ICutOff;\r
-                               \r
+\r
                                found = TRUE;\r
                        }\r
                }\r
        }\r
                                found = TRUE;\r
                        }\r
                }\r
        }\r
-       \r
+\r
        // If no valid entry is found, use defaults and return FALSE.\r
        if (!found) {\r
                BattData.Capacity = DEF_BAT_CAPACITY;\r
        // If no valid entry is found, use defaults and return FALSE.\r
        if (!found) {\r
                BattData.Capacity = DEF_BAT_CAPACITY;\r
@@ -397,7 +400,7 @@ unsigned char RIDLookUp (void)
                BattData.MaxTime = DEF_BAT_TIME_MAX;\r
                BattData.MinCurrent = DEF_BAT_CURRENT_MIN;\r
        }\r
                BattData.MaxTime = DEF_BAT_TIME_MAX;\r
                BattData.MinCurrent = DEF_BAT_CURRENT_MIN;\r
        }\r
-       \r
+\r
        return(found);\r
 }\r
 \r
        return(found);\r
 }\r
 \r
@@ -417,9 +420,9 @@ void NTCLookUp (void)
 {\r
        unsigned char i;\r
        unsigned char found = FALSE;\r
 {\r
        unsigned char i;\r
        unsigned char found = FALSE;\r
-       unsigned char adcs_rawNTC_tmp;\r
+       unsigned int adcs_rawNTC_tmp;\r
        unsigned char sreg_saved;\r
        unsigned char sreg_saved;\r
-       \r
+\r
        // Lookup in the NTC-table. Use the first entry which is equal or below\r
        // sampled NTC. Calculate temperature by using the index number, and the\r
        // difference between the measured NTC value and the one in the entry.\r
        // Lookup in the NTC-table. Use the first entry which is equal or below\r
        // sampled NTC. Calculate temperature by using the index number, and the\r
        // difference between the measured NTC value and the one in the entry.\r
@@ -430,14 +433,14 @@ void NTCLookUp (void)
                SREG = sreg_saved;\r
                if (adcs_rawNTC_tmp >= NTC[i].ADCV) {\r
                        BattData.Temperature = (i<<2) ;\r
                SREG = sreg_saved;\r
                if (adcs_rawNTC_tmp >= NTC[i].ADCV) {\r
                        BattData.Temperature = (i<<2) ;\r
-                       BattData.ADCSteps = NTC[i].ADCsteps;  \r
+                       BattData.ADCSteps = NTC[i].ADCsteps;\r
                        BattData.Temperature -= ((adcs_rawNTC_tmp - NTC[i].ADCV)<<1) / BattData.ADCSteps;\r
                        BattData.Temperature -= ((adcs_rawNTC_tmp - NTC[i].ADCV)<<1) / BattData.ADCSteps;\r
-                       \r
+\r
                        found = TRUE;  // Could be done with a break, but that violates MISRA.\r
                }\r
        }\r
                        found = TRUE;  // Could be done with a break, but that violates MISRA.\r
                }\r
        }\r
-       \r
-       // For safety, is temperature is greater than the NTC \r
+\r
+       // For safety, is temperature is greater than the NTC\r
        if (!found) {\r
                BattData.Temperature = 80;\r
        }\r
        if (!found) {\r
                BattData.Temperature = 80;\r
        }\r
index bb76eaf922eb8036c28be5a185fb46068685f937..2ad077003d953ea3dc728556ceb23f118009e123 100644 (file)
 //******************************************************************************\r
 // RID-less charging (for BatteryStatusRefresh())\r
 //******************************************************************************\r
 //******************************************************************************\r
 // RID-less charging (for BatteryStatusRefresh())\r
 //******************************************************************************\r
+\r
+#ifdef EASYPACK550\r
+\r
+#warning "using EasyPack 66590 711 099 (550mAh) settings - mthomas, no warranty!"\r
+// RID not connected\r
+#define ALLOW_NO_RID                //!< Use default battery data if no matching entry found.\r
+#define DEF_BAT_CAPACITY       550  //!< Default battery capacity, in mAh.\r
+#define DEF_BAT_CURRENT_MAX    260  //!< Default maximum charge current, in mA.\r
+#define DEF_BAT_TIME_MAX    (5*60)  //!< Default maximum charge time, in minutes.\r
+//! Default minimum current to stop charge, in mA.\r
+#define DEF_BAT_CURRENT_MIN     10\r
+\r
+#else\r
+\r
 //#define ALLOW_NO_RID  //!< Use default battery data if no matching entry found.\r
 \r
 #define DEF_BAT_CAPACITY               0  //!< Default battery capacity, in mAh.\r
 //#define ALLOW_NO_RID  //!< Use default battery data if no matching entry found.\r
 \r
 #define DEF_BAT_CAPACITY               0  //!< Default battery capacity, in mAh.\r
@@ -59,6 +73,7 @@
 //! Default minimum current to stop charge, in mA.\r
 #define DEF_BAT_CURRENT_MIN    0\r
 \r
 //! Default minimum current to stop charge, in mA.\r
 #define DEF_BAT_CURRENT_MIN    0\r
 \r
+#endif /* EASYPACK550 */\r
 \r
 \r
 //******************************************************************************\r
 \r
 \r
 //******************************************************************************\r
index 5f441b7f85dbc45970108c8fea68747f367c07ff..b3db020480f6a5991925d8bb41f2da57de7fd50e 100644 (file)
  *      AVR463: Charging NiMH Batteries with BC100\r
  *\r
  * \par Documentation\r
  *      AVR463: Charging NiMH Batteries with BC100\r
  *\r
  * \par Documentation\r
- *      For comprehensive code documentation, supported compilers, compiler \r
+ *      For comprehensive code documentation, supported compilers, compiler\r
  *      settings and supported devices see readme.html\r
  *\r
  * \author\r
  *      Atmel Corporation: http://www.atmel.com \n\r
  *      Support email: avr@atmel.com\r
  *\r
  *      settings and supported devices see readme.html\r
  *\r
  * \author\r
  *      Atmel Corporation: http://www.atmel.com \n\r
  *      Support email: avr@atmel.com\r
  *\r
- * \r
+ *\r
  * $Name$\r
  * $Revision: 2299 $\r
  * $RCSfile$\r
  * $Name$\r
  * $Revision: 2299 $\r
  * $RCSfile$\r
@@ -84,7 +84,7 @@ unsigned char ConstantCurrent(void)
                      wasStopped = FALSE;\r
        unsigned char sreg_saved;\r
        signed int adcs_avgIBAT_tmp;\r
                      wasStopped = FALSE;\r
        unsigned char sreg_saved;\r
        signed int adcs_avgIBAT_tmp;\r
-       \r
+\r
        do      {\r
                // Wait for ADC conversions to complete.\r
                ADC_Wait();\r
        do      {\r
                // Wait for ADC conversions to complete.\r
                ADC_Wait();\r
@@ -99,7 +99,7 @@ unsigned char ConstantCurrent(void)
                        // Continue charging!\r
                        if (wasStopped) {\r
                                wasStopped = FALSE;\r
                        // Continue charging!\r
                        if (wasStopped) {\r
                                wasStopped = FALSE;\r
-                               \r
+\r
                                // Timer variables are not reset by this.\r
                                Time_Start();\r
                        }\r
                                // Timer variables are not reset by this.\r
                                Time_Start();\r
                        }\r
@@ -113,7 +113,7 @@ unsigned char ConstantCurrent(void)
                        // +/- BAT_CURRENT_HYST.\r
                        if ((adcs_avgIBAT_tmp < 0) ||\r
                            (adcs_avgIBAT_tmp < (ChargeParameters.Current - BAT_CURRENT_HYST))) {\r
                        // +/- BAT_CURRENT_HYST.\r
                        if ((adcs_avgIBAT_tmp < 0) ||\r
                            (adcs_avgIBAT_tmp < (ChargeParameters.Current - BAT_CURRENT_HYST))) {\r
-                                        \r
+\r
                                if(!PWM_IncrementDutyCycle()) {\r
 #ifdef ABORT_IF_PWM_MAX\r
                                // If the duty cycle cannot be incremented, flag error and\r
                                if(!PWM_IncrementDutyCycle()) {\r
 #ifdef ABORT_IF_PWM_MAX\r
                                // If the duty cycle cannot be incremented, flag error and\r
@@ -125,7 +125,7 @@ unsigned char ConstantCurrent(void)
                                }\r
                        } else if ((adcs_avgIBAT_tmp >= 0) &&\r
                                 (adcs_avgIBAT_tmp > (ChargeParameters.Current + BAT_CURRENT_HYST))) {\r
                                }\r
                        } else if ((adcs_avgIBAT_tmp >= 0) &&\r
                                 (adcs_avgIBAT_tmp > (ChargeParameters.Current + BAT_CURRENT_HYST))) {\r
-                                        \r
+\r
                                if(!PWM_DecrementDutyCycle()) {\r
 #ifdef ABORT_IF_PWM_MIN\r
                                        // If the duty cycle cannot be decremented, flag error and\r
                                if(!PWM_DecrementDutyCycle()) {\r
 #ifdef ABORT_IF_PWM_MIN\r
                                        // If the duty cycle cannot be decremented, flag error and\r
@@ -165,12 +165,12 @@ unsigned char ConstantVoltage(void)
                      wasStopped = FALSE;\r
        unsigned char sreg_saved;\r
        unsigned int adcs_VBAT_tmp;\r
                      wasStopped = FALSE;\r
        unsigned char sreg_saved;\r
        unsigned int adcs_VBAT_tmp;\r
-       \r
+\r
        do{\r
        do{\r
-               \r
+\r
                // Wait for ADC conversions to complete.\r
                ADC_Wait();\r
                // Wait for ADC conversions to complete.\r
                ADC_Wait();\r
-               \r
+\r
                // If Master has flagged for a charge inhibit, pause charging.\r
                // (This is to prevent damage during prolonged serial communication.)\r
                if (eeprom_read_byte(&BattControl[BattActive]) & BIT_BATTERY_CHARGE_INHIBIT) {\r
                // If Master has flagged for a charge inhibit, pause charging.\r
                // (This is to prevent damage during prolonged serial communication.)\r
                if (eeprom_read_byte(&BattControl[BattActive]) & BIT_BATTERY_CHARGE_INHIBIT) {\r
@@ -178,16 +178,16 @@ unsigned char ConstantVoltage(void)
                        Time_Stop();\r
                        OCR1B = 0;\r
                }\r
                        Time_Stop();\r
                        OCR1B = 0;\r
                }\r
-               \r
+\r
                else {\r
                        // Continue charging!\r
                        if (wasStopped) {\r
                                wasStopped = FALSE;\r
                else {\r
                        // Continue charging!\r
                        if (wasStopped) {\r
                                wasStopped = FALSE;\r
-                               \r
+\r
                                // Timer variables aren't reset by this.\r
                                Time_Start();\r
                        }\r
                                // Timer variables aren't reset by this.\r
                                Time_Start();\r
                        }\r
-                       \r
+\r
                        sreg_saved = SREG;\r
                        cli();\r
                        adcs_VBAT_tmp = ADCS.VBAT;\r
                        sreg_saved = SREG;\r
                        cli();\r
                        adcs_VBAT_tmp = ADCS.VBAT;\r
@@ -237,7 +237,7 @@ unsigned char ConstantVoltage(void)
  *\r
  * The function also checks if the battery temperature is within limits,\r
  * if mains is OK, and if BatteryCheck() returns TRUE.\r
  *\r
  * The function also checks if the battery temperature is within limits,\r
  * if mains is OK, and if BatteryCheck() returns TRUE.\r
- * If an error is detected, the associated errorflag is set and \r
+ * If an error is detected, the associated errorflag is set and\r
  * ChargeParameters.NextState is changed to an appropriate state.\r
  *\r
  * \retval TRUE Halt now.\r
  * ChargeParameters.NextState is changed to an appropriate state.\r
  *\r
  * \retval TRUE Halt now.\r
@@ -256,7 +256,7 @@ unsigned char HaltNow(void)
        unsigned int adcs_rawNTC_tmp, adcs_VBAT_tmp;\r
        signed int adcs_avgIBAT_tmp;\r
        unsigned char sreg_saved;\r
        unsigned int adcs_rawNTC_tmp, adcs_VBAT_tmp;\r
        signed int adcs_avgIBAT_tmp;\r
        unsigned char sreg_saved;\r
-       \r
+\r
        // Wait for a full ADC-cycle to finish.\r
        ADC_Wait();\r
 \r
        // Wait for a full ADC-cycle to finish.\r
        ADC_Wait();\r
 \r
@@ -265,29 +265,29 @@ unsigned char HaltNow(void)
        // (Gets overridden if either mains is failing, or the battery changes.)\r
        for (i = 0x01; i != 0; i <<= 1) {\r
                if (HaltParameters.HaltFlags & i) {\r
        // (Gets overridden if either mains is failing, or the battery changes.)\r
        for (i = 0x01; i != 0; i <<= 1) {\r
                if (HaltParameters.HaltFlags & i) {\r
-                       \r
+\r
                        sreg_saved = SREG;\r
                        cli();\r
                        adcs_VBAT_tmp = ADCS.VBAT;\r
                        adcs_avgIBAT_tmp  = ADCS.avgIBAT;\r
                        SREG = sreg_saved;\r
                        sreg_saved = SREG;\r
                        cli();\r
                        adcs_VBAT_tmp = ADCS.VBAT;\r
                        adcs_avgIBAT_tmp  = ADCS.avgIBAT;\r
                        SREG = sreg_saved;\r
-                       \r
+\r
                        switch (i) {\r
                        // Is VBAT less than the recorded maximum?\r
                        case HALT_VOLTAGE_DROP:\r
                                // Update VBATMax if VBAT is higher. Evaluate for halt otherwise.\r
                                if (adcs_VBAT_tmp > HaltParameters.VBATMax) {\r
                                        HaltParameters.VBATMax = adcs_VBAT_tmp;\r
                        switch (i) {\r
                        // Is VBAT less than the recorded maximum?\r
                        case HALT_VOLTAGE_DROP:\r
                                // Update VBATMax if VBAT is higher. Evaluate for halt otherwise.\r
                                if (adcs_VBAT_tmp > HaltParameters.VBATMax) {\r
                                        HaltParameters.VBATMax = adcs_VBAT_tmp;\r
-                               } else if((HaltParameters.VBATMax - adcs_VBAT_tmp) >= \r
+                               } else if((HaltParameters.VBATMax - adcs_VBAT_tmp) >=\r
                                          HaltParameters.VoltageDrop) {\r
                                        halt = TRUE;\r
                                }\r
                        break;\r
 \r
                                          HaltParameters.VoltageDrop) {\r
                                        halt = TRUE;\r
                                }\r
                        break;\r
 \r
-                       \r
+\r
                        // Has VBAT reached the maximum limit?\r
                        // Has VBAT reached the maximum limit?\r
-                       case HALT_VOLTAGE_MAX:  \r
-                               \r
+                       case HALT_VOLTAGE_MAX:\r
+\r
                                if (adcs_VBAT_tmp >= HaltParameters.VoltageMax) {\r
                                        halt = TRUE;\r
                                }\r
                                if (adcs_VBAT_tmp >= HaltParameters.VoltageMax) {\r
                                        halt = TRUE;\r
                                }\r
@@ -296,16 +296,16 @@ unsigned char HaltNow(void)
 \r
                        // Has IBAT reached the minimum limit?\r
                        case HALT_CURRENT_MIN:\r
 \r
                        // Has IBAT reached the minimum limit?\r
                        case HALT_CURRENT_MIN:\r
-                               \r
+\r
                                if (adcs_avgIBAT_tmp <= HaltParameters.CurrentMin) {\r
                                        halt = TRUE;\r
                                }\r
                                break;\r
                                if (adcs_avgIBAT_tmp <= HaltParameters.CurrentMin) {\r
                                        halt = TRUE;\r
                                }\r
                                break;\r
-       \r
-                               \r
+\r
+\r
                        // Is the temperature rising too fast?\r
                        case HALT_TEMPERATURE_RISE:\r
                        // Is the temperature rising too fast?\r
                        case HALT_TEMPERATURE_RISE:\r
-                               \r
+\r
                                sreg_saved = SREG;\r
                                cli();\r
                                adcs_rawNTC_tmp = ADCS.rawNTC;\r
                                sreg_saved = SREG;\r
                                cli();\r
                                adcs_rawNTC_tmp = ADCS.rawNTC;\r
@@ -316,12 +316,12 @@ unsigned char HaltNow(void)
                                if (adcs_rawNTC_tmp > HaltParameters.LastNTC) {\r
                                        HaltParameters.LastNTC = adcs_rawNTC_tmp;\r
                                        Time_Set(TIMER_TEMP,0,30,0);\r
                                if (adcs_rawNTC_tmp > HaltParameters.LastNTC) {\r
                                        HaltParameters.LastNTC = adcs_rawNTC_tmp;\r
                                        Time_Set(TIMER_TEMP,0,30,0);\r
-                                       \r
+\r
                                // Is the increase in temperature greater than the set threshold?\r
                                } else  if ((HaltParameters.LastNTC - adcs_rawNTC_tmp) >=\r
                                  (BattData.ADCSteps * HaltParameters.TemperatureRise)) {\r
                                // Is the increase in temperature greater than the set threshold?\r
                                } else  if ((HaltParameters.LastNTC - adcs_rawNTC_tmp) >=\r
                                  (BattData.ADCSteps * HaltParameters.TemperatureRise)) {\r
-                                       \r
-                                       // If this happened within a timeframe of 30 seconds, the \r
+\r
+                                       // If this happened within a timeframe of 30 seconds, the\r
                                        // temperature is rising faster than we want.\r
                                        // If not, update LastNTC and reset timer.\r
                                        if (Time_Left(TIMER_TEMP))  {\r
                                        // temperature is rising faster than we want.\r
                                        // If not, update LastNTC and reset timer.\r
                                        if (Time_Left(TIMER_TEMP))  {\r
@@ -332,29 +332,31 @@ unsigned char HaltNow(void)
                                        }\r
                                }\r
                        break;\r
                                        }\r
                                }\r
                        break;\r
-       \r
-                       \r
+\r
+\r
                        // Is there any time left?\r
                        // Is there any time left?\r
-                       case HALT_TIME:  \r
-                               \r
+                       case HALT_TIME:\r
+\r
                                if (!Time_Left(TIMER_CHG)) {\r
                                        halt = TRUE;\r
                                if (!Time_Left(TIMER_CHG)) {\r
                                        halt = TRUE;\r
-                                       \r
-                                       // If exhaustion flagging is selected, stop the PWM, disable the \r
+\r
+                                       // If exhaustion flagging is selected, stop the PWM, disable the\r
                                        // battery and flag it as exhausted. Make ST_ERROR next state.\r
                                        if (HaltParameters.HaltFlags & HALT_FLAG_EXHAUSTION) {\r
                                                        PWM_Stop();\r
                                        // battery and flag it as exhausted. Make ST_ERROR next state.\r
                                        if (HaltParameters.HaltFlags & HALT_FLAG_EXHAUSTION) {\r
                                                        PWM_Stop();\r
+\r
                                                        Battery_t tmp = eeprom_read_byte(&BattControl[BattActive]);\r
                                                                                         tmp &= ~BIT_BATTERY_ENABLED; // Enabled = FALSE;\r
                                                                                         eeprom_write_byte(&BattControl[BattActive], tmp);\r
                                                        Battery_t tmp = eeprom_read_byte(&BattControl[BattActive]);\r
                                                                                         tmp &= ~BIT_BATTERY_ENABLED; // Enabled = FALSE;\r
                                                                                         eeprom_write_byte(&BattControl[BattActive], tmp);\r
+\r
                                                        BattData.Exhausted = TRUE;\r
                                                        SetErrorFlag(ERR_BATTERY_EXHAUSTED);\r
                                                        ChargeParameters.NextState = ST_ERROR;\r
                                        }\r
                                }\r
                        break;\r
                                                        BattData.Exhausted = TRUE;\r
                                                        SetErrorFlag(ERR_BATTERY_EXHAUSTED);\r
                                                        ChargeParameters.NextState = ST_ERROR;\r
                                        }\r
                                }\r
                        break;\r
-                       \r
-                       \r
+\r
+\r
                        default:  // Shouldn't end up here, but is needed for MISRA compliance.\r
                        break;\r
                        }\r
                        default:  // Shouldn't end up here, but is needed for MISRA compliance.\r
                        break;\r
                        }\r
@@ -366,7 +368,7 @@ unsigned char HaltNow(void)
        // Battery too cold or hot?\r
        if ((BattData.Temperature <= HaltParameters.TemperatureMin) ||\r
            (BattData.Temperature >= HaltParameters.TemperatureMax)) {\r
        // Battery too cold or hot?\r
        if ((BattData.Temperature <= HaltParameters.TemperatureMin) ||\r
            (BattData.Temperature >= HaltParameters.TemperatureMax)) {\r
-                       \r
+\r
                PWM_Stop();\r
                SetErrorFlag(ERR_BATTERY_TEMPERATURE);\r
                ChargeParameters.NextState = ST_ERROR;\r
                PWM_Stop();\r
                SetErrorFlag(ERR_BATTERY_TEMPERATURE);\r
                ChargeParameters.NextState = ST_ERROR;\r
index 9fc0ae5ae08669aecee4f6b6dfa13b1d2c4117c3..e0e265901ee3cb064da476f907b735a96c16e890 100644 (file)
@@ -123,7 +123,7 @@ unsigned char Initialize(unsigned char inp)
        sei();\r
 \r
        // Attempt to get ADC-readings (also gets RID-data) from both batteries.\r
        sei();\r
 \r
        // Attempt to get ADC-readings (also gets RID-data) from both batteries.\r
-       for (i = 0; i < 2; i++) {\r
+       for (i = 0; i < BATCONN; i++)   {\r
                EnableBattery(i);\r
                ADC_Wait();\r
                BatteryStatusRefresh();\r
                EnableBattery(i);\r
                ADC_Wait();\r
                BatteryStatusRefresh();\r
@@ -174,7 +174,7 @@ unsigned char BatteryControl(unsigned char inp)
 \r
        // Get ADC-readings, try to read EPROM, and start prequalification\r
        // of any uncharged battery.\r
 \r
        // Get ADC-readings, try to read EPROM, and start prequalification\r
        // of any uncharged battery.\r
-       for (i = 0; i < 2; i++) {\r
+       for (i = 0; i < BATCONN; i++) {\r
                if (eeprom_read_byte(&BattControl[i]) & BIT_BATTERY_ENABLED) {\r
                        EnableBattery(i);\r
                        ADC_Wait();\r
                if (eeprom_read_byte(&BattControl[i]) & BIT_BATTERY_ENABLED) {\r
                        EnableBattery(i);\r
                        ADC_Wait();\r
@@ -228,11 +228,13 @@ unsigned char Sleep(unsigned char inp)
 \r
                // If any batteries need charging, go to ST_BATCON.\r
                // Otherwise, keep sleeping.\r
 \r
                // If any batteries need charging, go to ST_BATCON.\r
                // Otherwise, keep sleeping.\r
-               for (i = 0; i < 2; i++) {\r
+               for (i = 0; i < BATCONN; i++) {\r
                        EnableBattery(i);\r
                        ADC_Wait();\r
                        EnableBattery(i);\r
                        ADC_Wait();\r
-                       if ((BatteryStatusRefresh()) && (!BattData.Charged)) {\r
-                               return(ST_BATCON);\r
+                       if ( BatteryStatusRefresh() ) {\r
+                               if ( !BattData.Charged ) {\r
+                                  return(ST_BATCON);\r
+                                }\r
                        }\r
                }\r
 \r
                        }\r
                }\r
 \r
@@ -282,6 +284,7 @@ void Doze(void)
                sleep_cpu();                            // Go to sleep, wake up by WDT.\r
        }\r
        else {\r
                sleep_cpu();                            // Go to sleep, wake up by WDT.\r
        }\r
        else {\r
+               // stay awake if PB6 is pulled low by master\r
                do {\r
                } while ( !(WatchdogFlag) );\r
        }\r
                do {\r
                } while ( !(WatchdogFlag) );\r
        }\r
index 9594f441213bbebb0bea1ee78b7a72a39d46cc56..699b93e5a939824f68380eb78a7a0ef5dbadfad2 100644 (file)
  *      AVR458: Charging Li-Ion Batteries with BC100\r
  *\r
  * \par Documentation\r
  *      AVR458: Charging Li-Ion Batteries with BC100\r
  *\r
  * \par Documentation\r
- *      For comprehensive code documentation, supported compilers, compiler \r
+ *      For comprehensive code documentation, supported compilers, compiler\r
  *      settings and supported devices see readme.html\r
  *\r
  * \author\r
  *      Atmel Corporation: http://www.atmel.com \n\r
  *      Support email: avr@atmel.com\r
  *\r
  *      settings and supported devices see readme.html\r
  *\r
  * \author\r
  *      Atmel Corporation: http://www.atmel.com \n\r
  *      Support email: avr@atmel.com\r
  *\r
- * \r
+ *\r
  * $Name$\r
  * $Revision: 2261 $\r
  * $RCSfile$\r
  * $Name$\r
  * $Revision: 2261 $\r
  * $RCSfile$\r
 #ifndef STATEFUNC_H\r
 #define STATEFUNC_H\r
 \r
 #ifndef STATEFUNC_H\r
 #define STATEFUNC_H\r
 \r
+//! number of connectors (1: just process A, 2 process A and B )\r
+#define BATCONN  1\r
+#if ( BATCONN < 1 ) || ( BATCONN > 2 )\r
+#error "Invalid BATCONN. Must be set to 1 or 2."\r
+#endif\r
 \r
 //******************************************************************************\r
 // Wanted SPI-mode\r
 \r
 //******************************************************************************\r
 // Wanted SPI-mode\r
@@ -36,7 +41,7 @@
 #define SPIMODE 0\r
 \r
 //! Sample on leading _falling_ edge, setup on trailing _rising_ edge.\r
 #define SPIMODE 0\r
 \r
 //! Sample on leading _falling_ edge, setup on trailing _rising_ edge.\r
-//#define SPIMODE 1    \r
+//#define SPIMODE 1\r
 \r
 \r
 //******************************************************************************\r
 \r
 \r
 //******************************************************************************\r
 // Error-flag bit identifiers\r
 //******************************************************************************\r
 //! Wrong jumper settings.\r
 // Error-flag bit identifiers\r
 //******************************************************************************\r
 //! Wrong jumper settings.\r
-#define   ERR_JUMPER_MISMATCH                          0x01  \r
+#define   ERR_JUMPER_MISMATCH                          0x01\r
 \r
 //! Both batteries disabled.\r
 \r
 //! Both batteries disabled.\r
-#define   ERR_NO_BATTERIES_ENABLED             0x02  \r
+#define   ERR_NO_BATTERIES_ENABLED             0x02\r
 \r
 //! PWM output too much/little.\r
 \r
 //! PWM output too much/little.\r
-#define   ERR_PWM_CONTROL                                      0x04  \r
+#define   ERR_PWM_CONTROL                                      0x04\r
 \r
 //! Battery temperature out of limits.\r
 \r
 //! Battery temperature out of limits.\r
-#define   ERR_BATTERY_TEMPERATURE              0x08  \r
+#define   ERR_BATTERY_TEMPERATURE              0x08\r
 \r
 //! Battery couldn't be charged.\r
 \r
 //! Battery couldn't be charged.\r
-#define   ERR_BATTERY_EXHAUSTED                        0x10  \r
+#define   ERR_BATTERY_EXHAUSTED                        0x10\r
 \r
 \r
 //******************************************************************************\r
 \r
 \r
 //******************************************************************************\r
index 742c17e94e9e97a98cc314a3ee197f4a687a67e1..e49462177c3f888743b9b8c754c3d6d0b1298307 100644 (file)
  */\r
 struct Batteries_struct\r
 {\r
  */\r
 struct Batteries_struct\r
 {\r
+#if 0\r
+#warning "no bitfield, used for debugging - mthomas"\r
+       unsigned char Present   ; //!< Battery found. (TRUE/FALSE)\r
+       unsigned char Charged   ; //!< Battery fully charged. (TRUE/FALSE)\r
+       unsigned char Low       ; //!< Battery low voltage. (TRUE/FALSE)\r
+       unsigned char Exhausted ; //!< Battery exhausted. (TRUE/FALSE)\r
+       unsigned char HasRID    ; //!< Battery has resistor ID. (TRUE/FALSE)\r
+#else\r
        unsigned char Present   : 1; //!< Battery found. (TRUE/FALSE)\r
        unsigned char Charged   : 1; //!< Battery fully charged. (TRUE/FALSE)\r
        unsigned char Low       : 1; //!< Battery low voltage. (TRUE/FALSE)\r
        unsigned char Exhausted : 1; //!< Battery exhausted. (TRUE/FALSE)\r
        unsigned char HasRID    : 1; //!< Battery has resistor ID. (TRUE/FALSE)\r
        unsigned char Present   : 1; //!< Battery found. (TRUE/FALSE)\r
        unsigned char Charged   : 1; //!< Battery fully charged. (TRUE/FALSE)\r
        unsigned char Low       : 1; //!< Battery low voltage. (TRUE/FALSE)\r
        unsigned char Exhausted : 1; //!< Battery exhausted. (TRUE/FALSE)\r
        unsigned char HasRID    : 1; //!< Battery has resistor ID. (TRUE/FALSE)\r
+#endif\r
        unsigned char Circuit;       //!< Battery safety circuit (family id).\r
        signed char Temperature;     //!< Battery temperature, in centigrade.\r
        unsigned char ADCSteps;      //!< ADC steps per half degree.\r
        unsigned char Circuit;       //!< Battery safety circuit (family id).\r
        signed char Temperature;     //!< Battery temperature, in centigrade.\r
        unsigned char ADCSteps;      //!< ADC steps per half degree.\r
index b1229a24dd07ec793d6a6bcd7b4df03c88e47f37..6ccc245f3bd40ce440def17460f9e21e576cd590 100644 (file)
@@ -33,6 +33,7 @@
 \r
 #include <ioavr.h>\r
 #include <inavr.h>\r
 \r
 #include <ioavr.h>\r
 #include <inavr.h>\r
+#include <intrinsics.h>\r
 \r
 #include "structs.h"\r
 \r
 \r
 #include "structs.h"\r
 \r
@@ -81,7 +82,7 @@ __eeprom unsigned char VBAT_RANGE = 1;
  * This ISR stores the sampled values in the ADC status-struct, then\r
  * updates the ADC MUX to the next channel in the scanning-sequence.\n\r
  * Once the sequence is completed, ADCS.Flag is set and unless\r
  * This ISR stores the sampled values in the ADC status-struct, then\r
  * updates the ADC MUX to the next channel in the scanning-sequence.\n\r
  * Once the sequence is completed, ADCS.Flag is set and unless\r
- * ADCS.Halt has been set, the sequence starts over. Otherwise, the ADC \r
+ * ADCS.Halt has been set, the sequence starts over. Otherwise, the ADC\r
  * is disabled.\n\r
  * If the mains voltage is below minimum, ADCS.Mains gets set to FALSE.\r
  *\r
  * is disabled.\n\r
  * If the mains voltage is below minimum, ADCS.Mains gets set to FALSE.\r
  *\r
@@ -116,11 +117,11 @@ __interrupt void ADC_ISR(void)
        static unsigned char avgIndex = 0;\r
        unsigned char i, Next, Signed;\r
        signed int  temp = 0;\r
        static unsigned char avgIndex = 0;\r
        unsigned char i, Next, Signed;\r
        signed int  temp = 0;\r
-       \r
+\r
        Signed = FALSE;  // Presume next conversion is unipolar.\r
        ADCSRA &= ~(1<<ADEN);  // Stop conversion before handling. This makes all\r
          // conversions take at least 25 ADCCLK. (It is restarted later)\r
        Signed = FALSE;  // Presume next conversion is unipolar.\r
        ADCSRA &= ~(1<<ADEN);  // Stop conversion before handling. This makes all\r
          // conversions take at least 25 ADCCLK. (It is restarted later)\r
-       \r
+\r
        // Handle the conversion, depending on what channel it is from, then\r
        // switch to the next channel in the sequence.\r
        switch (ADCS.MUX){\r
        // Handle the conversion, depending on what channel it is from, then\r
        // switch to the next channel in the sequence.\r
        switch (ADCS.MUX){\r
@@ -130,36 +131,37 @@ __interrupt void ADC_ISR(void)
                        Next=0x02;\r
                break;\r
 \r
                        Next=0x02;\r
                break;\r
 \r
-               \r
+\r
                // MUX = 0b000010 => ADC2 (PA2) = RID\r
                case 0x02:\r
                        ADCS.rawRID = ADC;\r
                        Next=0x03;\r
                break;\r
 \r
                // MUX = 0b000010 => ADC2 (PA2) = RID\r
                case 0x02:\r
                        ADCS.rawRID = ADC;\r
                        Next=0x03;\r
                break;\r
 \r
-               \r
+\r
                // MUX = 0b000011 => ADC3 (PA4) = VIN-\r
                case 0x03:\r
                        // Supply voltage is always divided by 16.\r
                        ADCS.VIN = ScaleU(4, (unsigned int)ADC);  // Cast because ADC is short.\r
                // MUX = 0b000011 => ADC3 (PA4) = VIN-\r
                case 0x03:\r
                        // Supply voltage is always divided by 16.\r
                        ADCS.VIN = ScaleU(4, (unsigned int)ADC);  // Cast because ADC is short.\r
-                       \r
+\r
                        // Is mains failing?\r
                        if (ADCS.VIN < VIN_MIN) {\r
                                ADCS.Mains = FALSE;\r
                        } else {\r
                                ADCS.Mains = TRUE;\r
                        }\r
                        // Is mains failing?\r
                        if (ADCS.VIN < VIN_MIN) {\r
                                ADCS.Mains = FALSE;\r
                        } else {\r
                                ADCS.Mains = TRUE;\r
                        }\r
-                       \r
+\r
                        Next=0x05;\r
                break;\r
 \r
                        Next=0x05;\r
                break;\r
 \r
-               \r
+\r
                // MUX = 0b000101 => ADC5 (PA6) = VBAT-\r
                case 0x05:\r
                        ADCS.rawVBAT = ADC;\r
                // MUX = 0b000101 => ADC5 (PA6) = VBAT-\r
                case 0x05:\r
                        ADCS.rawVBAT = ADC;\r
-                       \r
+\r
                        // Scale voltage according to jumper setting.\r
                        ADCS.VBAT = ScaleU(VBAT_RANGE, (unsigned int)ADC); // ADC is a short.\r
                        // Scale voltage according to jumper setting.\r
                        ADCS.VBAT = ScaleU(VBAT_RANGE, (unsigned int)ADC); // ADC is a short.\r
+                        __no_operation();\r
                        Next=0x17;\r
 //                     Signed = TRUE;  // Next conversion is bipolar. Halves sensitivity!\r
                break;\r
                        Next=0x17;\r
 //                     Signed = TRUE;  // Next conversion is bipolar. Halves sensitivity!\r
                break;\r
@@ -168,7 +170,7 @@ __interrupt void ADC_ISR(void)
                case 0x17:  // MUX = 0b010111 => 20 x [ADC6(PA7) - ADC5(PA6)] = IBAT\r
                        // If bipolar, from -512 to 0, to 511:\r
                        // 0x200 ... 0x3ff, 0x000, 0x001 ... 0x1FF\r
                case 0x17:  // MUX = 0b010111 => 20 x [ADC6(PA7) - ADC5(PA6)] = IBAT\r
                        // If bipolar, from -512 to 0, to 511:\r
                        // 0x200 ... 0x3ff, 0x000, 0x001 ... 0x1FF\r
-               \r
+\r
                        // Scale sample according to jumper setting, handle negative numbers.\r
                        if (ADC > 511) {\r
                                ADCS.IBAT = -(signed int)ScaleI(VBAT_RANGE,\r
                        // Scale sample according to jumper setting, handle negative numbers.\r
                        if (ADC > 511) {\r
                                ADCS.IBAT = -(signed int)ScaleI(VBAT_RANGE,\r
@@ -187,35 +189,35 @@ __interrupt void ADC_ISR(void)
                        for (i = 0; i < 4 ; i++) {\r
                                temp += ADCS.discIBAT[i];\r
                        }\r
                        for (i = 0; i < 4 ; i++) {\r
                                temp += ADCS.discIBAT[i];\r
                        }\r
-                       \r
+\r
                        ADCS.avgIBAT = (temp / 4);\r
                        ADCS.avgIBAT = (temp / 4);\r
-                       \r
+\r
                        ADCS.Flag = TRUE;\r
                        Next=0x01;\r
                        Signed = FALSE;  // This is the only bipolar conversion.\r
                break;\r
 \r
                        ADCS.Flag = TRUE;\r
                        Next=0x01;\r
                        Signed = FALSE;  // This is the only bipolar conversion.\r
                break;\r
 \r
-               \r
+\r
                default:  // Should not happen. (Invalid MUX-channel)\r
                        Next=0x01;  // Start at the beginning of sequence.\r
                break;\r
        }\r
                default:  // Should not happen. (Invalid MUX-channel)\r
                        Next=0x01;  // Start at the beginning of sequence.\r
                break;\r
        }\r
-       \r
+\r
        // Update MUX to next channel in sequence, set a bipolar conversion if\r
        // this has been flagged.\r
        // Update MUX to next channel in sequence, set a bipolar conversion if\r
        // this has been flagged.\r
-       ADCS.MUX = Next;                    \r
-       ADMUX = (1<<REFS0) + ADCS.MUX;      \r
+       ADCS.MUX = Next;\r
+       ADMUX = (1<<REFS0) + ADCS.MUX;\r
 \r
        if (Signed)     {\r
 \r
        if (Signed)     {\r
-         ADCSRB |= (1<<BIN);               \r
+         ADCSRB |= (1<<BIN);\r
        } else {\r
        } else {\r
-         ADCSRB &= ~(1<<BIN);              \r
+         ADCSRB &= ~(1<<BIN);\r
        }\r
 \r
        // Re-enable the ADC unless a halt has been flagged and a conversion\r
        // cycle has completed.\r
        if (!((ADCS.Halt) && (ADCS.Flag))) {\r
        }\r
 \r
        // Re-enable the ADC unless a halt has been flagged and a conversion\r
        // cycle has completed.\r
        if (!((ADCS.Halt) && (ADCS.Flag))) {\r
-         ADCSRA |= (1<<ADEN)|(1<<ADSC);    \r
+         ADCSRA |= (1<<ADEN)|(1<<ADSC);\r
        }\r
 }\r
 \r
        }\r
 }\r
 \r
@@ -257,7 +259,7 @@ unsigned int ScaleU(unsigned char setting, unsigned int data)
                // Jumper setting 4: mV/LSB = 39.06 ~= 39 + 1/16\r
                scaled = 39 * data;\r
                scaled += (data >> 4);\r
                // Jumper setting 4: mV/LSB = 39.06 ~= 39 + 1/16\r
                scaled = 39 * data;\r
                scaled += (data >> 4);\r
-               \r
+\r
                if (setting <3) {\r
                        // Jumper setting 0: mV/LSB = 4.883 = 39.06 / 8\r
                        //                1: mV/LSB = 9.766 = 39.06 / 4\r
                if (setting <3) {\r
                        // Jumper setting 0: mV/LSB = 4.883 = 39.06 / 8\r
                        //                1: mV/LSB = 9.766 = 39.06 / 4\r
@@ -298,7 +300,7 @@ unsigned int ScaleI(unsigned char setting, unsigned int data)
 {\r
        // Temporary variable needed.\r
        unsigned int  scaled = 0;\r
 {\r
        // Temporary variable needed.\r
        unsigned int  scaled = 0;\r
-       \r
+\r
        // Jumper setting 3: mA/LSB = 20.931mA ~= 21 - 1/16 + 1/128\r
        if (setting == 3) {\r
                scaled = 21 * data;\r
        // Jumper setting 3: mA/LSB = 20.931mA ~= 21 - 1/16 + 1/128\r
        if (setting == 3) {\r
                scaled = 21 * data;\r
@@ -308,7 +310,7 @@ unsigned int ScaleI(unsigned char setting, unsigned int data)
                scaled = 28 * data;\r
                scaled -= (data >> 3);\r
                scaled += (data >> 5);\r
                scaled = 28 * data;\r
                scaled -= (data >> 3);\r
                scaled += (data >> 5);\r
-               \r
+\r
                if (setting <3) {\r
                        // Jumper setting 0: mA/LSB = 3.489mA = 27.909 / 8\r
                        //                1: mA/LSB = 6.978mA = 27.909 / 4\r
                if (setting <3) {\r
                        // Jumper setting 0: mA/LSB = 3.489mA = 27.909 / 8\r
                        //                1: mA/LSB = 6.978mA = 27.909 / 4\r
@@ -316,7 +318,7 @@ unsigned int ScaleI(unsigned char setting, unsigned int data)
                        scaled = (scaled >> (3-setting));\r
                }\r
        }\r
                        scaled = (scaled >> (3-setting));\r
                }\r
        }\r
-       \r
+\r
        return(scaled);\r
 }\r
 \r
        return(scaled);\r
 }\r
 \r
@@ -325,19 +327,19 @@ unsigned int ScaleI(unsigned char setting, unsigned int data)
  *\r
  * This function clears the cycle complete-flag, then waits for it to be set\r
  * again. This is then repeated once before the function exits.\r
  *\r
  * This function clears the cycle complete-flag, then waits for it to be set\r
  * again. This is then repeated once before the function exits.\r
- * \r
+ *\r
  */\r
 void ADC_Wait(void)\r
 {\r
        // Clear ADC flag and wait for cycle to complete.\r
  */\r
 void ADC_Wait(void)\r
 {\r
        // Clear ADC flag and wait for cycle to complete.\r
-       ADCS.Flag = FALSE;              \r
+       ADCS.Flag = FALSE;\r
        do {\r
        do {\r
-       } while (ADCS.Flag == FALSE);      \r
-       \r
+       } while (ADCS.Flag == FALSE);\r
+\r
        // Repeat, so we are sure the data beong to the same cycle.\r
        // Repeat, so we are sure the data beong to the same cycle.\r
-       ADCS.Flag = FALSE;              \r
+       ADCS.Flag = FALSE;\r
        do {\r
        do {\r
-       } while (ADCS.Flag == FALSE);      \r
+       } while (ADCS.Flag == FALSE);\r
 }\r
 \r
 \r
 }\r
 \r
 \r
@@ -380,11 +382,11 @@ void ADC_Init(void)
 \r
        // Set ADC3 as reference, and MUX to measure the same pin.\r
        ADMUX = (1<<REFS0) | (1<<MUX0) | (1<<MUX1);\r
 \r
        // Set ADC3 as reference, and MUX to measure the same pin.\r
        ADMUX = (1<<REFS0) | (1<<MUX0) | (1<<MUX1);\r
-       \r
+\r
        ADCSRB = 0;\r
 \r
        // Start conversion, no interrupt (disable ADC-ISR).\r
        ADCSRB = 0;\r
 \r
        // Start conversion, no interrupt (disable ADC-ISR).\r
-       ADCSRA = (1<<ADEN) | (1<<ADSC) | ADC_PRESCALER; \r
+       ADCSRA = (1<<ADEN) | (1<<ADSC) | ADC_PRESCALER;\r
 \r
        do { // Wait for conversion to finish.\r
        } while (!(ADCSRA & (1<<ADIF)));\r
 \r
        do { // Wait for conversion to finish.\r
        } while (!(ADCSRA & (1<<ADIF)));\r
@@ -394,9 +396,9 @@ void ADC_Init(void)
        ADCS.ADC3_G20_OS = ADC;  // Save the sampled offset.\r
 \r
        ADMUX = (1<<REFS0) | 0x16;  // ADC5/ADC5 (external ref.), 20x\r
        ADCS.ADC3_G20_OS = ADC;  // Save the sampled offset.\r
 \r
        ADMUX = (1<<REFS0) | 0x16;  // ADC5/ADC5 (external ref.), 20x\r
-       \r
+\r
        // Start conversion, no interrupt. ADC_PRESCALER is defined in ADC.h.\r
        // Start conversion, no interrupt. ADC_PRESCALER is defined in ADC.h.\r
-       ADCSRA = (1<<ADEN) | (1<<ADSC) | ADC_PRESCALER; \r
+       ADCSRA = (1<<ADEN) | (1<<ADSC) | ADC_PRESCALER;\r
 \r
        do { // Wait for conversion to finish.\r
        } while (!(ADCSRA & (1<<ADIF)));\r
 \r
        do { // Wait for conversion to finish.\r
        } while (!(ADCSRA & (1<<ADIF)));\r
@@ -406,20 +408,20 @@ void ADC_Init(void)
        ADCS.ADC5_G20_OS = ADC;  // Save the sampled offset.\r
 \r
        // Reset the ADC-cycle.\r
        ADCS.ADC5_G20_OS = ADC;  // Save the sampled offset.\r
 \r
        // Reset the ADC-cycle.\r
-       ADCS.Flag = FALSE;      \r
-       ADCS.MUX = 0x01;                    \r
-       ADMUX = (1<<REFS0) | ADCS.MUX;      \r
+       ADCS.Flag = FALSE;\r
+       ADCS.MUX = 0x01;\r
+       ADMUX = (1<<REFS0) | ADCS.MUX;\r
 \r
        // Clear averaged battery current and the discrete readings.\r
        ADCS.avgIBAT = 0;\r
 \r
        // Clear averaged battery current and the discrete readings.\r
        ADCS.avgIBAT = 0;\r
-       \r
+\r
        for (i = 0; i < 4; i++) {\r
        for (i = 0; i < 4; i++) {\r
-               ADCS.discIBAT[i] = 0;             \r
+               ADCS.discIBAT[i] = 0;\r
        }\r
        }\r
-       \r
+\r
        // Re-enable the ADC and ISR.\r
        ADCSRA=(1<<ADEN)|(1<<ADSC)|(1<<ADIE)|ADC_PRESCALER;\r
        // Re-enable the ADC and ISR.\r
        ADCSRA=(1<<ADEN)|(1<<ADSC)|(1<<ADIE)|ADC_PRESCALER;\r
-       \r
+\r
        __enable_interrupt();\r
 \r
        // Get a complete cycle of data before returning.\r
        __enable_interrupt();\r
 \r
        // Get a complete cycle of data before returning.\r
index e662b1ef75dbe7a5a8614dbe45cc7f575e0bc933..5a30b35ace2a0ac01e69b806588acd12fdda1df7 100644 (file)
 #ifndef LIIONSPECS_H\r
 #define LIIONSPECS_H\r
 \r
 #ifndef LIIONSPECS_H\r
 #define LIIONSPECS_H\r
 \r
+/*\r
+ Information on Varta EasyPack 66590 711 099 collected by M. Thomas:\r
+\r
+ Connections:\r
+ Pad 1 - marked with + : Battery +\r
+ Pad 2 - not marked    : ID-Resistor (RID) to Pad 4, 3.9kOhm\r
+ Pad 3 - not marked    : NTC to Pad 4, 10kOhm B=3435K\r
+ Pad 4 - marked with - : Battery -\r
+ -> 1Wire not available\r
+\r
+ Capacity: nom. 550mAh (min. 520 mAh) at 0.2C from 4.2V to 3.0V\r
+ Nominal Voltage: 3.7V, Range: 2.75V - 4.2V\r
+ Charging Method: Constant Current + Constant Voltage\r
+  Charge Voltage: 4.2V\r
+  Initial charge Current: std. 260mA, rapid 520mA\r
+  Charging cut of either:\r
+  (a) at time: std. 5h, rapid 3h\r
+  (b) by min current of 10mA\r
+  Temparature 0 to 45degC\r
+ Discharge max. Current: 1040mA\r
+ Protection:\r
+  overcharge : 4.35V (resume at 4.0V)\r
+  discharge  : 2.2V\r
+  overcurrent: 3.0A\r
+\r
+ Additional from PoliFlex-Handbook:\r
+  - fast charging in termperatur-range 0 - 45degC\r
+  - max charge current 1C (=550mA here)\r
+  - max charge current has to be limited stricly to 4,2V +/- 50mV\r
+  - stop charge 3h after start of when current is <0.02C (=11mA here)\r
+*/\r
+\r
 \r
 //******************************************************************************\r
 // Cell limits\r
 //******************************************************************************\r
 // This is for common NiMH batteries.\r
 #define        CELL_VOLTAGE_SAFETY     0  /*!< \brief Buffer for unmatched batteries.\r
 \r
 //******************************************************************************\r
 // Cell limits\r
 //******************************************************************************\r
 // This is for common NiMH batteries.\r
 #define        CELL_VOLTAGE_SAFETY     0  /*!< \brief Buffer for unmatched batteries.\r
- * \r
+ *\r
  * If we are charging a multicell battery and the cells aren't matched, we\r
  * may risk overcharging at least one. Therefore, we may subtract this constant\r
  * per additional cell in battery to allow for a "buffer".\r
  * If we are charging a multicell battery and the cells aren't matched, we\r
  * may risk overcharging at least one. Therefore, we may subtract this constant\r
  * per additional cell in battery to allow for a "buffer".\r
 //! Charge voltage hysteresis, in mV.\r
 #define        BAT_VOLTAGE_HYST     10\r
 \r
 //! Charge voltage hysteresis, in mV.\r
 #define        BAT_VOLTAGE_HYST     10\r
 \r
-//! Maximum battery voltage, in mV. \r
+//! Maximum battery voltage, in mV.\r
 #define        BAT_VOLTAGE_MAX      (CELL_VOLTAGE_MAX * BAT_CELL_NUMBER) - \\r
                               ((BAT_CELL_NUMBER - 1) * CELL_VOLTAGE_SAFETY)\r
 \r
 #define        BAT_VOLTAGE_MAX      (CELL_VOLTAGE_MAX * BAT_CELL_NUMBER) - \\r
                               ((BAT_CELL_NUMBER - 1) * CELL_VOLTAGE_SAFETY)\r
 \r
index 4486197e7f3957d222568d05d6106238b99b5c82..406e49492c50cee96fa8708be051abccf51d1496 100644 (file)
 \r
  *\r
  * \par Documentation\r
 \r
  *\r
  * \par Documentation\r
- *      For comprehensive code documentation, supported compilers, compiler \r
+ *      For comprehensive code documentation, supported compilers, compiler\r
  *      settings and supported devices see readme.html\r
  *\r
  * \author\r
  *      Atmel Corporation: http://www.atmel.com \n\r
  *      Support email: avr@atmel.com\r
  *\r
  *      settings and supported devices see readme.html\r
  *\r
  * \author\r
  *      Atmel Corporation: http://www.atmel.com \n\r
  *      Support email: avr@atmel.com\r
  *\r
- * \r
+ *\r
  * $Name$\r
  * $Revision: 2299 $\r
  * $RCSfile$\r
  * $Name$\r
  * $Revision: 2299 $\r
  * $RCSfile$\r
@@ -129,7 +129,7 @@ const NTC_Lookup_t NTC[NTC_TABLE_SIZE] = {
  *\r
  * Stores current capacity, then attempts to refresh battery status.\n\r
  * If the refresh is successful, old capacity is compared with the new one.\r
  *\r
  * Stores current capacity, then attempts to refresh battery status.\n\r
  * If the refresh is successful, old capacity is compared with the new one.\r
- * \r
+ *\r
  * \retval FALSE Battery is disconnected, or capacity has changed.\r
  * \retval TRUE All OK.\r
  */\r
  * \retval FALSE Battery is disconnected, or capacity has changed.\r
  * \retval TRUE All OK.\r
  */\r
@@ -137,14 +137,14 @@ unsigned char BatteryCheck(void)
 {\r
        unsigned char success = TRUE;\r
        unsigned int  oldCapacity;\r
 {\r
        unsigned char success = TRUE;\r
        unsigned int  oldCapacity;\r
-       \r
+\r
        // Save to see if battery data has changed.\r
        // Save to see if battery data has changed.\r
-       oldCapacity = BattData.Capacity;  \r
-       \r
+       oldCapacity = BattData.Capacity;\r
+\r
        if (!BatteryStatusRefresh()) {\r
                success = FALSE;              // Battery not present or RID was invalid.\r
        }\r
        if (!BatteryStatusRefresh()) {\r
                success = FALSE;              // Battery not present or RID was invalid.\r
        }\r
-       \r
+\r
        if (oldCapacity != BattData.Capacity) {\r
                success = FALSE;              // Battery configuration has changed.\r
        }\r
        if (oldCapacity != BattData.Capacity) {\r
                success = FALSE;              // Battery configuration has changed.\r
        }\r
@@ -170,7 +170,7 @@ unsigned char BatteryStatusRefresh(void)
 {\r
        // Assume the worst..\r
        unsigned char success = FALSE;\r
 {\r
        // Assume the worst..\r
        unsigned char success = FALSE;\r
-       \r
+\r
        BattData.Present = FALSE;\r
        BattData.Charged = FALSE;\r
        BattData.Low = TRUE;\r
        BattData.Present = FALSE;\r
        BattData.Charged = FALSE;\r
        BattData.Low = TRUE;\r
@@ -196,7 +196,7 @@ unsigned char BatteryStatusRefresh(void)
 \r
        // If we are not charging, yet VBAT is above safe limit, battery is present.\r
        // If we are charging and there's a current flowing, the battery is present.\r
 \r
        // If we are not charging, yet VBAT is above safe limit, battery is present.\r
        // If we are charging and there's a current flowing, the battery is present.\r
-       \r
+\r
        /*! \todo If ABORT_IF_PWM_MAX is defined this last check battery presence\r
        * check is redundant since charging will be aborted due to low current at\r
        * max duty cycle. That is preferrable since the charge current reading is\r
        /*! \todo If ABORT_IF_PWM_MAX is defined this last check battery presence\r
        * check is redundant since charging will be aborted due to low current at\r
        * max duty cycle. That is preferrable since the charge current reading is\r
@@ -238,13 +238,13 @@ unsigned char BatteryDataRefresh(void)
        unsigned char offset;\r
        unsigned char i, crc, family, temp, page;\r
        unsigned char success;\r
        unsigned char offset;\r
        unsigned char i, crc, family, temp, page;\r
        unsigned char success;\r
-       \r
+\r
        // Look for EPROM and read 4 pages of 32 bytes each worth of data, if found.\r
        for (page = 0; page < 4; page++)        {\r
                success = FALSE;\r
        // Look for EPROM and read 4 pages of 32 bytes each worth of data, if found.\r
        for (page = 0; page < 4; page++)        {\r
                success = FALSE;\r
-       \r
+\r
                if (OWI_DetectPresence(OWIBUS) == OWIBUS) {\r
                if (OWI_DetectPresence(OWIBUS) == OWIBUS) {\r
-                       \r
+\r
                        // Presence detected, check type and CRC.\r
                        OWI_SendByte(OWI_ROM_READ, OWIBUS);\r
                        family = OWI_ReceiveByte(OWIBUS);\r
                        // Presence detected, check type and CRC.\r
                        OWI_SendByte(OWI_ROM_READ, OWIBUS);\r
                        family = OWI_ReceiveByte(OWIBUS);\r
@@ -274,14 +274,14 @@ unsigned char BatteryDataRefresh(void)
                                        // and writing it to EEPROM.\r
                                        if (OWI_ComputeCRC8(OWI_ReceiveByte(OWIBUS),crc) == 0) {\r
                                                crc = 0;\r
                                        // and writing it to EEPROM.\r
                                        if (OWI_ComputeCRC8(OWI_ReceiveByte(OWIBUS),crc) == 0) {\r
                                                crc = 0;\r
-                                               \r
+\r
                                                // Fill page with data.\r
                                                for (i=0; i<32; i++) {\r
                                                        temp = OWI_ReceiveByte(OWIBUS);\r
                                                        crc = OWI_ComputeCRC8(temp, crc);\r
                                                        BattEEPROM[page][i] = temp;\r
                                                }\r
                                                // Fill page with data.\r
                                                for (i=0; i<32; i++) {\r
                                                        temp = OWI_ReceiveByte(OWIBUS);\r
                                                        crc = OWI_ComputeCRC8(temp, crc);\r
                                                        BattEEPROM[page][i] = temp;\r
                                                }\r
-                                               \r
+\r
                                                if (OWI_ComputeCRC8(OWI_ReceiveByte(OWIBUS),crc) == 0) {\r
                                                                success = TRUE;  // Data read OK\r
                                                }\r
                                                if (OWI_ComputeCRC8(OWI_ReceiveByte(OWIBUS),crc) == 0) {\r
                                                                success = TRUE;  // Data read OK\r
                                                }\r
@@ -289,7 +289,7 @@ unsigned char BatteryDataRefresh(void)
                                        }\r
                                } else { // Wrong device type.\r
                                }\r
                                        }\r
                                } else { // Wrong device type.\r
                                }\r
-                       } else { // No device found.             \r
+                       } else { // No device found.\r
                        }\r
                } else { // No presence detected on one-wire bus.\r
                }\r
                        }\r
                } else { // No presence detected on one-wire bus.\r
                }\r
@@ -297,7 +297,10 @@ unsigned char BatteryDataRefresh(void)
          // Erase local EEPROM page if there were any errors during transfer.\r
                if (!success) {\r
                        for (i=0; i<32; i++) {\r
          // Erase local EEPROM page if there were any errors during transfer.\r
                if (!success) {\r
                        for (i=0; i<32; i++) {\r
-                               BattEEPROM[page][i] = 0;\r
+                          // mthomas: avoid unneeded writes\r
+                          if ( eeprom_read_byte( &BattEEPROM[page][i] ) != 0 ) {\r
+                            BattEEPROM[page][i] = 0;\r
+                          }\r
                        }\r
                }\r
        }\r
                        }\r
                }\r
        }\r
@@ -326,10 +329,10 @@ void EnableBattery(unsigned char bat)
        PORTB |= (1 << (PB4+bat));\r
 \r
        // Disconnect other battery.\r
        PORTB |= (1 << (PB4+bat));\r
 \r
        // Disconnect other battery.\r
-       PORTB &= ~(1<<(PB5-bat));     \r
+       PORTB &= ~(1<<(PB5-bat));\r
 \r
        do { // Let port switch settle.\r
 \r
        do { // Let port switch settle.\r
-       } while (Time_Left(TIMER_GEN));  \r
+       } while (Time_Left(TIMER_GEN));\r
 }\r
 \r
 \r
 }\r
 \r
 \r
@@ -340,7 +343,7 @@ void EnableBattery(unsigned char bat)
 void DisableBatteries(void)\r
 {\r
        // Turn off LEDs and disconnect batteries.\r
 void DisableBatteries(void)\r
 {\r
        // Turn off LEDs and disconnect batteries.\r
-       PORTB &= ~((1<<PB4)|(1<<PB5));  \r
+       PORTB &= ~((1<<PB4)|(1<<PB5));\r
 }\r
 \r
 \r
 }\r
 \r
 \r
@@ -356,7 +359,7 @@ void DisableBatteries(void)
 unsigned char RIDLookUp (void)\r
 {\r
        unsigned char i, found = FALSE;\r
 unsigned char RIDLookUp (void)\r
 {\r
        unsigned char i, found = FALSE;\r
-               \r
+\r
        // Lookup in the RID-table. If measured RID is within the limits\r
        // of an entry, those data are used, and TRUE is returned.\r
        for (i = 0 ; i < RID_TABLE_SIZE; i++) {\r
        // Lookup in the RID-table. If measured RID is within the limits\r
        // of an entry, those data are used, and TRUE is returned.\r
        for (i = 0 ; i < RID_TABLE_SIZE; i++) {\r
@@ -366,12 +369,12 @@ unsigned char RIDLookUp (void)
                                BattData.MaxCurrent = RID[i].Icharge;\r
                                BattData.MaxTime = RID[i].tCutOff;\r
                                BattData.MinCurrent = RID[i].ICutOff;\r
                                BattData.MaxCurrent = RID[i].Icharge;\r
                                BattData.MaxTime = RID[i].tCutOff;\r
                                BattData.MinCurrent = RID[i].ICutOff;\r
-                               \r
+\r
                                found = TRUE;\r
                        }\r
                }\r
        }\r
                                found = TRUE;\r
                        }\r
                }\r
        }\r
-       \r
+\r
        // If no valid entry is found, use defaults and return FALSE.\r
        if (!found) {\r
                BattData.Capacity = DEF_BAT_CAPACITY;\r
        // If no valid entry is found, use defaults and return FALSE.\r
        if (!found) {\r
                BattData.Capacity = DEF_BAT_CAPACITY;\r
@@ -379,7 +382,7 @@ unsigned char RIDLookUp (void)
                BattData.MaxTime = DEF_BAT_TIME_MAX;\r
                BattData.MinCurrent = DEF_BAT_CURRENT_MIN;\r
        }\r
                BattData.MaxTime = DEF_BAT_TIME_MAX;\r
                BattData.MinCurrent = DEF_BAT_CURRENT_MIN;\r
        }\r
-       \r
+\r
        return(found);\r
 }\r
 \r
        return(found);\r
 }\r
 \r
@@ -399,21 +402,21 @@ void NTCLookUp (void)
 {\r
        unsigned char i;\r
        unsigned char found = FALSE;\r
 {\r
        unsigned char i;\r
        unsigned char found = FALSE;\r
-       \r
+\r
        // Lookup in the NTC-table. Use the first entry which is equal or below\r
        // sampled NTC. Calculate temperature by using the index number, and the\r
        // difference between the measured NTC value and the one in the entry.\r
        for (i=0 ; (i < NTC_TABLE_SIZE) && (!found); i++)       {\r
                if (ADCS.rawNTC >= NTC[i].ADC) {\r
                        BattData.Temperature = (i<<2) ;\r
        // Lookup in the NTC-table. Use the first entry which is equal or below\r
        // sampled NTC. Calculate temperature by using the index number, and the\r
        // difference between the measured NTC value and the one in the entry.\r
        for (i=0 ; (i < NTC_TABLE_SIZE) && (!found); i++)       {\r
                if (ADCS.rawNTC >= NTC[i].ADC) {\r
                        BattData.Temperature = (i<<2) ;\r
-                       BattData.ADCSteps = NTC[i].ADCsteps;  \r
+                       BattData.ADCSteps = NTC[i].ADCsteps;\r
                        BattData.Temperature -= ((ADCS.rawNTC - NTC[i].ADC)<<1) / BattData.ADCSteps;\r
                        BattData.Temperature -= ((ADCS.rawNTC - NTC[i].ADC)<<1) / BattData.ADCSteps;\r
-                       \r
+\r
                        found = TRUE;  // Could be done with a break, but that violates MISRA.\r
                }\r
        }\r
                        found = TRUE;  // Could be done with a break, but that violates MISRA.\r
                }\r
        }\r
-       \r
-       // For safety, is temperature is greater than the NTC \r
+\r
+       // For safety, is temperature is greater than the NTC\r
        if (!found) {\r
                BattData.Temperature = 80;\r
        }\r
        if (!found) {\r
                BattData.Temperature = 80;\r
        }\r
index 1fa428a20682023f2d3a2357716adac43995c6f9..6b26f590cac6632619505317a9706edc8ccb1ab4 100644 (file)
 //******************************************************************************\r
 // RID-less charging (for BatteryStatusRefresh())\r
 //******************************************************************************\r
 //******************************************************************************\r
 // RID-less charging (for BatteryStatusRefresh())\r
 //******************************************************************************\r
+#ifdef EASYPACK550\r
+\r
+#warning "using EasyPack 66590 711 099 (550mAh) settings - mthomas, no warranty!"\r
+// RID not connected\r
+#define ALLOW_NO_RID                //!< Use default battery data if no matching entry found.\r
+#define DEF_BAT_CAPACITY       550  //!< Default battery capacity, in mAh.\r
+#define DEF_BAT_CURRENT_MAX    260  //!< Default maximum charge current, in mA.\r
+#define DEF_BAT_TIME_MAX    (5*60)  //!< Default maximum charge time, in minutes.\r
+//! Default minimum current to stop charge, in mA.\r
+#define DEF_BAT_CURRENT_MIN     10\r
+\r
+#else\r
+\r
 //#define ALLOW_NO_RID  //!< Use default battery data if no matching entry found.\r
 \r
 #define DEF_BAT_CAPACITY               0  //!< Default battery capacity, in mAh.\r
 //#define ALLOW_NO_RID  //!< Use default battery data if no matching entry found.\r
 \r
 #define DEF_BAT_CAPACITY               0  //!< Default battery capacity, in mAh.\r
@@ -57,6 +70,7 @@
 //! Default minimum current to stop charge, in mA.\r
 #define DEF_BAT_CURRENT_MIN    0\r
 \r
 //! Default minimum current to stop charge, in mA.\r
 #define DEF_BAT_CURRENT_MIN    0\r
 \r
+#endif /* EASYPACK550 */\r
 \r
 \r
 //******************************************************************************\r
 \r
 \r
 //******************************************************************************\r
index 9dbdde18c4cf8c6bcc5a93b03471ea840d4f048d..e4d5ff64c174469735dfc6378a7a4f84c7ee49cc 100644 (file)
@@ -115,7 +115,7 @@ unsigned char Initialize(unsigned char inp)
        Time_Init();\r
 \r
        // Attempt to get ADC-readings (also gets RID-data) from both batteries.\r
        Time_Init();\r
 \r
        // Attempt to get ADC-readings (also gets RID-data) from both batteries.\r
-       for (i = 0; i < 2; i++) {\r
+       for (i = 0; i < BATCONN; i++)   {\r
                EnableBattery(i);\r
                ADC_Wait();\r
                BatteryStatusRefresh();\r
                EnableBattery(i);\r
                ADC_Wait();\r
                BatteryStatusRefresh();\r
@@ -166,7 +166,7 @@ unsigned char BatteryControl(unsigned char inp)
 \r
        // Get ADC-readings, try to read EPROM, and start prequalification\r
        // of any uncharged battery.\r
 \r
        // Get ADC-readings, try to read EPROM, and start prequalification\r
        // of any uncharged battery.\r
-       for (i = 0; i < 2; i++) {\r
+       for (i = 0; i < BATCONN; i++) {\r
                if (BattControl[i].Enabled) {\r
                        EnableBattery(i);\r
                        ADC_Wait();\r
                if (BattControl[i].Enabled) {\r
                        EnableBattery(i);\r
                        ADC_Wait();\r
@@ -220,11 +220,13 @@ unsigned char Sleep(unsigned char inp)
 \r
                // If any batteries need charging, go to ST_BATCON.\r
                // Otherwise, keep sleeping.\r
 \r
                // If any batteries need charging, go to ST_BATCON.\r
                // Otherwise, keep sleeping.\r
-               for (i = 0; i < 2; i++) {\r
+               for (i = 0; i < BATCONN; i++) {\r
                        EnableBattery(i);\r
                        ADC_Wait();\r
                        EnableBattery(i);\r
                        ADC_Wait();\r
-                       if ((BatteryStatusRefresh()) && (!BattData.Charged)) {\r
-                               return(ST_BATCON);\r
+                       if ( BatteryStatusRefresh() ) {\r
+                               if ( !BattData.Charged ) {\r
+                                  return(ST_BATCON);\r
+                                }\r
                        }\r
                }\r
 \r
                        }\r
                }\r
 \r
@@ -275,6 +277,7 @@ void Doze(void)
                __sleep();                              // Go to sleep, wake up by WDT.\r
        }\r
        else {\r
                __sleep();                              // Go to sleep, wake up by WDT.\r
        }\r
        else {\r
+               // stay awake if PB6 is pulled low by master\r
                do {\r
                } while ( !(WatchdogFlag) );\r
        }\r
                do {\r
                } while ( !(WatchdogFlag) );\r
        }\r
index 9594f441213bbebb0bea1ee78b7a72a39d46cc56..699b93e5a939824f68380eb78a7a0ef5dbadfad2 100644 (file)
  *      AVR458: Charging Li-Ion Batteries with BC100\r
  *\r
  * \par Documentation\r
  *      AVR458: Charging Li-Ion Batteries with BC100\r
  *\r
  * \par Documentation\r
- *      For comprehensive code documentation, supported compilers, compiler \r
+ *      For comprehensive code documentation, supported compilers, compiler\r
  *      settings and supported devices see readme.html\r
  *\r
  * \author\r
  *      Atmel Corporation: http://www.atmel.com \n\r
  *      Support email: avr@atmel.com\r
  *\r
  *      settings and supported devices see readme.html\r
  *\r
  * \author\r
  *      Atmel Corporation: http://www.atmel.com \n\r
  *      Support email: avr@atmel.com\r
  *\r
- * \r
+ *\r
  * $Name$\r
  * $Revision: 2261 $\r
  * $RCSfile$\r
  * $Name$\r
  * $Revision: 2261 $\r
  * $RCSfile$\r
 #ifndef STATEFUNC_H\r
 #define STATEFUNC_H\r
 \r
 #ifndef STATEFUNC_H\r
 #define STATEFUNC_H\r
 \r
+//! number of connectors (1: just process A, 2 process A and B )\r
+#define BATCONN  1\r
+#if ( BATCONN < 1 ) || ( BATCONN > 2 )\r
+#error "Invalid BATCONN. Must be set to 1 or 2."\r
+#endif\r
 \r
 //******************************************************************************\r
 // Wanted SPI-mode\r
 \r
 //******************************************************************************\r
 // Wanted SPI-mode\r
@@ -36,7 +41,7 @@
 #define SPIMODE 0\r
 \r
 //! Sample on leading _falling_ edge, setup on trailing _rising_ edge.\r
 #define SPIMODE 0\r
 \r
 //! Sample on leading _falling_ edge, setup on trailing _rising_ edge.\r
-//#define SPIMODE 1    \r
+//#define SPIMODE 1\r
 \r
 \r
 //******************************************************************************\r
 \r
 \r
 //******************************************************************************\r
 // Error-flag bit identifiers\r
 //******************************************************************************\r
 //! Wrong jumper settings.\r
 // Error-flag bit identifiers\r
 //******************************************************************************\r
 //! Wrong jumper settings.\r
-#define   ERR_JUMPER_MISMATCH                          0x01  \r
+#define   ERR_JUMPER_MISMATCH                          0x01\r
 \r
 //! Both batteries disabled.\r
 \r
 //! Both batteries disabled.\r
-#define   ERR_NO_BATTERIES_ENABLED             0x02  \r
+#define   ERR_NO_BATTERIES_ENABLED             0x02\r
 \r
 //! PWM output too much/little.\r
 \r
 //! PWM output too much/little.\r
-#define   ERR_PWM_CONTROL                                      0x04  \r
+#define   ERR_PWM_CONTROL                                      0x04\r
 \r
 //! Battery temperature out of limits.\r
 \r
 //! Battery temperature out of limits.\r
-#define   ERR_BATTERY_TEMPERATURE              0x08  \r
+#define   ERR_BATTERY_TEMPERATURE              0x08\r
 \r
 //! Battery couldn't be charged.\r
 \r
 //! Battery couldn't be charged.\r
-#define   ERR_BATTERY_EXHAUSTED                        0x10  \r
+#define   ERR_BATTERY_EXHAUSTED                        0x10\r
 \r
 \r
 //******************************************************************************\r
 \r
 \r
 //******************************************************************************\r
index 9b809441bd25a64e92b458b8c553801e81d8bc68..602b3f7ca8c65f910320f5aff79bc49dc49ac320 100644 (file)
  */\r
 struct Batteries_struct\r
 {\r
  */\r
 struct Batteries_struct\r
 {\r
+#if 0\r
+#warning "no bitfield, used for debugging - mthomas"\r
+       unsigned char Present   ; //!< Battery found. (TRUE/FALSE)\r
+       unsigned char Charged   ; //!< Battery fully charged. (TRUE/FALSE)\r
+       unsigned char Low       ; //!< Battery low voltage. (TRUE/FALSE)\r
+       unsigned char Exhausted ; //!< Battery exhausted. (TRUE/FALSE)\r
+       unsigned char HasRID    ; //!< Battery has resistor ID. (TRUE/FALSE)\r
+#else\r
        unsigned char Present   : 1; //!< Battery found. (TRUE/FALSE)\r
        unsigned char Charged   : 1; //!< Battery fully charged. (TRUE/FALSE)\r
        unsigned char Low       : 1; //!< Battery low voltage. (TRUE/FALSE)\r
        unsigned char Exhausted : 1; //!< Battery exhausted. (TRUE/FALSE)\r
        unsigned char HasRID            : 1; //!< Battery has resistor ID. (TRUE/FALSE)\r
        unsigned char Present   : 1; //!< Battery found. (TRUE/FALSE)\r
        unsigned char Charged   : 1; //!< Battery fully charged. (TRUE/FALSE)\r
        unsigned char Low       : 1; //!< Battery low voltage. (TRUE/FALSE)\r
        unsigned char Exhausted : 1; //!< Battery exhausted. (TRUE/FALSE)\r
        unsigned char HasRID            : 1; //!< Battery has resistor ID. (TRUE/FALSE)\r
+#endif\r
        unsigned char Circuit;       //!< Battery safety circuit (family id).\r
        signed char Temperature;     //!< Battery temperature, in centigrade.\r
        unsigned char ADCSteps;      //!< ADC steps per half degree.\r
        unsigned char Circuit;       //!< Battery safety circuit (family id).\r
        signed char Temperature;     //!< Battery temperature, in centigrade.\r
        unsigned char ADCSteps;      //!< ADC steps per half degree.\r
@@ -62,10 +71,10 @@ struct Battery_struct
 {\r
        //! Battery valid, enabling allowed. (TRUE/FALSE)\r
        unsigned char Enabled           : 1;\r
 {\r
        //! Battery valid, enabling allowed. (TRUE/FALSE)\r
        unsigned char Enabled           : 1;\r
-       \r
+\r
        //! Disconnect allowed. (TRUE/FALSE)\r
        unsigned char DisconnectAllowed : 1;\r
        //! Disconnect allowed. (TRUE/FALSE)\r
        unsigned char DisconnectAllowed : 1;\r
-       \r
+\r
        //! Inhibit charging. (TRUE/FALSE) \todo Changed by master?\r
        unsigned char ChargeInhibit     : 1;\r
 };\r
        //! Inhibit charging. (TRUE/FALSE) \todo Changed by master?\r
        unsigned char ChargeInhibit     : 1;\r
 };\r
index da54f367067a7744e8cef7ac15e147e5a256c2b6..021982aa32079f3d113bf12ee05a57e811cbaa61 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,52 +1,93 @@
-2008-04-07 Kevin Rosenberg <kevin@rosenberg.net>\r
-       * BaseTinyFirmware/IAR: Port Martin's changes from 2008-04-03\r
-       to IAR\r
-       \r
-2008-04-03 Martin Thomas <mthomas@rhrk.uni-kl.de>\r
-       * BaseMegaFirmware/GCC: Experimental Master Code for the ATmega644\r
-       with basic "drivers" for\r
-               - keys incl. power-off with debounceing\r
-               - 74HC595 low-level "software-SPI"\r
-               - LEDs though 74HC595\r
-               - Power-off and Slave-Reset control though 74HC595\r
-               - hardware SPI for comm. with slave\r
-               - simple test-function for communication with slave\r
-       * BaseTinyFirmware/GCC/statefunc.c: \r
-               - prevent unneeded writes to eeprom if init fails\r
-               - prevent slave from entering sleep-mode standby if\r
-               "MASTER_INT" is low (so SPI communication with master is\r
-               possible even during the "8-second watchdog delay")\r
-\r
-2008-03-30 Kevin Rosenberg <kevin@rosenberg.net>\r
-       * BaseTinyFirmware/GCC Makefile's improved with more listing\r
-       output as well as added -Wl,-gc-sections option which stops\r
-       crashes using linker relaxation [thanks to Eric Weddington]\r
-\r
-2008-03-28 Kevin Rosenberg <kevin@rosenberg.net>\r
-       * BaseTinyFirmware/GCC/avr463/Makefile: Added -Wl,-relax to linker\r
-       flags. On my system this crashes avr-ld.exe, but others have\r
-       reported a large reduction in firmware size with this option. I\r
-       added this option for others to try.  *\r
-       BaseTinyFirmware/GCC/avr458/Makefile: Added missing file\r
-       \r
-2008-03-14 Martin Thomas <mthomas@rhrk.uni-kl.de>\r
-       Improvements to BaseTinyFirmware:\r
-       * added "volatile" to structure object and array declarations for\r
-       objects sed in main-thread and ISRs. I'm not sure about the\r
-       current state of implicitly "guaranteed" accesses in (avr-)gcc but\r
-       it should be a "better safe than sorry" extension.\r
-       * enveloped access to timer-values in timer.c to make them\r
-       "atomic" since they are unsigned long\r
-       * "atomic" access to singned int and unsigned int members of ADCS\r
-       * it maybe better to have one place to globally enable\r
-       interrupts ("sei").  Done in "initialize" now and not several\r
-       times in the driver init-functions.\r
-       * changed some space to tab as in the original code\r
-       * added header files to the AVR-Studio project workspace\r
-       * added -lm to the linker-options in the AVR Studio gcc-plugin,\r
-       not important for the basic application but might be good if\r
-       someone uses the ode as a base for own developments\r
-\r
-2008-03-12 Kevin Rosenberg <kevin@rosenberg.net>\r
-       * Initial GCC port performed and compiles without error\r
-       * Warning: Not yet tested on BC100 hardware!\r
+2008-06-26 Kevin Rosenberg <kevin@rosenberg.net>
+       * BaseTinyFirmwave/IAR: Port Martin's changes from 2008-06-12 to IAR
+
+2008-06-12 Martin Thomas <mthomas@rhrk.uni-kl.de>
+       Modifications to test AVR458 (LiIon). Tests done with
+       Varta EasyPack #66590 711 099: the BC100 at least enters
+       the charging-state now. Charging itself not fully monitored
+       so far. No tests done with NiMH (AVR463).
+
+       * BaseTinyFirmware/GCC/battery.c
+         - NTCLookUp(): type of adcs_rawNTC_tmp to uint16_t
+         - BatteryDataRefresh() avoid unneeded EEPROM writes
+       * BaseTinyFirmware/GCC/statefunc.h
+         - added BATCONN to set number of connectors to scan
+           (1=Battery A only, 2=Battery A and B)
+       * BaseTinyFirmware/GCC/structs.h
+         - Batteries_struct: option do disable bitfield (default: use bitfield)
+       * BaseTinyFirmware/GCC/statefunc.c
+         - sleep(): split if ( ... && ... ) into two ifs for easier debugging
+       * BaseTinyFirmware/GCC/LIIONspecs.h
+         - added comment with technical information on used battery
+           from Varta PoliFlex handbook and battery's datasheet
+       * Project settings:
+         - added -DEASYPACK550 in custom options [all files]
+         - NOT added: settings mentioned in entry "2008-04-21"
+           since they cause wrong code with avr-gcc 4.1.2/avr-binutils 2.17
+           (interrupt-vector not linked)
+       * BaseTinyFirmware/GCC/battery.h
+         - added DEF_BAT_*-values for the test-battery which
+           are enabled if EASYPACK550 is defined, RID not used,
+           #warning to indicate fixed settings (= 6 warnings on rebuild)
+         - NO warranty for these settings but even if something
+           goes wrong in firmware or BC100-hardware the battery
+           protects itself with it's  internal circuits.
+       * BaseMegaFirmware/GCC/bc100_slave.c
+         - bc100_slave_test(): added battery-data readout
+
+2008-04-21 Kevin Rosenberg <kevin@rosenberg.net>
+       * BaseTinyFirmware/GCC/*/Makefile: Add GCC optimizations from
+       Eric Weddington
+
+2008-04-07 Kevin Rosenberg <kevin@rosenberg.net>
+       * BaseTinyFirmware/IAR: Port Martin's changes from 2008-04-03
+       to IAR
+
+2008-04-03 Martin Thomas <mthomas@rhrk.uni-kl.de>
+       * BaseMegaFirmware/GCC: Experimental Master Code for the ATmega644
+       with basic "drivers" for
+               - keys incl. power-off with debounceing
+               - 74HC595 low-level "software-SPI"
+               - LEDs though 74HC595
+               - Power-off and Slave-Reset control though 74HC595
+               - hardware SPI for comm. with slave
+               - simple test-function for communication with slave
+       * BaseTinyFirmware/GCC/statefunc.c:
+               - prevent unneeded writes to eeprom if init fails
+               - prevent slave from entering sleep-mode standby if
+               "MASTER_INT" is low (so SPI communication with master is
+               possible even during the "8-second watchdog delay")
+
+2008-03-30 Kevin Rosenberg <kevin@rosenberg.net>
+       * BaseTinyFirmware/GCC Makefile's improved with more listing
+       output as well as added -Wl,-gc-sections option which stops
+       crashes using linker relaxation [thanks to Eric Weddington]
+
+2008-03-28 Kevin Rosenberg <kevin@rosenberg.net>
+       * BaseTinyFirmware/GCC/avr463/Makefile: Added -Wl,-relax to linker
+       flags. On my system this crashes avr-ld.exe, but others have
+       reported a large reduction in firmware size with this option. I
+       added this option for others to try.  *
+       BaseTinyFirmware/GCC/avr458/Makefile: Added missing file
+
+2008-03-14 Martin Thomas <mthomas@rhrk.uni-kl.de>
+       Improvements to BaseTinyFirmware:
+       * added "volatile" to structure object and array declarations for
+       objects sed in main-thread and ISRs. I'm not sure about the
+       current state of implicitly "guaranteed" accesses in (avr-)gcc but
+       it should be a "better safe than sorry" extension.
+       * enveloped access to timer-values in timer.c to make them
+       "atomic" since they are unsigned long
+       * "atomic" access to signed int and unsigned int members of ADCS
+       * it maybe better to have one place to globally enable
+       interrupts ("sei").  Done in "initialize" now and not several
+       times in the driver init-functions.
+       * changed some space to tab as in the original code
+       * added header files to the AVR-Studio project workspace
+       * added -lm to the linker-options in the AVR Studio gcc-plugin,
+       not important for the basic application but might be good if
+       someone uses the code as a base for own developments
+
+2008-03-12 Kevin Rosenberg <kevin@rosenberg.net>
+       * Initial GCC port performed and compiles without error
+       * Warning: Not yet tested on BC100 hardware!