hal_exports.h 2.83 KB
Newer Older
1 2 3
#ifndef __HAL_EXPORTS_H
#define __HAL_EXPORTS_H

4
#include <stdint.h>
5

6
#define HAL_MAX_PORTS 32
7 8 9

#define WRSW_HAL_SERVER_ADDR "wrsw_hal"

10
// checks if the calibration unit is idle
11 12
#define HEXP_CAL_CMD_CHECK_IDLE 1

13
// enables/disables transmission of calibration pattern
14 15
#define HEXP_CAL_CMD_TX_PATTERN 2

16
// requests a measurement of TX delta
17 18
#define HEXP_CAL_CMD_TX_MEASURE 4

19
// requests a measurement of RX delta
20 21 22 23 24 25 26 27
#define HEXP_CAL_CMD_RX_MEASURE 5

#define HEXP_CAL_RESP_BUSY 1
#define HEXP_CAL_RESP_OK 0
#define HEXP_CAL_RESP_ERROR -1

#define HEXP_LOCK_CMD_START 1
#define HEXP_LOCK_CMD_CHECK 2
28
#define HEXP_LOCK_CMD_ENABLE_TRACKING 3
29 30 31 32 33 34 35

#define HEXP_LOCK_STATUS_LOCKED 0
#define HEXP_LOCK_STATUS_BUSY 1
#define HEXP_LOCK_STATUS_NONE 2

#define HEXP_PPSG_CMD_GET 0
#define HEXP_PPSG_CMD_ADJUST_PHASE 1
36
#define HEXP_PPSG_CMD_ADJUST_SEC 2
37 38
#define HEXP_PPSG_CMD_ADJUST_NSEC 3
#define HEXP_PPSG_CMD_POLL 4
39
#define HEXP_PPSG_CMD_SET_VALID 5
40 41 42 43 44 45 46

#define HEXP_ON 1
#define HEXP_OFF 0

#define HEXP_FREQ 0
#define HEXP_PHASE 1

47
/////////////////added by ML//////////
48
#define HEXP_EXTSRC_CMD_CHECK 0
49

50
#define HEXP_EXTSRC_STATUS_LOCKED 0
51
#define HEXP_LOCK_STATUS_BUSY	  1
52
#define HEXP_EXTSRC_STATUS_NOSRC  2
53
/////////////////////////////////////
54

55 56 57 58
#define HAL_TIMING_MODE_GRAND_MASTER 0
#define HAL_TIMING_MODE_FREE_MASTER 1
#define HAL_TIMING_MODE_BC 2

59 60
typedef struct {

61
	char port_name[16];
62

63 64
	int pps_valid;

65 66
	uint32_t current_phase_shift;
	int32_t adjust_phase_shift;
67

68 69
	int64_t adjust_sec;
	int32_t adjust_nsec;
70

71 72
	uint64_t current_sec;
	uint32_t current_nsec;
73

74 75
} hexp_pps_params_t;

76
/* Port modes (hal_port_state.mode) */
77 78 79
#define HEXP_PORT_MODE_WR_MASTER 1
#define HEXP_PORT_MODE_WR_SLAVE 2
#define HEXP_PORT_MODE_NON_WR 3
80 81
#define HEXP_PORT_MODE_WR_M_AND_S 4
#define HEXP_PORT_MODE_NONE 5
82 83 84 85 86 87

#define FIX_ALPHA_FRACBITS 40
/*
#define HEXP_PORT_TSC_RISING 1
#define HEXP_PORT_TSC_FALLING 2
*/
88

89 90 91 92 93 94 95 96 97 98 99 100
/* Prototypes of functions that call on rpc */
extern int halexp_lock_cmd(const char *port_name, int command, int priority);
extern int halexp_pps_cmd(int cmd, hexp_pps_params_t *params);

/* Export structures, shared by server and client for argument matching */
#ifdef HAL_EXPORT_STRUCTURES

//int halexp_lock_cmd(const char *port_name, int command, int priority);
struct minipc_pd __rpcdef_lock_cmd = {
	.name = "lock_cmd",
	.retval = MINIPC_ARG_ENCODE(MINIPC_ATYPE_INT, int),
	.args = {
101 102 103 104 105
		 MINIPC_ARG_ENCODE(MINIPC_ATYPE_STRING, char *),
		 MINIPC_ARG_ENCODE(MINIPC_ATYPE_INT, int),
		 MINIPC_ARG_ENCODE(MINIPC_ATYPE_INT, int),
		 MINIPC_ARG_END,
		 },
106 107 108 109 110 111 112
};

//int halexp_pps_cmd(int cmd, hexp_pps_params_t *params);
struct minipc_pd __rpcdef_pps_cmd = {
	.name = "pps_cmd",
	.retval = MINIPC_ARG_ENCODE(MINIPC_ATYPE_INT, int),
	.args = {
113 114 115 116
		 MINIPC_ARG_ENCODE(MINIPC_ATYPE_INT, int),
		 MINIPC_ARG_ENCODE(MINIPC_ATYPE_STRUCT, hexp_pps_params_t),
		 MINIPC_ARG_END,
		 },
117 118 119
};

#endif /* HAL_EXPORT_STRUCTURES */
120 121

#endif