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