Skip to content

Commit cd41700

Browse files
zelenskiCS107E BOT
authored andcommitted
libmango updates (weak symbol for pullup so students can override, uart baud rate)
commit 25b5b13b253816867cffebeb00c39667e1bac601 Author: Julie Zelenski <[email protected]> Date: Tue Jan 14 00:42:45 2025 -0800 libmango updates (weak symbol for pullup so students can override, uart baud rate)
1 parent 795ba01 commit cd41700

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

cs107e/lib/libmango.a

37.4 KB
Binary file not shown.

cs107e/src/rand.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
*/
77

88
#include "rand.h"
9+
#include "timer.h"
910
#include <stdbool.h>
1011
#include <stdint.h>
1112

cs107e/src/uart.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,9 @@ static struct {
7272
};
7373

7474
// not published for now, used to do testing of alternate uarts
75-
void uart_reinit_custom(int, gpio_id_t, gpio_id_t, unsigned int);
75+
void uart_reinit_custom(int, int, gpio_id_t, gpio_id_t, unsigned int);
7676

77-
void uart_reinit_custom(int uart_id, gpio_id_t tx, gpio_id_t rx, unsigned int gpio_fn) {
77+
void uart_reinit_custom(int uart_id, int baud, gpio_id_t tx, gpio_id_t rx, unsigned int gpio_fn) {
7878
if (module.uart) { // shut down previous if active
7979
uart_flush();
8080
gpio_set_function(module.config.tx, GPIO_FN_DISABLED); // disconnect gpio
@@ -103,7 +103,6 @@ void uart_reinit_custom(int uart_id, gpio_id_t tx, gpio_id_t rx, unsigned int gp
103103
gpio_set_pullup(module.config.rx);
104104

105105
// configure baud rate
106-
uint32_t baud = 115200;
107106
module.uart->regs.fcr = 1; // enable TX/RX fifo
108107
module.uart->regs.halt = 1; // temporarily disable TX transfer
109108
uint32_t udiv = sys_clock_rate / (16 * baud);
@@ -131,7 +130,7 @@ void uart_init(void) {
131130
initialized = true;
132131
module.uart = NULL;
133132
// default to UART0 on pins PB8+9
134-
uart_reinit_custom(0, GPIO_PB8, GPIO_PB9, GPIO_FN_ALT6);
133+
uart_reinit_custom(0, 115200, GPIO_PB8, GPIO_PB9, GPIO_FN_ALT6);
135134
module.running_in_simulator = sys_running_in_simulator();
136135
uart_putchar('\f'); // clear terminal window on init
137136
}
@@ -221,7 +220,7 @@ void uart_start_error(void) {
221220
// All calls to uart operations are dead ends (that means no printf/assert!)
222221
// Force a call to uart_init here to enable reporting of problem
223222
// (otherwise lack of output is ultra mysterious)
224-
uart_reinit_custom(0, GPIO_PB8, GPIO_PB9, GPIO_FN_ALT6);
223+
uart_reinit_custom(0, 115200, GPIO_PB8, GPIO_PB9, GPIO_FN_ALT6);
225224
}
226225
uart_putstring("\e[31;1m"); // red-bold
227226
}

0 commit comments

Comments
 (0)