DUNE-DAQ
DUNE Trigger and Data Acquisition software
Toggle main menu visibility
Loading...
Searching...
No Matches
dunedaq
sourcecode
wibmod
src
WIB1
WIB_localFlash.cpp
Go to the documentation of this file.
1
#include "
wibmod/WIB1/WIB.hh
"
2
#include "
wibmod/WIB1/WIBException.hh
"
3
4
uint32_t
5
WIB::ReadLocalFlash
(uint16_t address)
6
{
7
// load the address
8
Write
(
"SYSTEM.FLASH.ADDRESS"
, address);
9
// start the read transaction
10
Write
(
"SYSTEM.FLASH.RW"
, 1);
11
Write
(
"SYSTEM.FLASH.RUN"
, 1);
12
13
// Wait for transaction to finish
14
while
(
Read
(
"SYSTEM.FLASH.DONE"
) == 0) {
15
printf(
"busy\n"
);
16
// sleep for 1ms
17
usleep(1000);
18
}
19
20
return
Read
(
"SYSTEM.FLASH.RD_DATA"
);
21
}
22
23
std::vector<uint32_t>
24
WIB::ReadLocalFlash
(uint16_t address,
size_t
n)
25
{
26
std::vector<uint32_t> readData;
27
size_t
current_address = address;
28
size_t
end_address = current_address + n;
29
for
(; current_address < end_address; current_address++) {
30
readData.push_back(
ReadLocalFlash
(current_address));
31
}
32
return
readData;
33
}
34
35
void
36
WIB::WriteLocalFlash
(uint16_t address, uint32_t data)
37
{
38
// load the address
39
Write
(
"SYSTEM.FLASH.ADDRESS"
, address);
40
// load the data to write
41
Write
(
"SYSTEM.FLASH.WR_DATA"
, data);
42
43
// start the read transaction
44
Write
(
"SYSTEM.FLASH.RW"
, 0);
45
Write
(
"SYSTEM.FLASH.RUN"
, 1);
46
// Wait for finish
47
while
(
Read
(
"SYSTEM.FLASH.DONE"
) == 0) {
48
// sleep for 1ms
49
usleep(1000);
50
}
51
}
52
53
void
54
WIB::WriteLocalFlash
(uint16_t address, std::vector<uint32_t>
const
& data)
55
{
56
for
(
size_t
iWord = 0; iWord < data.size(); iWord++) {
57
WriteLocalFlash
(address, data[iWord]);
58
address++;
59
}
60
}
WIBException.hh
WIB.hh
WIBBase::Read
uint32_t Read(uint16_t address)
Definition
WIBBase.cpp:147
WIBBase::Write
void Write(uint16_t address, uint32_t value)
Definition
WIBBase.cpp:168
WIB::ReadLocalFlash
uint32_t ReadLocalFlash(uint16_t address)
Definition
WIB_localFlash.cpp:5
WIB::WriteLocalFlash
void WriteLocalFlash(uint16_t address, uint32_t data)
Definition
WIB_localFlash.cpp:36
Generated on
for DUNE-DAQ by
1.18.0