|
MVMFirmwareCpp v0.1
|
Driver for the Nuclear Instruments V4 Hardware Board. More...
#include <fw_board_ni_v4.h>


Public Member Functions | |
| bool | Init () |
| Initialize hardware peripheral in the system. More... | |
| bool | I2CWrite (t_i2cdevices device, uint8_t *wbuffer, int wlength, bool stop) |
| Write buffer to I2C bus. More... | |
| bool | I2CRead (t_i2cdevices device, uint8_t *wbuffer, int wlength, uint8_t *rbuffer, int rlength, bool stop) |
| Write buffer to I2C bus and read data. More... | |
| bool | I2CRead (t_i2cdevices device, uint8_t *rbuffer, int rlength, bool stop) |
| Read I2c data. More... | |
| bool | PWMSet (hw_pwm id, float value) |
| Control PWM device (PV1) More... | |
| bool | IOSet (hw_gpio id, bool value) |
| Set a GPIO Status (IE Control PV6, Alarms, etc) More... | |
| bool | IOGet (hw_gpio id, bool *value) |
| Get GPIO Status. More... | |
| void | PrintDebugConsole (String s) |
| Print a message on console used for Debug. More... | |
| void | PrintLineDebugConsole (String s) |
| Print a message on console used for Debug with a CR+LR at end. More... | |
| void | Tick () |
| Tick function must be called periodically. More... | |
| bool | DataAvailableOnUART0 () |
| API to read if on the communication interfaces there are bytes to be read. More... | |
| String | ReadUART0UntilEOL () |
| Return a terminated string from communication interface. More... | |
| bool | WriteUART0 (String s) |
| API to write a string to the communication interfaces. More... | |
| void | GetPowerStatus (bool *batteryPowered, float *charge) |
| API to read battery charge and power supply status. More... | |
| float | GetPIN () |
| API return pressure on input of MVM. More... | |
| float | GetBoardTemperature () |
| API return temperature of the board. More... | |
| uint16_t | GetSupervisorAlarms () |
| API return Supervisor managed alarms. More... | |
Private Member Functions | |
| void | __service_i2c_detect () |
| Detect all I2C devices on bus. More... | |
| void | i2c_MuxSelect (uint8_t i) |
| Switch I2C multiplexer. More... | |
| t_i2cdev | GetIICDevice (t_i2cdevices device) |
| Search in the iic_devs list a particular device and return descriptor. More... | |
| uint16_t | ReadSupervisor (uint8_t i_address) |
| Read a supervisor register. More... | |
| void | WriteSupervisor (uint8_t i_address, uint16_t write_data) |
| Write a supervisor register. More... | |
Private Attributes | |
| bool | EnableWatchdogSupervisor = true |
| t_i2cdev | iic_devs [IIC_COUNT] |
| uint8_t | current_muxpos = 10 |
| uint64_t | batteryStatus_reading_LT |
| float | currentBatteryCharge |
| bool | pWall |
| float | pIN |
| float | BoardTemperature |
| uint16_t | HW_AlarmsFlags |
Driver for the Nuclear Instruments V4 Hardware Board.
Definition at line 23 of file fw_board_ni_v4.h.
|
private |
Detect all I2C devices on bus.
Definition at line 506 of file fw_board_ni_v4.cpp.

| bool HW_V4::DataAvailableOnUART0 | ( | ) |
API to read if on the communication interfaces there are bytes to be read.
Definition at line 452 of file fw_board_ni_v4.cpp.

| float HW_V4::GetBoardTemperature | ( | ) |
API return temperature of the board.
Definition at line 633 of file fw_board_ni_v4.cpp.

|
private |
Search in the iic_devs list a particular device and return descriptor.
| device | device (t_i2cdevices) to be searched for |
Definition at line 570 of file fw_board_ni_v4.cpp.

| float HW_V4::GetPIN | ( | ) |
API return pressure on input of MVM.
Definition at line 623 of file fw_board_ni_v4.cpp.

| void HW_V4::GetPowerStatus | ( | bool * | batteryPowered, |
| float * | charge | ||
| ) |
API to read battery charge and power supply status.
| batteryPowered | true the system is battery powered false the system is powered from 220v |
| charge | % of battery charge |
Definition at line 438 of file fw_board_ni_v4.cpp.

| uint16_t HW_V4::GetSupervisorAlarms | ( | ) |
API return Supervisor managed alarms.
bit 0 : input pressure too low
bit 1 : input pressure too high
bit 2 : board temperature too low
bit 3 : board temperature too high
bit 4 : no activity on the valves
bit 5 : power regulator issue
bit 6 : battery charge critical
Definition at line 652 of file fw_board_ni_v4.cpp.

|
private |
Switch I2C multiplexer.
Check if mux is already in the correct position otherwise commutate
| i |
Definition at line 546 of file fw_board_ni_v4.cpp.

| bool HW_V4::I2CRead | ( | t_i2cdevices | device, |
| uint8_t * | rbuffer, | ||
| int | rlength, | ||
| bool | stop | ||
| ) |
Read I2c data.
This function also switch mux port in order to access to required device
| device | name of the device listened in the iic_dev (t_i2cdevices) |
| rbuffer | reading buffer (should be allocated externally) |
| rlength | number of bytes to be read |
| stop | add stop at end of transaction |
Definition at line 227 of file fw_board_ni_v4.cpp.

| bool HW_V4::I2CRead | ( | t_i2cdevices | device, |
| uint8_t * | wbuffer, | ||
| int | wlength, | ||
| uint8_t * | rbuffer, | ||
| int | rlength, | ||
| bool | stop | ||
| ) |
Write buffer to I2C bus and read data.
This function also switch mux port in order to access to required device
| device | name of the device listened in the iic_dev (t_i2cdevices) |
| wbuffer | buffer to be written |
| wlength | length of the buffer to be written |
| rbuffer | reading buffer (should be allocated externally) |
| rlength | number of bytes to be read |
| stop | add stop at end of transaction |
Definition at line 182 of file fw_board_ni_v4.cpp.


| bool HW_V4::I2CWrite | ( | t_i2cdevices | device, |
| uint8_t * | wbuffer, | ||
| int | wlength, | ||
| bool | stop | ||
| ) |
Write buffer to I2C bus.
This function also switch mux port in order to access to required device
| device | name of the device listened in the t_i2cdevices iic_dev |
| wbuffer | buffer to be written |
| wlength | length of the buffer |
| stop | add stop bit at end of transaction |
Definition at line 145 of file fw_board_ni_v4.cpp.


| bool HW_V4::Init | ( | ) |
Initialize hardware peripheral in the system.
The function configure:
It also perform a I2C scan
Definition at line 36 of file fw_board_ni_v4.cpp.


| bool HW_V4::IOGet | ( | hw_gpio | id, |
| bool * | value | ||
| ) |
Get GPIO Status.
| id | name of the GPIO (enum hw_gpio) |
| value | OUTPUT true: logic level HI, low: logic level LOW |
Definition at line 325 of file fw_board_ni_v4.cpp.
| bool HW_V4::IOSet | ( | hw_gpio | id, |
| bool | value | ||
| ) |
Set a GPIO Status (IE Control PV6, Alarms, etc)
| id | name of the GPIO (enum hw_gpio) |
| value | true: logic level HI, low: logic level LOW |
Definition at line 288 of file fw_board_ni_v4.cpp.

| void HW_V4::PrintDebugConsole | ( | String | s | ) |
Print a message on console used for Debug.
For ESP32 this is the same console of interface bus this is dangerous and in production DEBUG LEVEL should be set in order to be sure that no debug message is forwarded on this console otherwise GUI will crash
| s | String to be print |
Definition at line 368 of file fw_board_ni_v4.cpp.

| void HW_V4::PrintLineDebugConsole | ( | String | s | ) |
Print a message on console used for Debug with a CR+LR at end.
For ESP32 this is the same console of interface bus this is dangerous and in production DEBUG LEVEL should be set in order to be sure that no debug message is forwarded on this console otherwise GUI will crash
| s | String to be print |
Definition at line 384 of file fw_board_ni_v4.cpp.


| bool HW_V4::PWMSet | ( | hw_pwm | id, |
| float | value | ||
| ) |
Control PWM device (PV1)
| id | name of the device (enum hw_pwm) |
| value | value from 0 to 100 |
Definition at line 256 of file fw_board_ni_v4.cpp.

|
private |
Read a supervisor register.
| i_address | address of the register in the supervisor register file |
Definition at line 587 of file fw_board_ni_v4.cpp.


| String HW_V4::ReadUART0UntilEOL | ( | ) |
Return a
terminated string from communication interface.
Definition at line 474 of file fw_board_ni_v4.cpp.


| void HW_V4::Tick | ( | ) |
Tick function must be called periodically.
The function performs in this driver polling task
Every seconds the function will contact the supervisor to do:
Definition at line 403 of file fw_board_ni_v4.cpp.


|
private |
Write a supervisor register.
| i_address | address of the register in the supervisor register file |
| write_data | value of the register |
Definition at line 607 of file fw_board_ni_v4.cpp.


| bool HW_V4::WriteUART0 | ( | String | s | ) |
API to write a string to the communication interfaces.
| s | String to be written |
Definition at line 463 of file fw_board_ni_v4.cpp.


|
private |
Definition at line 63 of file fw_board_ni_v4.h.
|
private |
Definition at line 68 of file fw_board_ni_v4.h.
|
private |
Definition at line 61 of file fw_board_ni_v4.h.
|
private |
Definition at line 64 of file fw_board_ni_v4.h.
|
private |
Definition at line 51 of file fw_board_ni_v4.h.
|
private |
Definition at line 69 of file fw_board_ni_v4.h.
Definition at line 60 of file fw_board_ni_v4.h.
|
private |
Definition at line 67 of file fw_board_ni_v4.h.
|
private |
Definition at line 65 of file fw_board_ni_v4.h.
1.8.18