KM3NeT CLB  2.0
KM3NeT CLB v2 Embedded Software
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
wrx.h
Go to the documentation of this file.
1 /*
2  * KM3NeT CLB v2 Firmware
3  * ----------------------
4  *
5  * Copyright 2013 KM3NeT Collaboration
6  *
7  * All Rights Reserved.
8  *
9  *
10  * File : wrx.h
11  * Created : 25 nov. 2013
12  * Author : Vincent van Beveren
13  */
14 
15 #ifndef WRX_H_
16 #define WRX_H_
17 
18 #include "wrx_proto.h"
19 
20 #include <stdbool.h>
21 #include <stdint.h>
22 
23 #include <errorcode.h>
24 
25 /**
26  * @file
27  *
28  * @ingroup wbdrivers
29  *
30  * WhiteRabbit exchange exchanges information between the 2nd LM32 and WhiteRabbit though
31  * a small client in the whiteRabbit code-base.
32  *
33  * Commands can be send between the 2nd LM32 and WhiteRabbit.
34  */
35 
36 #define E_WRX_EP_VER ( E_WRX + 1 ) ///! endpoint WRX version does not match
37 #define E_WRX_EP_VER_DESCR "Remote WRX version does not match"
38 
39 
40 
41 /**
42  * Initializes the whiteRabbit eXchange.
43  *
44  * @retval true Initialization succesful.
45  * @retval false Initialization failed, check errCode() for more info.
46  */
47 bool wrxInit();
48 
49 /**
50  * Returns whether or not the WhiteRabbit interface is up and running.
51  *
52  * @retval true Its up and running
53  * @retval false Its not up and running.
54  */
55 bool wrxUp();
56 
57 
58 /**
59  * Returns the whiteRabbit information structure if available, else NULL.
60  *
61  * @return WhiteRabbit information, or NULL is not available.
62  */
63 volatile WrxInfo * wrxInfo();
64 
65 /**
66  * Returns whether or not there is a command still pending to
67  * be executed.
68  *
69  * @retval true Yes
70  * @retval false No
71  */
72 bool wrxCmdPending();
73 
74 /**
75  * Returns the UTC time, or 0 if not available.
76  */
77 uint64_t wrxUtcTime();
78 
79 /**
80  * Returns autonegotation on or off.
81  *
82  * @param on Turn it on.
83  *
84  * @retval false Command failed, check error module for more information
85  * @retval true Command successful
86  */
87 bool wrxSetAutoNeg(bool on);
88 
89 /**
90  * Sets the tune-word. Depends on the tuning procedure.
91  *
92  * @retval false Command failed, check error module for more information
93  * @retval true Command successful
94  */
95 bool wrxSetTuneWord(int32_t tuneWord);
96 
97 /**
98  * Sets the fields of the WrxTuneInfo structure.
99  *
100  * @retval false Command failed, check error module for more information
101  * @retval true Command successful
102  */
103 bool wrxGetTuneInfo(WrxTuneInfo * info);
104 
105 /**
106  * Gets the sfp serial number. Makes string zero terminated by setting sn[16]='\0'
107  *
108  * @retval false Command failed, check error module for more information
109  * @retval true Command successful
110  */
111 bool wrxGetSFPSerialNo(char sn[17]);
112 
113 /**
114  * @brief Read SFP I2C bus (raw)
115  *
116  * Len = max 4 bytes
117  */
118 bool wrxModI2cRead(uint8_t addr, uint8_t reg, uint8_t len, uint8_t * buf);
119 
120 /**
121  * @brief Write SFP I2C bus (raw)
122  *
123  * Len = max 4 bytes
124  */
125 bool wrxModI2cWrite(uint8_t addr, uint8_t reg, uint8_t len, uint8_t * buf);
126 
127 
128 bool wrxSetSFPThreshold(int index, uint16_t value);
129 
130 #endif /* WRX_H_ */
bool wrxGetTuneInfo(WrxTuneInfo *info)
Sets the fields of the WrxTuneInfo structure.
Definition: wrx.c:130
bool wrxModI2cWrite(uint8_t addr, uint8_t reg, uint8_t len, uint8_t *buf)
Write SFP I2C bus (raw)
Definition: wrx.c:185
uint64_t wrxUtcTime()
Returns the UTC time, or 0 if not available.
Definition: wrx.c:111
bool wrxInit()
Initializes the whiteRabbit eXchange.
Definition: wrx.c:34
bool wrxSetTuneWord(int32_t tuneWord)
Sets the tune-word.
Definition: wrx.c:119
bool wrxGetSFPSerialNo(char sn[17])
Gets the sfp serial number.
Definition: wrx.c:144
bool wrxUp()
Returns whether or not the WhiteRabbit interface is up and running.
Definition: wrx.c:58
volatile WrxInfo * wrxInfo()
Returns the whiteRabbit information structure if available, else NULL.
Definition: wrx.c:63
This module is responsible for distributing error codes.
bool wrxModI2cRead(uint8_t addr, uint8_t reg, uint8_t len, uint8_t *buf)
Read SFP I2C bus (raw)
Definition: wrx.c:169
bool wrxCmdPending()
Returns whether or not there is a command still pending to be executed.
Definition: wrx.c:70
bool wrxSetAutoNeg(bool on)
Returns autonegotation on or off.
Definition: wrx.c:97