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// -------------------------------------------
5// --- DEFINES FOR PORTING IMPLEMENTATION ----
6// -------------------------------------------
7
8// Include LwIP headers here
9
10#include "lwip/netif.h"
11#include "lwip/tcpip.h"
12#include "lwip/udp.h"
13#include "lwip/igmp.h"
14#include "lwip/pbuf.h"
15
16// Give a printf-like printing implementation MSG(...)
17// Give a maskable printing implementation CLILOG(en,...)
18// Provide an SPRINTF-implementation SPRINTF(str,n,fmt,...)
19
20#include "utils.h"
21
22// Include hardware port files and fill the defines below to port the PTP stack to a physical hardware:
23// - PTP_HW_INIT(increment, addend): function initializing timestamping hardware
24// - PTP_MAIN_OSCILLATOR_FREQ_HZ: clock frequency fed into the timestamp unit [Hz]
25// - PTP_INCREMENT_NSEC: hardware clock increment [ns]
26// - PTP_UPDATE_CLOCK(s,ns): function jumping clock by defined value (negative time value means jumping backward)
27// - PTP_SET_ADDEND(addend): function writing hardware clock addend register
28
29#include "stm32h7xx_hal.h"
30extern ETH_HandleTypeDef EthHandle;
31
32#define PTP_MAIN_OSCILLATOR_FREQ_HZ (200000000)
33#define PTP_INCREMENT_NSEC (5)
34
35#define PTP_HW_INIT(increment, addend) ptphw_init(increment, addend)
36#define PTP_UPDATE_CLOCK(s,ns) ETH_UpdatePTPTime(&EthHandle, labs(s), abs(ns), (s * NANO_PREFIX + ns) < 0)
37#define PTP_SET_CLOCK(s,ns) ETH_InitPTPTime(&EthHandle, labs(s), abs(ns))
38#define PTP_SET_ADDEND(addend) ETH_SetPTPAddend(&EthHandle, addend)
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() pd_ctrl_init()
51#define PTP_SERVO_DEINIT() pd_ctrl_deinit()
52#define PTP_SERVO_RESET() pd_ctrl_reset()
53#define PTP_SERVO_RUN(d,pscd) pd_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
65#define CLI_REG_CMD(cmd_hintline,n_cmd,n_min_arg,cb) CLI_REG_CMD(cmd_hintline, n_cmd, n_min_arg, cb)
66
67// -------------------------------------------
68
69#endif // FLEXPTP_OPTIONS_STM32H743_H_
ETH_HandleTypeDef EthHandle