LCC Fusion Project 1.0
LCC Automation
Loading...
Searching...
No Matches
BSD Card Firmware

Firmware for the LCC Fusion BSD (Block Short Detection) Card. More...

Collaboration diagram for BSD Card Firmware:

Files

file  BsdRelay.h
 Per-channel Block Short Detection (BSD) relay control.
 
file  config.h
 Configuration constants and pin assignments for the UOD Card firmware.
 

Classes

struct  SensorRange
 Per-card occupancy thresholds (mA) for each sensor on a BSD Card. More...
 
class  BsdSensor
 Encapsulates one BSD channel (sense + decision + actuation). More...
 

Macros

#define WEB_SSID   "LCC_Fusion_BSD_Card"
 Web Serial SSID used when Web Serial is enabled.
 
#define BT_DEVICE_NAME   "LCC Fusion BSD Card"
 Bluetooth device name used when Bluetooth serial is enabled.
 

Enumerations

enum class  SensorState : uint8_t { SensorState::OK = 0 , SensorState::TRIPPED = 1 , SensorState::LOCKOUT = 2 }
 Sensor finite-state machine states. More...
 

Functions

static void onI2cRequest ()
 I²C on-request: write a 2-byte frame [OCC_lo, SHORT_hi]. More...
 
void setupHelpCallback ()
 Register help/usage text for this card (shown on user request). More...
 
void setupTestCallback ()
 Install the test callback for the Card commands. More...
 
void setupProgramCallback ()
 Install the progam callback for the Card commands.
 
void getSensorRanges ()
 Parse up to NUM_BSD_SENSORS_PER_CARD "< low_mA high_mA ... >" pairs and update thresholds. Rules: More...
 
void setup ()
 Arduino setup: configures ADC, sensors, relays, and I²C target mode. More...
 
void loop ()
 Arduino loop: advances each sensor; all host-visible bits are derived on demand. More...
 

Variables

static BsdSensor sensors [NUM_BSD_SENSORS_PER_CARD]
 Relays (level-driven MOSFET gates).
 
static SensorRange sensorRanges
 Zero-initialized instance (or make this a class member).
 
static constexpr uint8_t I2C_ADDR_OFFSET_PIN_SET [3] = { 23, 22, 21 }
 GPIO pins used for I2C address selection DIP switches. More...
 
PstTestPins pstTestPins
 Dynamically allocate array of player pointers.
 

Detailed Description

Firmware for the LCC Fusion BSD (Block Short Detection) Card.

High-level overview and links to the main entry points (setup/loop) and helper functions used by the BSD firmware.

Enumeration Type Documentation

◆ SensorState

enum class SensorState : uint8_t
strong

Sensor finite-state machine states.

Enumerator
OK 

Normal operation, rail connected.

TRIPPED 

Fault detected; rail disconnected; subject to retry.

LOCKOUT 

Persistent fault; remains disconnected until reset.

Definition at line 57 of file BsdSensor.h.

Function Documentation

◆ getSensorRanges()

void getSensorRanges ( )

Parse up to NUM_BSD_SENSORS_PER_CARD "< low_mA high_mA ... >" pairs and update thresholds. Rules:

  • Values parsed as base-10 unsigned, clamped to 0..65535.
  • If high==0 → disable block sensor (both set to 0).
  • If low>high (and high!=0) → swap to enforce low<=high.
  • Remaining sensors untouched if fewer pairs are provided.
  • Clears the input buffer after applying at least one pair to avoid reapplying.

Definition at line 185 of file BSD_Card.ino.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ loop()

void loop ( )

Arduino loop: advances each sensor; all host-visible bits are derived on demand.

Main loop: poll for complete packets and dispatch commands.

Note
BsdSensor::update() enforces SAMPLE_PERIOD_MS internally, so this loop may iterate faster without oversampling the ADC.

Definition at line 355 of file BSD_Card.ino.

Here is the call graph for this function:

◆ onI2cRequest()

static void onI2cRequest ( )
static

I²C on-request: write a 2-byte frame [OCC_lo, SHORT_hi].

Note
Bits above block sensor 7 are implicitly 0; the producer treats the two bytes as a single 16-bit word with low=OCC, high=SHORT.

Definition at line 125 of file BSD_Card.ino.

◆ setup()

void setup ( )

Arduino setup: configures ADC, sensors, relays, and I²C target mode.

Initialize system: Serial, SPIFFS, players, and input interfaces.

Steps:

  1. Configure ADC1 resolution and per-pin attenuation (11 dB for ~0..3.3 V).
  2. Begin each relay (default ON) and attach each relay to its sensor.
  3. Begin each sensor(enables rail + starts inrush blanking).
  4. Compute I²C address = base + DIP(0..7); start I²C target; register handlers.

Definition at line 332 of file BSD_Card.ino.

Here is the call graph for this function:

◆ setupHelpCallback()

void setupHelpCallback ( )

Register help/usage text for this card (shown on user request).

Install the help‐text callback for the Sound Card commands.

Purely diagnostic; does not alter ranges or bitmap.

Definition at line 139 of file BSD_Card.ino.

Here is the call graph for this function:

◆ setupTestCallback()

void setupTestCallback ( )

Install the test callback for the Card commands.

Install the test callback for the Audio Card commands.

Definition at line 152 of file BSD_Card.ino.

Here is the call graph for this function:

Variable Documentation

◆ I2C_ADDR_OFFSET_PIN_SET

constexpr uint8_t I2C_ADDR_OFFSET_PIN_SET[3] = { 23, 22, 21 }
staticconstexpr

GPIO pins used for I2C address selection DIP switches.

Each pin contributes a bit (pin1=+1, pin2=+2, pin3=+4) relative to base address. These pins must be configured with internal pull-ups; DIP switch grounds pin when closed.

Definition at line 67 of file config.h.