From: Kevin Rosenberg Date: Sun, 30 Mar 2008 15:08:18 +0000 (-0600) Subject: fix case name, improve syntax for linker option X-Git-Url: http://git.kpe.io/?p=avr_bc100.git;a=commitdiff_plain;h=0baf0366ad1924563e53f3d839d69730c7b14a44 fix case name, improve syntax for linker option --- diff --git a/BaseTinyFirmware/GCC/LIIONcharge.c b/BaseTinyFirmware/GCC/LIIONcharge.c new file mode 100644 index 0000000..0ce5427 --- /dev/null +++ b/BaseTinyFirmware/GCC/LIIONcharge.c @@ -0,0 +1,156 @@ +/* This file has been prepared for Doxygen automatic documentation generation.*/ +/*! \file ********************************************************************* + * + * \brief + * Charge state function for Li-Ion batteries + * + * Contains the charge state function, in which the Li-Ion charging + * algorithm is, plus the associated functions. + * + * \par Application note: + * AVR458: Charging Li-Ion Batteries with BC100 + * + * \par Documentation + * 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$ + * $URL: http://svn.norway.atmel.com/AppsAVR8/avr458_Charging_Li-Ion_Batteries_with_BC100/tag/20070904_release_1.0/code/IAR/LIIONcharge.c $ + * $Date: 2007-08-10 09:28:35 +0200 (fr, 10 aug 2007) $\n + ******************************************************************************/ + +#include + +#include "enums.h" +#include "structs.h" + +#include "battery.h" +#include "charge.h" +#include "chargefunc.h" +#include "main.h" +#include "menu.h" +#include "LIIONspecs.h" +#include "PWM.h" +#include "time.h" + +#ifndef LIION +#error LIION not defined in main.h! +#endif // LIION + + +//****************************************************************************** +// Functions +//****************************************************************************** +/*! \brief Controls the charging. + * + * This function contains the charging algorithm itself, divided into stages.\n + * For each stage the PWM may be started/stopped, and the timer, + * halt-requirements and charge parameters may be set.\n + * The charging functions return whatever state is next, and as long as no + * errors occur this is the next charging stage. + * + * \note If more stages are needed simply define more states in menu.h, include + * them in \ref menu_state[] in menu.c, then add the cases to this function. + * + * \note This algorithm is for Li-Ion batteries. + */ +unsigned char Charge(unsigned char inp) +{ + unsigned char NextState; + + switch (CurrentState) { + case ST_PREQUAL: // First step is prequalification. + + // Charge with the defined prequalifiction-current, and if no errors + // occur return ST_CCURRENT as the next state. + ChargeParameters.Current = BAT_CURRENT_PREQUAL; + ChargeParameters.NextState = ST_CCURRENT; + + // We want charging to halt if voltage reaches a limit or time runs out. + // In case of timeout the battery will be flagged as exhausted, and an + // error will be flagged. + HaltParameters.HaltFlags = (HALT_VOLTAGE_MAX | HALT_TIME | + HALT_FLAG_EXHAUSTION); + + // Set the maximum temperature and charge voltage limit. + HaltParameters.TemperatureMax = BAT_TEMPERATURE_MAX; + HaltParameters.TemperatureMin = BAT_TEMPERATURE_MIN; + HaltParameters.VoltageMax = BAT_VOLTAGE_PREQUAL; + + // Start PWM output and charging timer first. + PWM_Start(); + Time_Set(TIMER_CHG, BAT_TIME_PREQUAL, 0, 0); + + // Call the constant current charging-function. + // If all goes well, we will get ST_CCURRENT in return. + NextState = ConstantCurrent(); + break; + + + case ST_CCURRENT: // Second step is constant current charging. + + // Set charging timer to the battery's maximum charge time. + Time_Set(TIMER_CHG,BattData.MaxTime,0,0); + + // Charge at the battery's maximum current, go to ST_CVOLTAGE next. + ChargeParameters.Current = BattData.MaxCurrent; + ChargeParameters.NextState = ST_CVOLTAGE; + + + // Charge until the defined BatChargeVoltage is reached. + HaltParameters.VoltageMax = BAT_VOLTAGE_MAX; + + // Start charging using constant current. + NextState = ConstantCurrent(); + break; + + + case ST_CVOLTAGE: // Third step is constant voltage charging. + + // Charge with the defined charge-voltage, go to ST_ENDCHARGE next. + ChargeParameters.Voltage = BAT_VOLTAGE_MAX; + ChargeParameters.NextState = ST_ENDCHARGE; + + // We want charging to halt if temperature rises too high, if current + // sinks below limit, or time runs out. Also, flag error if temperature + // limit is reached. Timeout doesn't mean anything is wrong at this point. + HaltParameters.HaltFlags = (HALT_CURRENT_MIN | HALT_TIME); + + HaltParameters.CurrentMin = BattData.MinCurrent; + + // Start charging using constant voltage. We will continue on the + // timer started in ST_CCURRENT. + NextState = ConstantVoltage(); + break; + + + case ST_ENDCHARGE: // Charging is done! + + PWM_Stop(); + BattData.Charged = TRUE; + + // If the other battery is enabled go to ST_BATCON, otherwise + // go to ST_SLEEP. + if (eeprom_read_byte(&BattControl[(BattActive+1)%2]) & BIT_BATTERY_ENABLED) { + NextState = ST_BATCON; + } else { + NextState = ST_SLEEP; + } + break; + + + default: // Shouldn't end up here. Reinitialize for safety. + NextState = ST_INIT; + break; + } + + // Return the next state. + return(NextState); +} diff --git a/BaseTinyFirmware/GCC/NIMHcharge.c b/BaseTinyFirmware/GCC/NIMHcharge.c new file mode 100644 index 0000000..1a436cd --- /dev/null +++ b/BaseTinyFirmware/GCC/NIMHcharge.c @@ -0,0 +1,179 @@ +/* This file has been prepared for Doxygen automatic documentation generation.*/ +/*! \file ********************************************************************* + * + * \brief + * Charge state function for NiMH batteries + * + * Contains the charge state function, in which the NiMH charging + * algorithm is, plus the associated functions. + * + * \par Application note: + * AVR463: Charging NiMH Batteries with BC100 \n + * + * \par Documentation + * 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: 2255 $ + * $RCSfile$ + * $URL: http://svn.norway.atmel.com/AppsAVR8/avr463_Charging_NiMH_Batteries_with_BC100/trunk/code/IAR/NIMHcharge.c $ + * $Date: 2007-08-09 14:47:58 +0200 (to, 09 aug 2007) $\n + ******************************************************************************/ + +#include + +#include "enums.h" +#include "structs.h" + +#include "battery.h" +#include "charge.h" +#include "chargefunc.h" +#include "main.h" +#include "menu.h" +#include "NIMHspecs.h" +#include "PWM.h" +#include "time.h" + +#ifndef NIMH +#error NIMH not defined in main.h! +#endif // NIMH + + +//****************************************************************************** +// Functions +//****************************************************************************** +/*! \brief Controls the charging. + * + * This function contains the charging algorithm itself, divided into stages.\n + * For each stage the PWM may be started/stopped, and the timer, + * halt-requirements and charge parameters may be set.\n + * The charging functions return whatever state is next, and as long as no + * errors occur this is the next charging stage. + * + * \note If more stages are needed simply define more states in menu.h, include + * them in \ref menu_state[] in menu.c, then add the cases to this function. + * + * \note This algorithm is for NiMH batteries. + */ +unsigned char Charge(unsigned char inp) +{ + unsigned char NextState; + + switch (CurrentState) { + // First stage is a prequalification. Attempt to charge battery to 1 V, + // using a 0.1 C current, within 2 minutes. + // If this fails, the battery is likely damaged. + // If it succeeds, start a fast charge. + case ST_PREQUAL: + + // Set up charge current and next state. + ChargeParameters.Current = BattData.Capacity / 10; + ChargeParameters.NextState = ST_FASTCHARGE; + + // Halt charge on voltage limit or timeout. + // Timeout means battery exhaustion. + HaltParameters.HaltFlags = (HALT_VOLTAGE_MAX | HALT_TIME | + HALT_FLAG_EXHAUSTION); + + // Set up voltage limit and temperature limits. + HaltParameters.VoltageMax = BAT_VOLTAGE_PREQUAL; + HaltParameters.TemperatureMin = BAT_TEMPERATURE_MIN; + HaltParameters.TemperatureMax = 35; + + // Reset temperature measurement for HaltNow(). + HaltParameters.LastNTC = 0; + + // Start PWM and charge timer before calling the charge function. + PWM_Start(); + Time_Set(TIMER_CHG, BAT_TIME_PREQUAL, 0, 0); + + // Call charge function, get next state. + NextState = ConstantCurrent(); + break; + + + // Second stage is a fast charge. Charge at 1.0 C for at most 1.5 hours, + // until either rate of temperature increase or voltage reaches limit, or + // the voltage drops sufficiently. + // Timeout doesn't mean battery exhaustion now. + case ST_FASTCHARGE: + + // Set up charge current and next state. + ChargeParameters.Current = BattData.Capacity; + ChargeParameters.NextState = ST_LOWRATECHARGE; + + // Halt charge on voltage limit, timeout, voltage drop or rate of + // temperature increase. + HaltParameters.HaltFlags = (HALT_VOLTAGE_MAX | HALT_TIME | + HALT_VOLTAGE_DROP | HALT_TEMPERATURE_RISE); + + // Set up limits for voltage, voltage drop, temperature and rate of + // temperature increase (1 degree C per minute). + HaltParameters.VoltageMax = BAT_VOLTAGE_MAX; + HaltParameters.VoltageDrop = BAT_VOLTAGE_DROP; + HaltParameters.TemperatureMax = BAT_TEMPERATURE_MAX; + HaltParameters.TemperatureRise = 1; + + // Reset maximum voltage measurement for HaltNow(). + HaltParameters.VBATMax = 0; + + // Start timer, PWM should still be running. + Time_Set(TIMER_CHG, BattData.MaxTime, 0, 0); + + // Call charge function, get next state. + NextState = ConstantCurrent(); + break; + + + // Last stage is a trickle charge. Charge at 0.1 C for at most 30 minutes, + // until either rate of temperature increase or voltage reaches limit. + case ST_LOWRATECHARGE: + + // Set up charge current and next state. + ChargeParameters.Current = BattData.Capacity / 10; + ChargeParameters.NextState = ST_ENDCHARGE; + + // Halt charge on voltage limit, timeout or temperature rise. + // Use the same requirements as during the last stage (ST_FASTCHARGE). + HaltParameters.HaltFlags = (HALT_VOLTAGE_MAX | HALT_TIME | + HALT_TEMPERATURE_RISE); + + // Start timer, 30 minutes. + Time_Set(TIMER_CHG, 30, 0, 0); + + // Call charge function, get next state. + NextState = ConstantCurrent(); + break; + + + // Charging is done! + case ST_ENDCHARGE: + + // Stop the PWM output and flag battery as charged. + PWM_Stop(); + BattData.Charged = TRUE; + + // If the other battery is enabled go to ST_BATCON, otherwise + // go to ST_SLEEP. + if (eeprom_read_byte(&BattControl[(BattActive+1)%2]) & BIT_BATTERY_ENABLED) { + NextState = ST_BATCON; + } else { + NextState = ST_SLEEP; + } + break; + + + default: // Shouldn't end up here. Reinitialize for safety. + NextState = ST_INIT; + break; + } + + // Return the next state to main(). + return(NextState); +} diff --git a/BaseTinyFirmware/GCC/avr458/Makefile b/BaseTinyFirmware/GCC/avr458/Makefile index d74f9d4..e457082 100644 --- a/BaseTinyFirmware/GCC/avr458/Makefile +++ b/BaseTinyFirmware/GCC/avr458/Makefile @@ -6,7 +6,7 @@ PROJECT = avr458 MCU = attiny861 TARGET = $(PROJECT).elf -CC = avr-gcc.exe +CC = avr-gcc ## Options common to compile, link and assembly rules COMMON = -mmcu=$(MCU) @@ -23,7 +23,7 @@ ASMFLAGS += -x assembler-with-cpp -Wa,-gdwarf2 ## Linker flags LDFLAGS = $(COMMON) -LDFLAGS += -Wl,-Map=$(PROJECT).map -Wl,-relax +LDFLAGS += -Wl,-Map=$(PROJECT).map -Wl,--relax ## Intel Hex file production flags diff --git a/BaseTinyFirmware/GCC/avr463/Makefile b/BaseTinyFirmware/GCC/avr463/Makefile index 826b345..736b3f8 100644 --- a/BaseTinyFirmware/GCC/avr463/Makefile +++ b/BaseTinyFirmware/GCC/avr463/Makefile @@ -6,7 +6,7 @@ PROJECT = avr463 MCU = attiny861 TARGET = $(PROJECT).elf -CC = avr-gcc.exe +CC = avr-gcc ## Options common to compile, link and assembly rules COMMON = -mmcu=$(MCU) @@ -23,7 +23,7 @@ ASMFLAGS += -x assembler-with-cpp -Wa,-gdwarf2 ## Linker flags LDFLAGS = $(COMMON) -LDFLAGS += -Wl,-Map=$(PROJECT).map -Wl,-relax +LDFLAGS += -Wl,-Map=$(PROJECT).map -Wl,--relax ## Intel Hex file production flags diff --git a/BaseTinyFirmware/GCC/liioncharge.c b/BaseTinyFirmware/GCC/liioncharge.c deleted file mode 100644 index 0ce5427..0000000 --- a/BaseTinyFirmware/GCC/liioncharge.c +++ /dev/null @@ -1,156 +0,0 @@ -/* This file has been prepared for Doxygen automatic documentation generation.*/ -/*! \file ********************************************************************* - * - * \brief - * Charge state function for Li-Ion batteries - * - * Contains the charge state function, in which the Li-Ion charging - * algorithm is, plus the associated functions. - * - * \par Application note: - * AVR458: Charging Li-Ion Batteries with BC100 - * - * \par Documentation - * 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$ - * $URL: http://svn.norway.atmel.com/AppsAVR8/avr458_Charging_Li-Ion_Batteries_with_BC100/tag/20070904_release_1.0/code/IAR/LIIONcharge.c $ - * $Date: 2007-08-10 09:28:35 +0200 (fr, 10 aug 2007) $\n - ******************************************************************************/ - -#include - -#include "enums.h" -#include "structs.h" - -#include "battery.h" -#include "charge.h" -#include "chargefunc.h" -#include "main.h" -#include "menu.h" -#include "LIIONspecs.h" -#include "PWM.h" -#include "time.h" - -#ifndef LIION -#error LIION not defined in main.h! -#endif // LIION - - -//****************************************************************************** -// Functions -//****************************************************************************** -/*! \brief Controls the charging. - * - * This function contains the charging algorithm itself, divided into stages.\n - * For each stage the PWM may be started/stopped, and the timer, - * halt-requirements and charge parameters may be set.\n - * The charging functions return whatever state is next, and as long as no - * errors occur this is the next charging stage. - * - * \note If more stages are needed simply define more states in menu.h, include - * them in \ref menu_state[] in menu.c, then add the cases to this function. - * - * \note This algorithm is for Li-Ion batteries. - */ -unsigned char Charge(unsigned char inp) -{ - unsigned char NextState; - - switch (CurrentState) { - case ST_PREQUAL: // First step is prequalification. - - // Charge with the defined prequalifiction-current, and if no errors - // occur return ST_CCURRENT as the next state. - ChargeParameters.Current = BAT_CURRENT_PREQUAL; - ChargeParameters.NextState = ST_CCURRENT; - - // We want charging to halt if voltage reaches a limit or time runs out. - // In case of timeout the battery will be flagged as exhausted, and an - // error will be flagged. - HaltParameters.HaltFlags = (HALT_VOLTAGE_MAX | HALT_TIME | - HALT_FLAG_EXHAUSTION); - - // Set the maximum temperature and charge voltage limit. - HaltParameters.TemperatureMax = BAT_TEMPERATURE_MAX; - HaltParameters.TemperatureMin = BAT_TEMPERATURE_MIN; - HaltParameters.VoltageMax = BAT_VOLTAGE_PREQUAL; - - // Start PWM output and charging timer first. - PWM_Start(); - Time_Set(TIMER_CHG, BAT_TIME_PREQUAL, 0, 0); - - // Call the constant current charging-function. - // If all goes well, we will get ST_CCURRENT in return. - NextState = ConstantCurrent(); - break; - - - case ST_CCURRENT: // Second step is constant current charging. - - // Set charging timer to the battery's maximum charge time. - Time_Set(TIMER_CHG,BattData.MaxTime,0,0); - - // Charge at the battery's maximum current, go to ST_CVOLTAGE next. - ChargeParameters.Current = BattData.MaxCurrent; - ChargeParameters.NextState = ST_CVOLTAGE; - - - // Charge until the defined BatChargeVoltage is reached. - HaltParameters.VoltageMax = BAT_VOLTAGE_MAX; - - // Start charging using constant current. - NextState = ConstantCurrent(); - break; - - - case ST_CVOLTAGE: // Third step is constant voltage charging. - - // Charge with the defined charge-voltage, go to ST_ENDCHARGE next. - ChargeParameters.Voltage = BAT_VOLTAGE_MAX; - ChargeParameters.NextState = ST_ENDCHARGE; - - // We want charging to halt if temperature rises too high, if current - // sinks below limit, or time runs out. Also, flag error if temperature - // limit is reached. Timeout doesn't mean anything is wrong at this point. - HaltParameters.HaltFlags = (HALT_CURRENT_MIN | HALT_TIME); - - HaltParameters.CurrentMin = BattData.MinCurrent; - - // Start charging using constant voltage. We will continue on the - // timer started in ST_CCURRENT. - NextState = ConstantVoltage(); - break; - - - case ST_ENDCHARGE: // Charging is done! - - PWM_Stop(); - BattData.Charged = TRUE; - - // If the other battery is enabled go to ST_BATCON, otherwise - // go to ST_SLEEP. - if (eeprom_read_byte(&BattControl[(BattActive+1)%2]) & BIT_BATTERY_ENABLED) { - NextState = ST_BATCON; - } else { - NextState = ST_SLEEP; - } - break; - - - default: // Shouldn't end up here. Reinitialize for safety. - NextState = ST_INIT; - break; - } - - // Return the next state. - return(NextState); -} diff --git a/BaseTinyFirmware/GCC/nimhcharge.c b/BaseTinyFirmware/GCC/nimhcharge.c deleted file mode 100644 index 1a436cd..0000000 --- a/BaseTinyFirmware/GCC/nimhcharge.c +++ /dev/null @@ -1,179 +0,0 @@ -/* This file has been prepared for Doxygen automatic documentation generation.*/ -/*! \file ********************************************************************* - * - * \brief - * Charge state function for NiMH batteries - * - * Contains the charge state function, in which the NiMH charging - * algorithm is, plus the associated functions. - * - * \par Application note: - * AVR463: Charging NiMH Batteries with BC100 \n - * - * \par Documentation - * 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: 2255 $ - * $RCSfile$ - * $URL: http://svn.norway.atmel.com/AppsAVR8/avr463_Charging_NiMH_Batteries_with_BC100/trunk/code/IAR/NIMHcharge.c $ - * $Date: 2007-08-09 14:47:58 +0200 (to, 09 aug 2007) $\n - ******************************************************************************/ - -#include - -#include "enums.h" -#include "structs.h" - -#include "battery.h" -#include "charge.h" -#include "chargefunc.h" -#include "main.h" -#include "menu.h" -#include "NIMHspecs.h" -#include "PWM.h" -#include "time.h" - -#ifndef NIMH -#error NIMH not defined in main.h! -#endif // NIMH - - -//****************************************************************************** -// Functions -//****************************************************************************** -/*! \brief Controls the charging. - * - * This function contains the charging algorithm itself, divided into stages.\n - * For each stage the PWM may be started/stopped, and the timer, - * halt-requirements and charge parameters may be set.\n - * The charging functions return whatever state is next, and as long as no - * errors occur this is the next charging stage. - * - * \note If more stages are needed simply define more states in menu.h, include - * them in \ref menu_state[] in menu.c, then add the cases to this function. - * - * \note This algorithm is for NiMH batteries. - */ -unsigned char Charge(unsigned char inp) -{ - unsigned char NextState; - - switch (CurrentState) { - // First stage is a prequalification. Attempt to charge battery to 1 V, - // using a 0.1 C current, within 2 minutes. - // If this fails, the battery is likely damaged. - // If it succeeds, start a fast charge. - case ST_PREQUAL: - - // Set up charge current and next state. - ChargeParameters.Current = BattData.Capacity / 10; - ChargeParameters.NextState = ST_FASTCHARGE; - - // Halt charge on voltage limit or timeout. - // Timeout means battery exhaustion. - HaltParameters.HaltFlags = (HALT_VOLTAGE_MAX | HALT_TIME | - HALT_FLAG_EXHAUSTION); - - // Set up voltage limit and temperature limits. - HaltParameters.VoltageMax = BAT_VOLTAGE_PREQUAL; - HaltParameters.TemperatureMin = BAT_TEMPERATURE_MIN; - HaltParameters.TemperatureMax = 35; - - // Reset temperature measurement for HaltNow(). - HaltParameters.LastNTC = 0; - - // Start PWM and charge timer before calling the charge function. - PWM_Start(); - Time_Set(TIMER_CHG, BAT_TIME_PREQUAL, 0, 0); - - // Call charge function, get next state. - NextState = ConstantCurrent(); - break; - - - // Second stage is a fast charge. Charge at 1.0 C for at most 1.5 hours, - // until either rate of temperature increase or voltage reaches limit, or - // the voltage drops sufficiently. - // Timeout doesn't mean battery exhaustion now. - case ST_FASTCHARGE: - - // Set up charge current and next state. - ChargeParameters.Current = BattData.Capacity; - ChargeParameters.NextState = ST_LOWRATECHARGE; - - // Halt charge on voltage limit, timeout, voltage drop or rate of - // temperature increase. - HaltParameters.HaltFlags = (HALT_VOLTAGE_MAX | HALT_TIME | - HALT_VOLTAGE_DROP | HALT_TEMPERATURE_RISE); - - // Set up limits for voltage, voltage drop, temperature and rate of - // temperature increase (1 degree C per minute). - HaltParameters.VoltageMax = BAT_VOLTAGE_MAX; - HaltParameters.VoltageDrop = BAT_VOLTAGE_DROP; - HaltParameters.TemperatureMax = BAT_TEMPERATURE_MAX; - HaltParameters.TemperatureRise = 1; - - // Reset maximum voltage measurement for HaltNow(). - HaltParameters.VBATMax = 0; - - // Start timer, PWM should still be running. - Time_Set(TIMER_CHG, BattData.MaxTime, 0, 0); - - // Call charge function, get next state. - NextState = ConstantCurrent(); - break; - - - // Last stage is a trickle charge. Charge at 0.1 C for at most 30 minutes, - // until either rate of temperature increase or voltage reaches limit. - case ST_LOWRATECHARGE: - - // Set up charge current and next state. - ChargeParameters.Current = BattData.Capacity / 10; - ChargeParameters.NextState = ST_ENDCHARGE; - - // Halt charge on voltage limit, timeout or temperature rise. - // Use the same requirements as during the last stage (ST_FASTCHARGE). - HaltParameters.HaltFlags = (HALT_VOLTAGE_MAX | HALT_TIME | - HALT_TEMPERATURE_RISE); - - // Start timer, 30 minutes. - Time_Set(TIMER_CHG, 30, 0, 0); - - // Call charge function, get next state. - NextState = ConstantCurrent(); - break; - - - // Charging is done! - case ST_ENDCHARGE: - - // Stop the PWM output and flag battery as charged. - PWM_Stop(); - BattData.Charged = TRUE; - - // If the other battery is enabled go to ST_BATCON, otherwise - // go to ST_SLEEP. - if (eeprom_read_byte(&BattControl[(BattActive+1)%2]) & BIT_BATTERY_ENABLED) { - NextState = ST_BATCON; - } else { - NextState = ST_SLEEP; - } - break; - - - default: // Shouldn't end up here. Reinitialize for safety. - NextState = ST_INIT; - break; - } - - // Return the next state to main(). - return(NextState); -}