From d550beec270ae429aae6922b8115f477bad73770 Mon Sep 17 00:00:00 2001 From: Jason Xu <40355221+JasonBrave@users.noreply.github.com> Date: Mon, 18 Nov 2024 21:55:42 -0500 Subject: [PATCH] Update LED flash frequency --- board.h | 4 ---- main.c | 4 ++++ rocketlib | 2 +- spi.c | 5 ++--- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/board.h b/board.h index 1a69d77..3fb0065 100644 --- a/board.h +++ b/board.h @@ -1,10 +1,6 @@ #ifndef BOARD_H #define BOARD_H -#define MAX_TC_TIME_DIFF_ms 200 -#define MAX_HEARTBEAT_TIME_DIFF_ms 2000 -#define MAX_BUS_DEAD_TIME_ms 2000 - #define RED_LED_ON() (LATB3 = 0) #define RED_LED_OFF() (LATB3 = 1) #define RED_LED_TOGGLE() (LATB3 ^= 1) diff --git a/main.c b/main.c index a1e700b..2966a68 100644 --- a/main.c +++ b/main.c @@ -10,6 +10,10 @@ #include "spi.h" #include "thermocouple.h" +#define MAX_TC_TIME_DIFF_ms 200 // 5 Hz +#define MAX_HEARTBEAT_TIME_DIFF_ms 500 // 2 Hz +#define MAX_BUS_DEAD_TIME_ms 5000 // 5 s + #if (BOARD_UNIQUE_ID == BOARD_ID_THERMOCOUPLE_1) #define build_tc_temp_data_msg(timestamp, id, temp, msg) \ build_temp_data_msg(timestamp, id, temp, msg); diff --git a/rocketlib b/rocketlib index 5ac35f3..b911cef 160000 --- a/rocketlib +++ b/rocketlib @@ -1 +1 @@ -Subproject commit 5ac35f30e49ce7d4c9424a8df76591c8a01a4b7e +Subproject commit b911cef3085efe0017b63429b53cf569c11994f5 diff --git a/spi.c b/spi.c index 0081f82..5452034 100644 --- a/spi.c +++ b/spi.c @@ -26,14 +26,13 @@ void spi1_init(void) { SPI1CON0bits.EN = 1; // enable SPI } -/**/ uint8_t spi1_exchange(uint8_t data) { INTCON0bits.GIE = 0; SPI1CON2bits.TXR = 0; SPI1CON2bits.RXR = 1; SPI1TCNT = 1; SPI1TXB = data; /*if we're sending data, send it. if we're recieving, this is 0 (unless you - // initialized bad), but makes sure we output a clock*/ + initialized bad), but makes sure we output a clock*/ while (!PIR2bits.SPI1RXIF) { } // wait until receive buffer is not empty?? (basically until theres a clock) data = SPI1RXB; @@ -45,7 +44,7 @@ void spi1_exchange_buffer(uint8_t *data, uint8_t data_len) { // set data length SPI1TCNTL = data_len; SPI1TCNTH = 0; - // uint8_t *block = data; + while (data_len) { *data = spi1_exchange(*data); // sends pointer, so data gets shoved into array data++; // increment array