// fw_board_ni_v4.h
#ifndef _FW_BOARD_NI_V4_h
#define _FW_BOARD_NI_V4_h
#if defined(ARDUINO) && ARDUINO >= 100
	#include "arduino.h"
#else
	#include "WProgram.h"
#endif
#include "hw.h"
#define IIC_COUNT 8
#define PLOOP_MODEL     GS_05
#define PPATIENT_MODEL  DS_01
#define PVENTURI        DS_01
/**
 * \brief Driver for the Nuclear Instruments V4 Hardware Board
 */
class HW_V4 : public HW {<--- The class 'HW_V4' does not have a constructor although it has private member variables. [+]The class 'HW_V4' does not have a constructor although it has private member variables. Member variables of builtin types are left uninitialized when the class is instantiated. That may cause bugs or undefined behavior.
 <--- The class 'HW_V4' does not have a constructor although it has private member variables. [+]The class 'HW_V4' does not have a constructor although it has private member variables. Member variables of builtin types are left uninitialized when the class is instantiated. That may cause bugs or undefined behavior.
 <--- The class 'HW_V4' does not have a constructor although it has private member variables. [+]The class 'HW_V4' does not have a constructor although it has private member variables. Member variables of builtin types are left uninitialized when the class is instantiated. That may cause bugs or undefined behavior.
 <--- The class 'HW_V4' does not have a constructor although it has private member variables. [+]The class 'HW_V4' does not have a constructor although it has private member variables. Member variables of builtin types are left uninitialized when the class is instantiated. That may cause bugs or undefined behavior.
 <--- The class 'HW_V4' does not have a constructor although it has private member variables. [+]The class 'HW_V4' does not have a constructor although it has private member variables. Member variables of builtin types are left uninitialized when the class is instantiated. That may cause bugs or undefined behavior.
 <--- The class 'HW_V4' does not have a constructor although it has private member variables. [+]The class 'HW_V4' does not have a constructor although it has private member variables. Member variables of builtin types are left uninitialized when the class is instantiated. That may cause bugs or undefined behavior.
 <--- The class 'HW_V4' does not have a constructor although it has private member variables. [+]The class 'HW_V4' does not have a constructor although it has private member variables. Member variables of builtin types are left uninitialized when the class is instantiated. That may cause bugs or undefined behavior.
 
public:
    bool Init();<--- Function in derived class<--- Function in derived class<--- Function in derived class<--- Function in derived class<--- Function in derived class<--- Function in derived class<--- Function in derived class
    bool I2CWrite(t_i2cdevices device, uint8_t* wbuffer, int wlength, bool stop);<--- Function in derived class<--- Function in derived class<--- Function in derived class<--- Function in derived class<--- Function in derived class<--- Function in derived class<--- Function in derived class
    bool I2CRead(t_i2cdevices device, uint8_t* wbuffer, int wlength, uint8_t* rbuffer, int rlength, bool stop);<--- Function in derived class<--- Function in derived class<--- Function in derived class<--- Function in derived class<--- Function in derived class<--- Function in derived class<--- Function in derived class
    bool I2CRead(t_i2cdevices device, uint8_t* rbuffer, int rlength, bool stop);<--- Function in derived class<--- Function in derived class<--- Function in derived class<--- Function in derived class<--- Function in derived class<--- Function in derived class<--- Function in derived class
    bool PWMSet(hw_pwm id, float value);<--- Function in derived class<--- Function in derived class<--- Function in derived class<--- Function in derived class<--- Function in derived class<--- Function in derived class<--- Function in derived class
    bool IOSet(hw_gpio id, bool value);<--- Function in derived class<--- Function in derived class<--- Function in derived class<--- Function in derived class<--- Function in derived class<--- Function in derived class<--- Function in derived class
    bool IOGet(hw_gpio id, bool* value);<--- Function in derived class<--- Function in derived class<--- Function in derived class<--- Function in derived class<--- Function in derived class<--- Function in derived class<--- Function in derived class
    void PrintDebugConsole(String s);<--- Function in derived class<--- Function in derived class<--- Function in derived class<--- Function in derived class<--- Function in derived class<--- Function in derived class<--- Function in derived class
    void PrintLineDebugConsole(String s);<--- Function in derived class<--- Function in derived class<--- Function in derived class<--- Function in derived class<--- Function in derived class<--- Function in derived class<--- Function in derived class
    void __delay_blocking_ms(uint32_t ms);<--- Function in derived class<--- Function in derived class<--- Function in derived class<--- Function in derived class<--- Function in derived class<--- Function in derived class<--- Function in derived class
    void Tick();<--- Function in derived class<--- Function in derived class<--- Function in derived class<--- Function in derived class<--- Function in derived class<--- Function in derived class<--- Function in derived class
    uint64_t GetMillis();<--- Function in derived class<--- Function in derived class<--- Function in derived class<--- Function in derived class<--- Function in derived class<--- Function in derived class<--- Function in derived class
    int64_t Get_dT_millis(uint64_t ms);<--- Function in derived class<--- Function in derived class<--- Function in derived class<--- Function in derived class<--- Function in derived class<--- Function in derived class<--- Function in derived class
    bool DataAvailableOnUART0();<--- Function in derived class<--- Function in derived class<--- Function in derived class<--- Function in derived class<--- Function in derived class<--- Function in derived class<--- Function in derived class
    String ReadUART0UntilEOL();<--- Function in derived class<--- Function in derived class<--- Function in derived class<--- Function in derived class<--- Function in derived class<--- Function in derived class<--- Function in derived class
    bool WriteUART0(String s);<--- Function in derived class<--- Function in derived class<--- Function in derived class<--- Function in derived class<--- Function in derived class<--- Function in derived class<--- Function in derived class
    void GetPowerStatus(bool* batteryPowered, float* charge);<--- Function in derived class<--- Function in derived class<--- Function in derived class<--- Function in derived class<--- Function in derived class<--- Function in derived class<--- Function in derived class
    float GetPIN();<--- Function in derived class<--- Function in derived class<--- Function in derived class<--- Function in derived class<--- Function in derived class<--- Function in derived class<--- Function in derived class
    float GetBoardTemperature();<--- Function in derived class<--- Function in derived class<--- Function in derived class<--- Function in derived class<--- Function in derived class<--- Function in derived class<--- Function in derived class
    uint16_t GetSupervisorAlarms();<--- Function in derived class<--- Function in derived class<--- Function in derived class<--- Function in derived class<--- Function in derived class<--- Function in derived class<--- Function in derived class
    
private:
    bool EnableWatchdogSupervisor = true;
    void __service_i2c_detect();
    void i2c_MuxSelect(uint8_t i);
    t_i2cdev GetIICDevice(t_i2cdevices device);
    uint16_t ReadSupervisor( uint8_t i_address);
    void WriteSupervisor(uint8_t i_address, uint16_t write_data);
    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;
};
#endif
//                  #     # ### 
//                  ##    #  #  
//                  # #   #  #  
//                  #  #  #  #  
//                  #   # #  #  
//                  #    ##  #  
//                  #     # ### 
//
// Nuclear Instruments 2020 - All rights reserved
// Any commercial use of this code is forbidden
// Contact info@nuclearinstruments.eu