Skip to content

Commit

Permalink
Update LED flash frequency
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonBrave committed Nov 19, 2024
1 parent 33857c1 commit 4b77fd3
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 8 deletions.
4 changes: 0 additions & 4 deletions board.h
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
4 changes: 4 additions & 0 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 2 additions & 3 deletions spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down

0 comments on commit 4b77fd3

Please sign in to comment.