![]() |
flexPTP 1.0
An IEEE 1588 PTP implementation designed for microcontrollers
|
#include "task_ptp.h"
#include <string.h>
#include "config.h"
#include "event.h"
#include "flexptp/port/osless/fifo.h"
#include "msg_buf.h"
#include "network_stack_driver.h"
#include "profiles.h"
#include "ptp_core.h"
#include "ptp_defs.h"
#include "ptp_types.h"
#include "settings_interface.h"
#include <flexptp_options.h>
#include <time.h>
#include "minmax.h"
Go to the source code of this file.
Data Structures | |
struct | TxTs |
Structure for communicating transmit timestamp writeback. More... | |
Macros | |
#define | RX_PACKET_FIFO_LENGTH (16) |
Receive packet FIFO length. | |
#define | TX_PACKET_FIFO_LENGTH (16) |
Transmit packet FIFO length. | |
#define | EVENT_FIFO_LENGTH (16) |
Event FIFO length. | |
#define | NOTIFICATION_FIFO_LENGTH (16) |
Notification FIFO length. | |
#define | TX_CALLBACK_FIFO_LENGTH (10) |
Transmit callback FIFO length. | |
#define | TX_TTL_MS (2000) |
TTL for outbound packets. | |
#define | RX_TTL_MS (2000) |
TTL for inbound packets. | |
Enumerations | |
enum | ProcThreadNotification { PTN_NONE = 0x00 , PTN_RECEIVE = 0x01 , PTN_TRANSMIT = 0x02 , PTN_TRANSMIT_DONE = 0x04 , PTN_EVENT = 0x08 } |
Notifications for the processing thread. More... | |
Functions | |
static void | task_ptp (void *pParam) |
static void | ptp_heartbeat_tmr_cb (TimerHandle_t timer) |
static bool | ptp_create_heartbeat_tmr () |
static void | ptp_remove_heartbeat_tmr () |
void | ptp_start_heartbeat_tmr () |
void | ptp_stop_heartbeat_tmr () |
static bool | ptp_create_message_queues () |
static void | ptp_destroy_message_queues () |
bool | reg_task_ptp () |
void | unreg_task_ptp () |
bool | ptp_event_enqueue (const PtpCoreEvent *event) |
void | ptp_receive_enqueue (const void *pPayload, uint32_t len, uint32_t ts_sec, uint32_t ts_ns, int tp) |
bool | ptp_transmit_enqueue (const RawPtpMessage *pMsg) |
void | ptp_transmit_timestamp_cb (uint32_t uid, uint32_t seconds, uint32_t nanoseconds) |
bool | ptp_read_and_clear_transmit_timestamp (uint32_t tag, TimestampI *pTs) |
bool | is_flexPTP_operating () |
Variables | |
static TaskHandle_t | sTH |
static bool | sPTP_operating = false |
#define EVENT_FIFO_LENGTH (16) |
Event FIFO length.
Definition at line 54 of file task_ptp.c.
#define NOTIFICATION_FIFO_LENGTH (16) |
Notification FIFO length.
Definition at line 55 of file task_ptp.c.
#define RX_PACKET_FIFO_LENGTH (16) |
Receive packet FIFO length.
Definition at line 49 of file task_ptp.c.
#define RX_TTL_MS (2000) |
TTL for inbound packets.
Definition at line 60 of file task_ptp.c.
#define TX_CALLBACK_FIFO_LENGTH (10) |
Transmit callback FIFO length.
Definition at line 56 of file task_ptp.c.
#define TX_PACKET_FIFO_LENGTH (16) |
Transmit packet FIFO length.
Definition at line 50 of file task_ptp.c.
#define TX_TTL_MS (2000) |
TTL for outbound packets.
Definition at line 59 of file task_ptp.c.
Notifications for the processing thread.
Definition at line 67 of file task_ptp.c.
bool is_flexPTP_operating | ( | ) |
Is the PTP task operating?
Definition at line 786 of file task_ptp.c.
|
static |
Construct the heartbeat timer.
Definition at line 164 of file task_ptp.c.
|
static |
Definition at line 240 of file task_ptp.c.
|
static |
Definition at line 300 of file task_ptp.c.
bool ptp_event_enqueue | ( | const PtpCoreEvent * | event | ) |
Post an event.
event | pointer to a filled event object |
Definition at line 430 of file task_ptp.c.
|
static |
Provide the flexPTP with periodic ticks of PTP_HEARTBEAT_TICKRATE_MS intervals. This function is only exposed if operating in FLEXPTP_OSLESS mode!
Call this function at PTP_HEARTBEAT_TICKRATE_MS intervals if operating in FLEXPTP_OSLESS mode, otherwise flexPTP manages it.
Definition at line 148 of file task_ptp.c.
bool ptp_read_and_clear_transmit_timestamp | ( | uint32_t | tag, |
TimestampI * | pTs | ||
) |
Read transmit timestamp and release message buffer area.
tag | unique message tag |
pTs | pointer to a TimestampI object |
Definition at line 564 of file task_ptp.c.
void ptp_receive_enqueue | ( | const void * | pPayload, |
uint32_t | len, | ||
uint32_t | ts_sec, | ||
uint32_t | ts_ns, | ||
int | tp | ||
) |
Enqueue PTP message.
pPayload | message payload |
len | message length |
ts_sec | reception timestamp seconds part |
ts_ns | reception timestamp nanoseconds part |
tp | transport protocol (L2/L4) |
Definition at line 457 of file task_ptp.c.
|
static |
Remove the heartbeat timer.
Definition at line 196 of file task_ptp.c.
void ptp_start_heartbeat_tmr | ( | ) |
Start the heartbeat timer.
Definition at line 210 of file task_ptp.c.
void ptp_stop_heartbeat_tmr | ( | ) |
Stop the heartbeat timer.
Definition at line 225 of file task_ptp.c.
bool ptp_transmit_enqueue | ( | const RawPtpMessage * | pMsg | ) |
Put a PTP message into the transmit queue.
pMsg | pointer to raw PTP message. Can be discarded after the function has returned. |
Definition at line 502 of file task_ptp.c.
void ptp_transmit_timestamp_cb | ( | uint32_t | uid, |
uint32_t | seconds, | ||
uint32_t | nanoseconds | ||
) |
Transmit timestamp callback handler.
tag | unique message tag |
seconds | transmit timestamp seconds part |
nanoseconds | transmit timestamp nanoseconds part |
Definition at line 537 of file task_ptp.c.
bool reg_task_ptp | ( | ) |
|
static |
flexPTP's main loop. This function is only exposed if operating in FLEXPTP_OSLESS mode!
Call this function periodically to advance internal processing if operating in FLEXPTP_OSLESS mode, otherwise the library internally manages it.
Definition at line 588 of file task_ptp.c.
void unreg_task_ptp | ( | ) |
Unreg PTP task.
Definition at line 404 of file task_ptp.c.
|
static |
Definition at line 39 of file task_ptp.c.
|
static |
Definition at line 25 of file task_ptp.c.