KM3NeT CLB  2.0
KM3NeT CLB v2 Embedded Software
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
edfa-eau.h
Go to the documentation of this file.
1 /*
2  * KM3NeT CLB v2 Firmware
3  *
4  * Copyright 2015 KM3NeT Collaboration
5  *
6  * All Rights Reserved.
7  *
8  *
9  * File : edfa-eau.h
10  * Created : 16 feb 2015
11  * Author : Riccardo Travaglini
12  */
13 #ifndef EDFAEAU_H_
14 #define EDFAEAU_H_
15 
16 /**
17  * @file
18  *
19  * @ingroup uartdrivers
20  *
21  * EDFA-EAU (30-C3-20-C) Uart driver.
22  */
23 
24 #include "stdbool.h"
25 #include "cfg_board.h"
26 #include "errorcode.h"
27 #include "util/float.h"
28 #include "drv/wb/suart.h"
29 
30 #define _EDFA_NOAGC
31 
32 #define E_EDFA_TIMEOUT E_EDFA + 1 ///< Receive timeout
33 #define E_EDFA_TIMEOUT_DESCR "EDFA Response Timeout"
34 
35 #define E_EDFA_BDCM E_EDFA + 2 ///< bd command
36 #define E_EDFA_BDCM_DESCR "EDFA Bad Command"
37 
38 
39 #define E_EDFA_NOCMD E_EDFA + 3 ///< no echoed command back
40 #define E_EDFA_NOCMD_DESCR "EDFA No Echoed Command"
41 
42 #define E_EDFA_NOCOMMA E_EDFA + 4 ///< no comma when required in response
43 #define E_EDFA_NOCOMMA_DESCR "EDFA No Comma"
44 
45 #define E_EDFA_TOOLONG E_EDFA + 5 ///< command parameter too long
46 #define E_EDFA_TOOLONG_DESCR "EDFA input parameter too long"
47 
48 #define E_EDFA_INVALID E_EDFA + 6 ///< invalid
49 #define E_EDFA_INVALID_DESCR "EDFA invalid parameter"
50 
51 
52 
53 #define EDFA_BAUDRATE_DEFAULT SUART_BAUDRATE_57600 //!< Default Baudrate
54 
55 #define EDFA_MAX_RET_LEN 80
56 
57 
58 /**
59  * Initializes the EDFA
60  *
61  * @param
62  */
63 static inline void edfaInit()
64 {
65  suartInit(EDFA_UART, EDFA_BAUDRATE_DEFAULT);
66 }
67 
68 /*
69 EDFA manual - command ReadStatus
70 *
71 * @param
72  a int pointer to the returned emission status (1= on, 0=off)
73  a int pointer returning info whether Device is in 3 second emission startup period. (1= yes, 0=no)
74 
75 
76 */
77 bool edfaReadStatus(bool* emission,bool* startup);
78 
79 /*
80 This command will attempt to start emission. The device status
81 should be checked to see if emission was successfully started.
82 */
83 bool edfaEmOn();
84 
85 /*
86 Turns off emission.
87 */
88 bool edfaEmOff();
89 
90 /* Reads the output power level of the device.
91 
92 Parameter: pointer to a string with the returned output power level in dBm.
93 */
94 bool edfaReadCompOutPw(char** retString);
95 
96 /* Reads the input power level of the device.
97 
98 Parameter: pointer to a string with the returned input power level in dBm.
99 */
100 bool edfaReadCompInPw(char** retString);
101 
102 /* Reads the driving current in Pump laser diode bank
103 
104 Parameter: pointer to a string with the returned diode current in milliamps.
105 */
106 bool edfaReadPumpDiodeCur(char** retString);
107 
108 /* Reads the temperature of the device.
109 
110 Parameter: pointer to a string with the returned temperature in degrees Celsius.
111 */
112 bool edfaReadTemp(char** retString);
113 
114 
115 /* Makes APC (Power Stabilization) mode the device control mode.
116 (The control mode cannot be changed when emission is on)
117 
118 Parameter: pointer to a string If emission
119 is on, the response will be “ERR: Emission is on”.
120 Otherwise string is empty
121 */
122 bool edfaSetAPCMode(char** retString);
123 
124 /*
125 Sets the power setpoint for APC (Power Stabilization) mode.
126 Parameters:
127  1 A string with the desired power setpoint in dBm
128  2 a pointer to a string with the just set power setpoint in dBm.
129 */
130 bool edfaSetCompOutPw(const char* s_dbm, char** retString);
131 
132 /* Reads the existing power setpoint for APC (Power Stabilization) mode from the
133 device.
134 
135 Parameter: pointer to a string with the returned power setpoint in dBm.
136 */
137 bool edfaReadCompPwSet(char** retString);
138 
139 /* Reads the maximum allowable power setting for the device in APC (Power
140 Stabilization) mode.
141 
142 Parameter: pointer to a string with the returned maximum power setting in dBm.
143 */
144 bool edfaReadMaxCompOutPw(char** retString);
145 
146 /*Makes AGC (Gain Stabilization) mode the device control mode.
147 (The control mode cannot be changed when emission is on)
148 
149 Parameter: pointer to a string If emission
150 is on, the response will be “ERR: Emission is on”.
151 Otherwise string is empty
152 */
153 #ifndef _EDFA_NOAGC
154 bool edfaSetAGCMode(char** retString);
155 
156 
157 /* Sets the Gain setpoint for AGC (Gain Stabilization) mode
158 
159 Parameters:
160  1 A string with the desired Gain setpoint in dB.
161  2 a pointer to a string with the setpoint that is
162 actually set in the laser in dB
163 */
164 bool edfaSetGainSet(const char* s_db, char** retString);
165 
166 /*
167 Reads the existing Gain setpoint for AGC (Gain Stabilization) mode from the
168 device
169 
170 Parameters: a string with the returned Gain setpoint in dB.
171 */
172 bool edfaReadGainSet(char** retString);
173 
174 /*
175 Reads the actual Gain level of the
176 device
177 
178 Parameters: a string with the returned Gain level in dB.
179 */
180 bool edfaReadActGain(char** retString);
181 
182 /*
183 Reads the maximum allowable Gain setting for the device in AGC (Gain
184 Stabilization) mode.
185 
186 Parameters: a string with the returned maximum Gain setting in dB.
187 */
188 bool edfaReadMaxGain(char** retString);
189 
190 /*
191 Reads the minimum allowable Gain setting for the device in AGC (Gain
192 Stabilization) mode.
193 
194 Parameters: a string with the returned minimum Gain setting in dB.
195 */
196 bool edfaReadMinGain(char** retString);
197 #endif
198 /*
199 Reads the maximum temperature for the optical module.
200 
201 Parameters: a string with the returned maximum temperature of the optical module in °C.
202 */
203 bool edfaReadMaxTemp(char** retString);
204 
205 /*
206 Reads the maximum Pump Diodes current.
207 
208 Parameters: a string with the returned maximum diode current in milliamps.
209 */
210 bool edfaReadMaxPumpDiodeCur(char** retString);
211 
212 /*
213 Reads the firmware part number of the device.
214 
215 Parameters: a string with the returned firmware part number .
216 */
217 bool edfaReadPart(char** retString);
218 
219 /*
220 Reads the firmware version of the device controller.
221 
222 Parameters: a string with the returned firmware version of the firmware running in the device controller.
223 The version has the format:
224 <Major Version>.<Minor Version>.<Build Number>
225 */
226 bool edfaReadFwVer(char** retString);
227 
228 /*
229 Reads the date of manufacture of the device.
230 
231 Parameters: a string with the returned date of manufacture of the device.
232 */
233 bool edfaReadDate(char** retString);
234 
235 /*
236 Reads the Serial number of the device.
237 
238 Parameters: a string with the returned EDFA Serial Number
239 */
240 bool edfaReadSerial(char** retString);
241 
242 /* Reads the output power level of the device.
243 
244 Return:int with the returned output power level in milli dBm.
245 */
246 
247 int edfaOutputPower();
248 
249 /* Reads the input power level of the device.
250 
251 Return:int with the returned output power level in milli dBm.
252 */
253 int edfaInputPower();
254 
255 /* Reads the Setpoint power level of the device.
256 
257 Return:int with the returned output power level in milli dBm.
258 */
259 int edfaReadSetpoint();
260 
261 
262 /* Reads the Diode Current
263 
264 Return:int with the returned output power level in micro Amps
265 */
266 int edfaPumpCur();
267 
268 
269 /* Reads the temperature of the device.
270 
271 Return:int with the returned temperature in milli Celsius.
272 */
273 int edfaTemp();
274 
275 void edfaWriteSetpoint(f32_t val, char** retString);
276 
277 /**
278  * Execute an EDFA debug command, and returns the reply.
279  *
280  * @param cmd The command to execute
281  * @param retString The result
282  *
283  * @retval true Command/Response sequence executed succesfully
284  * @retval false Command/Response sequence failed
285  */
286 bool edfaDbgCmdReply(const char * cmd, char ** retString);
287 
288 /**
289  * Execute an EDFA debug command w/o a reply
290  *
291  * @param cmd The command to execute
292  *
293  * @retval true Command/Response sequence executed succesfully
294  * @retval false Command/Response sequence failed
295  */
296 bool edfaDbgCmd(const char * cmd);
297 
298 
299 #endif /* EDFAEAU_H_ */
Special library for primitive IEEE 754 floating point handling without dragging all float support alo...
White Rabbit Simple UART Driver.
#define EDFA_BAUDRATE_DEFAULT
Default Baudrate.
Definition: edfa-eau.h:53
static void edfaInit()
Initializes the EDFA.
Definition: edfa-eau.h:63
void suartInit(SUART_Descriptor *desc, unsigned int baudrate)
Initializes the simple UART.
Definition: suart.c:44
uint32_t f32_t
32 bit representation for float.
Definition: float.h:30
This module is responsible for distributing error codes.
bool edfaDbgCmdReply(const char *cmd, char **retString)
Execute an EDFA debug command, and returns the reply.
Definition: edfa-eau.c:627
Configures the board-specific peripherals, like I2C, SPI etc...
bool edfaDbgCmd(const char *cmd)
Execute an EDFA debug command w/o a reply.
Definition: edfa-eau.c:631