mirror of
https://github.com/intrepidcs/libicsneo.git
synced 2026-08-05 01:18:36 +02:00
Settings: Add GPTP
This commit is contained in:
committed by
Kyle Schwarz
parent
2d0b0c63ed
commit
299766403f
@@ -613,6 +613,18 @@ enum : uint8_t
|
||||
RESISTOR_OFF
|
||||
};
|
||||
|
||||
enum RADGPTPProfile : icsneoc2_gptp_profile_t {
|
||||
RAD_GPTP_PROFILE_STANDARD = icsneoc2_gptp_profile_standard,
|
||||
RAD_GPTP_PROFILE_AUTOMOTIVE = icsneoc2_gptp_profile_automotive,
|
||||
};
|
||||
|
||||
enum RADGPTPRole : icsneoc2_gptp_role_t {
|
||||
RAD_GPTP_ROLE_DISABLED = icsneoc2_gptp_role_disabled,
|
||||
RAD_GPTP_ROLE_PASSIVE = icsneoc2_gptp_role_passive,
|
||||
RAD_GPTP_ROLE_MASTER = icsneoc2_gptp_role_master,
|
||||
RAD_GPTP_ROLE_SLAVE = icsneoc2_gptp_role_slave,
|
||||
};
|
||||
|
||||
/* Mode in LIN_SETTINGS */
|
||||
enum LINMode
|
||||
{
|
||||
@@ -1278,6 +1290,18 @@ public:
|
||||
virtual bool setMiscIOAnalogOutputEnabled(uint8_t pin, bool enabled);
|
||||
virtual bool setMiscIOAnalogOutput(uint8_t pin, MiscIOAnalogVoltage voltage);
|
||||
|
||||
// gPTP methods
|
||||
std::optional<RADGPTPProfile> getGPTPProfile() const;
|
||||
bool setGPTPProfile(RADGPTPProfile profile);
|
||||
std::optional<RADGPTPRole> getGPTPRole() const;
|
||||
bool setGPTPRole(RADGPTPRole role);
|
||||
std::optional<uint8_t> getGPTPEnabledPort() const;
|
||||
bool setGPTPEnabledPort(uint8_t port);
|
||||
std::optional<bool> isGPTPClockSyntonizationEnabled() const;
|
||||
bool setGPTPClockSyntonizationEnabled(bool enable);
|
||||
virtual const RAD_GPTP_SETTINGS* getGPTPSettings() const { return nullptr; }
|
||||
virtual RAD_GPTP_SETTINGS* getMutableGPTPSettings() { return nullptr; }
|
||||
|
||||
const void* getRawStructurePointer() const { return settingsInDeviceRAM.data(); }
|
||||
void* getMutableRawStructurePointer() { return settings.data(); }
|
||||
template<typename T> const T* getStructurePointer() const { return reinterpret_cast<const T*>(getRawStructurePointer()); }
|
||||
|
||||
@@ -171,6 +171,15 @@ public:
|
||||
cfg->perf_en = !!enable;
|
||||
return true;
|
||||
}
|
||||
|
||||
const RAD_GPTP_SETTINGS* getGPTPSettings() const override {
|
||||
auto cfg = getStructurePointer<neoviconnect_settings_t>();
|
||||
return cfg ? &cfg->gPTP : nullptr;
|
||||
}
|
||||
RAD_GPTP_SETTINGS* getMutableGPTPSettings() override {
|
||||
auto cfg = getMutableStructurePointer<neoviconnect_settings_t>();
|
||||
return cfg ? &cfg->gPTP : nullptr;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -422,6 +422,15 @@ protected:
|
||||
return nullptr;
|
||||
return &cfg->termination_enables;
|
||||
}
|
||||
|
||||
const RAD_GPTP_SETTINGS* getGPTPSettings() const override {
|
||||
auto cfg = getStructurePointer<neovifire3_settings_t>();
|
||||
return cfg ? &cfg->gPTP : nullptr;
|
||||
}
|
||||
RAD_GPTP_SETTINGS* getMutableGPTPSettings() override {
|
||||
auto cfg = getMutableStructurePointer<neovifire3_settings_t>();
|
||||
return cfg ? &cfg->gPTP : nullptr;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -261,6 +261,15 @@ protected:
|
||||
return nullptr;
|
||||
return &cfg->termination_enables;
|
||||
}
|
||||
|
||||
const RAD_GPTP_SETTINGS* getGPTPSettings() const override {
|
||||
auto cfg = getStructurePointer<neovifire3flexray_settings_t>();
|
||||
return cfg ? &cfg->gPTP : nullptr;
|
||||
}
|
||||
RAD_GPTP_SETTINGS* getMutableGPTPSettings() override {
|
||||
auto cfg = getMutableStructurePointer<neovifire3flexray_settings_t>();
|
||||
return cfg ? &cfg->gPTP : nullptr;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -572,6 +572,15 @@ protected:
|
||||
return nullptr;
|
||||
return &cfg->termination_enables;
|
||||
}
|
||||
|
||||
const RAD_GPTP_SETTINGS* getGPTPSettings() const override {
|
||||
auto cfg = getStructurePointer<neovifire3t1slin_settings_t>();
|
||||
return cfg ? &cfg->gPTP : nullptr;
|
||||
}
|
||||
RAD_GPTP_SETTINGS* getMutableGPTPSettings() override {
|
||||
auto cfg = getMutableStructurePointer<neovifire3t1slin_settings_t>();
|
||||
return cfg ? &cfg->gPTP : nullptr;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -320,6 +320,15 @@ protected:
|
||||
return nullptr;
|
||||
return &cfg->termination_enables;
|
||||
}
|
||||
|
||||
const RAD_GPTP_SETTINGS* getGPTPSettings() const override {
|
||||
auto cfg = getStructurePointer<neovired2_settings_t>();
|
||||
return cfg ? &cfg->gPTP : nullptr;
|
||||
}
|
||||
RAD_GPTP_SETTINGS* getMutableGPTPSettings() override {
|
||||
auto cfg = getMutableStructurePointer<neovired2_settings_t>();
|
||||
return cfg ? &cfg->gPTP : nullptr;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -259,6 +259,15 @@ public:
|
||||
cfg->perf_en = !!enable;
|
||||
return true;
|
||||
}
|
||||
|
||||
const RAD_GPTP_SETTINGS* getGPTPSettings() const override {
|
||||
auto cfg = getStructurePointer<rada2b_settings_t>();
|
||||
return cfg ? &cfg->gPTP : nullptr;
|
||||
}
|
||||
RAD_GPTP_SETTINGS* getMutableGPTPSettings() override {
|
||||
auto cfg = getMutableStructurePointer<rada2b_settings_t>();
|
||||
return cfg ? &cfg->gPTP : nullptr;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -290,6 +290,15 @@ private:
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
const RAD_GPTP_SETTINGS* getGPTPSettings() const override {
|
||||
auto cfg = getStructurePointer<radcomet2_settings_t>();
|
||||
return cfg ? &cfg->gPTP : nullptr;
|
||||
}
|
||||
RAD_GPTP_SETTINGS* getMutableGPTPSettings() override {
|
||||
auto cfg = getMutableStructurePointer<radcomet2_settings_t>();
|
||||
return cfg ? &cfg->gPTP : nullptr;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -728,6 +728,15 @@ private:
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
const RAD_GPTP_SETTINGS* getGPTPSettings() const override {
|
||||
auto cfg = getStructurePointer<radcomet3_settings_t>();
|
||||
return cfg ? &cfg->gPTP : nullptr;
|
||||
}
|
||||
RAD_GPTP_SETTINGS* getMutableGPTPSettings() override {
|
||||
auto cfg = getMutableStructurePointer<radcomet3_settings_t>();
|
||||
return cfg ? &cfg->gPTP : nullptr;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -290,6 +290,15 @@ public:
|
||||
cfg->perf_en = !!enable;
|
||||
return true;
|
||||
}
|
||||
|
||||
const RAD_GPTP_SETTINGS* getGPTPSettings() const override {
|
||||
auto cfg = getStructurePointer<radgalaxy_settings_t>();
|
||||
return cfg ? &cfg->gPTP : nullptr;
|
||||
}
|
||||
RAD_GPTP_SETTINGS* getMutableGPTPSettings() override {
|
||||
auto cfg = getMutableStructurePointer<radgalaxy_settings_t>();
|
||||
return cfg ? &cfg->gPTP : nullptr;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -277,6 +277,15 @@ public:
|
||||
cfg->perf_en = !!enable;
|
||||
return true;
|
||||
}
|
||||
|
||||
const RAD_GPTP_SETTINGS* getGPTPSettings() const override {
|
||||
auto cfg = getStructurePointer<radgalaxy2_settings_t>();
|
||||
return cfg ? &cfg->gPTP : nullptr;
|
||||
}
|
||||
RAD_GPTP_SETTINGS* getMutableGPTPSettings() override {
|
||||
auto cfg = getMutableStructurePointer<radgalaxy2_settings_t>();
|
||||
return cfg ? &cfg->gPTP : nullptr;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -203,6 +203,15 @@ protected:
|
||||
return nullptr;
|
||||
return &cfg->termination_enables;
|
||||
}
|
||||
|
||||
const RAD_GPTP_SETTINGS* getGPTPSettings() const override {
|
||||
auto cfg = getStructurePointer<radgigastar_settings_t>();
|
||||
return cfg ? &cfg->gPTP : nullptr;
|
||||
}
|
||||
RAD_GPTP_SETTINGS* getMutableGPTPSettings() override {
|
||||
auto cfg = getMutableStructurePointer<radgigastar_settings_t>();
|
||||
return cfg ? &cfg->gPTP : nullptr;
|
||||
}
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
|
||||
@@ -645,6 +645,14 @@ namespace icsneo
|
||||
return nullptr;
|
||||
return &cfg->termination_enables;
|
||||
}
|
||||
const RAD_GPTP_SETTINGS* getGPTPSettings() const override {
|
||||
auto cfg = getStructurePointer<radgigastar2_settings_t>();
|
||||
return cfg ? &cfg->gPTP : nullptr;
|
||||
}
|
||||
RAD_GPTP_SETTINGS* getMutableGPTPSettings() override {
|
||||
auto cfg = getMutableStructurePointer<radgigastar2_settings_t>();
|
||||
return cfg ? &cfg->gPTP : nullptr;
|
||||
}
|
||||
};
|
||||
|
||||
typedef struct
|
||||
|
||||
@@ -43,6 +43,15 @@ static_assert(sizeof(radmoon2_settings_t) == 170, "RADMoon2 settings size mismat
|
||||
class RADMoon2Settings : public IDeviceSettings {
|
||||
public:
|
||||
RADMoon2Settings(std::shared_ptr<Communication> com) : IDeviceSettings(com, sizeof(radmoon2_settings_t)) {}
|
||||
|
||||
const RAD_GPTP_SETTINGS* getGPTPSettings() const override {
|
||||
auto cfg = getStructurePointer<radmoon2_settings_t>();
|
||||
return cfg ? &cfg->gPTP : nullptr;
|
||||
}
|
||||
RAD_GPTP_SETTINGS* getMutableGPTPSettings() override {
|
||||
auto cfg = getMutableStructurePointer<radmoon2_settings_t>();
|
||||
return cfg ? &cfg->gPTP : nullptr;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -380,6 +380,15 @@ private:
|
||||
cfg->t1sExt.multi_id[index] = id;
|
||||
return true;
|
||||
}
|
||||
|
||||
const RAD_GPTP_SETTINGS* getGPTPSettings() const override {
|
||||
auto cfg = getStructurePointer<radmoont1s_settings_t>();
|
||||
return cfg ? &cfg->gPTP : nullptr;
|
||||
}
|
||||
RAD_GPTP_SETTINGS* getMutableGPTPSettings() override {
|
||||
auto cfg = getMutableStructurePointer<radmoont1s_settings_t>();
|
||||
return cfg ? &cfg->gPTP : nullptr;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -134,6 +134,15 @@ public:
|
||||
cfg->perf_en = !!enable;
|
||||
return true;
|
||||
}
|
||||
|
||||
const RAD_GPTP_SETTINGS* getGPTPSettings() const override {
|
||||
auto cfg = getStructurePointer<radstar2_settings_t>();
|
||||
return cfg ? &cfg->gPTP : nullptr;
|
||||
}
|
||||
RAD_GPTP_SETTINGS* getMutableGPTPSettings() override {
|
||||
auto cfg = getMutableStructurePointer<radstar2_settings_t>();
|
||||
return cfg ? &cfg->gPTP : nullptr;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -581,6 +581,27 @@ icsneoc2_error_t icsneoc2_device_tc10_sleep_request(const icsneoc2_device_t* dev
|
||||
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
|
||||
*/
|
||||
icsneoc2_error_t icsneoc2_device_tc10_status_get(const icsneoc2_device_t* device, icsneoc2_netid_t netid, icsneoc2_tc10_sleep_status_t* sleep_status, icsneoc2_tc10_wake_status_t* wake_status);
|
||||
|
||||
/**
|
||||
* Check if the device supports gPTP.
|
||||
*
|
||||
* @param[in] device The device to check against.
|
||||
* @param[out] supported Pointer to a bool to copy the value into.
|
||||
*
|
||||
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
|
||||
*/
|
||||
icsneoc2_error_t icsneoc2_device_supports_gptp(const icsneoc2_device_t* device, bool* supported);
|
||||
|
||||
/**
|
||||
* Get the current gPTP status from the device.
|
||||
*
|
||||
* @param[in] device The device to query.
|
||||
* @param[in] timeout_ms Timeout in milliseconds to wait for the device response.
|
||||
* @param[out] status Pointer to an icsneoc2_gptp_status_t to copy the status into.
|
||||
*
|
||||
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters or icsneoc2_error_invalid_type otherwise.
|
||||
*/
|
||||
icsneoc2_error_t icsneoc2_device_gptp_status_get(const icsneoc2_device_t* device, uint32_t timeout_ms, icsneoc2_gptp_status_t* status);
|
||||
/**
|
||||
* Get the current state of a digital I/O pin.
|
||||
*
|
||||
|
||||
@@ -676,6 +676,86 @@ icsneoc2_error_t icsneoc2_settings_disabled_get(icsneoc2_device_t* device, bool*
|
||||
*/
|
||||
icsneoc2_error_t icsneoc2_settings_readonly_get(icsneoc2_device_t* device, bool* value);
|
||||
|
||||
/**
|
||||
* Get the gPTP profile.
|
||||
*
|
||||
* @param[in] device The device to check.
|
||||
* @param[out] value Pointer to store the gPTP profile.
|
||||
*
|
||||
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
|
||||
*/
|
||||
icsneoc2_error_t icsneoc2_settings_gptp_profile_get(icsneoc2_device_t* device, icsneoc2_gptp_profile_t* value);
|
||||
|
||||
/**
|
||||
* Set the gPTP profile.
|
||||
*
|
||||
* @param[in] device The device to configure.
|
||||
* @param[in] value The gPTP profile to set.
|
||||
*
|
||||
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters or icsneoc2_error_set_settings_failure otherwise.
|
||||
*/
|
||||
icsneoc2_error_t icsneoc2_settings_gptp_profile_set(icsneoc2_device_t* device, icsneoc2_gptp_profile_t value);
|
||||
|
||||
/**
|
||||
* Get the gPTP port role.
|
||||
*
|
||||
* @param[in] device The device to check.
|
||||
* @param[out] value Pointer to store the gPTP port role.
|
||||
*
|
||||
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
|
||||
*/
|
||||
icsneoc2_error_t icsneoc2_settings_gptp_role_get(icsneoc2_device_t* device, icsneoc2_gptp_role_t* value);
|
||||
|
||||
/**
|
||||
* Set the gPTP port role.
|
||||
*
|
||||
* @param[in] device The device to configure.
|
||||
* @param[in] value The gPTP port role to set.
|
||||
*
|
||||
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters or icsneoc2_error_set_settings_failure otherwise.
|
||||
*/
|
||||
icsneoc2_error_t icsneoc2_settings_gptp_role_set(icsneoc2_device_t* device, icsneoc2_gptp_role_t value);
|
||||
|
||||
/**
|
||||
* Get the gPTP enabled port index. A value of 0 indicates gPTP is disabled.
|
||||
*
|
||||
* @param[in] device The device to check.
|
||||
* @param[out] value Pointer to store the enabled port index.
|
||||
*
|
||||
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
|
||||
*/
|
||||
icsneoc2_error_t icsneoc2_settings_gptp_enabled_port_get(icsneoc2_device_t* device, uint8_t* value);
|
||||
|
||||
/**
|
||||
* Set the gPTP enabled port index. Set to 0 to disable gPTP.
|
||||
*
|
||||
* @param[in] device The device to configure.
|
||||
* @param[in] value The port index to enable gPTP on, or 0 to disable.
|
||||
*
|
||||
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters or icsneoc2_error_set_settings_failure otherwise.
|
||||
*/
|
||||
icsneoc2_error_t icsneoc2_settings_gptp_enabled_port_set(icsneoc2_device_t* device, uint8_t value);
|
||||
|
||||
/**
|
||||
* Check if gPTP clock syntonization is enabled.
|
||||
*
|
||||
* @param[in] device The device to check.
|
||||
* @param[out] value Pointer to store the clock syntonization enable state.
|
||||
*
|
||||
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
|
||||
*/
|
||||
icsneoc2_error_t icsneoc2_settings_gptp_clock_syntonization_enabled_get(icsneoc2_device_t* device, bool* value);
|
||||
|
||||
/**
|
||||
* Enable or disable gPTP clock syntonization.
|
||||
*
|
||||
* @param[in] device The device to configure.
|
||||
* @param[in] value The clock syntonization enable state to set.
|
||||
*
|
||||
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters or icsneoc2_error_set_settings_failure otherwise.
|
||||
*/
|
||||
icsneoc2_error_t icsneoc2_settings_gptp_clock_syntonization_enabled_set(icsneoc2_device_t* device, bool value);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -352,6 +352,41 @@ typedef enum _icsneoc2_misc_io_analog_voltage_t {
|
||||
|
||||
typedef uint8_t icsneoc2_misc_io_analog_voltage_t;
|
||||
|
||||
typedef enum _icsneoc2_gptp_profile_t {
|
||||
icsneoc2_gptp_profile_standard = 0, // IEEE 802.1AS standard profile
|
||||
icsneoc2_gptp_profile_automotive = 1, // Automotive gPTP profile
|
||||
|
||||
// Must be last entry. Don't use as a gPTP profile.
|
||||
icsneoc2_gptp_profile_maxsize
|
||||
} _icsneoc2_gptp_profile_t;
|
||||
|
||||
typedef uint8_t icsneoc2_gptp_profile_t;
|
||||
|
||||
typedef enum _icsneoc2_gptp_role_t {
|
||||
icsneoc2_gptp_role_disabled = 0, // gPTP disabled on this port
|
||||
icsneoc2_gptp_role_passive = 1, // Passive role
|
||||
icsneoc2_gptp_role_master = 2, // Master role
|
||||
icsneoc2_gptp_role_slave = 3, // Slave role
|
||||
|
||||
// Must be last entry. Don't use as a gPTP role.
|
||||
icsneoc2_gptp_role_maxsize
|
||||
} _icsneoc2_gptp_role_t;
|
||||
|
||||
typedef uint8_t icsneoc2_gptp_role_t;
|
||||
|
||||
typedef struct icsneoc2_gptp_status_t {
|
||||
uint64_t current_time_seconds; // Current PTP time (seconds portion)
|
||||
uint32_t current_time_nanoseconds; // Current PTP time (nanoseconds portion)
|
||||
int64_t ms_offset_ns; // Master-slave clock offset in nanoseconds
|
||||
uint8_t is_sync; // Non-zero if the clock is synchronized
|
||||
uint8_t link_status; // Non-zero if the link is up
|
||||
int64_t link_delay_ns; // One-way propagation delay in nanoseconds
|
||||
uint8_t selected_role; // Negotiated port role (see icsneoc2_gptp_role_t)
|
||||
uint8_t as_capable; // Non-zero if the port is AS-capable (802.1AS)
|
||||
uint8_t is_syntonized; // Non-zero if frequency is locked to grandmaster
|
||||
uint8_t short_format; // Non-zero if firmware returned a partial response
|
||||
} icsneoc2_gptp_status_t;
|
||||
|
||||
typedef struct icsneoc2_disk_details_t icsneoc2_disk_details_t;
|
||||
|
||||
typedef enum _icsneoc2_disk_layout_t {
|
||||
|
||||
Reference in New Issue
Block a user