flexPTP 1.0
An IEEE 1588 PTP implementation designed for microcontrollers
Loading...
Searching...
No Matches
flexptp_options_tm4c1294.h
Go to the documentation of this file.
1#ifndef FLEXPTP_OPTIONS_TM4C1294_H_
2#define FLEXPTP_OPTIONS_TM4C1294_H_
3
4// -------------------------------------------
5// --- DEFINES FOR PORTING IMPLEMENTATION ----
6// -------------------------------------------
7
8// Include LwIP headers here
9
10#include "utils/lwiplib.h"
11#include "utils/uartstdio.h"
12
13#include "driverlib/emac.h"
14#include "driverlib/gpio.h"
15#include "inc/hw_memmap.h"
16#include "driverlib/pin_map.h"
17
18// Give a printf-like printing implementation MSG(...)
19// Give a maskable printing implementation CLILOG(en,...)
20
21#include "utils.h"
22
23// Include hardware port files and fill the defines below to port the PTP stack to a physical hardware:
24// - PTP_HW_INIT(increment, addend): function initializing timestamping hardware
25// - PTP_MAIN_OSCILLATOR_FREQ_HZ: clock frequency fed into the timestamp unit [Hz]
26// - PTP_INCREMENT_NSEC: hardware clock increment [ns]
27// - PTP_UPDATE_CLOCK(s,ns): function jumping clock by defined value (negative time value means jumping backward)
28// - PTP_SET_ADDEND(addend): function writing hardware clock addend register
29
30
31#define PTP_MAIN_OSCILLATOR_FREQ_HZ (25000000)
32#define PTP_INCREMENT_NSEC (50)
33
34#define PTP_HW_INIT(increment, addend) ptphw_init(increment, addend)
35#define PTP_UPDATE_CLOCK(s,ns) EMACTimestampSysTimeUpdate(EMAC0_BASE, labs(s), abs(ns), (s * NANO_PREFIX + ns) < 0)
36#define PTP_SET_ADDEND(addend) EMACTimestampAddendSet(EMAC0_BASE, addend)
37#define PTP_HW_GET_TIME(pt) ptphw_gettime(pt)
38
39// Include the clock servo (controller) and define the following:
40// - PTP_SERVO_INIT(): function initializing clock servo
41// - PTP_SERVO_DEINIT(): function deinitializing clock servo
42// - PTP_SERVO_RESET(): function reseting clock servo
43// - PTP_SERVO_RUN(d): function running the servo, input: master-slave time difference (error), return: clock tuning value in PPB
44//
45
47
48#define PTP_SERVO_INIT() pd_ctrl_init()
49#define PTP_SERVO_DEINIT() pd_ctrl_deinit()
50#define PTP_SERVO_RESET() pd_ctrl_reset()
51#define PTP_SERVO_RUN(d,pscd) pd_ctrl_run(d,pscd)
52
53// Optionally add interactive, tokenizing CLI-support
54// - CLI_REG_CMD(cmd_hintline,n_cmd,n_min_arg,cb): function for registering CLI-commands
55// cmd_hintline: text line printed in the help beginning with the actual command, separated from help text by \t charaters
56// n_cmd: number of tokens (words) the command consists of
57// n_arg: minimal number of arguments must be passed with the command
58// cb: callback function cb(const CliToken_Type *ppArgs, uint8_t argc)
59// return: cmd id (can be null, if discarded)
60
61#include "cli.h"
62
63#define CLI_REG_CMD(cmd_hintline,n_cmd,n_min_arg,cb) CLI_REG_CMD(cmd_hintline, n_cmd, n_min_arg, cb)
64
65// -------------------------------------------
66
67#endif // FLEXPTP_OPTIONS_TM4C1294_H_