add projects

This commit is contained in:
2022-01-21 14:53:11 -06:00
parent 39ab045662
commit ca7c76e436
111 changed files with 37834 additions and 0 deletions

44
labW3barnestr/Inc/delay.h Normal file
View File

@@ -0,0 +1,44 @@
/*
* delay.h
*
* Author: Trevor Barnes
*/
//include guards
#ifndef DELAY_H_
#define DELAY_H_
#define STK_CTRL (volatile uint32_t*) 0xE000E010
#define STK_LOAD (volatile uint32_t*) 0xE000E014
#define STK_VAL (volatile uint32_t*) 0xE000E018
#define EN 1
#define TICKINT (1<<1)
#define CLKSOURCE (1<<2)
#define COUNTFLAG (1<<16)
/*
* delay_ms
* Busy wait for n ms
*
* For n iterations
* load number of cycles for 1 ms
* set one to enable and clock source
*
* wait for countflag to be set
*/
void delay_ms(uint32_t n);
/*
* delay_ms
* Busy wait for n us
*
* For n iterations
* load number of cycles for 1 us
* set one to enable and clock source
*
* wait for countflag to be set
*/
void delay_us(uint32_t n);
#endif /* DELAY_H_ */

View File

@@ -0,0 +1,51 @@
/*
* keypad.h
*
* Created on: Dec 17, 2021
* Author: Trevor Barnes
*/
#ifndef KEYPAD_H_
#define KEYPAD_H_
#include <inttypes.h>
#define RCC_AHB1ENR (volatile uint32_t*) 0x40023830
#define GPIOCEN 2
#define GPIOC_MODER (volatile uint32_t*) 0x40020800
#define GPIOC_PUPDR (volatile uint32_t*) 0x4002080C
#define GPIOC_IDR (volatile uint32_t*) 0x40020810
#define GPIOC_ODR (volatile uint32_t*) 0x40020814
#define GPIOC_BSRR (volatile uint32_t*) 0x40020818
extern void keypad_init();
//Returns the code for the current key pressed
// 0 - No key
// 1 2 3 4
//
// 5 6 7 8
//
// 9 10 11 12
//
// 13 14 15 16
// 255 - Error
// This function does not block the flow of the program
extern uint8_t keypad_getKeyNoBlock();
//Returns the code for the next pressed
// 0 - No key
// 1 2 3 4
//
// 5 6 7 8
//
// 9 10 11 12
//
// 13 14 15 16
// 255 - Error
// This function will block the flow of the program until a
// key is pressed.
extern uint8_t keypad_getKey();
#endif /* KEYPAD_H_ */

84
labW3barnestr/Inc/lcd.h Normal file
View File

@@ -0,0 +1,84 @@
/*
* LCD.H
*
* Created on: Dec 17, 2020
* Author: Trevor Barnes
*/
//Include Guards
#ifndef LCD_H_
#define LCD_H_
#include <inttypes.h>
#define RCC_AHB1ENR (volatile uint32_t*) 0x40023830
// GPIO A Addresses and Values
#define GPIOA_MODER (volatile uint32_t*) 0x40020000
#define GPIOA_IDR (volatile uint32_t*) 0x40020010
#define GPIOA_ODR (volatile uint32_t*) 0x40020014
#define GPIOA_BSRR (volatile uint32_t*) 0x40020018
#define GPIOAEN (1<<0)
// GPIO C Addresses and Values
#define GPIOC_MODER (volatile uint32_t*) 0x40020800
#define GPIOC_IDR (volatile uint32_t*) 0x40020810
#define GPIOC_ODR (volatile uint32_t*) 0x40020814
#define GPIOC_BSRR (volatile uint32_t*) 0x40020818
#define GPIOCEN 2
#define RS (1<<8)
#define RW (1<<9)
#define E (1<<10)
#define FUNCTION_SET 0x38
#define DISPLAY_TOGGLE 0x0F
#define DISPLAY_CLEAR 0x01
#define ENTRY_MODE_SET 0x06
/*
* lcdInit()
* Initializes the lcd by:
* - Setting DB and Control Ports to Outputs
* - Turns on clears the display
*/
void lcd_init();
/*
* lcdClear()
* Clears the lcd
*/
void lcd_clear();
/*
* lcdHome()
* Sets the cursor to the home position
*/
void lcd_home();
/*
* lcdSetPosition()
* Sets the cursor to the index passed in (1-32)
*/
void lcd_set_position(uint8_t posIndex);
/*
* lcdPrintString()
*
*/
int lcd_print_string(char* str);
/*
* lcdPrintChar()
*
*/
void lcd_print_char(char c);
/*
* lcdPrintNum()
*
*/
int lcd_print_num(int i);
#endif /* LCD_H */