flexPTP 1.0
An IEEE 1588 PTP implementation designed for microcontrollers
Loading...
Searching...
No Matches
flexptp_options_mk64f.h
Go to the documentation of this file.
1#ifndef FLEXPTP_OPTIONS_MK64F_H_
2#define FLEXPTP_OPTIONS_MK64F_H_
3
4#define LWIP
5#define PTP_HLT_INTERFACE
6
7#define FLEXPTP_TASK_PRIORITY 24
8
9// -------------------------------------------
10// --- DEFINES FOR PORTING IMPLEMENTATION ----
11// -------------------------------------------
12
13// Include LwIP/EtherLib headers here
14
15#include <lwip/ip_addr.h>
16#include <lwip/netif.h>
17
18// Give a printf-like printing implementation MSG(...)
19// Give a maskable printing implementation CLILOG(en,...)
20// Provide an SPRINTF-implementation SPRINTF(str,n,fmt,...)
21
22#include "embfmt/embformat.h"
23#include "standard_output/standard_output.h"
24
25#define FLEXPTP_SNPRINTF(...) embfmt(__VA_ARGS__)
26
27// Include hardware port files and fill the defines below to port the PTP stack to a physical hardware:
28
29#include <stdlib.h>
30
31#include <eth_custom/ethernetif.h>
32#include "flexPTP_port/ptp_port_mk64f_lwip.h"
33
34#define PTP_CONFIG_LEADING_PARAMS netif_default
35
36#define PTP_HW_INIT() ethernetif_ptp_init(PTP_CONFIG_LEADING_PARAMS)
37#define PTP_SET_CLOCK(s, ns) ethernetif_ptp_set_clock(PTP_CONFIG_LEADING_PARAMS, labs(s), abs(ns))
38#define PTP_SET_TUNING(tuning) ethernetif_ptp_set_tuning(PTP_CONFIG_LEADING_PARAMS, tuning)
39#define PTP_HW_GET_TIME(pt) ptphw_gettime(pt)
40
41// Include the clock servo (controller) and define the following:
42// - PTP_SERVO_INIT(): function initializing clock servo
43// - PTP_SERVO_DEINIT(): function deinitializing clock servo
44// - PTP_SERVO_RESET(): function reseting clock servo
45// - PTP_SERVO_RUN(d): function running the servo, input: master-slave time difference (error), return: clock tuning value in PPB
46//
47
49
50#define PTP_SERVO_INIT() pid_ctrl_init()
51#define PTP_SERVO_DEINIT() pid_ctrl_deinit()
52#define PTP_SERVO_RESET() pid_ctrl_reset()
53#define PTP_SERVO_RUN(d, pscd) pid_ctrl_run(d, pscd)
54
55// Optionally add interactive, tokenizing CLI-support
56// - CLI_REG_CMD(cmd_hintline,n_cmd,n_min_arg,cb): function for registering CLI-commands
57// cmd_hintline: text line printed in the help beginning with the actual command, separated from help text by \t charaters
58// n_cmd: number of tokens (words) the command consists of
59// n_arg: minimal number of arguments must be passed with the command
60// cb: callback function cb(const CliToken_Type *ppArgs, uint8_t argc)
61// return: cmd id (can be null, if discarded)
62
63#include "cli.h"
64#define CLI_REG_CMD(cmd_hintline, n_cmd, n_min_arg, cb) cli_register_command(cmd_hintline, n_cmd, n_min_arg, cb)
65//#define CLI_REG_CMD(cmd_hintline, n_cmd, n_min_arg, cb)
66
67// -------------------------------------------
68
69#define CLILOG(en, ...) \
70 { \
71 if (en) \
72 MSG(__VA_ARGS__); \
73 }
74
75// -------------------------------------------
76
77#define PTP_ENABLE_MASTER_OPERATION (1) // Enable or disable master operations
78
79// Static fields of the Announce message
80#define PTP_CLOCK_PRIORITY1 (128) // priority1 (0-255)
81#define PTP_CLOCK_PRIORITY2 (128) // priority2 (0-255)
82#define PTP_BEST_CLOCK_CLASS (PTP_CC_DEFAULT) // best clock class of this device
83#define PTP_WORST_ACCURACY (PTP_CA_UNKNOWN) // worst accucary of the clock
84#define PTP_TIME_SOURCE (PTP_TSRC_INTERNAL_OSCILLATOR) // source of the distributed time
85
86// -------------------------------------------
87
88// #include "flexptp/event.h"
89// extern void flexptp_user_event_cb(PtpUserEventCode uev);
90// #define PTP_USER_EVENT_CALLBACK flexptp_user_event_cb
91
92#endif /* MK64F_H_ */