KM3NeT CLB  2.0
KM3NeT CLB v2 Embedded Software
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
sub_acs.c
1 /*
2  * KM3NeT CLB v2 Firmware
3  * ----------------------
4  *
5  * Copyright 2013 KM3NeT Collaboration
6  *
7  * All Rights Reserved.
8  *
9  *
10  * File : sub_acs.c
11  * Created : 6 jan. 2014
12  * Author : Vincent van Beveren
13  */
14 
15 
16 #include "clbstate.h"
17 #include "pv/vars.h"
18 #include "drv/wb/acou.h"
19 #include "modules/octopus.h"
20 
21 
22 // Implement actions to happen on state transitions. See clbstate.h for possible events.
23 void _subsAcsExecEvent (ClbEvent event)
24 {
25  switch (event)
26  {
27  case clbEventReset:
28  case clbEventBoot:
29  // defaults (is this the place?)
30  acs.acou_chan = ACOU_CH_1; // only enable channel 1
31  acs.acou_res = ACOU_RES_24BIT; // 24 bits
32  acouOff();
33  break;
34  case clbEventInit:
35  acouInit();
36  break;
37  case clbEventConfigure:
38  // TODO: Sanity check on configured values.
42 #ifndef BASE
43  octoPiezo(true);
44 #endif
45  acouOn();
46  } else {
47  // turn it off, is ENA_ACS is false.
48  acouOff();
49  }
50 
51  break;
52  case clbEventStart:
53  break;
54  case clbEventStop:
55 #ifndef BASE
56  octoPiezo(false);
57  errClear();
58 #endif
59  break;
60  default:
61  break;
62  }
63  _clbStateUpdate(clbSys2Idx[CLB_SUB_ACS], event, 0);
64 }
65 
66 // Called each second to update process variables.
67 bool _subsAcsUpdate(ClbState state, uint32_t time)
68 {
69  return true;
70 }
This module implements the functionality required by the octopus board (large).
#define SYS_SYS_RUN_ENA_ACS
Bit which enables Acoustics during run.
Definition: vars.h:90
bool octoPiezo(bool on)
Turns the Piezo on or off.
Definition: octopus.c:197
ClbEvent
All state change events.
Definition: clbstate.h:88
void acouOn()
Turns the hydrophone on.
Definition: acou.c:30
Provides access to all variables of the various subsystems.
void acouInit()
Initializes the acoustics (AES)
Definition: acou.c:23
Ready => Running.
Definition: clbstate.h:94
uint8_t clbSys2Idx[6]
Mapping from subsystem ID to index.
Definition: clbstate.c:59
sys_t sys
Provides access to all process variables of subsystem System.
Definition: vars.c:8
ClbState
Various states.
Definition: clbstate.h:59
void acouOff()
Truns the hydrohpone off.
Definition: acou.c:39
Undefined => Idle, for internal use only.
Definition: clbstate.h:91
acs_t acs
Provides access to all process variables of subsystem Acoustics.
Definition: vars.c:265
StandBy => Idle.
Definition: clbstate.h:99
void errClear()
Clears the current error.
Definition: err.c:46
uint8_t sys_run_ena
Run-state Enable mask.
Definition: vars.h:149
uint8_t acou_res
Acoustic resolution.
Definition: vars.h:490
The CLB stare module tracks is responsible for state management of the various sub-systems on the CLB...
Idle => StandBy.
Definition: clbstate.h:92
void acouSetResolution(AcouRes val)
Set the bit resolution.
Definition: acou.c:51
StandBy => Ready.
Definition: clbstate.h:93
Paused => StandBy.
Definition: clbstate.h:97
void acouSetChannel(AcouCh val)
Set the channel configuration.
Definition: acou.c:57
uint8_t acou_chan
Acoustics channel config.
Definition: vars.h:487
void _clbStateUpdate(int idx, ClbEvent event, uint8_t status)
Invoked by the subsystem to indicate a state change has happened.
Definition: clbstate.c:204
Channel 1.
Definition: acou.h:59
Acoustic Driver.
32 bits
Definition: acou.h:51