SWE-350 TOTP Generator Milestone 5
The DE-10 board has six 7-segment displays, this can be used to display and generate a time based one-time pin (TOTP).
Loading...
Searching...
No Matches
/Users/erickgrant/Documents/Computer Programming/Software-Class/swe350MS/main.c File Reference
#include "LCD/terasic_os_includes.h"
#include "LCD/LCD_Lib.h"
#include "LCD/lcd_graphic.h"
#include "LCD/font.h"
#include "randomKey/randomKey.h"
#include "address_map_arm.h"
#include "HPS-incrementLEDS/increment_leds/increment_leds.h"
#include "7-segment/7seg.h"
#include "QRCode/src/qrcode.h"
#include <stdio.h>
#include "TOTP-MCU-master/TOTP.h"
#include <time.h>
#include <stdint.h>
#include <string.h>
Include dependency graph for main.c:

Go to the source code of this file.

Data Structures

struct  GpioRegister
 

Macros

#define HW_REGS_BASE   ( ALT_STM_OFST )
 
#define HW_REGS_SPAN   ( 0x04000000 )
 
#define HW_REGS_MASK   ( HW_REGS_SPAN - 1 )
 
#define HEX3_HEX0_BASE   0x00000020
 Register address of the right-most four 7-segment displays.
 
#define HEX5_HEX4_BASE   0x00000030
 Register address of the left-most two 7-segment displays.
 

Functions

void runTests ()
 Main Unit Testing function This function is run initially at runtime, tests all features made by Erick Grant.
 
void displayCode (int x)
 
int main ()
 Main Function Runs all other code.
 

Variables

char knownKey [32]
 Holds the key in a human readable format.
 
size_t output_len
 The length of the uint_8 key in bytes.
 
void * virtual_base
 
volatile int * HEX_ptr
 Virtual address pointer Pointer for the 3-6 7-segment display lights Used to define the address of the 7-segment displays.
 
volatile int * HEX45_ptr
 Virtual address pointer Pointer for the 1-2 7-segment display lights Used to define the address of the 7-segment displays for the 2 left-most displays.
 
int fd = -1
 
void * LW_virtual
 
volatile int * KEY_ptr
 Pointer to the buttons on the board.
 
time_t seconds
 Used to return the time.
 
LCD_CANVAS LcdCanvas
 Creates a LCD_CANVAS object.
 
QRCode qrcode
 Creates a QRCode object.
 
char codeStr [6]
 Stores the 6-digit code in a string format.
 
int secondsRemaining = 0
 Seconds remaining.
 
uint32_t newCode
 Code as a byte array.
 
GpioRegistergpioRegister
 
volatile unsigned int * JP1_ptr
 

Macro Definition Documentation

◆ HEX3_HEX0_BASE

#define HEX3_HEX0_BASE   0x00000020

Register address of the right-most four 7-segment displays.

Accepts a long long int to this address, the int is created by combining four 8 bit binary numbers, corresponding to the physical lights on the 7-segment.

Definition at line 85 of file main.c.

◆ HEX5_HEX4_BASE

#define HEX5_HEX4_BASE   0x00000030

Register address of the left-most two 7-segment displays.

Accepts a long long int to this address, the int is created by combining two 8-bit binary numbers, corresponding to the physical lights on the 7-segment.

Definition at line 94 of file main.c.

◆ HW_REGS_BASE

#define HW_REGS_BASE   ( ALT_STM_OFST )

Definition at line 73 of file main.c.

◆ HW_REGS_MASK

#define HW_REGS_MASK   ( HW_REGS_SPAN - 1 )

Definition at line 75 of file main.c.

◆ HW_REGS_SPAN

#define HW_REGS_SPAN   ( 0x04000000 )

Definition at line 74 of file main.c.

Function Documentation

◆ displayCode()

void displayCode ( int x)

Definition at line 246 of file main.c.

Here is the caller graph for this function:

◆ main()

int main ( void )

Main Function Runs all other code.

Returns
int

Definition at line 275 of file main.c.

Here is the call graph for this function:

◆ runTests()

void runTests ( )

Main Unit Testing function This function is run initially at runtime, tests all features made by Erick Grant.

Returns
void

Definition at line 225 of file main.c.

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

Variable Documentation

◆ codeStr

char codeStr[6]

Stores the 6-digit code in a string format.

The pin is stored in a string format, before outputting to the 7-segment displays.

Definition at line 198 of file main.c.

◆ fd

int fd = -1

Definition at line 152 of file main.c.

◆ gpioRegister

GpioRegister* gpioRegister

Definition at line 242 of file main.c.

◆ HEX45_ptr

volatile int* HEX45_ptr

Virtual address pointer Pointer for the 1-2 7-segment display lights Used to define the address of the 7-segment displays for the 2 left-most displays.

Definition at line 146 of file main.c.

◆ HEX_ptr

volatile int* HEX_ptr

Virtual address pointer Pointer for the 3-6 7-segment display lights Used to define the address of the 7-segment displays.

Definition at line 140 of file main.c.

◆ JP1_ptr

volatile unsigned int* JP1_ptr

Definition at line 244 of file main.c.

◆ KEY_ptr

volatile int* KEY_ptr

Pointer to the buttons on the board.

This isn't developed yet, but will be used for the reset button.

Definition at line 168 of file main.c.

◆ knownKey

char knownKey[32]

Holds the key in a human readable format.

The key supports the upper-case alphabet and 2-7 to fill up the 32-bits The key will be trimmed to 32-bits

Definition at line 119 of file main.c.

◆ LcdCanvas

LCD_CANVAS LcdCanvas

Creates a LCD_CANVAS object.

Creates a LCD_CANVAS object for the LCD.

Definition at line 182 of file main.c.

◆ LW_virtual

void* LW_virtual

Definition at line 157 of file main.c.

◆ newCode

uint32_t newCode

Code as a byte array.

Non-human readable format from the TOTP library, will be copied into codeStr

Definition at line 212 of file main.c.

◆ output_len

size_t output_len

The length of the uint_8 key in bytes.

Typically this will be about 20, this will be the length of the decoded array and cloned array.

Definition at line 126 of file main.c.

◆ qrcode

QRCode qrcode

Creates a QRCode object.

Used for the QRCode generator for the LCD display.

Definition at line 190 of file main.c.

◆ seconds

time_t seconds

Used to return the time.

Used to calculate the current time in seconds from EPOCH.

Definition at line 175 of file main.c.

◆ secondsRemaining

int secondsRemaining = 0

Seconds remaining.

Calculated from seconds (in epoch) % 30

Definition at line 205 of file main.c.

◆ virtual_base

void* virtual_base

Definition at line 134 of file main.c.