From ba441e112ea2d64a1621e7dc1549effb0c2eaa03 Mon Sep 17 00:00:00 2001 From: "Sam S. Yu" <25761223+yudataguy@users.noreply.github.com> Date: Mon, 3 Nov 2025 16:32:50 -0800 Subject: [PATCH 1/4] distance sensor, testing return 0 --- .../Components/Drv/CMakeLists.txt | 1 + .../Drv/DistanceSensorManager/CMakeLists.txt | 36 +++ .../DistanceSensorManager.cpp | 224 ++++++++++++++++++ .../DistanceSensorManager.fpp | 64 +++++ .../DistanceSensorManager.hpp | 115 +++++++++ .../Top/ReferenceDeploymentPackets.fppi | 1 + .../ReferenceDeployment/Top/instances.fpp | 2 + .../ReferenceDeployment/Top/topology.fpp | 2 + .../project/config/AcConstants.fpp | 72 ++++++ .../project/config/CMakeLists.txt | 1 + .../proves_flight_control_board_v5.dtsi | 21 ++ prj.conf | 3 + 12 files changed, 542 insertions(+) create mode 100644 FprimeZephyrReference/Components/Drv/DistanceSensorManager/CMakeLists.txt create mode 100644 FprimeZephyrReference/Components/Drv/DistanceSensorManager/DistanceSensorManager.cpp create mode 100644 FprimeZephyrReference/Components/Drv/DistanceSensorManager/DistanceSensorManager.fpp create mode 100644 FprimeZephyrReference/Components/Drv/DistanceSensorManager/DistanceSensorManager.hpp create mode 100644 FprimeZephyrReference/project/config/AcConstants.fpp diff --git a/FprimeZephyrReference/Components/Drv/CMakeLists.txt b/FprimeZephyrReference/Components/Drv/CMakeLists.txt index 69454247..1288c83b 100644 --- a/FprimeZephyrReference/Components/Drv/CMakeLists.txt +++ b/FprimeZephyrReference/Components/Drv/CMakeLists.txt @@ -1,4 +1,5 @@ add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/Helpers/") +add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/DistanceSensorManager/") add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/Lis2mdlManager/") add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/Lsm6dsoManager/") add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/RtcManager") diff --git a/FprimeZephyrReference/Components/Drv/DistanceSensorManager/CMakeLists.txt b/FprimeZephyrReference/Components/Drv/DistanceSensorManager/CMakeLists.txt new file mode 100644 index 00000000..047bd987 --- /dev/null +++ b/FprimeZephyrReference/Components/Drv/DistanceSensorManager/CMakeLists.txt @@ -0,0 +1,36 @@ +#### +# F Prime CMakeLists.txt: +# +# SOURCES: list of source files (to be compiled) +# AUTOCODER_INPUTS: list of files to be passed to the autocoders +# DEPENDS: list of libraries that this module depends on +# +# More information in the F´ CMake API documentation: +# https://fprime.jpl.nasa.gov/latest/docs/reference/api/cmake/API/ +# +#### + +# Module names are derived from the path from the nearest project/library/framework +# root when not specifically overridden by the developer. i.e. The module defined by +# `Ref/SignalGen/CMakeLists.txt` will be named `Ref_SignalGen`. + +register_fprime_library( + AUTOCODER_INPUTS + "${CMAKE_CURRENT_LIST_DIR}/DistanceSensorManager.fpp" + SOURCES + "${CMAKE_CURRENT_LIST_DIR}/DistanceSensorManager.cpp" + DEPENDS + FprimeZephyrReference_Components_Drv_Helpers +) + +### Unit Tests ### +# register_fprime_ut( +# AUTOCODER_INPUTS +# "${CMAKE_CURRENT_LIST_DIR}/DistanceSensorManager.fpp" +# SOURCES +# "${CMAKE_CURRENT_LIST_DIR}/test/ut/DistanceSensorManagerTestMain.cpp" +# "${CMAKE_CURRENT_LIST_DIR}/test/ut/DistanceSensorManagerTester.cpp" +# DEPENDS +# STest # For rules-based testing +# UT_AUTO_HELPERS +# ) diff --git a/FprimeZephyrReference/Components/Drv/DistanceSensorManager/DistanceSensorManager.cpp b/FprimeZephyrReference/Components/Drv/DistanceSensorManager/DistanceSensorManager.cpp new file mode 100644 index 00000000..ea2e5fdb --- /dev/null +++ b/FprimeZephyrReference/Components/Drv/DistanceSensorManager/DistanceSensorManager.cpp @@ -0,0 +1,224 @@ +// ====================================================================== +// \title DistanceSensorManager.cpp +// \brief cpp file for DistanceSensorManager component implementation class +// ====================================================================== + +#include "FprimeZephyrReference/Components/Drv/DistanceSensorManager/DistanceSensorManager.hpp" + +#include + +namespace Drv { + +// ---------------------------------------------------------------------- +// Component construction and destruction +// ---------------------------------------------------------------------- + +DistanceSensorManager::DistanceSensorManager(const char* const compName) + : DistanceSensorManagerComponentBase(compName), + i2c_spec(I2C_DT_SPEC_GET(DT_NODELABEL(vl6180))), + initialized(false) { + // Check if I2C device is ready + if (!i2c_is_ready_dt(&i2c_spec)) { + this->log_WARNING_HI_DeviceNotReady(); + return; + } + + // Initialize the sensor + if (!initializeSensor()) { + this->log_WARNING_HI_InitializationFailed(); + return; + } + + initialized = true; +} + +DistanceSensorManager::~DistanceSensorManager() {} + +// ---------------------------------------------------------------------- +// Handler implementations for typed input ports +// ---------------------------------------------------------------------- + +F64 DistanceSensorManager::distanceGet_handler(FwIndexType portNum) { + if (!initialized || !i2c_is_ready_dt(&i2c_spec)) { + this->log_WARNING_HI_DeviceNotReady(); + return 0.0; + } + this->log_WARNING_HI_DeviceNotReady_ThrottleClear(); + + // Start a single-shot range measurement + if (startRangeMeasurement() != 0) { + this->log_WARNING_HI_I2cError(); + return 0.0; + } + + // Wait for measurement to complete (typical: ~10ms for single-shot) + k_msleep(30); + + // Read the range result + uint8_t distance_mm = 0; + if (readRangeResult(&distance_mm) != 0) { + this->log_WARNING_HI_I2cError(); + return 0.0; + } + this->log_WARNING_HI_I2cError_ThrottleClear(); + + // Convert to F64 and send telemetry + F64 distance = static_cast(distance_mm); + this->tlmWrite_Distance(distance); + + return distance; +} + +void DistanceSensorManager::run_handler(FwIndexType portNum, U32 context) { + // Trigger a distance measurement + this->distanceGet_handler(0); +} + +// ---------------------------------------------------------------------- +// Command handler implementations +// ---------------------------------------------------------------------- + +void DistanceSensorManager::READ_DISTANCE_cmdHandler(FwOpcodeType opCode, U32 cmdSeq) { + // Trigger a distance measurement + F64 distance = this->distanceGet_handler(0); + + // Send event with the reading + this->log_ACTIVITY_LO_DistanceReading(distance); + + // Send command response + this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::OK); +} + +// ---------------------------------------------------------------------- +// Private helper methods +// ---------------------------------------------------------------------- + +bool DistanceSensorManager::initializeSensor() { + uint8_t model_id = 0; + + // Read model ID to verify communication + if (readRegister(VL6180_REG_IDENTIFICATION_MODEL_ID, &model_id) != 0) { + return false; + } + + if (model_id != VL6180_MODEL_ID) { + return false; + } + + // Check if sensor needs initialization (fresh out of reset) + uint8_t fresh_out_of_reset = 0; + if (readRegister(VL6180_REG_SYSTEM_FRESH_OUT_OF_RESET, &fresh_out_of_reset) != 0) { + return false; + } + + if (fresh_out_of_reset == 0x01) { + // Perform mandatory private registers initialization (from VL6180 datasheet) + // These are required settings from ST's application note + writeRegister(0x0207, 0x01); + writeRegister(0x0208, 0x01); + writeRegister(0x0096, 0x00); + writeRegister(0x0097, 0xFD); + writeRegister(0x00E3, 0x00); + writeRegister(0x00E4, 0x04); + writeRegister(0x00E5, 0x02); + writeRegister(0x00E6, 0x01); + writeRegister(0x00E7, 0x03); + writeRegister(0x00F5, 0x02); + writeRegister(0x00D9, 0x05); + writeRegister(0x00DB, 0xCE); + writeRegister(0x00DC, 0x03); + writeRegister(0x00DD, 0xF8); + writeRegister(0x009F, 0x00); + writeRegister(0x00A3, 0x3C); + writeRegister(0x00B7, 0x00); + writeRegister(0x00BB, 0x3C); + writeRegister(0x00B2, 0x09); + writeRegister(0x00CA, 0x09); + writeRegister(0x0198, 0x01); + writeRegister(0x01B0, 0x17); + writeRegister(0x01AD, 0x00); + writeRegister(0x00FF, 0x05); + writeRegister(0x0100, 0x05); + writeRegister(0x0199, 0x05); + writeRegister(0x01A6, 0x1B); + writeRegister(0x01AC, 0x3E); + writeRegister(0x01A7, 0x1F); + writeRegister(0x0030, 0x00); + + // Clear fresh_out_of_reset flag + writeRegister(VL6180_REG_SYSTEM_FRESH_OUT_OF_RESET, 0x00); + } + + // Configure range measurement settings + writeRegister(VL6180_REG_SYSRANGE_VHV_REPEAT_RATE, 0xFF); + writeRegister(VL6180_REG_SYSRANGE_INTERMEASUREMENT_PERIOD, 0x00); + + return true; +} + +int DistanceSensorManager::readRegister(uint16_t reg, uint8_t* value) { + // VL6180 uses 16-bit register addresses (big-endian) + uint8_t reg_addr[2]; + reg_addr[0] = (reg >> 8) & 0xFF; // MSB + reg_addr[1] = reg & 0xFF; // LSB + + // Write register address then read the value + int ret = i2c_write_read_dt(&i2c_spec, reg_addr, 2, value, 1); + + return ret; +} + +int DistanceSensorManager::writeRegister(uint16_t reg, uint8_t value) { + // VL6180 uses 16-bit register addresses (big-endian) + uint8_t buf[3]; + buf[0] = (reg >> 8) & 0xFF; // Register MSB + buf[1] = reg & 0xFF; // Register LSB + buf[2] = value; // Data + + int ret = i2c_write_dt(&i2c_spec, buf, 3); + + return ret; +} + +int DistanceSensorManager::startRangeMeasurement() { + // Clear any interrupts + writeRegister(VL6180_REG_SYSTEM_INTERRUPT_CLEAR, 0x07); + + // Start single-shot range measurement + return writeRegister(VL6180_REG_SYSRANGE_START, VL6180_RANGE_START_SINGLE_SHOT); +} + +int DistanceSensorManager::readRangeResult(uint8_t* distance_mm) { + uint8_t status = 0; + int timeout = 100; // Maximum wait cycles + + // Poll for measurement ready (bit 2 of interrupt status) + while (timeout-- > 0) { + if (readRegister(VL6180_REG_RESULT_RANGE_STATUS, &status) != 0) { + return -1; + } + + // Check if new sample is ready (bit 2) + if ((status & 0x04) != 0) { + break; + } + + k_msleep(1); + } + + if (timeout <= 0) { + return -2; // Timeout + } + + // Read the range value + if (readRegister(VL6180_REG_RESULT_RANGE_VAL, distance_mm) != 0) { + return -3; + } + + // Clear interrupts + writeRegister(VL6180_REG_SYSTEM_INTERRUPT_CLEAR, 0x07); + + return 0; +} + +} // namespace Drv diff --git a/FprimeZephyrReference/Components/Drv/DistanceSensorManager/DistanceSensorManager.fpp b/FprimeZephyrReference/Components/Drv/DistanceSensorManager/DistanceSensorManager.fpp new file mode 100644 index 00000000..603b195f --- /dev/null +++ b/FprimeZephyrReference/Components/Drv/DistanceSensorManager/DistanceSensorManager.fpp @@ -0,0 +1,64 @@ +# Port definition +module Drv { + port DistanceGet -> F64 +} + +# Component definition +module Drv { + @ VL6180 Distance Sensor Driver Component for F Prime FSW framework. + passive component DistanceSensorManager { + # Ports + @ Port to read the current distance in millimeters. + sync input port distanceGet: DistanceGet + + @ Port to trigger periodic distance reading (called by rate group). + sync input port run: Svc.Sched + + # Commands + @ Command to manually trigger a distance reading + sync command READ_DISTANCE() + + # Telemetry channels + @ Telemetry channel for current distance in millimeters. + telemetry Distance: F64 + + @ Event for reporting VL6180 not ready error + event DeviceNotReady() severity warning high format "VL6180 device not ready" throttle 5 + + @ Event for reporting VL6180 initialization error + event InitializationFailed() severity warning high format "VL6180 initialization failed" + + @ Event for reporting I2C communication error + event I2cError() severity warning high format "VL6180 I2C communication error" throttle 5 + + @ Event for reporting successful distance reading + event DistanceReading( + distance: F64 @< Distance reading in millimeters + ) \ + severity activity low \ + format "VL6180 distance: {} mm" + + ############################################################################### + # Standard AC Ports: Required for Channels, Events, Commands, and Parameters # + ############################################################################### + @ Port for receiving commands + command recv port cmdIn + + @ Port for sending command registrations + command reg port cmdRegOut + + @ Port for sending command responses + command resp port cmdResponseOut + @ Port for requesting the current time + time get port timeCaller + + @ Port for sending textual representation of events + text event port logTextOut + + @ Port for sending events to downlink + event port logOut + + @ Port for sending telemetry channels to downlink + telemetry port tlmOut + } +} diff --git a/FprimeZephyrReference/Components/Drv/DistanceSensorManager/DistanceSensorManager.hpp b/FprimeZephyrReference/Components/Drv/DistanceSensorManager/DistanceSensorManager.hpp new file mode 100644 index 00000000..27b77393 --- /dev/null +++ b/FprimeZephyrReference/Components/Drv/DistanceSensorManager/DistanceSensorManager.hpp @@ -0,0 +1,115 @@ +// ====================================================================== +// \title DistanceSensorManager.hpp +// \brief hpp file for DistanceSensorManager component implementation class +// ====================================================================== + +#ifndef Components_DistanceSensorManager_HPP +#define Components_DistanceSensorManager_HPP + +// clang-format off +// Keep the includes in this order +#include "FprimeZephyrReference/Components/Drv/DistanceSensorManager/DistanceSensorManagerComponentAc.hpp" +#include "FprimeZephyrReference/Components/Drv/Helpers/Helpers.hpp" +// clang-format on + +#include +#include +#include + +namespace Drv { + +// VL6180 Register Definitions +#define VL6180_REG_IDENTIFICATION_MODEL_ID 0x0000 +#define VL6180_REG_SYSTEM_INTERRUPT_CONFIG 0x0014 +#define VL6180_REG_SYSTEM_INTERRUPT_CLEAR 0x0015 +#define VL6180_REG_SYSTEM_FRESH_OUT_OF_RESET 0x0016 +#define VL6180_REG_SYSRANGE_START 0x0018 +#define VL6180_REG_SYSRANGE_INTERMEASUREMENT_PERIOD 0x001B +#define VL6180_REG_SYSRANGE_VHV_REPEAT_RATE 0x0031 +#define VL6180_REG_SYSRANGE_VHV_RECALIBRATE 0x002E +#define VL6180_REG_SYSRANGE_RANGE_CHECK_ENABLES 0x002D +#define VL6180_REG_RESULT_RANGE_STATUS 0x004D +#define VL6180_REG_RESULT_RANGE_VAL 0x0062 + +// VL6180 Constants +#define VL6180_MODEL_ID 0xB4 +#define VL6180_RANGE_START_SINGLE_SHOT 0x01 + +class DistanceSensorManager final : public DistanceSensorManagerComponentBase { + public: + // ---------------------------------------------------------------------- + // Component construction and destruction + // ---------------------------------------------------------------------- + + //! Construct DistanceSensorManager object + DistanceSensorManager(const char* const compName); + + //! Destroy DistanceSensorManager object + ~DistanceSensorManager(); + + private: + // ---------------------------------------------------------------------- + // Handler implementations for typed input ports + // ---------------------------------------------------------------------- + + //! Get the distance reading from the VL6180 sensor + F64 distanceGet_handler(const FwIndexType portNum //!< The port number + ) override; + + //! Handler for run port (called by rate group) + void run_handler(const FwIndexType portNum, //!< The port number + U32 context //!< The call order + ) override; + + // ---------------------------------------------------------------------- + // Command handler implementations + // ---------------------------------------------------------------------- + + //! Handler for READ_DISTANCE command + void READ_DISTANCE_cmdHandler(FwOpcodeType opCode, //!< The opcode + U32 cmdSeq //!< The command sequence number + ) override; + + // ---------------------------------------------------------------------- + // Private helper methods + // ---------------------------------------------------------------------- + + //! Initialize the VL6180 sensor + //! \return true if initialization succeeded, false otherwise + bool initializeSensor(); + + //! Read a byte from VL6180 register + //! \param reg Register address (16-bit) + //! \param value Pointer to store the read value + //! \return 0 on success, negative error code on failure + int readRegister(uint16_t reg, uint8_t* value); + + //! Write a byte to VL6180 register + //! \param reg Register address (16-bit) + //! \param value Value to write + //! \return 0 on success, negative error code on failure + int writeRegister(uint16_t reg, uint8_t value); + + //! Start a single-shot range measurement + //! \return 0 on success, negative error code on failure + int startRangeMeasurement(); + + //! Read the range result + //! \param distance_mm Pointer to store distance in millimeters + //! \return 0 on success, negative error code on failure + int readRangeResult(uint8_t* distance_mm); + + // ---------------------------------------------------------------------- + // Member variables + // ---------------------------------------------------------------------- + + //! Zephyr I2C device spec for communicating with VL6180 + struct i2c_dt_spec i2c_spec; + + //! Flag indicating whether sensor is initialized + bool initialized; +}; + +} // namespace Drv + +#endif diff --git a/FprimeZephyrReference/ReferenceDeployment/Top/ReferenceDeploymentPackets.fppi b/FprimeZephyrReference/ReferenceDeployment/Top/ReferenceDeploymentPackets.fppi index 43f0bbf9..7ff692a6 100644 --- a/FprimeZephyrReference/ReferenceDeployment/Top/ReferenceDeploymentPackets.fppi +++ b/FprimeZephyrReference/ReferenceDeployment/Top/ReferenceDeploymentPackets.fppi @@ -49,6 +49,7 @@ telemetry packets ReferenceDeploymentPackets { ReferenceDeployment.lsm6dsoManager.AngularVelocity ReferenceDeployment.lsm6dsoManager.Temperature ReferenceDeployment.lis2mdlManager.MagneticField + ReferenceDeployment.distanceSensorManager.Distance } packet LoRa id 7 group 4 { diff --git a/FprimeZephyrReference/ReferenceDeployment/Top/instances.fpp b/FprimeZephyrReference/ReferenceDeployment/Top/instances.fpp index 26eebbf7..37f72b55 100644 --- a/FprimeZephyrReference/ReferenceDeployment/Top/instances.fpp +++ b/FprimeZephyrReference/ReferenceDeployment/Top/instances.fpp @@ -70,6 +70,8 @@ module ReferenceDeployment { instance lsm6dsoManager: Drv.Lsm6dsoManager base id 0x10019000 + instance distanceSensorManager: Drv.DistanceSensorManager base id 0x10031000 + instance bootloaderTrigger: Components.BootloaderTrigger base id 0x10020000 instance burnwire: Components.Burnwire base id 0x10021000 diff --git a/FprimeZephyrReference/ReferenceDeployment/Top/topology.fpp b/FprimeZephyrReference/ReferenceDeployment/Top/topology.fpp index ec3bcfb5..1ff85c7a 100644 --- a/FprimeZephyrReference/ReferenceDeployment/Top/topology.fpp +++ b/FprimeZephyrReference/ReferenceDeployment/Top/topology.fpp @@ -35,6 +35,7 @@ module ReferenceDeployment { instance imuManager instance lis2mdlManager instance lsm6dsoManager + instance distanceSensorManager instance bootloaderTrigger instance comDelay instance burnwire @@ -137,6 +138,7 @@ module ReferenceDeployment { rateGroup1Hz.RateGroupMemberOut[7] -> burnwire.schedIn rateGroup1Hz.RateGroupMemberOut[8] -> antennaDeployer.schedIn rateGroup1Hz.RateGroupMemberOut[9] -> fsSpace.run + rateGroup1Hz.RateGroupMemberOut[10] -> distanceSensorManager.run } diff --git a/FprimeZephyrReference/project/config/AcConstants.fpp b/FprimeZephyrReference/project/config/AcConstants.fpp new file mode 100644 index 00000000..173929fe --- /dev/null +++ b/FprimeZephyrReference/project/config/AcConstants.fpp @@ -0,0 +1,72 @@ +# ====================================================================== +# AcConstants.fpp +# Project-specific overrides for F Prime configuration constants +# Based on lib/fprime/default/config/AcConstants.fpp +# ====================================================================== + +@ Number of rate group member output ports for ActiveRateGroup +@ Increased from default 10 to 11 to support all rate group members +constant ActiveRateGroupOutputPorts = 11 + +@ Number of rate group member output ports for PassiveRateGroup +constant PassiveRateGroupOutputPorts = 10 + +@ Used to drive rate groups +constant RateGroupDriverRateGroupPorts = 3 + +@ Used for command and registration ports +constant CmdDispatcherComponentCommandPorts = 30 + +@ Used for uplink/sequencer buffer/response ports +constant CmdDispatcherSequencePorts = 5 + +@ Used for dispatching sequences to command sequencers +constant SeqDispatcherSequencerPorts = 2 + +@ Used for sizing the command splitter input arrays +constant CmdSplitterPorts = CmdDispatcherSequencePorts + +@ Number of static memory allocations +constant StaticMemoryAllocations = 4 + +@ Used to ping active components +constant HealthPingPorts = 25 + +@ Used for broadcasting completed file downlinks +constant FileDownCompletePorts = 1 + +@ Used for number of Fw::Com type ports supported by Svc::ComQueue +constant ComQueueComPorts = 2 + +@ Used for number of Fw::Buffer type ports supported by Svc::ComQueue +constant ComQueueBufferPorts = 1 + +@ Used for maximum number of connected buffer repeater consumers +constant BufferRepeaterOutputPorts = 10 + +@ Size of port array for DpManager +constant DpManagerNumPorts = 5 + +@ Size of processing port array for DpWriter +constant DpWriterNumProcPorts = 5 + +@ The size of a file name string +constant FileNameStringSize = 200 + +@ The size of an assert text string +constant FwAssertTextSize = 256 + +@ The size of a file name in an AssertFatalAdapter event +@ Note: File names in assertion failures are also truncated by +@ the constants FW_ASSERT_TEXT_SIZE and FW_LOG_STRING_MAX_SIZE, set +@ in FpConfig.h. +constant AssertFatalAdapterEventFileSize = FileNameStringSize + +# ---------------------------------------------------------------------- +# Hub connections. Connections on all deployments should mirror these settings. +# ---------------------------------------------------------------------- + +constant GenericHubInputPorts = 10 +constant GenericHubOutputPorts = 10 +constant GenericHubInputBuffers = 10 +constant GenericHubOutputBuffers = 10 diff --git a/FprimeZephyrReference/project/config/CMakeLists.txt b/FprimeZephyrReference/project/config/CMakeLists.txt index cf115d7b..0e62ab4e 100644 --- a/FprimeZephyrReference/project/config/CMakeLists.txt +++ b/FprimeZephyrReference/project/config/CMakeLists.txt @@ -5,6 +5,7 @@ #### register_fprime_config( CONFIGURATION_OVERRIDES + "${CMAKE_CURRENT_LIST_DIR}/AcConstants.fpp" "${CMAKE_CURRENT_LIST_DIR}/CdhCoreConfig.fpp" "${CMAKE_CURRENT_LIST_DIR}/CdhCoreTlmConfig.fpp" "${CMAKE_CURRENT_LIST_DIR}/CdhCoreFatalHandlerConfig.fpp" diff --git a/boards/bronco_space/proves_flight_control_board_v5/proves_flight_control_board_v5.dtsi b/boards/bronco_space/proves_flight_control_board_v5/proves_flight_control_board_v5.dtsi index 11db77df..eb093e01 100644 --- a/boards/bronco_space/proves_flight_control_board_v5/proves_flight_control_board_v5.dtsi +++ b/boards/bronco_space/proves_flight_control_board_v5/proves_flight_control_board_v5.dtsi @@ -166,4 +166,25 @@ zephyr_udc0: &usbd { lsb-microamp = <100>; label = "INA219"; }; + + tca9548a: tca9548a@70 { + compatible = "ti,tca9548a"; + reg = <0x70>; + #address-cells = <1>; + #size-cells = <0>; + label = "TCA9548A"; + + tca_channel0: channel@0 { + compatible = "ti,tca9548a-channel"; + reg = <0>; + #address-cells = <1>; + #size-cells = <0>; + + vl6180: vl6180@29 { + compatible = "st,vl6180"; + reg = <0x29>; + label = "VL6180"; + }; + }; + }; }; diff --git a/prj.conf b/prj.conf index b1e35675..504c1384 100644 --- a/prj.conf +++ b/prj.conf @@ -28,6 +28,9 @@ CONFIG_GPIO=y CONFIG_LED=y CONFIG_PWM=n CONFIG_I2C=y +# I2C multiplexer (TCA9548A) priority configuration +CONFIG_I2C_TCA954X_ROOT_INIT_PRIO=70 +CONFIG_I2C_TCA954X_CHANNEL_INIT_PRIO=71 CONFIG_SPI=y CONFIG_PINCTRL=y CONFIG_ASSERT=y From f92e8823855b7d6314af97b014afeca90e3453da Mon Sep 17 00:00:00 2001 From: "Sam S. Yu" <25761223+yudataguy@users.noreply.github.com> Date: Mon, 3 Nov 2025 16:48:42 -0800 Subject: [PATCH 2/4] changed the config --- .../project/config/AcConstants.fpp | 72 ------------------- .../project/config/CMakeLists.txt | 1 - 2 files changed, 73 deletions(-) delete mode 100644 FprimeZephyrReference/project/config/AcConstants.fpp diff --git a/FprimeZephyrReference/project/config/AcConstants.fpp b/FprimeZephyrReference/project/config/AcConstants.fpp deleted file mode 100644 index 173929fe..00000000 --- a/FprimeZephyrReference/project/config/AcConstants.fpp +++ /dev/null @@ -1,72 +0,0 @@ -# ====================================================================== -# AcConstants.fpp -# Project-specific overrides for F Prime configuration constants -# Based on lib/fprime/default/config/AcConstants.fpp -# ====================================================================== - -@ Number of rate group member output ports for ActiveRateGroup -@ Increased from default 10 to 11 to support all rate group members -constant ActiveRateGroupOutputPorts = 11 - -@ Number of rate group member output ports for PassiveRateGroup -constant PassiveRateGroupOutputPorts = 10 - -@ Used to drive rate groups -constant RateGroupDriverRateGroupPorts = 3 - -@ Used for command and registration ports -constant CmdDispatcherComponentCommandPorts = 30 - -@ Used for uplink/sequencer buffer/response ports -constant CmdDispatcherSequencePorts = 5 - -@ Used for dispatching sequences to command sequencers -constant SeqDispatcherSequencerPorts = 2 - -@ Used for sizing the command splitter input arrays -constant CmdSplitterPorts = CmdDispatcherSequencePorts - -@ Number of static memory allocations -constant StaticMemoryAllocations = 4 - -@ Used to ping active components -constant HealthPingPorts = 25 - -@ Used for broadcasting completed file downlinks -constant FileDownCompletePorts = 1 - -@ Used for number of Fw::Com type ports supported by Svc::ComQueue -constant ComQueueComPorts = 2 - -@ Used for number of Fw::Buffer type ports supported by Svc::ComQueue -constant ComQueueBufferPorts = 1 - -@ Used for maximum number of connected buffer repeater consumers -constant BufferRepeaterOutputPorts = 10 - -@ Size of port array for DpManager -constant DpManagerNumPorts = 5 - -@ Size of processing port array for DpWriter -constant DpWriterNumProcPorts = 5 - -@ The size of a file name string -constant FileNameStringSize = 200 - -@ The size of an assert text string -constant FwAssertTextSize = 256 - -@ The size of a file name in an AssertFatalAdapter event -@ Note: File names in assertion failures are also truncated by -@ the constants FW_ASSERT_TEXT_SIZE and FW_LOG_STRING_MAX_SIZE, set -@ in FpConfig.h. -constant AssertFatalAdapterEventFileSize = FileNameStringSize - -# ---------------------------------------------------------------------- -# Hub connections. Connections on all deployments should mirror these settings. -# ---------------------------------------------------------------------- - -constant GenericHubInputPorts = 10 -constant GenericHubOutputPorts = 10 -constant GenericHubInputBuffers = 10 -constant GenericHubOutputBuffers = 10 diff --git a/FprimeZephyrReference/project/config/CMakeLists.txt b/FprimeZephyrReference/project/config/CMakeLists.txt index 0e62ab4e..cf115d7b 100644 --- a/FprimeZephyrReference/project/config/CMakeLists.txt +++ b/FprimeZephyrReference/project/config/CMakeLists.txt @@ -5,7 +5,6 @@ #### register_fprime_config( CONFIGURATION_OVERRIDES - "${CMAKE_CURRENT_LIST_DIR}/AcConstants.fpp" "${CMAKE_CURRENT_LIST_DIR}/CdhCoreConfig.fpp" "${CMAKE_CURRENT_LIST_DIR}/CdhCoreTlmConfig.fpp" "${CMAKE_CURRENT_LIST_DIR}/CdhCoreFatalHandlerConfig.fpp" From f8aa3dc55eb5b80f4d00e10a4bcf65a746401e0e Mon Sep 17 00:00:00 2001 From: "Sam S. Yu" <25761223+yudataguy@users.noreply.github.com> Date: Mon, 3 Nov 2025 17:35:33 -0800 Subject: [PATCH 3/4] add AcConstants.fpp --- .../project/config/AcConstants.fpp | 70 +++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 FprimeZephyrReference/project/config/AcConstants.fpp diff --git a/FprimeZephyrReference/project/config/AcConstants.fpp b/FprimeZephyrReference/project/config/AcConstants.fpp new file mode 100644 index 00000000..8eeefb4b --- /dev/null +++ b/FprimeZephyrReference/project/config/AcConstants.fpp @@ -0,0 +1,70 @@ +# ====================================================================== +# AcConstants.fpp +# F Prime configuration constants +# ====================================================================== + +@ Number of rate group member output ports for ActiveRateGroup +constant ActiveRateGroupOutputPorts = 15 + +@ Number of rate group member output ports for PassiveRateGroup +constant PassiveRateGroupOutputPorts = 10 + +@ Used to drive rate groups +constant RateGroupDriverRateGroupPorts = 3 + +@ Used for command and registration ports +constant CmdDispatcherComponentCommandPorts = 30 + +@ Used for uplink/sequencer buffer/response ports +constant CmdDispatcherSequencePorts = 5 + +@ Used for dispatching sequences to command sequencers +constant SeqDispatcherSequencerPorts = 2 + +@ Used for sizing the command splitter input arrays +constant CmdSplitterPorts = CmdDispatcherSequencePorts + +@ Number of static memory allocations +constant StaticMemoryAllocations = 4 + +@ Used to ping active components +constant HealthPingPorts = 25 + +@ Used for broadcasting completed file downlinks +constant FileDownCompletePorts = 1 + +@ Used for number of Fw::Com type ports supported by Svc::ComQueue +constant ComQueueComPorts = 2 + +@ Used for number of Fw::Buffer type ports supported by Svc::ComQueue +constant ComQueueBufferPorts = 1 + +@ Used for maximum number of connected buffer repeater consumers +constant BufferRepeaterOutputPorts = 10 + +@ Size of port array for DpManager +constant DpManagerNumPorts = 5 + +@ Size of processing port array for DpWriter +constant DpWriterNumProcPorts = 5 + +@ The size of a file name string +constant FileNameStringSize = 200 + +@ The size of an assert text string +constant FwAssertTextSize = 256 + +@ The size of a file name in an AssertFatalAdapter event +@ Note: File names in assertion failures are also truncated by +@ the constants FW_ASSERT_TEXT_SIZE and FW_LOG_STRING_MAX_SIZE, set +@ in FpConfig.h. +constant AssertFatalAdapterEventFileSize = FileNameStringSize + +# ---------------------------------------------------------------------- +# Hub connections. Connections on all deployments should mirror these settings. +# ---------------------------------------------------------------------- + +constant GenericHubInputPorts = 10 +constant GenericHubOutputPorts = 10 +constant GenericHubInputBuffers = 10 +constant GenericHubOutputBuffers = 10 From 5e5d52ae06327756441b60bbfcfca1c07bca43b5 Mon Sep 17 00:00:00 2001 From: "Sam S. Yu" <25761223+yudataguy@users.noreply.github.com> Date: Mon, 3 Nov 2025 17:42:55 -0800 Subject: [PATCH 4/4] fix cmake --- FprimeZephyrReference/project/config/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/FprimeZephyrReference/project/config/CMakeLists.txt b/FprimeZephyrReference/project/config/CMakeLists.txt index cf115d7b..0e62ab4e 100644 --- a/FprimeZephyrReference/project/config/CMakeLists.txt +++ b/FprimeZephyrReference/project/config/CMakeLists.txt @@ -5,6 +5,7 @@ #### register_fprime_config( CONFIGURATION_OVERRIDES + "${CMAKE_CURRENT_LIST_DIR}/AcConstants.fpp" "${CMAKE_CURRENT_LIST_DIR}/CdhCoreConfig.fpp" "${CMAKE_CURRENT_LIST_DIR}/CdhCoreTlmConfig.fpp" "${CMAKE_CURRENT_LIST_DIR}/CdhCoreFatalHandlerConfig.fpp"