|
fsp_err_t | R_GPTP_Open (gptp_ctrl_t *const p_ctrl, gptp_cfg_t const *const p_cfg) |
|
fsp_err_t | R_GPTP_Close (gptp_ctrl_t *const p_ctrl) |
|
fsp_err_t | R_GPTP_TimerCfg (gptp_ctrl_t *const p_ctrl, uint8_t timer, gptp_timer_cfg_t const *const p_timer_cfg) |
|
fsp_err_t | R_GPTP_Start (gptp_ctrl_t *const p_ctrl, uint8_t timer) |
|
fsp_err_t | R_GPTP_Stop (gptp_ctrl_t *const p_ctrl, uint8_t timer) |
|
fsp_err_t | R_GPTP_TimerValueGet (gptp_ctrl_t *const p_ctrl, uint8_t timer, gptp_timer_value_t *const p_timer_value) |
|
fsp_err_t | R_GPTP_TimerOffsetSet (gptp_ctrl_t *const p_ctrl, uint8_t timer, int64_t offset) |
|
fsp_err_t | R_GPTP_TimerRateSet (gptp_ctrl_t *const p_ctrl, uint8_t timer, uint32_t rate) |
|
fsp_err_t | R_GPTP_PulseGeneratorSet (gptp_ctrl_t *const p_ctrl, uint8_t timer, gptp_pulse_generator_t *p_pulse) |
|
fsp_err_t | R_GPTP_CallbackSet (gptp_ctrl_t *const p_ctrl, void(*p_callback)(gptp_callback_args_t *), void *const p_context, gptp_callback_args_t *const p_callback_memory) |
|
Driver for the Ethernet peripheral on RA MCUs. This module implements the GPTP Interface.
Overview
Ethernet Generic PTP timer (GPTP) enables accurate synchronization of the clock in the control system.
This module supports two GPTP timer.
Features
The GPTP module has the following features:
- Supports start and stop gPTP timer.
- Supports set timer offset.
- Supports set timer rate.
- Supports set pulse generator.
Configuration
Build Time Configurations for r_gptp
The following build time configurations are defined in fsp_cfg/r_gptp_cfg.h:
Configuration | Options | Default | Description |
Parameter Checking |
-
Default (BSP)
-
Enabled
-
Disabled
| Default (BSP) | If selected code for parameter checking is included in the build. |
Configurations for Networking > Ethernet Generic PTP Timer (r_gptp)
This module can be added to the Stacks tab via New Stack > Networking > Ethernet Generic PTP Timer (r_gptp). Non-secure callable guard functions can be generated for this module by right clicking the module in the RA Configuration tool and checking the "Non-secure Callable" box.
Configuration | Options | Default | Description |
General |
Name | Name must be a valid C symbol | g_gptp0 | Module name. |
Callback | Name must be a valid C symbol | NULL | Callback provided when an ISR occurs |
Clock Configuration
The GPTP clock is based on the ESWCLK frequency. You can set the PTPTIVCt (t = 0 or 1) register to timer increment value according to ESWCLK frequency.
Usage Notes
Examples
This is a basic example of minimal use of the GPTP in an application.
void gptp_basic_example (void)
{
uint8_t timer = GPTP_EXAMPLE_TIMER_NUMBER;
int64_t offset = GPTP_EXAMPLE_OFFSET;
uint32_t rate = GPTP_EXAMPLE_RATE;
{
.time_sec_lower = 0,
.time_nsec = 0,
};
{
.start_sec_upper = 0,
.start_sec_lower = 0,
.start_ns = 0,
.wide = 0,
.period_sec_upper = 0,
.period_sec_lower = 0,
.period_ns = 0,
};
{
.start_sec_upper = 0,
.start_sec_lower = 0,
.start_ns = 0,
.wide = 0,
.period_sec_upper = 0,
.period_sec_lower = 0,
.period_ns = 0,
};
{
.start_sec_upper = 0,
.start_sec_lower = 0,
.start_ns = 0,
.wide = 0,
.period_sec_upper = 0,
.period_sec_lower = 0,
.period_ns = 0,
};
{
.start_sec_upper = 0,
.start_sec_lower = 0,
.start_ns = 0,
.wide = 0,
.period_sec_upper = 0,
.period_sec_lower = 0,
.period_ns = 0,
};
{
{&pulsed_output_cfg0, &pulsed_output_cfg1, &pulsed_output_cfg2, &pulsed_output_cfg3},
};
assert(FSP_SUCCESS == err);
assert(FSP_SUCCESS == err);
assert(FSP_SUCCESS == err);
assert(FSP_SUCCESS == err);
assert(FSP_SUCCESS == err);
assert(FSP_SUCCESS == err);
assert(FSP_SUCCESS == err);
assert(FSP_SUCCESS == err);
assert(FSP_SUCCESS == err);
}
◆ gptp_pulsed_output_cfg_t
struct gptp_pulsed_output_cfg_t |
Pulsed output configuration.
Data Fields |
uint8_t |
pulse_num |
Pulse generator number. |
uint16_t |
start_sec_upper |
Pulse start second(upper 16 bit). |
uint32_t |
start_sec_lower |
Pulse start second(lower 32 bit). |
uint32_t |
start_ns |
Pulse start nanosecond. |
uint16_t |
wide |
Pulse width. |
uint16_t |
period_sec_upper |
Pulse period second(upper 16 bit). |
uint32_t |
period_sec_lower |
Pulse period second(lower 32 bit). |
uint32_t |
period_ns |
Pulse period nanosecond. |
◆ gptp_pulse_generator_t
struct gptp_pulse_generator_t |
Data Fields |
gptp_pulsed_output_cfg_t * |
p_pulsed_output_cfg_list[BSP_FEATURE_ESWM_GPTP_PULSE_GENERATOR_NUM] |
List of pointer to pulsed output configuration. |
◆ gptp_instance_ctrl_t
struct gptp_instance_ctrl_t |
GPTP control block. DO NOT INITIALIZE. Initialization occurs when gptp_api_t::open is called.
◆ R_GPTP_Open()
Initializes the gptp module and applies configurations.
- Return values
-
FSP_SUCCESS | Module opened successfully. |
FSP_ERR_ASSERTION | Pointer to GPTP control block or configuration structure is NULL. |
FSP_ERR_ALREADY_OPEN | Control block has already been opened or channel is being used by another instance. Call close() then open() to reconfigure. |
FSP_ERR_INVALID_POINTER | Pointer to arguments are NULL. |
◆ R_GPTP_Close()
Close the gptp module.
- Return values
-
FSP_SUCCESS | Successfully closed. |
FSP_ERR_ASSERTION | Pointer to GPTP control block is NULL. |
FSP_ERR_NOT_OPEN | The control block has not been opened |
◆ R_GPTP_TimerCfg()
Configures the gptp timer parameters.
- Return values
-
FSP_SUCCESS | Command successfully. |
FSP_ERR_ASSERTION | Pointer to control block is NULL. |
FSP_ERR_NOT_OPEN | The control block has not been opened. |
FSP_ERR_INVALID_ARGUMENT | Invalid timer id. |
FSP_ERR_INVALID_POINTER | Invalid poiter to the timer cfg. |
◆ R_GPTP_Start()
Starts gptp timer.
- Return values
-
FSP_SUCCESS | Timer started.. |
FSP_ERR_ASSERTION | Pointer to control block is NULL. |
FSP_ERR_NOT_OPEN | The control block has not been opened. |
FSP_ERR_INVALID_ARGUMENT | Invalid timer id. |
◆ R_GPTP_Stop()
Stops gptp timer.
- Return values
-
FSP_SUCCESS | Timer stopped. |
FSP_ERR_ASSERTION | Pointer to control block is NULL. |
FSP_ERR_NOT_OPEN | The control block has not been opened. |
FSP_ERR_INVALID_ARGUMENT | Invalid timer id. |
◆ R_GPTP_TimerValueGet()
Gets the current time value to the timer with the specified gptp timer number.
- Return values
-
FSP_SUCCESS | Sec upper, sec lower, and nano sec srored in p_timestamp. |
FSP_ERR_ASSERTION | Pointer to control block is NULL. |
FSP_ERR_NOT_OPEN | The control block has not been opened. |
FSP_ERR_INVALID_POINTER | Pointer to arguments are NULL. |
FSP_ERR_INVALID_ARGUMENT | Invalid input parameter. |
◆ R_GPTP_TimerOffsetSet()
Sets the offset correction for the specified gptp timer number.
- Return values
-
FSP_SUCCESS | Time offset set successfully. |
FSP_ERR_ASSERTION | Pointer to control block is NULL. |
FSP_ERR_NOT_OPEN | The control block has not been opened. |
FSP_ERR_INVALID_ARGUMENT | Invalid input parameter. |
◆ R_GPTP_TimerRateSet()
Sets clock rate correction for the specified timer.
- Return values
-
FSP_SUCCESS | Time rate set successfully. |
FSP_ERR_ASSERTION | Pointer to control block is NULL. |
FSP_ERR_NOT_OPEN | The control block has not been opened. |
FSP_ERR_INVALID_POINTER | Pointer to arguments are NULL. |
FSP_ERR_INVALID_ARGUMENT | Invalid input parameter. |
◆ R_GPTP_PulseGeneratorSet()
Sets pulse generator.
- Return values
-
FSP_SUCCESS | Pulse generator set successfully. |
FSP_ERR_ASSERTION | Pointer to control block is NULL. |
FSP_ERR_NOT_OPEN | The control block has not been opened. |
FSP_ERR_INVALID_POINTER | Pointer to arguments are NULL. |
FSP_ERR_INVALID_ARGUMENT | Invalid input parameter. |
◆ R_GPTP_CallbackSet()
Updates the user callback with the option to provide memory for the callback argument structure. Implements gptp_api_t::callbackSet.
- Return values
-
FSP_SUCCESS | Callback updated successfully. |
FSP_ERR_ASSERTION | A required pointer is NULL. |
FSP_ERR_NOT_OPEN | The control block has not been opened. |
FSP_ERR_NO_CALLBACK_MEMORY | p_callback is non-secure and p_callback_memory is either secure or NULL. |