diff --git a/labW6barnestr/.cproject b/labW6barnestr/.cproject
index ad14e0f..48784cc 100644
--- a/labW6barnestr/.cproject
+++ b/labW6barnestr/.cproject
@@ -21,14 +21,16 @@
-
+
+
+
-
-
+
+
@@ -52,7 +54,7 @@
-
+
@@ -94,38 +96,38 @@
-
-
-
-
-
-
-
+
+
+
+
+
+
+
-
+
-
+
-
-
-
+
+
+
-
+
-
-
+
+
-
+
@@ -149,6 +151,7 @@
+
@@ -166,4 +169,12 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/labW6barnestr/Inc/piezoSpeaker.h b/labW6barnestr/Inc/piezoSpeaker.h
index 6a436f5..2005d7d 100644
--- a/labW6barnestr/Inc/piezoSpeaker.h
+++ b/labW6barnestr/Inc/piezoSpeaker.h
@@ -14,6 +14,7 @@
#ifndef PIEZOSPEAKER_H_
#define PIEZOSPEAKER_H_
+#include
// RCC
typedef struct {
uint32_t CR;
@@ -105,7 +106,6 @@ typedef struct {
} SYSCFG;
// Interrupt
-#define SYSCFG_EXTICR4 (volatile uint32_t*) 0x40013814
#define NVIC_ISER1 (volatile uint32_t*) 0xE000E104
typedef struct {
uint32_t IMR;
@@ -116,12 +116,15 @@ typedef struct {
uint32_t PR;
} EXTI;
-
typedef struct {
unsigned int noteFrequency;
unsigned int noteDuration;
} Note;
+extern Note songIM[];
+extern Note songMT[];
+extern Note songFG[];
+
// Initializes the piezo speaker to be used with timer 3
void piezo_init();
@@ -131,8 +134,6 @@ void play_note(Note noteToPlay);
// Iterates through an array of note structs and ends at the termination value "END"
void play_song(Note *songToPlay);
-void play_note_br(Note noteToplay);
-
void play_song_br(Note *songToPlay);
// Frequency Value Signifying a rest
diff --git a/labW6barnestr/Src/main.c b/labW6barnestr/Src/main.c
index 906d55a..881aa6c 100644
--- a/labW6barnestr/Src/main.c
+++ b/labW6barnestr/Src/main.c
@@ -1,13 +1,7 @@
/**
* @file main.c
* @author Trevor Barnes
- * @brief Main Driver for the Week 5 "Play a Tune" Lab. This program uses a similar menu style to the previous
- * lab. The user is given a new option to play 3 different hard coded songs in arrays of "Note" structs,
- * provided by the piezoSpeaker.h file.
- * Experience: As a former music student I enjoyed working on this lab very much, to the point that I became
- * sort of a perfectionist with its implementation. Getting the timer configured and working with the piezo speaker
- * was certainly the most difficult and time consuming part. Once I had that figured out though figuring
- * out the best note implementation and songs to play was very enjoyable.
+ * @brief
* @version 0.1
* @date 2022-01-19
*
@@ -27,45 +21,6 @@
#define F_CPU 16000000UL
-// Imperial March - Star Wars
-Note songIM[138] = {
- {A4, Q}, {A4, Q}, {A4, Q}, {F4, S*3}, {C5, S}, {A4, Q}, {F4, S*3}, {C5, S}, {A4, H},
- {E5, Q}, {E5, Q}, {E5, Q}, {F5, S*3}, {C5, S}, {Ab4, Q}, {F4, S*3}, {C5, S}, {A4, H},
- {A5, Q}, {A4, S*3}, {A4, S}, {A5, Q}, {Ab5, S*3}, {G5, S},
- {Gb5, S}, {F5, S}, {Gb5, E}, {r, E}, {Bb4, E}, {Eb5, Q}, {D5, S*3}, {Db5, S},
- {C5, S}, {B4, S}, {C5, E}, {r, E}, {F4, E}, {Ab4, Q}, {F4, S*3}, {A4, S},
- {C5, Q}, {A4, S*3}, {C5, S}, {E5, H},
- {A5, Q}, {A4, S*3}, {A4, S}, {A5, Q}, {Ab5, S*3}, {G5, S},
- {Gb5, S}, {F5, S}, {Gb5, E}, {r, E}, {Bb4, E}, {Eb5, Q}, {D5, S*3}, {Db5, S},
- {C5, S}, {B4, S}, {C5, E}, {r, E}, {F4, E}, {Ab4, Q}, {F4, S*3}, {C5, S},
- {A4, Q}, {F4, S*3}, {C5, S}, {A4, H},
- {END}
- };
-
-// Metropolis Theme - Ratchet & Clank
-Note songMT[33] = {
- {B5, E}, {G5, E}, {E5, E}, {G5, E}, {B5, E}, {G5, E}, {E5, E}, {B5, E},
- {Bb5, E}, {F5, E}, {D5, E}, {F5, E}, {Bb5, E}, {F5, E}, {D5, E}, {Bb5, E},
- {B5, E}, {G5, E}, {E5, E}, {G5, E}, {B5, E}, {G5, E}, {E5, E}, {B5, E},
- {Bb5, E}, {F5, E}, {D5, E}, {F5, E}, {Bb5, E}, {F5, E}, {D5, E}, {Bb5, E},
- {END}
- };
-
-// Flower Garden - Yoshi's Island
-Note songFG[77] = {
- {E4, E}, {r, E}, {G4, E}, {r, S}, {G4, S}, {E4, E}, {C4, E}, {r, Q},
- {A3, E}, {r, E}, {C4, E}, {r, S}, {A3, S}, {D4, E}, {E4, E}, {r, Q},
- {E4, E}, {r, E}, {G4, E}, {r, S}, {G4, S}, {E4, E}, {C4, E}, {r, Q},
- {A3, E}, {r, E}, {C4, E}, {r, S}, {A3, S}, {E4, E}, {D4, E}, {r, Q},
- {G5, S}, {Gb5, S}, {G5, E+(Q*3)},
- {r , E}, {F5, E}, {E5, E}, {F5, E}, {E5, E}, {C5, E}, {A4, E}, {G4, E+(Q*5)}, {r, E},
- {C5, E}, {B4, E}, {D5, E}, {A5, E}, {G5, E+H+Q}, {r, E},
- {A5, E}, {B5, E}, {A5, E}, {G5, E}, {F5, E}, {E5, E}, {D5, E}, {E5, Q}, {C5, E}, {G4, E+(Q*3)}, {r, E},
- {C5, E}, {B4, E}, {C5, E}, {D5, E}, {E5, E+Q}, {G5, Q}, {C5, Q}, {E5, Q},
- {F5, E}, {E5, E}, {F5, E}, {D5, E*2}, {C5, E}, {B4, E}, {C5, E+W},
- {END}
- };
-
void printHelp() {
printf("*Commands*\n\r");
printf("'rmw {hex address}' - Reads mem at a given address\n\r");
@@ -119,13 +74,13 @@ int main(void) {
} else if (!strcmp(command, "ps")) {
// Song Selection Command Format:
// "ps {songSelection} {background}"
- sscanf(line, "%s %u %c", command, &songSelection, background);
+ sscanf(line, "%s %u %c", command, &songSelection, &background);
if (background == 'b') {
switch(songSelection) {
case 1:
printf("Playing Imperial March in the background\n\r");
play_song_br(songIM);
- break;
+ break;
case 2:
printf("Playing Metropolis Theme in the background\n\r");
play_song_br(songMT);
diff --git a/labW6barnestr/Src/piezoSpeaker.c b/labW6barnestr/Src/piezoSpeaker.c
index 165adbb..a3c4f1d 100644
--- a/labW6barnestr/Src/piezoSpeaker.c
+++ b/labW6barnestr/Src/piezoSpeaker.c
@@ -14,11 +14,55 @@
#include "piezoSpeaker.h"
#include "delay.h"
-volatile RCC* const rcc = 0x40023800;
-volatile GPIO* const gpiob = 0x40020400;
-volatile TIM* const tim3 = 0x40000400;
-volatile SYSCFG* const syscfg = 0x40013800;
-volatile EXTI* const exti4 = 0x40013C00;
+volatile RCC* const rcc = (RCC*) 0x40023800;
+volatile GPIO* const gpiob = (GPIO*) 0x40020400;
+volatile TIM* const tim3 = (TIM*) 0x40000400;
+volatile SYSCFG* const syscfg = (SYSCFG*) 0x40013800;
+volatile EXTI* const exti4 = (EXTI*) 0x40013C00;
+
+volatile Note* currentSong;
+volatile int currentNoteIndex;
+
+typedef enum {PLAY, STOP}songStatus;
+
+// Imperial March - Star Wars
+Note songIM[138] = {
+ {A4, Q}, {A4, Q}, {A4, Q}, {F4, S*3}, {C5, S}, {A4, Q}, {F4, S*3}, {C5, S}, {A4, H},
+ {E5, Q}, {E5, Q}, {E5, Q}, {F5, S*3}, {C5, S}, {Ab4, Q}, {F4, S*3}, {C5, S}, {A4, H},
+ {A5, Q}, {A4, S*3}, {A4, S}, {A5, Q}, {Ab5, S*3}, {G5, S},
+ {Gb5, S}, {F5, S}, {Gb5, E}, {r, E}, {Bb4, E}, {Eb5, Q}, {D5, S*3}, {Db5, S},
+ {C5, S}, {B4, S}, {C5, E}, {r, E}, {F4, E}, {Ab4, Q}, {F4, S*3}, {A4, S},
+ {C5, Q}, {A4, S*3}, {C5, S}, {E5, H},
+ {A5, Q}, {A4, S*3}, {A4, S}, {A5, Q}, {Ab5, S*3}, {G5, S},
+ {Gb5, S}, {F5, S}, {Gb5, E}, {r, E}, {Bb4, E}, {Eb5, Q}, {D5, S*3}, {Db5, S},
+ {C5, S}, {B4, S}, {C5, E}, {r, E}, {F4, E}, {Ab4, Q}, {F4, S*3}, {C5, S},
+ {A4, Q}, {F4, S*3}, {C5, S}, {A4, H},
+ {END}
+ };
+
+// Metropolis Theme - Ratchet & Clank
+Note songMT[33] = {
+ {B5, E}, {G5, E}, {E5, E}, {G5, E}, {B5, E}, {G5, E}, {E5, E}, {B5, E},
+ {Bb5, E}, {F5, E}, {D5, E}, {F5, E}, {Bb5, E}, {F5, E}, {D5, E}, {Bb5, E},
+ {B5, E}, {G5, E}, {E5, E}, {G5, E}, {B5, E}, {G5, E}, {E5, E}, {B5, E},
+ {Bb5, E}, {F5, E}, {D5, E}, {F5, E}, {Bb5, E}, {F5, E}, {D5, E}, {Bb5, E},
+ {END}
+ };
+
+// Flower Garden - Yoshi's Island
+Note songFG[77] = {
+ {E4, E}, {r, E}, {G4, E}, {r, S}, {G4, S}, {E4, E}, {C4, E}, {r, Q},
+ {A3, E}, {r, E}, {C4, E}, {r, S}, {A3, S}, {D4, E}, {E4, E}, {r, Q},
+ {E4, E}, {r, E}, {G4, E}, {r, S}, {G4, S}, {E4, E}, {C4, E}, {r, Q},
+ {A3, E}, {r, E}, {C4, E}, {r, S}, {A3, S}, {E4, E}, {D4, E}, {r, Q},
+ {G5, S}, {Gb5, S}, {G5, E+(Q*3)},
+ {r , E}, {F5, E}, {E5, E}, {F5, E}, {E5, E}, {C5, E}, {A4, E}, {G4, E+(Q*5)}, {r, E},
+ {C5, E}, {B4, E}, {D5, E}, {A5, E}, {G5, E+W+E}, {r, E},
+ {A5, E}, {B5, E}, {A5, E}, {G5, E}, {F5, E}, {E5, E}, {D5, E}, {E5, Q}, {C5, E}, {G4, E+(Q*3)}, {r, E},
+ {C5, E}, {B4, E}, {C5, E}, {D5, E}, {E5, E+Q}, {G5, Q}, {C5, Q}, {E5, Q},
+ {F5, E}, {E5, E}, {F5, E}, {D5, E*2}, {C5, E}, {B4, E}, {C5, E+W},
+ {END}
+ };
void piezo_init(){
@@ -73,35 +117,45 @@ void play_song(Note *songToPlay){
}
}
-void play_note_br(Note noteToplay) {
-
-}
-
void TIM3_IRQHandler(void) {
- (*tim3).PSC = 15;
- // Pitch divisor to scale with timer
- (*tim3).ARR = (pitchDivisor)/(noteToPlay.noteFrequency);
- // Volume (Smaller dividend = louder sound)
- unsigned int freq = (noteToPlay.noteFrequency/10);
+ //temp
+ if(PLAY) {
+ (*tim3).PSC = 15;
+ // Pitch divisor to scale with timer
+ //current note frequency global variable
+ //(*tim3).ARR = (pitchDivisor)/(noteToPlay.noteFrequency);
- // Clear CCR
- (*tim3).CCR1 = ((*tim3).CCR1&~(0xFFFF));
- (*tim3).CCR1 = freq;
+ // Volume (Smaller dividend = louder sound)
+ //current note frequency global variable
+ //unsigned int freq = (noteToPlay.noteFrequency/10);
- // Set EGR
- (*tim3).EGR |= EGR_UG;
+ // Clear CCR
+ (*tim3).CCR1 = ((*tim3).CCR1&~(0xFFFF));
+ //(*tim3).CCR1 = freq;
- // Playing note
- // Enables timer
- (*tim3).CR1 |= 1;
- // Delay for duration of note
- // This is gonna have to change
- delay_1ms(noteToPlay.noteDuration);
- // Disables timer
- (*tim3).CR1 &= ~1;
+ // Set EGR
+ (*tim3).EGR |= EGR_UG;
+
+ // Playing note
+ // Enables timer
+ (*tim3).CR1 |= 1;
+ // Delay for duration of note
+ // This is gonna have to change
+ //delay_1ms(noteToPlay.noteDuration);
+ // Load timer with value of note duration
+ //currentNote = currentSong[currentNoteIndex];
+ } else {
+ while(currentSong[currentNoteIndex].noteFrequency != END) {
+
+ }
+ //currentNote = currentSong
+ }
}
void play_song_br(Note *songToPlay) {
+ // Set current song global variable
+ currentSong = songToPlay;
+ // Configure Interrupt
// PB4 Connected to EXTI4
(*syscfg).EXTICR2 &= ~(0xF);
(*syscfg).EXTICR2 &= ~(0x1);
diff --git a/labW7barnestr/.cproject b/labW7barnestr/.cproject
index a9cd4fb..4d9f7de 100644
--- a/labW7barnestr/.cproject
+++ b/labW7barnestr/.cproject
@@ -21,7 +21,7 @@
-
+
@@ -94,38 +94,38 @@
-
-
-
-
-
-
-
+
+
+
+
+
+
+
-
+
-
+
-
-
-
+
+
+
-
+
-
-
+
+
-
+
@@ -149,6 +149,7 @@
+
@@ -166,4 +167,5 @@
+
\ No newline at end of file
diff --git a/labW7barnestr/Src/main.c b/labW7barnestr/Src/main.c
index 2a53113..71a4119 100644
--- a/labW7barnestr/Src/main.c
+++ b/labW7barnestr/Src/main.c
@@ -1,29 +1,16 @@
/**
- ******************************************************************************
- * @file : main.c
- * @author : Auto-generated by STM32CubeIDE
- * @brief : Main program body
- ******************************************************************************
- * @attention
- *
- * Copyright (c) 2022 STMicroelectronics.
- * All rights reserved.
- *
- * This software is licensed under terms that can be found in the LICENSE file
- * in the root directory of this software component.
- * If no LICENSE file comes with this software, it is provided AS-IS.
- *
- ******************************************************************************
+ * @file main.c
+ * @author Trevor Barnes
+ * @brief
+ * @version 0.1
+ * @date 2022-01-28
+ *
+ * @copyright Copyright (c) 2022
+ *
*/
-#include
-
-#if !defined(__SOFT_FP__) && defined(__ARM_FP)
- #warning "FPU is not initialized, but the project is compiling for an FPU. Please initialize the FPU before use."
-#endif
int main(void)
{
- /* Loop forever */
for(;;);
}
diff --git a/labW7barnestr/Src/syscalls.c b/labW7barnestr/Src/syscalls.c
deleted file mode 100644
index 8370509..0000000
--- a/labW7barnestr/Src/syscalls.c
+++ /dev/null
@@ -1,155 +0,0 @@
-/**
- ******************************************************************************
- * @file syscalls.c
- * @author Auto-generated by STM32CubeIDE
- * @brief STM32CubeIDE Minimal System calls file
- *
- * For more information about which c-functions
- * need which of these lowlevel functions
- * please consult the Newlib libc-manual
- ******************************************************************************
- * @attention
- *
- * Copyright (c) 2021 STMicroelectronics.
- * All rights reserved.
- *
- * This software is licensed under terms that can be found in the LICENSE file
- * in the root directory of this software component.
- * If no LICENSE file comes with this software, it is provided AS-IS.
- *
- ******************************************************************************
- */
-
-/* Includes */
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-
-/* Variables */
-extern int __io_putchar(int ch) __attribute__((weak));
-extern int __io_getchar(void) __attribute__((weak));
-
-
-char *__env[1] = { 0 };
-char **environ = __env;
-
-
-/* Functions */
-void initialise_monitor_handles()
-{
-}
-
-int _getpid(void)
-{
- return 1;
-}
-
-int _kill(int pid, int sig)
-{
- errno = EINVAL;
- return -1;
-}
-
-void _exit (int status)
-{
- _kill(status, -1);
- while (1) {} /* Make sure we hang here */
-}
-
-__attribute__((weak)) int _read(int file, char *ptr, int len)
-{
- int DataIdx;
-
- for (DataIdx = 0; DataIdx < len; DataIdx++)
- {
- *ptr++ = __io_getchar();
- }
-
-return len;
-}
-
-__attribute__((weak)) int _write(int file, char *ptr, int len)
-{
- int DataIdx;
-
- for (DataIdx = 0; DataIdx < len; DataIdx++)
- {
- __io_putchar(*ptr++);
- }
- return len;
-}
-
-int _close(int file)
-{
- return -1;
-}
-
-
-int _fstat(int file, struct stat *st)
-{
- st->st_mode = S_IFCHR;
- return 0;
-}
-
-int _isatty(int file)
-{
- return 1;
-}
-
-int _lseek(int file, int ptr, int dir)
-{
- return 0;
-}
-
-int _open(char *path, int flags, ...)
-{
- /* Pretend like we always fail */
- return -1;
-}
-
-int _wait(int *status)
-{
- errno = ECHILD;
- return -1;
-}
-
-int _unlink(char *name)
-{
- errno = ENOENT;
- return -1;
-}
-
-int _times(struct tms *buf)
-{
- return -1;
-}
-
-int _stat(char *file, struct stat *st)
-{
- st->st_mode = S_IFCHR;
- return 0;
-}
-
-int _link(char *old, char *new)
-{
- errno = EMLINK;
- return -1;
-}
-
-int _fork(void)
-{
- errno = EAGAIN;
- return -1;
-}
-
-int _execve(char *name, char **argv, char **env)
-{
- errno = ENOMEM;
- return -1;
-}
diff --git a/labW7barnestr/Src/sysmem.c b/labW7barnestr/Src/sysmem.c
deleted file mode 100644
index 4353a47..0000000
--- a/labW7barnestr/Src/sysmem.c
+++ /dev/null
@@ -1,79 +0,0 @@
-/**
- ******************************************************************************
- * @file sysmem.c
- * @author Generated by STM32CubeIDE
- * @brief STM32CubeIDE System Memory calls file
- *
- * For more information about which C functions
- * need which of these lowlevel functions
- * please consult the newlib libc manual
- ******************************************************************************
- * @attention
- *
- * Copyright (c) 2021 STMicroelectronics.
- * All rights reserved.
- *
- * This software is licensed under terms that can be found in the LICENSE file
- * in the root directory of this software component.
- * If no LICENSE file comes with this software, it is provided AS-IS.
- *
- ******************************************************************************
- */
-
-/* Includes */
-#include
-#include
-
-/**
- * Pointer to the current high watermark of the heap usage
- */
-static uint8_t *__sbrk_heap_end = NULL;
-
-/**
- * @brief _sbrk() allocates memory to the newlib heap and is used by malloc
- * and others from the C library
- *
- * @verbatim
- * ############################################################################
- * # .data # .bss # newlib heap # MSP stack #
- * # # # # Reserved by _Min_Stack_Size #
- * ############################################################################
- * ^-- RAM start ^-- _end _estack, RAM end --^
- * @endverbatim
- *
- * This implementation starts allocating at the '_end' linker symbol
- * The '_Min_Stack_Size' linker symbol reserves a memory for the MSP stack
- * The implementation considers '_estack' linker symbol to be RAM end
- * NOTE: If the MSP stack, at any point during execution, grows larger than the
- * reserved size, please increase the '_Min_Stack_Size'.
- *
- * @param incr Memory size
- * @return Pointer to allocated memory
- */
-void *_sbrk(ptrdiff_t incr)
-{
- extern uint8_t _end; /* Symbol defined in the linker script */
- extern uint8_t _estack; /* Symbol defined in the linker script */
- extern uint32_t _Min_Stack_Size; /* Symbol defined in the linker script */
- const uint32_t stack_limit = (uint32_t)&_estack - (uint32_t)&_Min_Stack_Size;
- const uint8_t *max_heap = (uint8_t *)stack_limit;
- uint8_t *prev_heap_end;
-
- /* Initialize heap end at first call */
- if (NULL == __sbrk_heap_end)
- {
- __sbrk_heap_end = &_end;
- }
-
- /* Protect heap from growing into the reserved MSP stack */
- if (__sbrk_heap_end + incr > max_heap)
- {
- errno = ENOMEM;
- return (void *)-1;
- }
-
- prev_heap_end = __sbrk_heap_end;
- __sbrk_heap_end += incr;
-
- return (void *)prev_heap_end;
-}
diff --git a/labW8barnestr/.cproject b/labW8barnestr/.cproject
new file mode 100644
index 0000000..4ac15dc
--- /dev/null
+++ b/labW8barnestr/.cproject
@@ -0,0 +1,171 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/labW8barnestr/.project b/labW8barnestr/.project
new file mode 100644
index 0000000..4d491f1
--- /dev/null
+++ b/labW8barnestr/.project
@@ -0,0 +1,31 @@
+
+
+ labW8barnestr
+
+
+
+
+
+ org.eclipse.cdt.managedbuilder.core.genmakebuilder
+ clean,full,incremental,
+
+
+
+
+ org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
+ full,incremental,
+
+
+
+
+
+ com.st.stm32cube.ide.mcu.MCUProjectNature
+ org.eclipse.cdt.core.cnature
+ com.st.stm32cube.ide.mcu.MCUCubeIdeServicesRevAev2ProjectNature
+ com.st.stm32cube.ide.mcu.MCUManagedMakefileProjectNature
+ com.st.stm32cube.ide.mcu.MCUSingleCpuProjectNature
+ com.st.stm32cube.ide.mcu.MCURootProjectNature
+ org.eclipse.cdt.managedbuilder.core.managedBuildNature
+ org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
+
+
diff --git a/labW8barnestr/STM32F446RETX_FLASH.ld b/labW8barnestr/STM32F446RETX_FLASH.ld
new file mode 100644
index 0000000..db39937
--- /dev/null
+++ b/labW8barnestr/STM32F446RETX_FLASH.ld
@@ -0,0 +1,185 @@
+/*
+******************************************************************************
+**
+** @file : LinkerScript.ld
+**
+** @author : Auto-generated by STM32CubeIDE
+**
+** @brief : Linker script for STM32F446RETx Device from STM32F4 series
+** 512Kbytes FLASH
+** 128Kbytes RAM
+**
+** Set heap size, stack size and stack location according
+** to application requirements.
+**
+** Set memory bank area and size if external memory is used
+**
+** Target : STMicroelectronics STM32
+**
+** Distribution: The file is distributed as is, without any warranty
+** of any kind.
+**
+******************************************************************************
+** @attention
+**
+** Copyright (c) 2022 STMicroelectronics.
+** All rights reserved.
+**
+** This software is licensed under terms that can be found in the LICENSE file
+** in the root directory of this software component.
+** If no LICENSE file comes with this software, it is provided AS-IS.
+**
+******************************************************************************
+*/
+
+/* Entry Point */
+ENTRY(Reset_Handler)
+
+/* Highest address of the user mode stack */
+_estack = ORIGIN(RAM) + LENGTH(RAM); /* end of "RAM" Ram type memory */
+
+_Min_Heap_Size = 0x200; /* required amount of heap */
+_Min_Stack_Size = 0x400; /* required amount of stack */
+
+/* Memories definition */
+MEMORY
+{
+ RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K
+ FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 512K
+}
+
+/* Sections */
+SECTIONS
+{
+ /* The startup code into "FLASH" Rom type memory */
+ .isr_vector :
+ {
+ . = ALIGN(4);
+ KEEP(*(.isr_vector)) /* Startup code */
+ . = ALIGN(4);
+ } >FLASH
+
+ /* The program code and other data into "FLASH" Rom type memory */
+ .text :
+ {
+ . = ALIGN(4);
+ *(.text) /* .text sections (code) */
+ *(.text*) /* .text* sections (code) */
+ *(.glue_7) /* glue arm to thumb code */
+ *(.glue_7t) /* glue thumb to arm code */
+ *(.eh_frame)
+
+ KEEP (*(.init))
+ KEEP (*(.fini))
+
+ . = ALIGN(4);
+ _etext = .; /* define a global symbols at end of code */
+ } >FLASH
+
+ /* Constant data into "FLASH" Rom type memory */
+ .rodata :
+ {
+ . = ALIGN(4);
+ *(.rodata) /* .rodata sections (constants, strings, etc.) */
+ *(.rodata*) /* .rodata* sections (constants, strings, etc.) */
+ . = ALIGN(4);
+ } >FLASH
+
+ .ARM.extab : {
+ . = ALIGN(4);
+ *(.ARM.extab* .gnu.linkonce.armextab.*)
+ . = ALIGN(4);
+ } >FLASH
+
+ .ARM : {
+ . = ALIGN(4);
+ __exidx_start = .;
+ *(.ARM.exidx*)
+ __exidx_end = .;
+ . = ALIGN(4);
+ } >FLASH
+
+ .preinit_array :
+ {
+ . = ALIGN(4);
+ PROVIDE_HIDDEN (__preinit_array_start = .);
+ KEEP (*(.preinit_array*))
+ PROVIDE_HIDDEN (__preinit_array_end = .);
+ . = ALIGN(4);
+ } >FLASH
+
+ .init_array :
+ {
+ . = ALIGN(4);
+ PROVIDE_HIDDEN (__init_array_start = .);
+ KEEP (*(SORT(.init_array.*)))
+ KEEP (*(.init_array*))
+ PROVIDE_HIDDEN (__init_array_end = .);
+ . = ALIGN(4);
+ } >FLASH
+
+ .fini_array :
+ {
+ . = ALIGN(4);
+ PROVIDE_HIDDEN (__fini_array_start = .);
+ KEEP (*(SORT(.fini_array.*)))
+ KEEP (*(.fini_array*))
+ PROVIDE_HIDDEN (__fini_array_end = .);
+ . = ALIGN(4);
+ } >FLASH
+
+ /* Used by the startup to initialize data */
+ _sidata = LOADADDR(.data);
+
+ /* Initialized data sections into "RAM" Ram type memory */
+ .data :
+ {
+ . = ALIGN(4);
+ _sdata = .; /* create a global symbol at data start */
+ *(.data) /* .data sections */
+ *(.data*) /* .data* sections */
+ *(.RamFunc) /* .RamFunc sections */
+ *(.RamFunc*) /* .RamFunc* sections */
+
+ . = ALIGN(4);
+ _edata = .; /* define a global symbol at data end */
+
+ } >RAM AT> FLASH
+
+ /* Uninitialized data section into "RAM" Ram type memory */
+ . = ALIGN(4);
+ .bss :
+ {
+ /* This is used by the startup in order to initialize the .bss section */
+ _sbss = .; /* define a global symbol at bss start */
+ __bss_start__ = _sbss;
+ *(.bss)
+ *(.bss*)
+ *(COMMON)
+
+ . = ALIGN(4);
+ _ebss = .; /* define a global symbol at bss end */
+ __bss_end__ = _ebss;
+ } >RAM
+
+ /* User_heap_stack section, used to check that there is enough "RAM" Ram type memory left */
+ ._user_heap_stack :
+ {
+ . = ALIGN(8);
+ PROVIDE ( end = . );
+ PROVIDE ( _end = . );
+ . = . + _Min_Heap_Size;
+ . = . + _Min_Stack_Size;
+ . = ALIGN(8);
+ } >RAM
+
+ /* Remove information from the compiler libraries */
+ /DISCARD/ :
+ {
+ libc.a ( * )
+ libm.a ( * )
+ libgcc.a ( * )
+ }
+
+ .ARM.attributes 0 : { *(.ARM.attributes) }
+}
diff --git a/labW8barnestr/STM32F446RETX_RAM.ld b/labW8barnestr/STM32F446RETX_RAM.ld
new file mode 100644
index 0000000..a3ed812
--- /dev/null
+++ b/labW8barnestr/STM32F446RETX_RAM.ld
@@ -0,0 +1,185 @@
+/*
+******************************************************************************
+**
+** @file : LinkerScript.ld (debug in RAM dedicated)
+**
+** @author : Auto-generated by STM32CubeIDE
+**
+** @brief : Linker script for STM32F446RETx Device from STM32F4 series
+** 512Kbytes FLASH
+** 128Kbytes RAM
+**
+** Set heap size, stack size and stack location according
+** to application requirements.
+**
+** Set memory bank area and size if external memory is used
+**
+** Target : STMicroelectronics STM32
+**
+** Distribution: The file is distributed as is, without any warranty
+** of any kind.
+**
+******************************************************************************
+** @attention
+**
+** Copyright (c) 2022 STMicroelectronics.
+** All rights reserved.
+**
+** This software is licensed under terms that can be found in the LICENSE file
+** in the root directory of this software component.
+** If no LICENSE file comes with this software, it is provided AS-IS.
+**
+******************************************************************************
+*/
+
+/* Entry Point */
+ENTRY(Reset_Handler)
+
+/* Highest address of the user mode stack */
+_estack = ORIGIN(RAM) + LENGTH(RAM); /* end of "RAM" Ram type memory */
+
+_Min_Heap_Size = 0x200; /* required amount of heap */
+_Min_Stack_Size = 0x400; /* required amount of stack */
+
+/* Memories definition */
+MEMORY
+{
+ RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K
+ FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 512K
+}
+
+/* Sections */
+SECTIONS
+{
+ /* The startup code into "RAM" Ram type memory */
+ .isr_vector :
+ {
+ . = ALIGN(4);
+ KEEP(*(.isr_vector)) /* Startup code */
+ . = ALIGN(4);
+ } >RAM
+
+ /* The program code and other data into "RAM" Ram type memory */
+ .text :
+ {
+ . = ALIGN(4);
+ *(.text) /* .text sections (code) */
+ *(.text*) /* .text* sections (code) */
+ *(.glue_7) /* glue arm to thumb code */
+ *(.glue_7t) /* glue thumb to arm code */
+ *(.eh_frame)
+ *(.RamFunc) /* .RamFunc sections */
+ *(.RamFunc*) /* .RamFunc* sections */
+
+ KEEP (*(.init))
+ KEEP (*(.fini))
+
+ . = ALIGN(4);
+ _etext = .; /* define a global symbols at end of code */
+ } >RAM
+
+ /* Constant data into "RAM" Ram type memory */
+ .rodata :
+ {
+ . = ALIGN(4);
+ *(.rodata) /* .rodata sections (constants, strings, etc.) */
+ *(.rodata*) /* .rodata* sections (constants, strings, etc.) */
+ . = ALIGN(4);
+ } >RAM
+
+ .ARM.extab : {
+ . = ALIGN(4);
+ *(.ARM.extab* .gnu.linkonce.armextab.*)
+ . = ALIGN(4);
+ } >RAM
+
+ .ARM : {
+ . = ALIGN(4);
+ __exidx_start = .;
+ *(.ARM.exidx*)
+ __exidx_end = .;
+ . = ALIGN(4);
+ } >RAM
+
+ .preinit_array :
+ {
+ . = ALIGN(4);
+ PROVIDE_HIDDEN (__preinit_array_start = .);
+ KEEP (*(.preinit_array*))
+ PROVIDE_HIDDEN (__preinit_array_end = .);
+ . = ALIGN(4);
+ } >RAM
+
+ .init_array :
+ {
+ . = ALIGN(4);
+ PROVIDE_HIDDEN (__init_array_start = .);
+ KEEP (*(SORT(.init_array.*)))
+ KEEP (*(.init_array*))
+ PROVIDE_HIDDEN (__init_array_end = .);
+ . = ALIGN(4);
+ } >RAM
+
+ .fini_array :
+ {
+ . = ALIGN(4);
+ PROVIDE_HIDDEN (__fini_array_start = .);
+ KEEP (*(SORT(.fini_array.*)))
+ KEEP (*(.fini_array*))
+ PROVIDE_HIDDEN (__fini_array_end = .);
+ . = ALIGN(4);
+ } >RAM
+
+ /* Used by the startup to initialize data */
+ _sidata = LOADADDR(.data);
+
+ /* Initialized data sections into "RAM" Ram type memory */
+ .data :
+ {
+ . = ALIGN(4);
+ _sdata = .; /* create a global symbol at data start */
+ *(.data) /* .data sections */
+ *(.data*) /* .data* sections */
+
+ . = ALIGN(4);
+ _edata = .; /* define a global symbol at data end */
+
+ } >RAM
+
+ /* Uninitialized data section into "RAM" Ram type memory */
+ . = ALIGN(4);
+ .bss :
+ {
+ /* This is used by the startup in order to initialize the .bss section */
+ _sbss = .; /* define a global symbol at bss start */
+ __bss_start__ = _sbss;
+ *(.bss)
+ *(.bss*)
+ *(COMMON)
+
+ . = ALIGN(4);
+ _ebss = .; /* define a global symbol at bss end */
+ __bss_end__ = _ebss;
+ } >RAM
+
+ /* User_heap_stack section, used to check that there is enough "RAM" Ram type memory left */
+ ._user_heap_stack :
+ {
+ . = ALIGN(8);
+ PROVIDE ( end = . );
+ PROVIDE ( _end = . );
+ . = . + _Min_Heap_Size;
+ . = . + _Min_Stack_Size;
+ . = ALIGN(8);
+ } >RAM
+
+ /* Remove information from the compiler libraries */
+ /DISCARD/ :
+ {
+ libc.a ( * )
+ libm.a ( * )
+ libgcc.a ( * )
+ }
+
+ .ARM.attributes 0 : { *(.ARM.attributes) }
+}
diff --git a/labW8barnestr/Src/main.c b/labW8barnestr/Src/main.c
new file mode 100644
index 0000000..e2cb1aa
--- /dev/null
+++ b/labW8barnestr/Src/main.c
@@ -0,0 +1,16 @@
+/**
+ * @file main.c
+ * @author Trevor Barnes
+ * @brief
+ * @version 0.1
+ * @date 2022-02-04
+ *
+ * @copyright Copyright (c) 2022
+ *
+ */
+
+
+int main(void)
+{
+ for(;;);
+}
diff --git a/labW8barnestr/Startup/startup_stm32f446retx.s b/labW8barnestr/Startup/startup_stm32f446retx.s
new file mode 100644
index 0000000..94030ea
--- /dev/null
+++ b/labW8barnestr/Startup/startup_stm32f446retx.s
@@ -0,0 +1,539 @@
+/**
+ ******************************************************************************
+ * @file startup_stm32f446retx.s
+ * @author Auto-generated by STM32CubeIDE
+ * @brief STM32F446RETx device vector table for GCC toolchain.
+ * This module performs:
+ * - Set the initial SP
+ * - Set the initial PC == Reset_Handler,
+ * - Set the vector table entries with the exceptions ISR address
+ * - Branches to main in the C library (which eventually
+ * calls main()).
+ ******************************************************************************
+ * @attention
+ *
+ * Copyright (c) ${year} STMicroelectronics.
+ * All rights reserved.
+ *
+ * This software is licensed under terms that can be found in the LICENSE file
+ * in the root directory of this software component.
+ * If no LICENSE file comes with this software, it is provided AS-IS.
+ *
+ ******************************************************************************
+ */
+
+.syntax unified
+.cpu cortex-m4
+.fpu softvfp
+.thumb
+
+.global g_pfnVectors
+.global Default_Handler
+
+/* start address for the initialization values of the .data section.
+defined in linker script */
+.word _sidata
+/* start address for the .data section. defined in linker script */
+.word _sdata
+/* end address for the .data section. defined in linker script */
+.word _edata
+/* start address for the .bss section. defined in linker script */
+.word _sbss
+/* end address for the .bss section. defined in linker script */
+.word _ebss
+
+/**
+ * @brief This is the code that gets called when the processor first
+ * starts execution following a reset event. Only the absolutely
+ * necessary set is performed, after which the application
+ * supplied main() routine is called.
+ * @param None
+ * @retval : None
+*/
+
+ .section .text.Reset_Handler
+ .weak Reset_Handler
+ .type Reset_Handler, %function
+Reset_Handler:
+ ldr r0, =_estack
+ mov sp, r0 /* set stack pointer */
+/* Call the clock system initialization function.*/
+ bl SystemInit
+
+/* Copy the data segment initializers from flash to SRAM */
+ ldr r0, =_sdata
+ ldr r1, =_edata
+ ldr r2, =_sidata
+ movs r3, #0
+ b LoopCopyDataInit
+
+CopyDataInit:
+ ldr r4, [r2, r3]
+ str r4, [r0, r3]
+ adds r3, r3, #4
+
+LoopCopyDataInit:
+ adds r4, r0, r3
+ cmp r4, r1
+ bcc CopyDataInit
+
+/* Zero fill the bss segment. */
+ ldr r2, =_sbss
+ ldr r4, =_ebss
+ movs r3, #0
+ b LoopFillZerobss
+
+FillZerobss:
+ str r3, [r2]
+ adds r2, r2, #4
+
+LoopFillZerobss:
+ cmp r2, r4
+ bcc FillZerobss
+
+/* Call static constructors */
+ bl __libc_init_array
+/* Call the application's entry point.*/
+ bl main
+
+LoopForever:
+ b LoopForever
+
+ .size Reset_Handler, .-Reset_Handler
+
+/**
+ * @brief This is the code that gets called when the processor receives an
+ * unexpected interrupt. This simply enters an infinite loop, preserving
+ * the system state for examination by a debugger.
+ *
+ * @param None
+ * @retval : None
+*/
+ .section .text.Default_Handler,"ax",%progbits
+Default_Handler:
+Infinite_Loop:
+ b Infinite_Loop
+ .size Default_Handler, .-Default_Handler
+
+/******************************************************************************
+*
+* The STM32F446RETx vector table. Note that the proper constructs
+* must be placed on this to ensure that it ends up at physical address
+* 0x0000.0000.
+*
+******************************************************************************/
+ .section .isr_vector,"a",%progbits
+ .type g_pfnVectors, %object
+ .size g_pfnVectors, .-g_pfnVectors
+
+g_pfnVectors:
+ .word _estack
+ .word Reset_Handler
+ .word NMI_Handler
+ .word HardFault_Handler
+ .word MemManage_Handler
+ .word BusFault_Handler
+ .word UsageFault_Handler
+ .word 0
+ .word 0
+ .word 0
+ .word 0
+ .word SVC_Handler
+ .word DebugMon_Handler
+ .word 0
+ .word PendSV_Handler
+ .word SysTick_Handler
+ .word WWDG_IRQHandler /* Window Watchdog interrupt */
+ .word PVD_IRQHandler /* PVD through EXTI line detection interrupt */
+ .word TAMP_STAMP_IRQHandler /* Tamper and TimeStamp interrupts through the EXTI line */
+ .word RTC_WKUP_IRQHandler /* RTC Wakeup interrupt through the EXTI line */
+ .word FLASH_IRQHandler /* Flash global interrupt */
+ .word RCC_IRQHandler /* RCC global interrupt */
+ .word EXTI0_IRQHandler /* EXTI Line0 interrupt */
+ .word EXTI1_IRQHandler /* EXTI Line1 interrupt */
+ .word EXTI2_IRQHandler /* EXTI Line2 interrupt */
+ .word EXTI3_IRQHandler /* EXTI Line3 interrupt */
+ .word EXTI4_IRQHandler /* EXTI Line4 interrupt */
+ .word DMA1_Stream0_IRQHandler /* DMA1 Stream0 global interrupt */
+ .word DMA1_Stream1_IRQHandler /* DMA1 Stream1 global interrupt */
+ .word DMA1_Stream2_IRQHandler /* DMA1 Stream2 global interrupt */
+ .word DMA1_Stream3_IRQHandler /* DMA1 Stream3 global interrupt */
+ .word DMA1_Stream4_IRQHandler /* DMA1 Stream4 global interrupt */
+ .word DMA1_Stream5_IRQHandler /* DMA1 Stream5 global interrupt */
+ .word DMA1_Stream6_IRQHandler /* DMA1 Stream6 global interrupt */
+ .word ADC_IRQHandler /* ADC1 global interrupt */
+ .word CAN1_TX_IRQHandler /* CAN1 TX interrupts */
+ .word CAN1_RX0_IRQHandler /* CAN1 RX0 interrupts */
+ .word CAN1_RX1_IRQHandler /* CAN1 RX1 interrupts */
+ .word CAN1_SCE_IRQHandler /* CAN1 SCE interrupt */
+ .word EXTI9_5_IRQHandler /* EXTI Line[9:5] interrupts */
+ .word TIM1_BRK_TIM9_IRQHandler /* TIM1 Break interrupt and TIM9 global interrupt */
+ .word TIM1_UP_TIM10_IRQHandler /* TIM1 Update interrupt and TIM10 global interrupt */
+ .word TIM1_TRG_COM_TIM11_IRQHandler /* TIM1 Trigger and Commutation interrupts and TIM11 global interrupt */
+ .word TIM1_CC_IRQHandler /* TIM1 Capture Compare interrupt */
+ .word TIM2_IRQHandler /* TIM2 global interrupt */
+ .word TIM3_IRQHandler /* TIM3 global interrupt */
+ .word TIM4_IRQHandler /* TIM4 global interrupt */
+ .word I2C1_EV_IRQHandler /* I2C1 event interrupt */
+ .word I2C1_ER_IRQHandler /* I2C1 error interrupt */
+ .word I2C2_EV_IRQHandler /* I2C2 event interrupt */
+ .word I2C2_ER_IRQHandler /* I2C2 error interrupt */
+ .word SPI1_IRQHandler /* SPI1 global interrupt */
+ .word SPI2_IRQHandler /* SPI2 global interrupt */
+ .word USART1_IRQHandler /* USART1 global interrupt */
+ .word USART2_IRQHandler /* USART2 global interrupt */
+ .word USART3_IRQHandler /* USART3 global interrupt */
+ .word EXTI15_10_IRQHandler /* EXTI Line[15:10] interrupts */
+ .word RTC_Alarm_IRQHandler /* RTC Alarms (A and B) through EXTI line interrupt */
+ .word OTG_FS_WKUP_IRQHandler /* USB On-The-Go FS Wakeup through EXTI line interrupt */
+ .word TIM8_BRK_TIM12_IRQHandler /* TIM8 Break interrupt and TIM12 global interrupt */
+ .word TIM8_UP_TIM13_IRQHandler /* TIM8 Update interrupt and TIM13 global interrupt */
+ .word TIM8_TRG_COM_TIM14_IRQHandler /* TIM8 Trigger and Commutation interrupts and TIM14 global interrupt */
+ .word TIM8_CC_IRQHandler /* TIM8 Capture Compare interrupt */
+ .word DMA1_Stream7_IRQHandler /* DMA1 Stream7 global interrupt */
+ .word FMC_IRQHandler /* FMC global interrupt */
+ .word SDIO_IRQHandler /* SDIO global interrupt */
+ .word TIM5_IRQHandler /* TIM5 global interrupt */
+ .word SPI3_IRQHandler /* SPI3 global interrupt */
+ .word UART4_IRQHandler /* UART4 global interrupt */
+ .word UART5_IRQHandler /* UART5 global interrupt */
+ .word TIM6_DAC_IRQHandler /* TIM6 global interrupt, DAC1 and DAC2 underrun error interrupt */
+ .word TIM7_IRQHandler /* TIM7 global interrupt */
+ .word DMA2_Stream0_IRQHandler /* DMA2 Stream0 global interrupt */
+ .word DMA2_Stream1_IRQHandler /* DMA2 Stream1 global interrupt */
+ .word DMA2_Stream2_IRQHandler /* DMA2 Stream2 global interrupt */
+ .word DMA2_Stream3_IRQHandler /* DMA2 Stream3 global interrupt */
+ .word DMA2_Stream4_IRQHandler /* DMA2 Stream4 global interrupt */
+ .word 0 /* Reserved */
+ .word 0 /* Reserved */
+ .word CAN2_TX_IRQHandler /* CAN2 TX interrupts */
+ .word CAN2_RX0_IRQHandler /* CAN2 RX0 interrupts */
+ .word CAN2_RX1_IRQHandler /* CAN2 RX1 interrupts */
+ .word CAN2_SCE_IRQHandler /* CAN2 SCE interrupt */
+ .word OTG_FS_IRQHandler /* USB On The Go FS global interrupt */
+ .word DMA2_Stream5_IRQHandler /* DMA2 Stream5 global interrupt */
+ .word DMA2_Stream6_IRQHandler /* DMA2 Stream6 global interrupt */
+ .word DMA2_Stream7_IRQHandler /* DMA2 Stream7 global interrupt */
+ .word USART6_IRQHandler /* USART6 global interrupt */
+ .word I2C3_EV_IRQHandler /* I2C3 event interrupt */
+ .word I2C3_ER_IRQHandler /* I2C3 error interrupt */
+ .word OTG_HS_EP1_OUT_IRQHandler /* USB On The Go HS End Point 1 Out */
+ .word OTG_HS_EP1_IN_IRQHandler /* USB On The Go HS End Point 1 In */
+ .word OTG_HS_WKUP_IRQHandler /* USB On The Go HS Wakeup */
+ .word OTG_HS_IRQHandler /* USB On The Go HS global interrupt */
+ .word DCMI_IRQHandler /* DCMI global interrupt */
+ .word 0 /* Reserved */
+ .word 0 /* Reserved */
+ .word FPU_IRQHandler /* Floating point unit interrupt */
+ .word 0 /* Reserved */
+ .word 0 /* Reserved */
+ .word SPI4_IRQHandler /* SPI 4 global interrupt */
+ .word 0 /* Reserved */
+ .word 0 /* Reserved */
+ .word SAI1_IRQHandler /* SAI1 global interrupt */
+ .word 0 /* Reserved */
+ .word 0 /* Reserved */
+ .word 0 /* Reserved */
+ .word SAI2_IRQHandler /* SAI2 global interrupt */
+ .word QuadSPI_IRQHandler /* QuadSPI global interrupt */
+ .word HDMI_CEC_IRQHandler /* HDMI-CEC global interrupt */
+ .word SPDIF_Rx_IRQHandler /* SPDIF-Rx global interrupt */
+ .word FMPI2C1_IRQHandler /* FMPI2C1 event interrupt */
+ .word FMPI2C1_error_IRQHandler /* FMPI2C1 error interrupt */
+
+/*******************************************************************************
+*
+* Provide weak aliases for each Exception handler to the Default_Handler.
+* As they are weak aliases, any function with the same name will override
+* this definition.
+*
+*******************************************************************************/
+
+ .weak NMI_Handler
+ .thumb_set NMI_Handler,Default_Handler
+
+ .weak HardFault_Handler
+ .thumb_set HardFault_Handler,Default_Handler
+
+ .weak MemManage_Handler
+ .thumb_set MemManage_Handler,Default_Handler
+
+ .weak BusFault_Handler
+ .thumb_set BusFault_Handler,Default_Handler
+
+ .weak UsageFault_Handler
+ .thumb_set UsageFault_Handler,Default_Handler
+
+ .weak SVC_Handler
+ .thumb_set SVC_Handler,Default_Handler
+
+ .weak DebugMon_Handler
+ .thumb_set DebugMon_Handler,Default_Handler
+
+ .weak PendSV_Handler
+ .thumb_set PendSV_Handler,Default_Handler
+
+ .weak SysTick_Handler
+ .thumb_set SysTick_Handler,Default_Handler
+
+ .weak WWDG_IRQHandler
+ .thumb_set WWDG_IRQHandler,Default_Handler
+
+ .weak PVD_IRQHandler
+ .thumb_set PVD_IRQHandler,Default_Handler
+
+ .weak TAMP_STAMP_IRQHandler
+ .thumb_set TAMP_STAMP_IRQHandler,Default_Handler
+
+ .weak RTC_WKUP_IRQHandler
+ .thumb_set RTC_WKUP_IRQHandler,Default_Handler
+
+ .weak FLASH_IRQHandler
+ .thumb_set FLASH_IRQHandler,Default_Handler
+
+ .weak RCC_IRQHandler
+ .thumb_set RCC_IRQHandler,Default_Handler
+
+ .weak EXTI0_IRQHandler
+ .thumb_set EXTI0_IRQHandler,Default_Handler
+
+ .weak EXTI1_IRQHandler
+ .thumb_set EXTI1_IRQHandler,Default_Handler
+
+ .weak EXTI2_IRQHandler
+ .thumb_set EXTI2_IRQHandler,Default_Handler
+
+ .weak EXTI3_IRQHandler
+ .thumb_set EXTI3_IRQHandler,Default_Handler
+
+ .weak EXTI4_IRQHandler
+ .thumb_set EXTI4_IRQHandler,Default_Handler
+
+ .weak DMA1_Stream0_IRQHandler
+ .thumb_set DMA1_Stream0_IRQHandler,Default_Handler
+
+ .weak DMA1_Stream1_IRQHandler
+ .thumb_set DMA1_Stream1_IRQHandler,Default_Handler
+
+ .weak DMA1_Stream2_IRQHandler
+ .thumb_set DMA1_Stream2_IRQHandler,Default_Handler
+
+ .weak DMA1_Stream3_IRQHandler
+ .thumb_set DMA1_Stream3_IRQHandler,Default_Handler
+
+ .weak DMA1_Stream4_IRQHandler
+ .thumb_set DMA1_Stream4_IRQHandler,Default_Handler
+
+ .weak DMA1_Stream5_IRQHandler
+ .thumb_set DMA1_Stream5_IRQHandler,Default_Handler
+
+ .weak DMA1_Stream6_IRQHandler
+ .thumb_set DMA1_Stream6_IRQHandler,Default_Handler
+
+ .weak ADC_IRQHandler
+ .thumb_set ADC_IRQHandler,Default_Handler
+
+ .weak CAN1_TX_IRQHandler
+ .thumb_set CAN1_TX_IRQHandler,Default_Handler
+
+ .weak CAN1_RX0_IRQHandler
+ .thumb_set CAN1_RX0_IRQHandler,Default_Handler
+
+ .weak CAN1_RX1_IRQHandler
+ .thumb_set CAN1_RX1_IRQHandler,Default_Handler
+
+ .weak CAN1_SCE_IRQHandler
+ .thumb_set CAN1_SCE_IRQHandler,Default_Handler
+
+ .weak EXTI9_5_IRQHandler
+ .thumb_set EXTI9_5_IRQHandler,Default_Handler
+
+ .weak TIM1_BRK_TIM9_IRQHandler
+ .thumb_set TIM1_BRK_TIM9_IRQHandler,Default_Handler
+
+ .weak TIM1_UP_TIM10_IRQHandler
+ .thumb_set TIM1_UP_TIM10_IRQHandler,Default_Handler
+
+ .weak TIM1_TRG_COM_TIM11_IRQHandler
+ .thumb_set TIM1_TRG_COM_TIM11_IRQHandler,Default_Handler
+
+ .weak TIM1_CC_IRQHandler
+ .thumb_set TIM1_CC_IRQHandler,Default_Handler
+
+ .weak TIM2_IRQHandler
+ .thumb_set TIM2_IRQHandler,Default_Handler
+
+ .weak TIM3_IRQHandler
+ .thumb_set TIM3_IRQHandler,Default_Handler
+
+ .weak TIM4_IRQHandler
+ .thumb_set TIM4_IRQHandler,Default_Handler
+
+ .weak I2C1_EV_IRQHandler
+ .thumb_set I2C1_EV_IRQHandler,Default_Handler
+
+ .weak I2C1_ER_IRQHandler
+ .thumb_set I2C1_ER_IRQHandler,Default_Handler
+
+ .weak I2C2_EV_IRQHandler
+ .thumb_set I2C2_EV_IRQHandler,Default_Handler
+
+ .weak I2C2_ER_IRQHandler
+ .thumb_set I2C2_ER_IRQHandler,Default_Handler
+
+ .weak SPI1_IRQHandler
+ .thumb_set SPI1_IRQHandler,Default_Handler
+
+ .weak SPI2_IRQHandler
+ .thumb_set SPI2_IRQHandler,Default_Handler
+
+ .weak USART1_IRQHandler
+ .thumb_set USART1_IRQHandler,Default_Handler
+
+ .weak USART2_IRQHandler
+ .thumb_set USART2_IRQHandler,Default_Handler
+
+ .weak USART3_IRQHandler
+ .thumb_set USART3_IRQHandler,Default_Handler
+
+ .weak EXTI15_10_IRQHandler
+ .thumb_set EXTI15_10_IRQHandler,Default_Handler
+
+ .weak RTC_Alarm_IRQHandler
+ .thumb_set RTC_Alarm_IRQHandler,Default_Handler
+
+ .weak OTG_FS_WKUP_IRQHandler
+ .thumb_set OTG_FS_WKUP_IRQHandler,Default_Handler
+
+ .weak TIM8_BRK_TIM12_IRQHandler
+ .thumb_set TIM8_BRK_TIM12_IRQHandler,Default_Handler
+
+ .weak TIM8_UP_TIM13_IRQHandler
+ .thumb_set TIM8_UP_TIM13_IRQHandler,Default_Handler
+
+ .weak TIM8_TRG_COM_TIM14_IRQHandler
+ .thumb_set TIM8_TRG_COM_TIM14_IRQHandler,Default_Handler
+
+ .weak TIM8_CC_IRQHandler
+ .thumb_set TIM8_CC_IRQHandler,Default_Handler
+
+ .weak DMA1_Stream7_IRQHandler
+ .thumb_set DMA1_Stream7_IRQHandler,Default_Handler
+
+ .weak FMC_IRQHandler
+ .thumb_set FMC_IRQHandler,Default_Handler
+
+ .weak SDIO_IRQHandler
+ .thumb_set SDIO_IRQHandler,Default_Handler
+
+ .weak TIM5_IRQHandler
+ .thumb_set TIM5_IRQHandler,Default_Handler
+
+ .weak SPI3_IRQHandler
+ .thumb_set SPI3_IRQHandler,Default_Handler
+
+ .weak UART4_IRQHandler
+ .thumb_set UART4_IRQHandler,Default_Handler
+
+ .weak UART5_IRQHandler
+ .thumb_set UART5_IRQHandler,Default_Handler
+
+ .weak TIM6_DAC_IRQHandler
+ .thumb_set TIM6_DAC_IRQHandler,Default_Handler
+
+ .weak TIM7_IRQHandler
+ .thumb_set TIM7_IRQHandler,Default_Handler
+
+ .weak DMA2_Stream0_IRQHandler
+ .thumb_set DMA2_Stream0_IRQHandler,Default_Handler
+
+ .weak DMA2_Stream1_IRQHandler
+ .thumb_set DMA2_Stream1_IRQHandler,Default_Handler
+
+ .weak DMA2_Stream2_IRQHandler
+ .thumb_set DMA2_Stream2_IRQHandler,Default_Handler
+
+ .weak DMA2_Stream3_IRQHandler
+ .thumb_set DMA2_Stream3_IRQHandler,Default_Handler
+
+ .weak DMA2_Stream4_IRQHandler
+ .thumb_set DMA2_Stream4_IRQHandler,Default_Handler
+
+ .weak CAN2_TX_IRQHandler
+ .thumb_set CAN2_TX_IRQHandler,Default_Handler
+
+ .weak CAN2_RX0_IRQHandler
+ .thumb_set CAN2_RX0_IRQHandler,Default_Handler
+
+ .weak CAN2_RX1_IRQHandler
+ .thumb_set CAN2_RX1_IRQHandler,Default_Handler
+
+ .weak CAN2_SCE_IRQHandler
+ .thumb_set CAN2_SCE_IRQHandler,Default_Handler
+
+ .weak OTG_FS_IRQHandler
+ .thumb_set OTG_FS_IRQHandler,Default_Handler
+
+ .weak DMA2_Stream5_IRQHandler
+ .thumb_set DMA2_Stream5_IRQHandler,Default_Handler
+
+ .weak DMA2_Stream6_IRQHandler
+ .thumb_set DMA2_Stream6_IRQHandler,Default_Handler
+
+ .weak DMA2_Stream7_IRQHandler
+ .thumb_set DMA2_Stream7_IRQHandler,Default_Handler
+
+ .weak USART6_IRQHandler
+ .thumb_set USART6_IRQHandler,Default_Handler
+
+ .weak I2C3_EV_IRQHandler
+ .thumb_set I2C3_EV_IRQHandler,Default_Handler
+
+ .weak I2C3_ER_IRQHandler
+ .thumb_set I2C3_ER_IRQHandler,Default_Handler
+
+ .weak OTG_HS_EP1_OUT_IRQHandler
+ .thumb_set OTG_HS_EP1_OUT_IRQHandler,Default_Handler
+
+ .weak OTG_HS_EP1_IN_IRQHandler
+ .thumb_set OTG_HS_EP1_IN_IRQHandler,Default_Handler
+
+ .weak OTG_HS_WKUP_IRQHandler
+ .thumb_set OTG_HS_WKUP_IRQHandler,Default_Handler
+
+ .weak OTG_HS_IRQHandler
+ .thumb_set OTG_HS_IRQHandler,Default_Handler
+
+ .weak DCMI_IRQHandler
+ .thumb_set DCMI_IRQHandler,Default_Handler
+
+ .weak FPU_IRQHandler
+ .thumb_set FPU_IRQHandler,Default_Handler
+
+ .weak SPI4_IRQHandler
+ .thumb_set SPI4_IRQHandler,Default_Handler
+
+ .weak SAI1_IRQHandler
+ .thumb_set SAI1_IRQHandler,Default_Handler
+
+ .weak SAI2_IRQHandler
+ .thumb_set SAI2_IRQHandler,Default_Handler
+
+ .weak QuadSPI_IRQHandler
+ .thumb_set QuadSPI_IRQHandler,Default_Handler
+
+ .weak HDMI_CEC_IRQHandler
+ .thumb_set HDMI_CEC_IRQHandler,Default_Handler
+
+ .weak SPDIF_Rx_IRQHandler
+ .thumb_set SPDIF_Rx_IRQHandler,Default_Handler
+
+ .weak FMPI2C1_IRQHandler
+ .thumb_set FMPI2C1_IRQHandler,Default_Handler
+
+ .weak FMPI2C1_error_IRQHandler
+ .thumb_set FMPI2C1_error_IRQHandler,Default_Handler
+
+ .weak SystemInit
+
+/************************ (C) COPYRIGHT STMicroelectonics *****END OF FILE****/
diff --git a/labW9barnestr/.cproject b/labW9barnestr/.cproject
index 0c71977..9a794a8 100644
--- a/labW9barnestr/.cproject
+++ b/labW9barnestr/.cproject
@@ -10,54 +10,55 @@
+
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
-
+
-
+
-
-
-
+
+
+
-
+
-
-
+
+
-
+
-
+
@@ -87,53 +88,54 @@
+
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
-
+
-
+
-
-
-
+
+
+
-
+
-
-
+
+
-
+
-
+
@@ -169,4 +171,5 @@
-
+
+
\ No newline at end of file
diff --git a/labW9barnestr/Inc/delay.h b/labW9barnestr/Inc/delay.h
new file mode 100644
index 0000000..fc2a61b
--- /dev/null
+++ b/labW9barnestr/Inc/delay.h
@@ -0,0 +1,37 @@
+/*
+ * delay.h
+ *
+ * Created on: Dec 10, 2021
+ * Author: Trevor Barnes
+ */
+
+//include guards
+#ifndef DELAY_H_
+#define DELAY_H_
+
+#include
+
+#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_1ms
+ * 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_1ms(uint32_t n);
+
+
+
+#endif /* DELAY_H_ */
diff --git a/labW9barnestr/Inc/led.h b/labW9barnestr/Inc/led.h
new file mode 100644
index 0000000..e927468
--- /dev/null
+++ b/labW9barnestr/Inc/led.h
@@ -0,0 +1,101 @@
+/*
+ * led.h
+ *
+ * Created on: Dec 10, 2021
+ * Author: Trevor Barnes
+ */
+
+#ifndef LED_H_
+#define LED_H_
+
+#include
+
+#define RCC_AHB1ENR (volatile uint32_t*) 0x40023830
+#define GPIOBEN 1
+#define GPIOB_MODER (volatile uint32_t*) 0x40020400
+#define GPIOB_PUPDR (volatile uint32_t*) 0x4002040C
+#define GPIOB_IDR (volatile uint32_t*) 0x40020410
+#define GPIOB_ODR (volatile uint32_t*) 0x40020414
+#define GPIOB_BSRR (volatile uint32_t*) 0x40020418
+
+#define ALL_LEDS (0b11110111111<<5)
+
+/*
+ * led_init()
+ * This function should:
+ * 1. Enable the GPIOB in RCC_AHB1ENR
+ * 2. Turn on to set LED0 - LED9 to output mode ("01")
+ */
+void led_init();
+
+/*
+ * led_allOn()
+ * 1. Turn on all leds (hint use ODR or BSRR)
+ * Note you should not effect other pins on PortB
+ */
+void led_allOn();
+
+/*
+ * led_allOff()
+ * 1. Turn off all leds (hint use ODR or BSRR)
+ * Note you should not effect other pins on PortB
+ */
+void led_allOff();
+
+/*
+ * led_on()
+ * Args: 0-9 to turn on specific led
+ * print error message is arg is out of range
+ */
+void led_on(uint8_t ledIndex);
+
+/*
+ * led_off()
+ * Args: 0-9 to turn off specific led
+ * print error message is arg is out of range
+ */
+void led_off(uint8_t ledIndex);
+
+
+/*
+ * led_scan()
+ * Scan the light across and back at the current speed
+ */
+void led_scan();
+
+/*
+ * led_flash()
+ * flash all of the lights 10 times at the current speed
+ */
+void led_flash();
+
+/*
+ * led_setSpeed (uint8_t speed)
+ * arg: speed (0 slow - 9 fast)
+ * Args out of range should print error to console
+ */
+void led_setSpeed(uint8_t speed);
+
+/*
+ * led_incSpeed()
+ * increases the speed by one
+ * if maxed out leaves the speed at the max value
+ */
+void led_incSpeed();
+
+/*
+ * led_decSpeed()
+ * decreases the speed by one
+ * if at zero should stay at zero
+ */
+void led_decSpeed();
+
+/*
+ * getCurrentSpeed
+ * returns the current speed
+ */
+uint8_t getCurrentSpeed();
+
+
+
+#endif
diff --git a/labW9barnestr/Inc/tasker.h b/labW9barnestr/Inc/tasker.h
new file mode 100644
index 0000000..6456f05
--- /dev/null
+++ b/labW9barnestr/Inc/tasker.h
@@ -0,0 +1,41 @@
+/**
+ * @file tasker.h
+ * @author Trevor Barnes
+ * @brief
+ * @version 0.1
+ * @date 2022-02-11
+ *
+ * @copyright Copyright (c) 2022
+ *
+ */
+
+#include
+
+typedef enum{PAUSED, ACTIVE} task_state;
+
+#define SCB_ICSR 0xE000D04
+#define PENDSVSET 28
+
+extern int num_tasks;
+extern int current_task;
+extern int next_task;
+extern Task tasks[];
+
+
+typedef struct {
+ uint32_t* stack_pointer;
+ uint32_t ticks_starting;
+ uint32_t ticks_remaining;
+ task_state state;
+} Task;
+
+void SysTick_Init();
+
+void tasker_tick();
+
+void init_tasker(uint32_t total_tasks, uint32_t main_ticks);
+
+void init_task(uint32_t task_num, uint32_t stacksize,
+ void(*entry_point)(void), uint32_t ticks);
+
+void PendSV_Handler(void __attribute__((naked)));
\ No newline at end of file
diff --git a/labW9barnestr/Inc/uart_driver.h b/labW9barnestr/Inc/uart_driver.h
new file mode 100644
index 0000000..a1d6427
--- /dev/null
+++ b/labW9barnestr/Inc/uart_driver.h
@@ -0,0 +1,49 @@
+/*
+ * uart_driver.h
+ *
+ * Created on: Nov 8, 2016
+ * Author: barnekow
+ */
+
+#ifndef UART_DRIVER_H_
+#define UART_DRIVER_H_
+
+#include
+
+// RCC registers
+#define RCC_APB1ENR (volatile uint32_t*) 0x40023840
+#define RCC_AHB1ENR (volatile uint32_t*) 0x40023830
+
+#define GPIOAEN 0 // GPIOA Enable is bit 0 in RCC_APB1LPENR
+#define USART2EN 17 // USART2 enable is bit 17 in RCC_AHB1LPENR
+
+// GPIOA registers
+#define GPIOA_MODER (volatile uint32_t*) 0x40020000
+#define GPIOA_AFRL (volatile uint32_t*) 0x40020020
+#define USART_SR (volatile uint32_t*) 0x40004400
+#define USART_DR (volatile uint32_t*) 0x40004404
+#define USART_BRR (volatile uint32_t*) 0x40004408
+#define USART_CR1 (volatile uint32_t*) 0x4000440c
+#define USART_CR2 (volatile uint32_t*) 0x40004410
+#define USART_CR3 (volatile uint32_t*) 0x40004414
+
+// CR1 bits
+#define UE 13 //UART enable
+#define TE 3 // Transmitter enable
+#define RE 2 // Receiver enable
+
+// Status register bits
+#define TXE 7 // Transmit register empty
+#define RXNE 5 // Receive register is not empty..char received
+
+// Function prototypes
+extern void init_usart2(uint32_t baud, uint32_t sysclk);
+extern char usart2_getch();
+extern void usart2_putch(char c);
+
+// syscalls overrides
+int _read(int file, char *ptr, int len);
+int _write(int file, char *ptr, int len);
+
+
+#endif /* UART_DRIVER_H_ */
diff --git a/labW9barnestr/Src/delay.c b/labW9barnestr/Src/delay.c
new file mode 100644
index 0000000..e0e9355
--- /dev/null
+++ b/labW9barnestr/Src/delay.c
@@ -0,0 +1,28 @@
+/*
+ * delay.c
+ *
+ * Created on: Dec 10, 2021
+ * Author: Trevor Barnes
+ */
+
+#include
+#include "delay.h" //include declaration header file
+
+void delay_1ms(uint32_t n){
+
+ // 1ms = 16,000 ticks
+ for (int i = n ; i > 0 ; i--) {
+ // Clear value register
+ *STK_VAL = 0x0000;
+ // Store 16,000 in STK_LOAD
+ *STK_LOAD = 16000;
+ // Enable clock, no prescaler, no interrupt
+ *STK_CTRL |= CLKSOURCE;
+ *STK_CTRL |= EN;
+ // Loop n times: Wait for countflag high
+ int flag;
+ do {
+ flag = ((*STK_CTRL & (1<<16))>>16);
+ } while (flag != 1);
+ }
+}
diff --git a/labW9barnestr/Src/led.c b/labW9barnestr/Src/led.c
new file mode 100644
index 0000000..69add9b
--- /dev/null
+++ b/labW9barnestr/Src/led.c
@@ -0,0 +1,147 @@
+/*
+ * led.c
+ *
+ * Created on: Dec 10, 2021
+ * Author: Trevor Barnes
+ */
+
+#include "led.h"
+#include "delay.h"
+#include
+#include
+
+int ledSpeed = 5;
+
+void led_init(){
+ // Initialize corresponding RCC and GPIO registers
+ *RCC_AHB1ENR |= (1<= 6) {
+ // Add pin offset to index
+ *GPIOB_BSRR = (1<<(22+ledIndex));
+ } else {
+ printf("LED index out of range\n\r");
+ }
+}
+
+void led_scan(){
+ led_allOff();
+ // Right to left each LED
+ for (int i = 0; i <= 9 ; i++) {
+ // Scaled Delay
+ delay_1ms(50+(ledSpeed*50));
+ if(i != 0){
+ led_off(i-1);
+ }
+ led_on(i);
+ }
+ // Left to right each LED
+ for (int i = 9; i >= 0; i--) {
+ if(i != 9){
+ led_off(i+1);
+ }
+ led_on(i);
+ // Scaled Delay
+ delay_1ms(50+(ledSpeed*50));
+ }
+ led_off(0);
+}
+
+void led_flash(){
+ // Flash LED on and off 10 times at a speed between 0-1 seconds
+ for (int i = 0; i < 10; i++) {
+ led_allOn();
+ delay_1ms(100+(ledSpeed*100));
+ led_allOff();
+ delay_1ms(100+(ledSpeed*100));
+ }
+}
+
+void led_setSpeed(uint8_t speed){
+ ledSpeed = speed;
+}
+
+void led_incSpeed(){
+ if (ledSpeed == 0){
+ printf("Speed too fast\n\r");
+ } else {
+ ledSpeed--;
+ }
+}
+
+void led_decSpeed(){
+ if (ledSpeed == 9){
+ printf("Speed too slow\n\r");
+ } else {
+ ledSpeed++;
+ }
+}
+
+uint8_t getCurrentSpeed()
+{
+ return ledSpeed;
+}
+
+
diff --git a/labW9barnestr/Src/main.c b/labW9barnestr/Src/main.c
index d404eb7..743e0e8 100644
--- a/labW9barnestr/Src/main.c
+++ b/labW9barnestr/Src/main.c
@@ -1,17 +1,23 @@
/**
- ******************************************************************************
- * @file main.c
- * @author Auto-generated by STM32CubeIDE
- * @version V1.0
- * @brief Default main function.
- ******************************************************************************
-*/
+ * @file main.c
+ * @author Trevor Barnes
+ * @brief
+ * @version 0.1
+ * @date 2022-02-11
+ *
+ * @copyright Copyright (c) 2022
+ *
+ */
-#if !defined(__SOFT_FP__) && defined(__ARM_FP)
- #warning "FPU is not initialized, but the project is compiling for an FPU. Please initialize the FPU before use."
-#endif
+#include
+#include
+#include
+#include
+#include "uart_driver.h"
+#include "delay.h"
+#include "led.h"
+#include "tasker.h"
+
+int main(void) {
-int main(void)
-{
- for(;;);
}
diff --git a/labW9barnestr/Src/syscalls.c b/labW9barnestr/Src/syscalls.c
deleted file mode 100644
index 9f32dad..0000000
--- a/labW9barnestr/Src/syscalls.c
+++ /dev/null
@@ -1,184 +0,0 @@
-/**
-*****************************************************************************
-**
-** File : syscalls.c
-**
-** Author : Auto-generated by STM32CubeIDE
-**
-** Abstract : STM32CubeIDE Minimal System calls file
-**
-** For more information about which c-functions
-** need which of these lowlevel functions
-** please consult the Newlib libc-manual
-**
-** Environment : STM32CubeIDE MCU
-**
-** Distribution: The file is distributed as is, without any warranty
-** of any kind.
-**
-*****************************************************************************
-**
-** © COPYRIGHT(c) 2018 STMicroelectronics
-**
-** Redistribution and use in source and binary forms, with or without modification,
-** are permitted provided that the following conditions are met:
-** 1. Redistributions of source code must retain the above copyright notice,
-** this list of conditions and the following disclaimer.
-** 2. Redistributions in binary form must reproduce the above copyright notice,
-** this list of conditions and the following disclaimer in the documentation
-** and/or other materials provided with the distribution.
-** 3. Neither the name of STMicroelectronics nor the names of its contributors
-** may be used to endorse or promote products derived from this software
-** without specific prior written permission.
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
-** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-** SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-** OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-**
-**
-*****************************************************************************
-*/
-
-/* Includes */
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-
-/* Variables */
-//#undef errno
-extern int errno;
-extern int __io_putchar(int ch) __attribute__((weak));
-extern int __io_getchar(void) __attribute__((weak));
-
-register char * stack_ptr asm("sp");
-
-char *__env[1] = { 0 };
-char **environ = __env;
-
-
-/* Functions */
-void initialise_monitor_handles()
-{
-}
-
-int _getpid(void)
-{
- return 1;
-}
-
-int _kill(int pid, int sig)
-{
- errno = EINVAL;
- return -1;
-}
-
-void _exit (int status)
-{
- _kill(status, -1);
- while (1) {} /* Make sure we hang here */
-}
-
-__attribute__((weak)) int _read(int file, char *ptr, int len)
-{
- int DataIdx;
-
- for (DataIdx = 0; DataIdx < len; DataIdx++)
- {
- *ptr++ = __io_getchar();
- }
-
-return len;
-}
-
-__attribute__((weak)) int _write(int file, char *ptr, int len)
-{
- int DataIdx;
-
- for (DataIdx = 0; DataIdx < len; DataIdx++)
- {
- __io_putchar(*ptr++);
- }
- return len;
-}
-
-int _close(int file)
-{
- return -1;
-}
-
-
-int _fstat(int file, struct stat *st)
-{
- st->st_mode = S_IFCHR;
- return 0;
-}
-
-int _isatty(int file)
-{
- return 1;
-}
-
-int _lseek(int file, int ptr, int dir)
-{
- return 0;
-}
-
-int _open(char *path, int flags, ...)
-{
- /* Pretend like we always fail */
- return -1;
-}
-
-int _wait(int *status)
-{
- errno = ECHILD;
- return -1;
-}
-
-int _unlink(char *name)
-{
- errno = ENOENT;
- return -1;
-}
-
-int _times(struct tms *buf)
-{
- return -1;
-}
-
-int _stat(char *file, struct stat *st)
-{
- st->st_mode = S_IFCHR;
- return 0;
-}
-
-int _link(char *old, char *new)
-{
- errno = EMLINK;
- return -1;
-}
-
-int _fork(void)
-{
- errno = EAGAIN;
- return -1;
-}
-
-int _execve(char *name, char **argv, char **env)
-{
- errno = ENOMEM;
- return -1;
-}
diff --git a/labW9barnestr/Src/sysmem.c b/labW9barnestr/Src/sysmem.c
deleted file mode 100644
index e5e1bc2..0000000
--- a/labW9barnestr/Src/sysmem.c
+++ /dev/null
@@ -1,83 +0,0 @@
-/**
-*****************************************************************************
-**
-** File : sysmem.c
-**
-** Author : Auto-generated by STM32CubeIDE
-**
-** Abstract : STM32CubeIDE Minimal System Memory calls file
-**
-** For more information about which c-functions
-** need which of these lowlevel functions
-** please consult the Newlib libc-manual
-**
-** Environment : STM32CubeIDE MCU
-**
-** Distribution: The file is distributed as is, without any warranty
-** of any kind.
-**
-*****************************************************************************
-**
-** © COPYRIGHT(c) 2018 STMicroelectronics
-**
-** Redistribution and use in source and binary forms, with or without modification,
-** are permitted provided that the following conditions are met:
-** 1. Redistributions of source code must retain the above copyright notice,
-** this list of conditions and the following disclaimer.
-** 2. Redistributions in binary form must reproduce the above copyright notice,
-** this list of conditions and the following disclaimer in the documentation
-** and/or other materials provided with the distribution.
-** 3. Neither the name of STMicroelectronics nor the names of its contributors
-** may be used to endorse or promote products derived from this software
-** without specific prior written permission.
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
-** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-** SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-** OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-**
-**
-*****************************************************************************
-*/
-
-/* Includes */
-#include
-#include
-
-/* Variables */
-extern int errno;
-register char * stack_ptr asm("sp");
-
-/* Functions */
-
-/**
- _sbrk
- Increase program data space. Malloc and related functions depend on this
-**/
-caddr_t _sbrk(int incr)
-{
- extern char end asm("end");
- static char *heap_end;
- char *prev_heap_end;
-
- if (heap_end == 0)
- heap_end = &end;
-
- prev_heap_end = heap_end;
- if (heap_end + incr > stack_ptr)
- {
- errno = ENOMEM;
- return (caddr_t) -1;
- }
-
- heap_end += incr;
-
- return (caddr_t) prev_heap_end;
-}
-
diff --git a/labW9barnestr/Src/tasker.c b/labW9barnestr/Src/tasker.c
new file mode 100644
index 0000000..ae759b0
--- /dev/null
+++ b/labW9barnestr/Src/tasker.c
@@ -0,0 +1,76 @@
+/**
+ * @file tasker.c
+ * @author Trevor Barnes
+ * @brief
+ * @version 0.1
+ * @date 2022-02-11
+ *
+ * @copyright Copyright (c) 2022
+ *
+ */
+
+#include
+#include
+#include "tasker.h"
+
+void SysTick_Init() {
+
+}
+
+void init_task(uint32_t task_num, uint32_t stacksize, void(*entry_point)(void), uint32_t ticks) {
+ tasks[task_num].stack_pointer = (uint32_t*)malloc(stacksize*sizeof(uint32_t));
+ tasks[task_num].stack_pointer += stacksize;
+ *(--tasks[task_num].stack_pointer) = 0x01000000; // PSR
+ *(--tasks[task_num].stack_pointer) = ((uint32_t)entry_point);
+ *(--tasks[task_num].stack_pointer) = 0xFFFFFFFF;
+ *(--tasks[task_num].stack_pointer) = 0; // R12
+ *(--tasks[task_num].stack_pointer) = 0; // R3
+ *(--tasks[task_num].stack_pointer) = 0; // R2
+ *(--tasks[task_num].stack_pointer) = 0; // R1
+ *(--tasks[task_num].stack_pointer) = 0; // R0
+ *(--tasks[task_num].stack_pointer) = 0xFFFFFFF9; // ISR LR
+ *(--tasks[task_num].stack_pointer) = 0; // R11
+ *(--tasks[task_num].stack_pointer) = 0; // R10
+ *(--tasks[task_num].stack_pointer) = 0; // R9
+ *(--tasks[task_num].stack_pointer) = 0; // R8
+ *(--tasks[task_num].stack_pointer) = 0; // R7
+ *(--tasks[task_num].stack_pointer) = 0; // R6
+ *(--tasks[task_num].stack_pointer) = 0; // R5
+ *(--tasks[task_num].stack_pointer) = 0; // R4
+ tasks[task_num].state = ACTIVE;
+ tasks[task_num].ticks_starting = ticks;
+ tasks[task_num].ticks_remaining = 0;
+}
+
+void init_tasker(uint32_t total_tasks, uint32_t main_ticks) {
+ num_tasks = total_tasks;
+ *tasks = calloc(total_tasks, sizeof(Task));
+}
+
+
+void tasker_tick() {
+ tasks[current_task].ticks_remaining--;
+
+ if(tasks[current_task].ticks_remaining == 0) {
+ int i = 1;
+ while(tasks[(next_task = (current_task + i)%num_tasks)].state != ACTIVE) {
+ i++;
+ }
+ tasks[next_task].ticks_remaining = tasks[next_task].ticks_starting;
+ //*scb_icsr |= 1<
+#include
+
+
+// These will override _read and _write in syscalls.c, which are
+// prototyped as weak
+int _read(int file, char *ptr, int len)
+{
+ int DataIdx;
+ // Modified the for loop in order to get the correct behavior for fgets
+ int byteCnt = 0;
+ for (DataIdx = 0; DataIdx < len; DataIdx++)
+ {
+ //*ptr++ = __io_getchar();
+ byteCnt++;
+ //*ptr++ = usart2_getch();
+ *ptr = usart2_getch();
+ if(*ptr == '\n') break;
+ ptr++;
+ }
+
+ //return len;
+ return byteCnt; // Return byte count
+}
+
+int _write(int file, char *ptr, int len)
+{
+ int DataIdx;
+
+ for (DataIdx = 0; DataIdx < len; DataIdx++)
+ {
+ usart2_putch(*ptr++);
+ }
+ return len;
+}
+
+
+
+char usart2_getch(){
+ char c;
+ while((*(USART_SR)&(1<