1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
// 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 {
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