KM3NeT CLB  2.0
KM3NeT CLB v2 Embedded Software
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
sub_opt.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 : sub_opt.h
11  * Created : 28 apr. 2014
12  * Author : Vincent van Beveren
13  */
14 
15 #ifndef SUB_OPT_H_
16 #define SUB_OPT_H_
17 
18 #include "util/macro.h"
19 #include "appcode.h"
20 #include "modules/octopus.h"
21 
22 /**
23  * @file
24  *
25  * @ingroup subsys
26  *
27  * Optics subsystem. Controls everything related to optical detection.
28  */
29 
30 //! Invalid channel mapping error
31 #define E_OPT_CHCFG ( E_SUBOPT + 1 )
32 #define E_OPT_CHCFG_DESCR "Invalid channel configuration"
33 
34 
35 #define OPT_CH_COUNT 31
36 
37 
38 #define OPT_CHCFG_CHAN_MASK MASK(5) //!< ch number
39 
40 #define OPT_CFG_ENABLE BIT(0) //!< Enable the channel (incl. PMT, TDCs)
41 
42 
43 #define OPT_STS_ERR_COMM BIT(6) //!< I2C communication error
44 #define OPT_STS_ERR_OVERCUR BIT(5) //!< Over current
45 #define OPT_STS_WARN_HRVETO BIT(4) //!< High rate veto active
46 #define OPT_STS_WARN_ID BIT(3) //!< ID is inconsistent
47 
48 #define OPT_STS_ENABLED BIT(7) //!< Enabled
49 
50 #define OPT_SYS_ERR_ANY ( OPT_STS_ERR_COMM | OPT_STS_ERR_OVERCUR )
51 
52 #define OPT_HV_DEFAULT -800
53 #define OPT_THRS_DEFAULT 1070
54 
55 #define _OCT_SMALL_MASK 0x00000FFF
56 #define _OCT_LARGE_MASK 0x7FFFF000
57 
58 #define _OCT_SMALL_CH 12
59 #define _OCT_LARGE_CH 19
60 #define _OCT_BRD(IDX) ( ( IDX ) < ( _OCT_SMALL_CH ) ? ( OCTO_BRD_SMALL ) : ( OCTO_BRD_LARGE ) )
61 #define _OCT_CH(IDX) ( ( IDX ) < ( _OCT_SMALL_CH ) ? ( IDX ) : ( IDX - _OCT_SMALL_CH ) )
62 
63 /**
64  * Returns whether or not the HV is enabled.
65  */
66 bool optHvEnabled();
67 
68 /**
69  * Enables high voltage. Use with caution.
70  *
71  * @param hvOn true - Turn it on, false - turn it off.
72  */
73 void optHvEnable(bool hvOn);
74 
75 /**
76  * Updates the status of the optics.
77  */
78 bool optUpdate();
79 
80 #endif /* SUB_OPT_H_ */
This module implements the functionality required by the octopus board (large).
bool optHvEnabled()
Returns whether or not the HV is enabled.
Application specific error codes.
void optHvEnable(bool hvOn)
Enables high voltage.
bool optUpdate()
Updates the status of the optics.
Definition: sub_opt.c:170
Provides common macros.