Skip to content

Commit

Permalink
Merge pull request #8 from AllenNeuralDynamics/dev/max_uart_rate
Browse files Browse the repository at this point in the history
clamp max baud rate
  • Loading branch information
Poofjunior authored Sep 12, 2024
2 parents 4af89fb + ffabe04 commit 3ce116b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
6 changes: 4 additions & 2 deletions firmware/inc/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#define FW_VERSION_MAJOR (0)
#define FW_VERSION_MINOR (1)
#define FW_VERSION_PATCH (0)
#define FW_VERSION_PATCH (1)


#define HARP_CORE_LED_PIN (25)
Expand All @@ -18,7 +18,7 @@
#define HARP_UART (uart1)
// Baud rate and offset defined per spec.
// https://harp-tech.org/protocol/SynchronizationClock.html
#define HARP_SYNC_BAUDRATE (100000UL)
#define HARP_SYNC_BAUDRATE (100'000UL)
#define HARP_CLKOUT_PIN (4)
#define HARP_CLKIN_PIN (5)
#define HARP_SYNC_START_OFFSET_US (-1172) // Offset from spec to account for
Expand All @@ -37,6 +37,8 @@
// minimum baud rate, or we will not have
// enough time to emit a full 4-byte
// (+1 start and 1 stop bit) message at 1Hz.
#define MAX_AUX_SYNC_BAUDRATE (1'000'000UL) // Aux Baud rate should be slower
// than this value.
#define AUX_PIN (0)
#define AUX_SYNC_START_OFFSET_US (0) // Offset from spec to account for
// transmission time.
Expand Down
3 changes: 2 additions & 1 deletion firmware/src/white_rabbit_app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,8 @@ void write_aux_baud_rate(msg_t& msg)
uint32_t old_baud_rate = app_regs.AuxBaudRate;
HarpCore::copy_msg_payload_to_register(msg);
// Reject invalid baud rates.
if (app_regs.AuxBaudRate < MIN_AUX_SYNC_BAUDRATE)
if (app_regs.AuxBaudRate < MIN_AUX_SYNC_BAUDRATE ||
app_regs.AuxBaudRate > MAX_AUX_SYNC_BAUDRATE)
{
if (!HarpCore::is_muted())
HarpCore::send_harp_reply(WRITE_ERROR, msg.header.address);
Expand Down
4 changes: 2 additions & 2 deletions software/bonsai/device.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/harp-tech/reflex-generator/main/schema/device.json
device: WhiteRabbit
whoAmI: 1404
firmwareVersion: "0.0"
hardwareTargets: "0.0"
firmwareVersion: "0.1"
hardwareTargets: "0.1"
registers:
ConnectedDevices:
address: 32
Expand Down

0 comments on commit 3ce116b

Please sign in to comment.