binary Clock
Macros | Enumerations | Functions | Variables
main.c File Reference

Main logic of the Binary Clock firmware. Handles calling all other functions other than interrupt driven ISRs. More...

#include <avr/io.h>
#include "timer_4313.h"
#include "RTC_DS3231.h"
#include "LED.h"
#include "UART.h"
#include "i2c.h"
#include "hardware.h"
#include "color.h"
#include "ports.h"
#include "global_defines.h"
#include <stdint.h>

Macros

#define COMMAND_LENGTH   6
 number of bytes in a valid UART command. More...
 

Enumerations

enum  state_t { RUN_TIME, RUN_MANUAL }
 Current state of the clock. More...
 

Functions

int main (void)
 

Variables

state_t system_state = RUN_TIME
 keeps track of the system state. More...
 
uint8_t uart_command_received = 0
 valid command received flag. More...
 
uint8_t LED_multiplex_timer_count = 0
 count of mutiplex handler timer events. More...
 
uint8_t command_buffer [COMMAND_LENGTH]
 where UART commands are buffered. More...
 

Detailed Description

Main logic of the Binary Clock firmware. Handles calling all other functions other than interrupt driven ISRs.

Macro Definition Documentation

◆ COMMAND_LENGTH

#define COMMAND_LENGTH   6

number of bytes in a valid UART command.

Enumeration Type Documentation

◆ state_t

enum state_t

Current state of the clock.

Enumerator
RUN_TIME 

Runs time display mode. LEDs controlled by the current time.

RUN_MANUAL 

Runs manual display mode. LEDs controlled by UART commands.

Function Documentation

◆ main()

int main ( void  )

Runs the main program.

Order of opperation:

  1. Check if we've received enough data for a command.
    • If we have, process it.
  2. Check if we should run manual control or time control.
    • If manual control: a. run the LED multiplex function. b. keep time as well.
    • If time control: a. check if we need to update the time
      • if so, increment time and update the LED array b. run the LED multiplex function

Variable Documentation

◆ command_buffer

uint8_t command_buffer[COMMAND_LENGTH]

where UART commands are buffered.

◆ LED_multiplex_timer_count

uint8_t LED_multiplex_timer_count = 0

count of mutiplex handler timer events.

◆ system_state

state_t system_state = RUN_TIME

keeps track of the system state.

◆ uart_command_received

uint8_t uart_command_received = 0

valid command received flag.