DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
dunedaq::timing::SIChipSlave Class Reference

Utility class to interface to SI chips. More...

#include <SIChipSlave.hpp>

Inheritance diagram for dunedaq::timing::SIChipSlave:
[legend]
Collaboration diagram for dunedaq::timing::SIChipSlave:
[legend]

Public Member Functions

 SIChipSlave (const I2CMasterNode *i2c_master, uint8_t i2c_device_address)
 
virtual ~SIChipSlave ()
 
uint8_t read_page () const
 Reads the current page.
 
void switch_page (uint8_t page) const
 { function_description }
 
uint32_t read_device_version () const
 Reads a device version.
 
uint8_t read_clock_register (uint16_t address) const
 Reads a clock register.
 
void write_clock_register (uint16_t address, uint8_t data) const
 Writes a clock register.
 
- Public Member Functions inherited from dunedaq::timing::I2CSlave
virtual ~I2CSlave ()
 
uint8_t get_i2c_address () const
 
uint8_t read_i2c (uint32_t i2c_device_address, uint32_t i2c_reg_address) const
 comodity functions
 
uint8_t read_i2c (uint32_t i2c_reg_address) const
 
void write_i2c (uint32_t i2c_device_address, uint32_t i2c_reg_address, uint8_t data, bool send_stop=true) const
 
void write_i2c (uint32_t i2c_reg_address, uint8_t data, bool send_stop=true) const
 
std::vector< uint8_t > read_i2cArray (uint32_t i2c_device_address, uint32_t i2c_reg_address, uint32_t number_of_words) const
 
std::vector< uint8_t > read_i2cArray (uint32_t i2c_reg_address, uint32_t number_of_words) const
 
void write_i2cArray (uint32_t i2c_device_address, uint32_t i2c_reg_address, std::vector< uint8_t > data, bool send_stop=true) const
 
void write_i2cArray (uint32_t i2c_reg_address, std::vector< uint8_t > data, bool send_stop=true) const
 
std::vector< uint8_t > read_i2cPrimitive (uint32_t number_of_bytes) const
 
void write_i2cPrimitive (const std::vector< uint8_t > &data, bool send_stop=true) const
 
bool ping () const
 
std::string get_master_id () const
 

Additional Inherited Members

- Protected Member Functions inherited from dunedaq::timing::I2CSlave
 I2CSlave (const I2CMasterNode *i2c_master, uint8_t i2c_device_address)
 

Detailed Description

Utility class to interface to SI chips.

Author
Alessandro Thea
Date
May 2018

Definition at line 31 of file SIChipSlave.hpp.

Constructor & Destructor Documentation

◆ SIChipSlave()

dunedaq::timing::SIChipSlave::SIChipSlave ( const I2CMasterNode * i2c_master,
uint8_t i2c_device_address )

Definition at line 24 of file SIChipSlave.cpp.

25 : I2CSlave(i2c_master, address)
26{}
I2CSlave(const I2CMasterNode *i2c_master, uint8_t i2c_device_address)
Definition I2CSlave.cpp:33

◆ ~SIChipSlave()

dunedaq::timing::SIChipSlave::~SIChipSlave ( )
virtual

Definition at line 30 of file SIChipSlave.cpp.

30{}

Member Function Documentation

◆ read_clock_register()

uint8_t dunedaq::timing::SIChipSlave::read_clock_register ( uint16_t address) const

Reads a clock register.

Parameters
[in]addressA address
Returns
{ description_of_the_return_value }

Definition at line 73 of file SIChipSlave.cpp.

74{
75
76 uint8_t reg_address = (address & 0xff); // NOLINT(build/unsigned)
77 uint8_t page_address = (address >> 8) & 0xff; // NOLINT(build/unsigned)
78 std::stringstream debug_stream;
79 debug_stream << std::showbase << std::hex << "Read Address " << (uint32_t)address // NOLINT(build/unsigned)
80 << " reg: " << (uint32_t)reg_address // NOLINT(build/unsigned)
81 << " page: " << (uint32_t)page_address; // NOLINT(build/unsigned)
82 TLOG_DEBUG(6) << debug_stream.str();
83 // Change page only when required.
84 // (The SI5344 don't like to have the page register id to be written all the time.)
85 uint8_t current_address = read_page(); // NOLINT(build/unsigned)
86 if (page_address != current_address) {
87 switch_page(page_address);
88 }
89
90 // Read the register
91 return read_i2c(reg_address);
92}
uint8_t read_i2c(uint32_t i2c_device_address, uint32_t i2c_reg_address) const
comodity functions
Definition I2CSlave.cpp:46
void switch_page(uint8_t page) const
{ function_description }
uint8_t read_page() const
Reads the current page.
#define TLOG_DEBUG(lvl,...)
Definition Logging.hpp:112

◆ read_device_version()

uint32_t dunedaq::timing::SIChipSlave::read_device_version ( ) const

Reads a device version.

Returns
{ description_of_the_return_value }

Definition at line 59 of file SIChipSlave.cpp.

60{
61
62 // Go to the right page
63 switch_page(0x0);
64 // Read 2 words from 0x2
65 auto version = read_i2cArray(0x2, 2);
66
67 return (((uint32_t)version[1] << 8) + (uint32_t)version[0]); // NOLINT(build/unsigned)
68}
std::vector< uint8_t > read_i2cArray(uint32_t i2c_device_address, uint32_t i2c_reg_address, uint32_t number_of_words) const
Definition I2CSlave.cpp:81

◆ read_page()

uint8_t dunedaq::timing::SIChipSlave::read_page ( ) const

Reads the current page.

Returns
{ description_of_the_return_value }

Definition at line 35 of file SIChipSlave.cpp.

36{
37
38 TLOG_DEBUG(7) << "<- Reading page ";
39
40 // Read from the page address (0x1?)
41 return read_i2c(0x1);
42}

◆ switch_page()

void dunedaq::timing::SIChipSlave::switch_page ( uint8_t page) const

{ function_description }

Parameters
[in]pageA page

Definition at line 47 of file SIChipSlave.cpp.

48{
49
50 // Prepare a data block with address and new page
51 // std::vector<uint8_t> lData = {0x1, page};// NOLINT(build/unsigned)
52 TLOG_DEBUG(7) << "-> Switching to page " << format_reg_value((uint32_t)page); // NOLINT(build/unsigned)
53 write_i2c(0x1, page);
54}
void write_i2c(uint32_t i2c_device_address, uint32_t i2c_reg_address, uint8_t data, bool send_stop=true) const
Definition I2CSlave.cpp:62
std::string format_reg_value(T reg_value, uint32_t base)
Definition toolbox.hxx:117

◆ write_clock_register()

void dunedaq::timing::SIChipSlave::write_clock_register ( uint16_t address,
uint8_t data ) const

Writes a clock register.

Parameters
[in]addressA address
[in]dataA data

Definition at line 97 of file SIChipSlave.cpp.

98{
99
100 uint8_t reg_address = (address & 0xff); // NOLINT(build/unsigned)
101 uint8_t page_address = (address >> 8) & 0xff; // NOLINT(build/unsigned)
102
103 std::stringstream debug_stream;
104 debug_stream << std::showbase << std::hex << "Write Address " << (uint32_t)address // NOLINT(build/unsigned)
105 << " reg: " << (uint32_t)reg_address // NOLINT(build/unsigned)
106 << " page: " << (uint32_t)page_address; // NOLINT(build/unsigned)
107 TLOG_DEBUG(6) << debug_stream.str();
108 // Change page only when required.
109 // (The SI5344 don't like to have the page register id to be written all the time.)
110 uint8_t current_address = read_page(); // NOLINT(build/unsigned)
111 if (page_address != current_address) {
112 switch_page(page_address);
113 }
114
115 return write_i2c(reg_address, data);
116}

The documentation for this class was generated from the following files: