Electronic Load  1.0
Programmable Constant Current Sink
Functions | Variables
Eload.c File Reference

The Main Program and miscellaneous Routines. More...

Include dependency graph for Eload.c:

Functions

void DelayMs (uint8_t ms)
 Delays for n Milliseconds. More...
 
static void DoCflags (void)
 Checks for Communication Flags. More...
 
void DoFlags ()
 Process Communication-, Time- and Key-Flags. More...
 
static void DoTflags (void)
 Checks for Time Flags. More...
 
void GetMCUSR (void)
 Get a copy of the MCUSR and reset it to 0. More...
 
void Init (void)
 Initializes the System. More...
 
 ISR (TIMER0_COMPA_vect)
 Timer0 compare interrupt (800Hz) More...
 
void LightShow (void)
 Performs a Light Show (visible LED test) More...
 
int main (void)
 The Main Program. More...
 
void Ticks2HMS (uint32_t ticks, char *str, size_t n)
 

Variables

uint32_t ahCnt
 Number of average values added to ahRaw;. More...
 
uint64_t ahRaw
 The sum of current values. More...
 
uint32_t ahTickCnt
 The number of 100Hz interrupts since ahRaw is counting. More...
 
uint8_t boCnt
 Counts the number of Brown Out Resets. More...
 
const char * build = __DATE__
 The Build Date as to be displayed in the Boot Screen. More...
 
static volatile delay_t delaycnt
 Counter for delay() More...
 
volatile uint8_t dFlags
 Flags Controlling Debug Output. More...
 
volatile uint8_t eflags
 Error Flags. More...
 
 FUSES
 Fuse settings for the Production ELF file. More...
 
volatile uint8_t hrCnt
 Hours of the RTC. More...
 
LED_DATA_t ledData
 This is the pattern the eight leds should blink. Every '1'-bit means the LED is on. Cycled in 200ms intervals from low to high. More...
 
LED_FLASH_t ledRedData
 This is the pattern the debug led should blink. More...
 
 LOCKBITS = (LB_MODE_1)
 The Lock Bits for the production File. More...
 
uint8_t mcusrMirror
 Copy of the MCUSR taken shortly after reset. More...
 
volatile uint8_t minCnt
 Minutes of the RTC. More...
 
const char eflag1 [] PROGMEM ="NTC 1 (case temp) malfunction\n"
 The structure of the main menu. More...
 
volatile uint8_t secCnt
 Seconds of the RTC. More...
 
volatile uint8_t tFlags
 Flags set by Timer Interrupt to signal Main Loop. More...
 
volatile uint8_t tickCnt
 Counter for timer0 interrupts. More...
 
const char * version ="1.0"
 
uint8_t wdrCnt
 Counts the number of Watchdog Resets. More...
 

Detailed Description

The Main Program and miscellaneous Routines.

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Function Documentation

◆ Ticks2HMS()

void Ticks2HMS ( uint32_t  ticks,
char *  str,
size_t  n 
)

◆ ISR()

ISR ( TIMER0_COMPA_vect  )

Timer0 compare interrupt (800Hz)

The 800Hz-interrupt is not only used to create a RTC (Real Time Clock) but also for other tasks that rely on a constant timing, e.g. debouncing of the keyboard.
If you change the frequency, be sure of all of the consequences!

Here is the call graph for this function:

◆ DelayMs()

void DelayMs ( uint8_t  ms)

Delays for n Milliseconds.

Note
The timer resolution is 1.25ms and the state of the timer when calling this function is normally undefined. The actual delay may differ up to 1.25ms from the given value (especially, it may be 0 if you specify 1ms)!
Parameters
msThe desired delay in Milliseconds
Here is the caller graph for this function:

◆ DoCflags()

static void DoCflags ( void  )
static

Checks for Communication Flags.

Note
Be sure to check and clear all Flags even if you don't use them to avoid unnecessary calls of this function
Here is the call graph for this function:
Here is the caller graph for this function:

◆ DoTflags()

static void DoTflags ( void  )
static

Checks for Time Flags.

Note
Be sure to check and clear all Flags even if you don't use them to avoid unnecessary calls of this function
Here is the call graph for this function:
Here is the caller graph for this function:

◆ DoFlags()

void DoFlags ( )

Process Communication-, Time- and Key-Flags.

Here is the call graph for this function:

◆ GetMCUSR()

void GetMCUSR ( void  )

Get a copy of the MCUSR and reset it to 0.

This has to be done as soon as possible after a reset and so the function has been put into section .init3. Also, the watchdog timer is disabled since it may be running. See datasheet for details.

Note
Making and keeping the copy in mcusr_mirror is not really necessary but the main program can determine the reset cause if you do.

◆ Init()

void Init ( void  )

Initializes the System.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ LightShow()

void LightShow ( void  )

Performs a Light Show (visible LED test)

Here is the call graph for this function:

◆ main()

int main ( void  )

The Main Program.

Here is the call graph for this function:

Variable Documentation

◆ version

const char* version ="1.0"

◆ FUSES

FUSES
Initial value:
=
{
.low = (FUSE_SUT1 & FUSE_SUT0 & FUSE_CKSEL1),
.high = (FUSE_SPIEN & FUSE_BOOTSZ1 & FUSE_BOOTSZ0),
.extended = (FUSE_BODLEVEL0 & FUSE_BODLEVEL1),
}

Fuse settings for the Production ELF file.

◆ LOCKBITS

LOCKBITS = (LB_MODE_1)

The Lock Bits for the production File.

◆ build

const char* build = __DATE__

The Build Date as to be displayed in the Boot Screen.

◆ dFlags

volatile uint8_t dFlags

Flags Controlling Debug Output.

◆ tickCnt

volatile uint8_t tickCnt

Counter for timer0 interrupts.

◆ secCnt

volatile uint8_t secCnt

Seconds of the RTC.

◆ minCnt

volatile uint8_t minCnt

Minutes of the RTC.

◆ hrCnt

volatile uint8_t hrCnt

Hours of the RTC.

◆ delaycnt

volatile delay_t delaycnt
static

Counter for delay()

◆ ledRedData

LED_FLASH_t ledRedData

This is the pattern the debug led should blink.

◆ ledData

LED_DATA_t ledData

This is the pattern the eight leds should blink. Every '1'-bit means the LED is on. Cycled in 200ms intervals from low to high.

◆ ahRaw

uint64_t ahRaw

The sum of current values.

◆ ahCnt

uint32_t ahCnt

Number of average values added to ahRaw;.

◆ ahTickCnt

uint32_t ahTickCnt

The number of 100Hz interrupts since ahRaw is counting.

◆ PROGMEM

const menu_t menuStructMain PROGMEM ="NTC 1 (case temp) malfunction\n"

The structure of the main menu.

◆ wdrCnt

uint8_t wdrCnt

Counts the number of Watchdog Resets.

◆ boCnt

uint8_t boCnt

Counts the number of Brown Out Resets.

◆ mcusrMirror

uint8_t mcusrMirror

Copy of the MCUSR taken shortly after reset.