Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
deviceRegister Class Reference
Class that contains positional information for registers in the register map. More...
#include <register.h>
Public Member Functions | |
| deviceRegister (uint8_t size) | |
| Constructor for class OPT3101::deviceRegister Constructor allocated size to each register instance on construction. | |
| void | operator= (int32_t value) |
| Operator overload for '='. | |
| uint32_t | read () |
| Function called to read the value of register. | |
Data Fields | |
| uint8_t | msb [1] |
| This is the MSB position of this register. The register occupies the OPT3101::deviceRegister::address from OPT3101::deviceRegister::msb to OPT3101::deviceRegister::lsb. | |
| uint8_t | lsb [1] |
| This is the LSB position of this register. The register occupies the OPT3101::deviceRegister::address from OPT3101::deviceRegister::msb to OPT3101::deviceRegister::lsb. | |
| uint8_t | address [1] |
| This is the ADDRESS of this register. The register occupies the OPT3101::deviceRegister::address from OPT3101::deviceRegister::msb to OPT3101::deviceRegister::lsb. | |
| uint8_t | size |
| This specifies how many ADDRESS does this register span across. For eg: There are registers which span multiple address locations in chunks. | |
Detailed Description
Class that contains positional information for registers in the register map.
Class that contains positional information for a register in OPT3101 device. OPT3101 has 256 registers each 24 bits wide (OPT3101::deviceRegister::msb of 23 and OPT3101::deviceRegister::lsb of 0 with OPT3101::deviceRegister::address varying from 0 to 255) Bits are groups together and are addressed with a name. Registers have names, placed at different segments of the register map. For eg: tmain (temperature of main temp sensor) of OPT3101 occupies location with address 10 from msb of 23 bits to 12 bits in other words OPT3101::deviceRegister::address=10 OPT3101::deviceRegister::msb=23 OPT3101::deviceRegister::lsb=12 This class helps resolve programmers to read and write I2C to OPT3101 device by writing program code with higher level of abstraction with register names rather than dealing with positions of registers OPT3101::deviceRegister class helps resolve MSB, LSB and ADDRESS fields for a register by its name. Using this class gives user a functional name for each register making the register read and write more readable and meaningful. In case of OPT3101 device there are some registers which span across 2 address positions, hence the OPT3101::deviceRegister::address, OPT3101::deviceRegister::msb and OPT3101::deviceRegister::lsb have 2 allocations each. In most register cases they may not end up using both the allocations. The actual usage can be found using OPT3101::deviceRegister::size member
Example of register which has more than 1 address is OPT3101::registers::amplitude_min_thr which spans across register 0x10 from bits 23:16 and 0x11 from bites 23:16
Definition at line 51 of file register.h.
Constructor & Destructor Documentation
| deviceRegister | ( | uint8_t | size ) |
Constructor for class OPT3101::deviceRegister Constructor allocated size to each register instance on construction.
hostController declaration This global variable declaration with name host of hostController is used by various methods to send specific control commands to the host
- Parameters:
-
[in] size; size (typically 1 or 2 bytes) determines the number of segments that the register is divided in to.
Algorithm of the method is as follows
* Assigns size from input argument to the class member OPT3101::deviceRegister::size
Definition at line 35 of file register.cpp.
Member Function Documentation
| void operator= | ( | int32_t | value ) |
Operator overload for '='.
This makes calling this class simpler. dev.register=value will resolve the register address and value and invoke hostController::writeI2C method With proper implementation of the hostController::writeI2C methods the h/w would receive resolved I2C WRITE commands The write operations are read modify writes to make the system robust A single call of this method could invoke up to 2 I2C READ and 2 I2C WRITE transaction depending on the register
- Parameters:
-
[in] value; value to be set to register
- Returns:
- Nothing
Definition at line 61 of file register.cpp.
| uint32_t read | ( | ) |
Function called to read the value of register.
This method provides an abstraction for register to be used seamlessly with code for read register operations. hostController::readI2C method is invoked with OPT3101::deviceRegister::address fields and the resulting register value is combined as per the register positional information and reported as a uint32_t number A single call of this method could invoke up to 2 I2C READ transaction depending on the register
- Returns:
- value; value is reading of register from OPT3101 device
Algorithm of the method is as follows
* Loops though the number of OPT3101::deviceRegister::address fields based on OPT3101::deviceRegister::size
* Invokes hostController::readI2C() method to get register value from h/w
* Masks the bits for the register value to be reported based on register positional information
* Assembles the value of the register
* Returns the value read from the h/w for the register name specified
Definition at line 65 of file register.cpp.
Field Documentation
| uint8_t address[1] |
This is the ADDRESS of this register. The register occupies the OPT3101::deviceRegister::address from OPT3101::deviceRegister::msb to OPT3101::deviceRegister::lsb.
Definition at line 88 of file register.h.
| uint8_t lsb[1] |
This is the LSB position of this register. The register occupies the OPT3101::deviceRegister::address from OPT3101::deviceRegister::msb to OPT3101::deviceRegister::lsb.
Definition at line 87 of file register.h.
| uint8_t msb[1] |
This is the MSB position of this register. The register occupies the OPT3101::deviceRegister::address from OPT3101::deviceRegister::msb to OPT3101::deviceRegister::lsb.
Definition at line 86 of file register.h.
| uint8_t size |
This specifies how many ADDRESS does this register span across. For eg: There are registers which span multiple address locations in chunks.
Definition at line 89 of file register.h.
Generated on Sun Jul 17 2022 05:22:03 by
1.7.2