Skip to content
Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
1dad937
Use custom board definition
nateinaction Sep 7, 2025
7fd3d7b
Remove commented config
nateinaction Sep 8, 2025
bbf35a3
Moving prj.conf sensors to board definition
nateinaction Sep 12, 2025
57e4183
Add d board
nateinaction Sep 12, 2025
e98a434
Try referencing c definitions in d board
nateinaction Sep 12, 2025
a75b69f
Making a common v5 board definition
nateinaction Sep 13, 2025
649e44f
Fix readme
nateinaction Sep 13, 2025
4aef1be
checkpoint rtc working
nateinaction Sep 17, 2025
d1613b0
Pushing what I have
nateinaction Sep 17, 2025
651eb05
poke
nateinaction Sep 17, 2025
08d1fbb
replaced chronotime with zepyhry time
ineskhou Sep 17, 2025
1ea3703
use direct power for rtc backup
nateinaction Sep 17, 2025
a674b21
This builds and runs but Fprime still does not know the time
nateinaction Sep 17, 2025
a1e5c4a
super working rtc component
nateinaction Sep 18, 2025
09e097b
Set fprime-zephyr submodule to latest main
nateinaction Sep 18, 2025
b7b442e
Split rtc manager/driver, confirmed working
nateinaction Sep 18, 2025
6d89365
Working on sdds
nateinaction Sep 18, 2025
8cb2b34
Update the RV3028 sdd
nateinaction Sep 18, 2025
3de364a
Update SDDs
nateinaction Sep 18, 2025
a5fd7b5
Merge branch 'main' of github.com:Open-Source-Space-Foundation/proves…
nateinaction Sep 18, 2025
f35a255
Merge branch 'main' of github.com:Open-Source-Space-Foundation/proves…
nateinaction Sep 18, 2025
60fb355
Merge branch 'main' of github.com:Open-Source-Space-Foundation/proves…
nateinaction Sep 18, 2025
72671c7
Revert submodule change
nateinaction Sep 18, 2025
e11fb04
Rename driver to `Rv3028Manager`
SamuelGomezG Sep 22, 2025
85cb11a
Rename references from Rv3028Driver to Rv3028Manager
SamuelGomezG Sep 22, 2025
f2c18bd
Remove assertion in constructor
SamuelGomezG Sep 22, 2025
7c40dd5
Change logging to use `Fw::Logger`
SamuelGomezG Sep 22, 2025
fab0b47
Most feedback covered
nateinaction Sep 23, 2025
2f447e8
appease linter
ineskhou Sep 26, 2025
6eff68e
Merge branch 'rtc' of github.com:Open-Source-Space-Foundation/proves-…
nateinaction Sep 27, 2025
f659d5b
Add integration tests
nateinaction Sep 28, 2025
aab21fb
Add typehinting
nateinaction Sep 28, 2025
ff77b96
Comment fix
nateinaction Sep 28, 2025
582ae5c
Test for previous time output when setting time
nateinaction Sep 28, 2025
6866735
Stop using EventData.get_dict()
nateinaction Sep 28, 2025
b7c3ddb
Now with microseconds!
nateinaction Sep 29, 2025
a454a07
Fix FPrime microsecond range expectation
nateinaction Sep 29, 2025
4b42cc4
Simplify RTC Manager
nateinaction Sep 29, 2025
d57ed57
Add command failure test
nateinaction Sep 30, 2025
ae3099e
Remove commented code
nateinaction Sep 30, 2025
fe5b6e8
Stop overwriting getTime
nateinaction Sep 30, 2025
7287ead
Use fprime getTime() to get the time
nateinaction Sep 30, 2025
ad4780f
Send command failure response if dev not ready
nateinaction Sep 30, 2025
690abd6
Merge branch 'main' of github.com:Open-Source-Space-Foundation/proves…
nateinaction Oct 2, 2025
16bea0b
Add input validation
nateinaction Oct 2, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions FprimeZephyrReference/Components/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# Include project-wide components here

add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/Drv")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/FatalHandler")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/Watchdog")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/RtcManager/")
1 change: 1 addition & 0 deletions FprimeZephyrReference/Components/Drv/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/Rv3028Driver")
36 changes: 36 additions & 0 deletions FprimeZephyrReference/Components/Drv/Rv3028Driver/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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}/Rv3028Driver.fpp"
SOURCES
"${CMAKE_CURRENT_LIST_DIR}/Rv3028Driver.cpp"
# DEPENDS
# MyPackage_MyOtherModule
)

### Unit Tests ###
# register_fprime_ut(
# AUTOCODER_INPUTS
# "${CMAKE_CURRENT_LIST_DIR}/Rv3028Driver.fpp"
# SOURCES
# "${CMAKE_CURRENT_LIST_DIR}/test/ut/Rv3028DriverTestMain.cpp"
# "${CMAKE_CURRENT_LIST_DIR}/test/ut/Rv3028DriverTester.cpp"
# DEPENDS
# STest # For rules-based testing
# UT_AUTO_HELPERS
# )
94 changes: 94 additions & 0 deletions FprimeZephyrReference/Components/Drv/Rv3028Driver/Rv3028Driver.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
// ======================================================================
// \title Rv3028Driver.cpp
// \brief cpp file for Rv3028Driver component implementation class
// ======================================================================

#include "FprimeZephyrReference/Components/Drv/Rv3028Driver/Rv3028Driver.hpp"

namespace Drv {

// ----------------------------------------------------------------------
// Component construction and destruction
// ----------------------------------------------------------------------

Rv3028Driver ::Rv3028Driver(const char* const compName) : Rv3028DriverComponentBase(compName) {
// Initialize device
this->rv3028 = device_get_binding("RV3028");
FW_ASSERT(device_is_ready(this->rv3028));
}

Rv3028Driver ::~Rv3028Driver() {}

// ----------------------------------------------------------------------
// Handler implementations for commands
// ----------------------------------------------------------------------

void Rv3028Driver ::timeGetPort_handler(FwIndexType portNum, Fw::Time& time) {
// Check device readiness
if (!device_is_ready(this->rv3028)) {
this->log_WARNING_HI_DeviceNotReady();
return;
}

// Fetch time from RTC
struct rtc_time time_rtc = {};
rtc_get_time(this->rv3028, &time_rtc);

// Convert time to POSIX time_t format
struct tm* time_tm = rtc_time_to_tm(&time_rtc);
time_t time_posix = timeutil_timegm(time_tm);

// Set FPrime time object
time.set(TimeBase::TB_WORKSTATION_TIME, 0, static_cast<U32>(time_posix), 0);
}

U32 Rv3028Driver ::timeRead_handler(FwIndexType portNum) {
// Check device readiness
if (!device_is_ready(this->rv3028)) {
this->log_WARNING_HI_DeviceNotReady();
return 0;
}

// Fetch time from RTC
struct rtc_time time_rtc = {};
rtc_get_time(this->rv3028, &time_rtc);

// Convert time to POSIX time_t format
struct tm* time_tm = rtc_time_to_tm(&time_rtc);
time_t time_posix = timeutil_timegm(time_tm);

return time_posix;
}

void Rv3028Driver ::timeSet_handler(FwIndexType portNum, const Drv::TimeData& t) {
// Check device readiness
if (!device_is_ready(this->rv3028)) {
this->log_WARNING_HI_DeviceNotReady();
return;
}

// Populate rtc_time structure from TimeData
const struct rtc_time time_rtc = {
.tm_sec = 0,
.tm_min = t.get_Minute(),
.tm_hour = t.get_Hour(),
.tm_mday = t.get_Day(),
.tm_mon = t.get_Month() - 1, // month [0-11]
.tm_year = t.get_Year() - 1900, // year since 1900
.tm_wday = 0,
.tm_yday = 0,
.tm_isdst = 0,
};

// Set time on RTC
const int status = rtc_set_time(this->rv3028, &time_rtc);

// Report whether setting the time was successful
if (status == 0) {
this->log_ACTIVITY_HI_TimeSet();
} else {
this->log_WARNING_HI_TimeNotSet();
}
}

} // namespace Drv
56 changes: 56 additions & 0 deletions FprimeZephyrReference/Components/Drv/Rv3028Driver/Rv3028Driver.fpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Type definition
module Drv {
struct TimeData {
Year: U32 @< Year value.
Month: U32 @< Month value.
Day: U32 @< Day value.
Hour: U32 @< Hour value.
Minute: U32 @< Minute value.
}
}

# Port definition
module Drv {
port TimeSet(t: TimeData)
port TimeRead -> U32
}

module Drv {
@ Manages the real time clock
passive component Rv3028Driver {
import Svc.Time

@ timeSet port to set the time on the RTC
@ Requirement Rv3028Driver-001
sync input port timeSet: TimeSet

@ timeRead port to get the time from the RTC
@ Requirement Rv3028Driver-002
sync input port timeRead: TimeRead

##############################################################################
#### Uncomment the following examples to start customizing your component ####
##############################################################################

@ DeviceNotReady event indicates that the RV3028 is not ready
event DeviceNotReady() severity warning high id 0 format "RV3028 not ready"

@ TimeSet event indicates that the time was set successfully
event TimeSet() severity activity high id 1 format "Time set on RV3028"

@ TimeNotSet event indicates that the time was not set successfully
event TimeNotSet() severity warning high id 2 format "Time not set on RV3028"

###############################################################################
# Standard AC Ports: Required for Channels, Events, Commands, and Parameters #
###############################################################################
@ 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
}
}
64 changes: 64 additions & 0 deletions FprimeZephyrReference/Components/Drv/Rv3028Driver/Rv3028Driver.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
// ======================================================================
// \title Rv3028Driver.hpp
// \brief hpp file for Rv3028Driver component implementation class
// ======================================================================

#ifndef Components_Rv3028Driver_HPP
#define Components_Rv3028Driver_HPP

#include "FprimeZephyrReference/Components/Drv/Rv3028Driver/Rv3028DriverComponentAc.hpp"

#include <zephyr/device.h>
#include <zephyr/drivers/rtc.h>
#include <zephyr/drivers/sensor.h>
#include <zephyr/kernel.h>
#include <zephyr/sys/timeutil.h>

namespace Drv {

class Rv3028Driver final : public Rv3028DriverComponentBase {
public:
// ----------------------------------------------------------------------
// Component construction and destruction
// ----------------------------------------------------------------------

//! Construct Rv3028Driver object
Rv3028Driver(const char* const compName //!< The component name
);

//! Destroy Rv3028Driver object
~Rv3028Driver();

private:
// ----------------------------------------------------------------------
// Handler implementations for commands
// ----------------------------------------------------------------------

//! Handler implementation for timeGetPort
//!
//! Port to retrieve time
void timeGetPort_handler(FwIndexType portNum, //!< The port number
Fw::Time& time //!< Reference to Time object
) override;

//! Handler implementation for timeRead
//!
//! timeRead port to get the time from the RTC
//! Requirement Rv3028Driver-002
U32 timeRead_handler(FwIndexType portNum //!< The port number
) override;

//! Handler implementation for timeSet
//!
//! timeSet port to set the time on the RTC
//! Requirement Rv3028Driver-001
void timeSet_handler(FwIndexType portNum, //!< The port number
const Drv::TimeData& time) override;

//! Zephyr device stores the initialized RV2038 sensor
const struct device* rv3028;
};

} // namespace Drv

#endif
Loading