From: Kevin Rosenberg Date: Fri, 27 Jun 2008 01:04:50 +0000 (-0600) Subject: Commit mthomas changes to GCC and port those changes to IAR X-Git-Url: http://git.kpe.io/?p=avr_bc100.git;a=commitdiff_plain;h=65612c4c7df34cdae10f9427ace6fd9e9e430d05 Commit mthomas changes to GCC and port those changes to IAR --- diff --git a/BaseMegaFirmware/GCC/bc100_slave.c b/BaseMegaFirmware/GCC/bc100_slave.c index a03a334..2ff06a8 100644 --- a/BaseMegaFirmware/GCC/bc100_slave.c +++ b/BaseMegaFirmware/GCC/bc100_slave.c @@ -96,6 +96,45 @@ uint8_t bc100_slave_test(void) } myprintf_P("average IBAT %d [mA]\n", ADCS.avgIBAT); + Batteries_t BattData; + myprintf_P("Current Battery:\n"); + out = BC100_SLAVE_READ | BC100_SLAVE_SRAM | sizeof(BattData); + SPI_rw( out ); + out = ADR_BATTDATA; + in = SPI_rw( out ); + myprintf_P("In1 : 0x%02x (expected 0xcc)\n", in ); + in = SPI_rw( dummy ); + myprintf_P("In2 : 0x%02x (expected 0xbb)\n", in ); + i = sizeof(BattData); + while ( i-- > 0 ) { + *( (unsigned char*)&BattData + i ) = SPI_rw(dummy); + } + if ( BattData.Present ) { + myprintf_P("Battery found\n"); + if ( BattData.Charged ) { + myprintf_P("- fully charged\n"); + } + if ( BattData.Low ) { + myprintf_P("- low voltage\n"); + } + if ( BattData.Exhausted) { + myprintf_P("- exhausted\n"); + } + if ( BattData.HasRID) { + myprintf_P("- has a ID-Resistor\n"); + } + myprintf_P("Safety circuit ID %d\n", BattData.Circuit ); + myprintf_P("Tempearture %d centi-degree C\n", BattData.Temperature ); + myprintf_P("ADCSteps/half degree %d\n", BattData.ADCSteps); + myprintf_P("Capacity %d mAh\n", BattData.Capacity); + myprintf_P("max. Current %d mA\n", BattData.MaxCurrent); + myprintf_P("max. cut-off Time %d min\n", BattData.MaxTime); + myprintf_P("min. cut-off Current %d mA\n", BattData.MinCurrent); + } + else { + myprintf_P("Battery not found\n"); + } + SPI_release(); return err; diff --git a/BaseTinyFirmware/GCC/ADC.c b/BaseTinyFirmware/GCC/ADC.c index 50814ca..3ed65b8 100644 --- a/BaseTinyFirmware/GCC/ADC.c +++ b/BaseTinyFirmware/GCC/ADC.c @@ -159,6 +159,7 @@ ISR(ADC_vect) // Scale voltage according to jumper setting. ADCS.VBAT = ScaleU(eeprom_read_byte(&VBAT_RANGE), (unsigned int)ADC); // ADC is a short. + __asm__ __volatile__ ("NOP"::); Next=0x17; // Signed = TRUE; // Next conversion is bipolar. Halves sensitivity! break; diff --git a/BaseTinyFirmware/GCC/LIIONspecs.h b/BaseTinyFirmware/GCC/LIIONspecs.h index e662b1e..5a30b35 100644 --- a/BaseTinyFirmware/GCC/LIIONspecs.h +++ b/BaseTinyFirmware/GCC/LIIONspecs.h @@ -28,13 +28,45 @@ #ifndef LIIONSPECS_H #define LIIONSPECS_H +/* + Information on Varta EasyPack 66590 711 099 collected by M. Thomas: + + Connections: + Pad 1 - marked with + : Battery + + Pad 2 - not marked : ID-Resistor (RID) to Pad 4, 3.9kOhm + Pad 3 - not marked : NTC to Pad 4, 10kOhm B=3435K + Pad 4 - marked with - : Battery - + -> 1Wire not available + + Capacity: nom. 550mAh (min. 520 mAh) at 0.2C from 4.2V to 3.0V + Nominal Voltage: 3.7V, Range: 2.75V - 4.2V + Charging Method: Constant Current + Constant Voltage + Charge Voltage: 4.2V + Initial charge Current: std. 260mA, rapid 520mA + Charging cut of either: + (a) at time: std. 5h, rapid 3h + (b) by min current of 10mA + Temparature 0 to 45degC + Discharge max. Current: 1040mA + Protection: + overcharge : 4.35V (resume at 4.0V) + discharge : 2.2V + overcurrent: 3.0A + + Additional from PoliFlex-Handbook: + - fast charging in termperatur-range 0 - 45degC + - max charge current 1C (=550mA here) + - max charge current has to be limited stricly to 4,2V +/- 50mV + - stop charge 3h after start of when current is <0.02C (=11mA here) +*/ + //****************************************************************************** // Cell limits //****************************************************************************** // This is for common NiMH batteries. #define CELL_VOLTAGE_SAFETY 0 /*!< \brief Buffer for unmatched batteries. - * + * * If we are charging a multicell battery and the cells aren't matched, we * may risk overcharging at least one. Therefore, we may subtract this constant * per additional cell in battery to allow for a "buffer". @@ -86,7 +118,7 @@ //! Charge voltage hysteresis, in mV. #define BAT_VOLTAGE_HYST 10 -//! Maximum battery voltage, in mV. +//! Maximum battery voltage, in mV. #define BAT_VOLTAGE_MAX (CELL_VOLTAGE_MAX * BAT_CELL_NUMBER) - \ ((BAT_CELL_NUMBER - 1) * CELL_VOLTAGE_SAFETY) diff --git a/BaseTinyFirmware/GCC/avr458/Makefile b/BaseTinyFirmware/GCC/avr458/Makefile index c2d1462..844d3db 100644 --- a/BaseTinyFirmware/GCC/avr458/Makefile +++ b/BaseTinyFirmware/GCC/avr458/Makefile @@ -15,6 +15,7 @@ COMMON = -mmcu=$(MCU) CFLAGS = $(COMMON) CFLAGS += -gdwarf-2 -std=gnu99 -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums CFLAGS += -Wall -Wstrict-prototypes -Wundef -Wa,-adhlns=./$(*F).lst +CFLAGS += -fno-inline-small-functions -fno-split-wide-types CFLAGS += -MMD -MP -MF dep/$(@F).d CFLAGS += -DLIION diff --git a/BaseTinyFirmware/GCC/avr463/Makefile b/BaseTinyFirmware/GCC/avr463/Makefile index c2c00b0..53aebb1 100644 --- a/BaseTinyFirmware/GCC/avr463/Makefile +++ b/BaseTinyFirmware/GCC/avr463/Makefile @@ -14,6 +14,7 @@ COMMON = -mmcu=$(MCU) ## Compile options common for all C compilation units. CFLAGS = $(COMMON) CFLAGS += -gdwarf-2 -std=gnu99 -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -ffunction-sections +CFLAGS += -fno-inline-small-functions -fno-split-wide-types CFLAGS += -Wall -Wstrict-prototypes -Wundef -Wa,-adhlns=./$(*F).lst CFLAGS += -MMD -MP -MF dep/$(@F).d CFLAGS += -DNIMH diff --git a/BaseTinyFirmware/GCC/battery.c b/BaseTinyFirmware/GCC/battery.c index b361711..97c9f3b 100644 --- a/BaseTinyFirmware/GCC/battery.c +++ b/BaseTinyFirmware/GCC/battery.c @@ -13,14 +13,14 @@ * * \par Documentation - * For comprehensive code documentation, supported compilers, compiler + * For comprehensive code documentation, supported compilers, compiler * settings and supported devices see readme.html * * \author * Atmel Corporation: http://www.atmel.com \n * Support email: avr@atmel.com * - * + * * $Name$ * $Revision: 2299 $ * $RCSfile$ @@ -124,7 +124,7 @@ const NTC_Lookup_t NTC[NTC_TABLE_SIZE] = { }; */ - + //****************************************************************************** // Functions //****************************************************************************** @@ -132,7 +132,7 @@ const NTC_Lookup_t NTC[NTC_TABLE_SIZE] = { * * Stores current capacity, then attempts to refresh battery status.\n * If the refresh is successful, old capacity is compared with the new one. - * + * * \retval FALSE Battery is disconnected, or capacity has changed. * \retval TRUE All OK. */ @@ -140,14 +140,14 @@ unsigned char BatteryCheck(void) { unsigned char success = TRUE; unsigned int oldCapacity; - + // Save to see if battery data has changed. - oldCapacity = BattData.Capacity; - + oldCapacity = BattData.Capacity; + if (!BatteryStatusRefresh()) { success = FALSE; // Battery not present or RID was invalid. } - + if (oldCapacity != BattData.Capacity) { success = FALSE; // Battery configuration has changed. } @@ -176,7 +176,7 @@ unsigned char BatteryStatusRefresh(void) unsigned char sreg_saved; unsigned int adcs_VBAT_tmp; signed int adcs_avgIBAT_tmp; - + BattData.Present = FALSE; BattData.Charged = FALSE; BattData.Low = TRUE; @@ -208,7 +208,7 @@ unsigned char BatteryStatusRefresh(void) // If we are not charging, yet VBAT is above safe limit, battery is present. // If we are charging and there's a current flowing, the battery is present. - + /*! \todo If ABORT_IF_PWM_MAX is defined this last check battery presence * check is redundant since charging will be aborted due to low current at * max duty cycle. That is preferrable since the charge current reading is @@ -250,13 +250,13 @@ unsigned char BatteryDataRefresh(void) unsigned char offset; unsigned char i, crc, family, temp, page; unsigned char success; - + // Look for EPROM and read 4 pages of 32 bytes each worth of data, if found. for (page = 0; page < 4; page++) { success = FALSE; - + if (OWI_DetectPresence(OWIBUS) == OWIBUS) { - + // Presence detected, check type and CRC. OWI_SendByte(OWI_ROM_READ, OWIBUS); family = OWI_ReceiveByte(OWIBUS); @@ -286,14 +286,14 @@ unsigned char BatteryDataRefresh(void) // and writing it to EEPROM. if (OWI_ComputeCRC8(OWI_ReceiveByte(OWIBUS),crc) == 0) { crc = 0; - + // Fill page with data. for (i=0; i<32; i++) { temp = OWI_ReceiveByte(OWIBUS); crc = OWI_ComputeCRC8(temp, crc); eeprom_write_byte(&BattEEPROM[page][i], temp); } - + if (OWI_ComputeCRC8(OWI_ReceiveByte(OWIBUS),crc) == 0) { success = TRUE; // Data read OK } @@ -301,7 +301,7 @@ unsigned char BatteryDataRefresh(void) } } else { // Wrong device type. } - } else { // No device found. + } else { // No device found. } } else { // No presence detected on one-wire bus. } @@ -309,7 +309,10 @@ unsigned char BatteryDataRefresh(void) // Erase local EEPROM page if there were any errors during transfer. if (!success) { for (i=0; i<32; i++) { - eeprom_write_byte(&BattEEPROM[page][i], 0); + // mthomas: avoid unneeded writes + if ( eeprom_read_byte( &BattEEPROM[page][i] ) != 0 ) { + eeprom_write_byte(&BattEEPROM[page][i], 0); + } } } } @@ -338,10 +341,10 @@ void EnableBattery(unsigned char bat) PORTB |= (1 << (PB4+bat)); // Disconnect other battery. - PORTB &= ~(1<<(PB5-bat)); + PORTB &= ~(1<<(PB5-bat)); do { // Let port switch settle. - } while (Time_Left(TIMER_GEN)); + } while (Time_Left(TIMER_GEN)); } @@ -352,7 +355,7 @@ void EnableBattery(unsigned char bat) void DisableBatteries(void) { // Turn off LEDs and disconnect batteries. - PORTB &= ~((1<= NTC[i].ADCV) { BattData.Temperature = (i<<2) ; - BattData.ADCSteps = NTC[i].ADCsteps; + BattData.ADCSteps = NTC[i].ADCsteps; BattData.Temperature -= ((adcs_rawNTC_tmp - NTC[i].ADCV)<<1) / BattData.ADCSteps; - + found = TRUE; // Could be done with a break, but that violates MISRA. } } - - // For safety, is temperature is greater than the NTC + + // For safety, is temperature is greater than the NTC if (!found) { BattData.Temperature = 80; } diff --git a/BaseTinyFirmware/GCC/battery.h b/BaseTinyFirmware/GCC/battery.h index bb76eaf..2ad0770 100644 --- a/BaseTinyFirmware/GCC/battery.h +++ b/BaseTinyFirmware/GCC/battery.h @@ -51,6 +51,20 @@ //****************************************************************************** // RID-less charging (for BatteryStatusRefresh()) //****************************************************************************** + +#ifdef EASYPACK550 + +#warning "using EasyPack 66590 711 099 (550mAh) settings - mthomas, no warranty!" +// RID not connected +#define ALLOW_NO_RID //!< Use default battery data if no matching entry found. +#define DEF_BAT_CAPACITY 550 //!< Default battery capacity, in mAh. +#define DEF_BAT_CURRENT_MAX 260 //!< Default maximum charge current, in mA. +#define DEF_BAT_TIME_MAX (5*60) //!< Default maximum charge time, in minutes. +//! Default minimum current to stop charge, in mA. +#define DEF_BAT_CURRENT_MIN 10 + +#else + //#define ALLOW_NO_RID //!< Use default battery data if no matching entry found. #define DEF_BAT_CAPACITY 0 //!< Default battery capacity, in mAh. @@ -59,6 +73,7 @@ //! Default minimum current to stop charge, in mA. #define DEF_BAT_CURRENT_MIN 0 +#endif /* EASYPACK550 */ //****************************************************************************** diff --git a/BaseTinyFirmware/GCC/chargefunc.c b/BaseTinyFirmware/GCC/chargefunc.c index 5f441b7..b3db020 100644 --- a/BaseTinyFirmware/GCC/chargefunc.c +++ b/BaseTinyFirmware/GCC/chargefunc.c @@ -12,14 +12,14 @@ * AVR463: Charging NiMH Batteries with BC100 * * \par Documentation - * For comprehensive code documentation, supported compilers, compiler + * For comprehensive code documentation, supported compilers, compiler * settings and supported devices see readme.html * * \author * Atmel Corporation: http://www.atmel.com \n * Support email: avr@atmel.com * - * + * * $Name$ * $Revision: 2299 $ * $RCSfile$ @@ -84,7 +84,7 @@ unsigned char ConstantCurrent(void) wasStopped = FALSE; unsigned char sreg_saved; signed int adcs_avgIBAT_tmp; - + do { // Wait for ADC conversions to complete. ADC_Wait(); @@ -99,7 +99,7 @@ unsigned char ConstantCurrent(void) // Continue charging! if (wasStopped) { wasStopped = FALSE; - + // Timer variables are not reset by this. Time_Start(); } @@ -113,7 +113,7 @@ unsigned char ConstantCurrent(void) // +/- BAT_CURRENT_HYST. if ((adcs_avgIBAT_tmp < 0) || (adcs_avgIBAT_tmp < (ChargeParameters.Current - BAT_CURRENT_HYST))) { - + if(!PWM_IncrementDutyCycle()) { #ifdef ABORT_IF_PWM_MAX // If the duty cycle cannot be incremented, flag error and @@ -125,7 +125,7 @@ unsigned char ConstantCurrent(void) } } else if ((adcs_avgIBAT_tmp >= 0) && (adcs_avgIBAT_tmp > (ChargeParameters.Current + BAT_CURRENT_HYST))) { - + if(!PWM_DecrementDutyCycle()) { #ifdef ABORT_IF_PWM_MIN // If the duty cycle cannot be decremented, flag error and @@ -165,12 +165,12 @@ unsigned char ConstantVoltage(void) wasStopped = FALSE; unsigned char sreg_saved; unsigned int adcs_VBAT_tmp; - + do{ - + // Wait for ADC conversions to complete. ADC_Wait(); - + // If Master has flagged for a charge inhibit, pause charging. // (This is to prevent damage during prolonged serial communication.) if (eeprom_read_byte(&BattControl[BattActive]) & BIT_BATTERY_CHARGE_INHIBIT) { @@ -178,16 +178,16 @@ unsigned char ConstantVoltage(void) Time_Stop(); OCR1B = 0; } - + else { // Continue charging! if (wasStopped) { wasStopped = FALSE; - + // Timer variables aren't reset by this. Time_Start(); } - + sreg_saved = SREG; cli(); adcs_VBAT_tmp = ADCS.VBAT; @@ -237,7 +237,7 @@ unsigned char ConstantVoltage(void) * * The function also checks if the battery temperature is within limits, * if mains is OK, and if BatteryCheck() returns TRUE. - * If an error is detected, the associated errorflag is set and + * If an error is detected, the associated errorflag is set and * ChargeParameters.NextState is changed to an appropriate state. * * \retval TRUE Halt now. @@ -256,7 +256,7 @@ unsigned char HaltNow(void) unsigned int adcs_rawNTC_tmp, adcs_VBAT_tmp; signed int adcs_avgIBAT_tmp; unsigned char sreg_saved; - + // Wait for a full ADC-cycle to finish. ADC_Wait(); @@ -265,29 +265,29 @@ unsigned char HaltNow(void) // (Gets overridden if either mains is failing, or the battery changes.) for (i = 0x01; i != 0; i <<= 1) { if (HaltParameters.HaltFlags & i) { - + sreg_saved = SREG; cli(); adcs_VBAT_tmp = ADCS.VBAT; adcs_avgIBAT_tmp = ADCS.avgIBAT; SREG = sreg_saved; - + switch (i) { // Is VBAT less than the recorded maximum? case HALT_VOLTAGE_DROP: // Update VBATMax if VBAT is higher. Evaluate for halt otherwise. if (adcs_VBAT_tmp > HaltParameters.VBATMax) { HaltParameters.VBATMax = adcs_VBAT_tmp; - } else if((HaltParameters.VBATMax - adcs_VBAT_tmp) >= + } else if((HaltParameters.VBATMax - adcs_VBAT_tmp) >= HaltParameters.VoltageDrop) { halt = TRUE; } break; - + // Has VBAT reached the maximum limit? - case HALT_VOLTAGE_MAX: - + case HALT_VOLTAGE_MAX: + if (adcs_VBAT_tmp >= HaltParameters.VoltageMax) { halt = TRUE; } @@ -296,16 +296,16 @@ unsigned char HaltNow(void) // Has IBAT reached the minimum limit? case HALT_CURRENT_MIN: - + if (adcs_avgIBAT_tmp <= HaltParameters.CurrentMin) { halt = TRUE; } break; - - + + // Is the temperature rising too fast? case HALT_TEMPERATURE_RISE: - + sreg_saved = SREG; cli(); adcs_rawNTC_tmp = ADCS.rawNTC; @@ -316,12 +316,12 @@ unsigned char HaltNow(void) if (adcs_rawNTC_tmp > HaltParameters.LastNTC) { HaltParameters.LastNTC = adcs_rawNTC_tmp; Time_Set(TIMER_TEMP,0,30,0); - + // Is the increase in temperature greater than the set threshold? } else if ((HaltParameters.LastNTC - adcs_rawNTC_tmp) >= (BattData.ADCSteps * HaltParameters.TemperatureRise)) { - - // If this happened within a timeframe of 30 seconds, the + + // If this happened within a timeframe of 30 seconds, the // temperature is rising faster than we want. // If not, update LastNTC and reset timer. if (Time_Left(TIMER_TEMP)) { @@ -332,29 +332,31 @@ unsigned char HaltNow(void) } } break; - - + + // Is there any time left? - case HALT_TIME: - + case HALT_TIME: + if (!Time_Left(TIMER_CHG)) { halt = TRUE; - - // If exhaustion flagging is selected, stop the PWM, disable the + + // If exhaustion flagging is selected, stop the PWM, disable the // battery and flag it as exhausted. Make ST_ERROR next state. if (HaltParameters.HaltFlags & HALT_FLAG_EXHAUSTION) { PWM_Stop(); + Battery_t tmp = eeprom_read_byte(&BattControl[BattActive]); tmp &= ~BIT_BATTERY_ENABLED; // Enabled = FALSE; eeprom_write_byte(&BattControl[BattActive], tmp); + BattData.Exhausted = TRUE; SetErrorFlag(ERR_BATTERY_EXHAUSTED); ChargeParameters.NextState = ST_ERROR; } } break; - - + + default: // Shouldn't end up here, but is needed for MISRA compliance. break; } @@ -366,7 +368,7 @@ unsigned char HaltNow(void) // Battery too cold or hot? if ((BattData.Temperature <= HaltParameters.TemperatureMin) || (BattData.Temperature >= HaltParameters.TemperatureMax)) { - + PWM_Stop(); SetErrorFlag(ERR_BATTERY_TEMPERATURE); ChargeParameters.NextState = ST_ERROR; diff --git a/BaseTinyFirmware/GCC/statefunc.c b/BaseTinyFirmware/GCC/statefunc.c index 9fc0ae5..e0e2659 100644 --- a/BaseTinyFirmware/GCC/statefunc.c +++ b/BaseTinyFirmware/GCC/statefunc.c @@ -123,7 +123,7 @@ unsigned char Initialize(unsigned char inp) sei(); // Attempt to get ADC-readings (also gets RID-data) from both batteries. - for (i = 0; i < 2; i++) { + for (i = 0; i < BATCONN; i++) { EnableBattery(i); ADC_Wait(); BatteryStatusRefresh(); @@ -174,7 +174,7 @@ unsigned char BatteryControl(unsigned char inp) // Get ADC-readings, try to read EPROM, and start prequalification // of any uncharged battery. - for (i = 0; i < 2; i++) { + for (i = 0; i < BATCONN; i++) { if (eeprom_read_byte(&BattControl[i]) & BIT_BATTERY_ENABLED) { EnableBattery(i); ADC_Wait(); @@ -228,11 +228,13 @@ unsigned char Sleep(unsigned char inp) // If any batteries need charging, go to ST_BATCON. // Otherwise, keep sleeping. - for (i = 0; i < 2; i++) { + for (i = 0; i < BATCONN; i++) { EnableBattery(i); ADC_Wait(); - if ((BatteryStatusRefresh()) && (!BattData.Charged)) { - return(ST_BATCON); + if ( BatteryStatusRefresh() ) { + if ( !BattData.Charged ) { + return(ST_BATCON); + } } } @@ -282,6 +284,7 @@ void Doze(void) sleep_cpu(); // Go to sleep, wake up by WDT. } else { + // stay awake if PB6 is pulled low by master do { } while ( !(WatchdogFlag) ); } diff --git a/BaseTinyFirmware/GCC/statefunc.h b/BaseTinyFirmware/GCC/statefunc.h index 9594f44..699b93e 100644 --- a/BaseTinyFirmware/GCC/statefunc.h +++ b/BaseTinyFirmware/GCC/statefunc.h @@ -10,14 +10,14 @@ * AVR458: Charging Li-Ion Batteries with BC100 * * \par Documentation - * For comprehensive code documentation, supported compilers, compiler + * For comprehensive code documentation, supported compilers, compiler * settings and supported devices see readme.html * * \author * Atmel Corporation: http://www.atmel.com \n * Support email: avr@atmel.com * - * + * * $Name$ * $Revision: 2261 $ * $RCSfile$ @@ -28,6 +28,11 @@ #ifndef STATEFUNC_H #define STATEFUNC_H +//! number of connectors (1: just process A, 2 process A and B ) +#define BATCONN 1 +#if ( BATCONN < 1 ) || ( BATCONN > 2 ) +#error "Invalid BATCONN. Must be set to 1 or 2." +#endif //****************************************************************************** // Wanted SPI-mode @@ -36,7 +41,7 @@ #define SPIMODE 0 //! Sample on leading _falling_ edge, setup on trailing _rising_ edge. -//#define SPIMODE 1 +//#define SPIMODE 1 //****************************************************************************** @@ -53,19 +58,19 @@ // Error-flag bit identifiers //****************************************************************************** //! Wrong jumper settings. -#define ERR_JUMPER_MISMATCH 0x01 +#define ERR_JUMPER_MISMATCH 0x01 //! Both batteries disabled. -#define ERR_NO_BATTERIES_ENABLED 0x02 +#define ERR_NO_BATTERIES_ENABLED 0x02 //! PWM output too much/little. -#define ERR_PWM_CONTROL 0x04 +#define ERR_PWM_CONTROL 0x04 //! Battery temperature out of limits. -#define ERR_BATTERY_TEMPERATURE 0x08 +#define ERR_BATTERY_TEMPERATURE 0x08 //! Battery couldn't be charged. -#define ERR_BATTERY_EXHAUSTED 0x10 +#define ERR_BATTERY_EXHAUSTED 0x10 //****************************************************************************** diff --git a/BaseTinyFirmware/GCC/structs.h b/BaseTinyFirmware/GCC/structs.h index 742c17e..e494621 100644 --- a/BaseTinyFirmware/GCC/structs.h +++ b/BaseTinyFirmware/GCC/structs.h @@ -41,11 +41,20 @@ */ struct Batteries_struct { +#if 0 +#warning "no bitfield, used for debugging - mthomas" + unsigned char Present ; //!< Battery found. (TRUE/FALSE) + unsigned char Charged ; //!< Battery fully charged. (TRUE/FALSE) + unsigned char Low ; //!< Battery low voltage. (TRUE/FALSE) + unsigned char Exhausted ; //!< Battery exhausted. (TRUE/FALSE) + unsigned char HasRID ; //!< Battery has resistor ID. (TRUE/FALSE) +#else unsigned char Present : 1; //!< Battery found. (TRUE/FALSE) unsigned char Charged : 1; //!< Battery fully charged. (TRUE/FALSE) unsigned char Low : 1; //!< Battery low voltage. (TRUE/FALSE) unsigned char Exhausted : 1; //!< Battery exhausted. (TRUE/FALSE) unsigned char HasRID : 1; //!< Battery has resistor ID. (TRUE/FALSE) +#endif unsigned char Circuit; //!< Battery safety circuit (family id). signed char Temperature; //!< Battery temperature, in centigrade. unsigned char ADCSteps; //!< ADC steps per half degree. diff --git a/BaseTinyFirmware/IAR/ADC.c b/BaseTinyFirmware/IAR/ADC.c index b1229a2..6ccc245 100644 --- a/BaseTinyFirmware/IAR/ADC.c +++ b/BaseTinyFirmware/IAR/ADC.c @@ -33,6 +33,7 @@ #include #include +#include #include "structs.h" @@ -81,7 +82,7 @@ __eeprom unsigned char VBAT_RANGE = 1; * This ISR stores the sampled values in the ADC status-struct, then * updates the ADC MUX to the next channel in the scanning-sequence.\n * Once the sequence is completed, ADCS.Flag is set and unless - * ADCS.Halt has been set, the sequence starts over. Otherwise, the ADC + * ADCS.Halt has been set, the sequence starts over. Otherwise, the ADC * is disabled.\n * If the mains voltage is below minimum, ADCS.Mains gets set to FALSE. * @@ -116,11 +117,11 @@ __interrupt void ADC_ISR(void) static unsigned char avgIndex = 0; unsigned char i, Next, Signed; signed int temp = 0; - + Signed = FALSE; // Presume next conversion is unipolar. ADCSRA &= ~(1< ADC2 (PA2) = RID case 0x02: ADCS.rawRID = ADC; Next=0x03; break; - + // MUX = 0b000011 => ADC3 (PA4) = VIN- case 0x03: // Supply voltage is always divided by 16. ADCS.VIN = ScaleU(4, (unsigned int)ADC); // Cast because ADC is short. - + // Is mains failing? if (ADCS.VIN < VIN_MIN) { ADCS.Mains = FALSE; } else { ADCS.Mains = TRUE; } - + Next=0x05; break; - + // MUX = 0b000101 => ADC5 (PA6) = VBAT- case 0x05: ADCS.rawVBAT = ADC; - + // Scale voltage according to jumper setting. ADCS.VBAT = ScaleU(VBAT_RANGE, (unsigned int)ADC); // ADC is a short. + __no_operation(); Next=0x17; // Signed = TRUE; // Next conversion is bipolar. Halves sensitivity! break; @@ -168,7 +170,7 @@ __interrupt void ADC_ISR(void) case 0x17: // MUX = 0b010111 => 20 x [ADC6(PA7) - ADC5(PA6)] = IBAT // If bipolar, from -512 to 0, to 511: // 0x200 ... 0x3ff, 0x000, 0x001 ... 0x1FF - + // Scale sample according to jumper setting, handle negative numbers. if (ADC > 511) { ADCS.IBAT = -(signed int)ScaleI(VBAT_RANGE, @@ -187,35 +189,35 @@ __interrupt void ADC_ISR(void) for (i = 0; i < 4 ; i++) { temp += ADCS.discIBAT[i]; } - + ADCS.avgIBAT = (temp / 4); - + ADCS.Flag = TRUE; Next=0x01; Signed = FALSE; // This is the only bipolar conversion. break; - + default: // Should not happen. (Invalid MUX-channel) Next=0x01; // Start at the beginning of sequence. break; } - + // Update MUX to next channel in sequence, set a bipolar conversion if // this has been flagged. - ADCS.MUX = Next; - ADMUX = (1<> 4); - + if (setting <3) { // Jumper setting 0: mV/LSB = 4.883 = 39.06 / 8 // 1: mV/LSB = 9.766 = 39.06 / 4 @@ -298,7 +300,7 @@ unsigned int ScaleI(unsigned char setting, unsigned int data) { // Temporary variable needed. unsigned int scaled = 0; - + // Jumper setting 3: mA/LSB = 20.931mA ~= 21 - 1/16 + 1/128 if (setting == 3) { scaled = 21 * data; @@ -308,7 +310,7 @@ unsigned int ScaleI(unsigned char setting, unsigned int data) scaled = 28 * data; scaled -= (data >> 3); scaled += (data >> 5); - + if (setting <3) { // Jumper setting 0: mA/LSB = 3.489mA = 27.909 / 8 // 1: mA/LSB = 6.978mA = 27.909 / 4 @@ -316,7 +318,7 @@ unsigned int ScaleI(unsigned char setting, unsigned int data) scaled = (scaled >> (3-setting)); } } - + return(scaled); } @@ -325,19 +327,19 @@ unsigned int ScaleI(unsigned char setting, unsigned int data) * * This function clears the cycle complete-flag, then waits for it to be set * again. This is then repeated once before the function exits. - * + * */ void ADC_Wait(void) { // Clear ADC flag and wait for cycle to complete. - ADCS.Flag = FALSE; + ADCS.Flag = FALSE; do { - } while (ADCS.Flag == FALSE); - + } while (ADCS.Flag == FALSE); + // Repeat, so we are sure the data beong to the same cycle. - ADCS.Flag = FALSE; + ADCS.Flag = FALSE; do { - } while (ADCS.Flag == FALSE); + } while (ADCS.Flag == FALSE); } @@ -380,11 +382,11 @@ void ADC_Init(void) // Set ADC3 as reference, and MUX to measure the same pin. ADMUX = (1< 1Wire not available + + Capacity: nom. 550mAh (min. 520 mAh) at 0.2C from 4.2V to 3.0V + Nominal Voltage: 3.7V, Range: 2.75V - 4.2V + Charging Method: Constant Current + Constant Voltage + Charge Voltage: 4.2V + Initial charge Current: std. 260mA, rapid 520mA + Charging cut of either: + (a) at time: std. 5h, rapid 3h + (b) by min current of 10mA + Temparature 0 to 45degC + Discharge max. Current: 1040mA + Protection: + overcharge : 4.35V (resume at 4.0V) + discharge : 2.2V + overcurrent: 3.0A + + Additional from PoliFlex-Handbook: + - fast charging in termperatur-range 0 - 45degC + - max charge current 1C (=550mA here) + - max charge current has to be limited stricly to 4,2V +/- 50mV + - stop charge 3h after start of when current is <0.02C (=11mA here) +*/ + //****************************************************************************** // Cell limits //****************************************************************************** // This is for common NiMH batteries. #define CELL_VOLTAGE_SAFETY 0 /*!< \brief Buffer for unmatched batteries. - * + * * If we are charging a multicell battery and the cells aren't matched, we * may risk overcharging at least one. Therefore, we may subtract this constant * per additional cell in battery to allow for a "buffer". @@ -86,7 +118,7 @@ //! Charge voltage hysteresis, in mV. #define BAT_VOLTAGE_HYST 10 -//! Maximum battery voltage, in mV. +//! Maximum battery voltage, in mV. #define BAT_VOLTAGE_MAX (CELL_VOLTAGE_MAX * BAT_CELL_NUMBER) - \ ((BAT_CELL_NUMBER - 1) * CELL_VOLTAGE_SAFETY) diff --git a/BaseTinyFirmware/IAR/battery.c b/BaseTinyFirmware/IAR/battery.c index 4486197..406e494 100644 --- a/BaseTinyFirmware/IAR/battery.c +++ b/BaseTinyFirmware/IAR/battery.c @@ -13,14 +13,14 @@ * * \par Documentation - * For comprehensive code documentation, supported compilers, compiler + * For comprehensive code documentation, supported compilers, compiler * settings and supported devices see readme.html * * \author * Atmel Corporation: http://www.atmel.com \n * Support email: avr@atmel.com * - * + * * $Name$ * $Revision: 2299 $ * $RCSfile$ @@ -129,7 +129,7 @@ const NTC_Lookup_t NTC[NTC_TABLE_SIZE] = { * * Stores current capacity, then attempts to refresh battery status.\n * If the refresh is successful, old capacity is compared with the new one. - * + * * \retval FALSE Battery is disconnected, or capacity has changed. * \retval TRUE All OK. */ @@ -137,14 +137,14 @@ unsigned char BatteryCheck(void) { unsigned char success = TRUE; unsigned int oldCapacity; - + // Save to see if battery data has changed. - oldCapacity = BattData.Capacity; - + oldCapacity = BattData.Capacity; + if (!BatteryStatusRefresh()) { success = FALSE; // Battery not present or RID was invalid. } - + if (oldCapacity != BattData.Capacity) { success = FALSE; // Battery configuration has changed. } @@ -170,7 +170,7 @@ unsigned char BatteryStatusRefresh(void) { // Assume the worst.. unsigned char success = FALSE; - + BattData.Present = FALSE; BattData.Charged = FALSE; BattData.Low = TRUE; @@ -196,7 +196,7 @@ unsigned char BatteryStatusRefresh(void) // If we are not charging, yet VBAT is above safe limit, battery is present. // If we are charging and there's a current flowing, the battery is present. - + /*! \todo If ABORT_IF_PWM_MAX is defined this last check battery presence * check is redundant since charging will be aborted due to low current at * max duty cycle. That is preferrable since the charge current reading is @@ -238,13 +238,13 @@ unsigned char BatteryDataRefresh(void) unsigned char offset; unsigned char i, crc, family, temp, page; unsigned char success; - + // Look for EPROM and read 4 pages of 32 bytes each worth of data, if found. for (page = 0; page < 4; page++) { success = FALSE; - + if (OWI_DetectPresence(OWIBUS) == OWIBUS) { - + // Presence detected, check type and CRC. OWI_SendByte(OWI_ROM_READ, OWIBUS); family = OWI_ReceiveByte(OWIBUS); @@ -274,14 +274,14 @@ unsigned char BatteryDataRefresh(void) // and writing it to EEPROM. if (OWI_ComputeCRC8(OWI_ReceiveByte(OWIBUS),crc) == 0) { crc = 0; - + // Fill page with data. for (i=0; i<32; i++) { temp = OWI_ReceiveByte(OWIBUS); crc = OWI_ComputeCRC8(temp, crc); BattEEPROM[page][i] = temp; } - + if (OWI_ComputeCRC8(OWI_ReceiveByte(OWIBUS),crc) == 0) { success = TRUE; // Data read OK } @@ -289,7 +289,7 @@ unsigned char BatteryDataRefresh(void) } } else { // Wrong device type. } - } else { // No device found. + } else { // No device found. } } else { // No presence detected on one-wire bus. } @@ -297,7 +297,10 @@ unsigned char BatteryDataRefresh(void) // Erase local EEPROM page if there were any errors during transfer. if (!success) { for (i=0; i<32; i++) { - BattEEPROM[page][i] = 0; + // mthomas: avoid unneeded writes + if ( eeprom_read_byte( &BattEEPROM[page][i] ) != 0 ) { + BattEEPROM[page][i] = 0; + } } } } @@ -326,10 +329,10 @@ void EnableBattery(unsigned char bat) PORTB |= (1 << (PB4+bat)); // Disconnect other battery. - PORTB &= ~(1<<(PB5-bat)); + PORTB &= ~(1<<(PB5-bat)); do { // Let port switch settle. - } while (Time_Left(TIMER_GEN)); + } while (Time_Left(TIMER_GEN)); } @@ -340,7 +343,7 @@ void EnableBattery(unsigned char bat) void DisableBatteries(void) { // Turn off LEDs and disconnect batteries. - PORTB &= ~((1<= NTC[i].ADC) { BattData.Temperature = (i<<2) ; - BattData.ADCSteps = NTC[i].ADCsteps; + BattData.ADCSteps = NTC[i].ADCsteps; BattData.Temperature -= ((ADCS.rawNTC - NTC[i].ADC)<<1) / BattData.ADCSteps; - + found = TRUE; // Could be done with a break, but that violates MISRA. } } - - // For safety, is temperature is greater than the NTC + + // For safety, is temperature is greater than the NTC if (!found) { BattData.Temperature = 80; } diff --git a/BaseTinyFirmware/IAR/battery.h b/BaseTinyFirmware/IAR/battery.h index 1fa428a..6b26f59 100644 --- a/BaseTinyFirmware/IAR/battery.h +++ b/BaseTinyFirmware/IAR/battery.h @@ -49,6 +49,19 @@ //****************************************************************************** // RID-less charging (for BatteryStatusRefresh()) //****************************************************************************** +#ifdef EASYPACK550 + +#warning "using EasyPack 66590 711 099 (550mAh) settings - mthomas, no warranty!" +// RID not connected +#define ALLOW_NO_RID //!< Use default battery data if no matching entry found. +#define DEF_BAT_CAPACITY 550 //!< Default battery capacity, in mAh. +#define DEF_BAT_CURRENT_MAX 260 //!< Default maximum charge current, in mA. +#define DEF_BAT_TIME_MAX (5*60) //!< Default maximum charge time, in minutes. +//! Default minimum current to stop charge, in mA. +#define DEF_BAT_CURRENT_MIN 10 + +#else + //#define ALLOW_NO_RID //!< Use default battery data if no matching entry found. #define DEF_BAT_CAPACITY 0 //!< Default battery capacity, in mAh. @@ -57,6 +70,7 @@ //! Default minimum current to stop charge, in mA. #define DEF_BAT_CURRENT_MIN 0 +#endif /* EASYPACK550 */ //****************************************************************************** diff --git a/BaseTinyFirmware/IAR/statefunc.c b/BaseTinyFirmware/IAR/statefunc.c index 9dbdde1..e4d5ff6 100644 --- a/BaseTinyFirmware/IAR/statefunc.c +++ b/BaseTinyFirmware/IAR/statefunc.c @@ -115,7 +115,7 @@ unsigned char Initialize(unsigned char inp) Time_Init(); // Attempt to get ADC-readings (also gets RID-data) from both batteries. - for (i = 0; i < 2; i++) { + for (i = 0; i < BATCONN; i++) { EnableBattery(i); ADC_Wait(); BatteryStatusRefresh(); @@ -166,7 +166,7 @@ unsigned char BatteryControl(unsigned char inp) // Get ADC-readings, try to read EPROM, and start prequalification // of any uncharged battery. - for (i = 0; i < 2; i++) { + for (i = 0; i < BATCONN; i++) { if (BattControl[i].Enabled) { EnableBattery(i); ADC_Wait(); @@ -220,11 +220,13 @@ unsigned char Sleep(unsigned char inp) // If any batteries need charging, go to ST_BATCON. // Otherwise, keep sleeping. - for (i = 0; i < 2; i++) { + for (i = 0; i < BATCONN; i++) { EnableBattery(i); ADC_Wait(); - if ((BatteryStatusRefresh()) && (!BattData.Charged)) { - return(ST_BATCON); + if ( BatteryStatusRefresh() ) { + if ( !BattData.Charged ) { + return(ST_BATCON); + } } } @@ -275,6 +277,7 @@ void Doze(void) __sleep(); // Go to sleep, wake up by WDT. } else { + // stay awake if PB6 is pulled low by master do { } while ( !(WatchdogFlag) ); } diff --git a/BaseTinyFirmware/IAR/statefunc.h b/BaseTinyFirmware/IAR/statefunc.h index 9594f44..699b93e 100644 --- a/BaseTinyFirmware/IAR/statefunc.h +++ b/BaseTinyFirmware/IAR/statefunc.h @@ -10,14 +10,14 @@ * AVR458: Charging Li-Ion Batteries with BC100 * * \par Documentation - * For comprehensive code documentation, supported compilers, compiler + * For comprehensive code documentation, supported compilers, compiler * settings and supported devices see readme.html * * \author * Atmel Corporation: http://www.atmel.com \n * Support email: avr@atmel.com * - * + * * $Name$ * $Revision: 2261 $ * $RCSfile$ @@ -28,6 +28,11 @@ #ifndef STATEFUNC_H #define STATEFUNC_H +//! number of connectors (1: just process A, 2 process A and B ) +#define BATCONN 1 +#if ( BATCONN < 1 ) || ( BATCONN > 2 ) +#error "Invalid BATCONN. Must be set to 1 or 2." +#endif //****************************************************************************** // Wanted SPI-mode @@ -36,7 +41,7 @@ #define SPIMODE 0 //! Sample on leading _falling_ edge, setup on trailing _rising_ edge. -//#define SPIMODE 1 +//#define SPIMODE 1 //****************************************************************************** @@ -53,19 +58,19 @@ // Error-flag bit identifiers //****************************************************************************** //! Wrong jumper settings. -#define ERR_JUMPER_MISMATCH 0x01 +#define ERR_JUMPER_MISMATCH 0x01 //! Both batteries disabled. -#define ERR_NO_BATTERIES_ENABLED 0x02 +#define ERR_NO_BATTERIES_ENABLED 0x02 //! PWM output too much/little. -#define ERR_PWM_CONTROL 0x04 +#define ERR_PWM_CONTROL 0x04 //! Battery temperature out of limits. -#define ERR_BATTERY_TEMPERATURE 0x08 +#define ERR_BATTERY_TEMPERATURE 0x08 //! Battery couldn't be charged. -#define ERR_BATTERY_EXHAUSTED 0x10 +#define ERR_BATTERY_EXHAUSTED 0x10 //****************************************************************************** diff --git a/BaseTinyFirmware/IAR/structs.h b/BaseTinyFirmware/IAR/structs.h index 9b80944..602b3f7 100644 --- a/BaseTinyFirmware/IAR/structs.h +++ b/BaseTinyFirmware/IAR/structs.h @@ -41,11 +41,20 @@ */ struct Batteries_struct { +#if 0 +#warning "no bitfield, used for debugging - mthomas" + unsigned char Present ; //!< Battery found. (TRUE/FALSE) + unsigned char Charged ; //!< Battery fully charged. (TRUE/FALSE) + unsigned char Low ; //!< Battery low voltage. (TRUE/FALSE) + unsigned char Exhausted ; //!< Battery exhausted. (TRUE/FALSE) + unsigned char HasRID ; //!< Battery has resistor ID. (TRUE/FALSE) +#else unsigned char Present : 1; //!< Battery found. (TRUE/FALSE) unsigned char Charged : 1; //!< Battery fully charged. (TRUE/FALSE) unsigned char Low : 1; //!< Battery low voltage. (TRUE/FALSE) unsigned char Exhausted : 1; //!< Battery exhausted. (TRUE/FALSE) unsigned char HasRID : 1; //!< Battery has resistor ID. (TRUE/FALSE) +#endif unsigned char Circuit; //!< Battery safety circuit (family id). signed char Temperature; //!< Battery temperature, in centigrade. unsigned char ADCSteps; //!< ADC steps per half degree. @@ -62,10 +71,10 @@ struct Battery_struct { //! Battery valid, enabling allowed. (TRUE/FALSE) unsigned char Enabled : 1; - + //! Disconnect allowed. (TRUE/FALSE) unsigned char DisconnectAllowed : 1; - + //! Inhibit charging. (TRUE/FALSE) \todo Changed by master? unsigned char ChargeInhibit : 1; }; diff --git a/ChangeLog b/ChangeLog index da54f36..021982a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,52 +1,93 @@ -2008-04-07 Kevin Rosenberg - * BaseTinyFirmware/IAR: Port Martin's changes from 2008-04-03 - to IAR - -2008-04-03 Martin Thomas - * 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 - * 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 - * 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 - 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 singned 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 ode as a base for own developments - -2008-03-12 Kevin Rosenberg - * Initial GCC port performed and compiles without error - * Warning: Not yet tested on BC100 hardware! +2008-06-26 Kevin Rosenberg + * BaseTinyFirmwave/IAR: Port Martin's changes from 2008-06-12 to IAR + +2008-06-12 Martin Thomas + 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 + * BaseTinyFirmware/GCC/*/Makefile: Add GCC optimizations from + Eric Weddington + +2008-04-07 Kevin Rosenberg + * BaseTinyFirmware/IAR: Port Martin's changes from 2008-04-03 + to IAR + +2008-04-03 Martin Thomas + * 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 + * 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 + * 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 + 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 + * Initial GCC port performed and compiles without error + * Warning: Not yet tested on BC100 hardware!