aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Embedded_SW/Embedded/Modules/Waste/newWHS_init.c
blob: d2b200c4600541a278941919df010af502a2d76a (plain)
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
87
88
#include "include.h"
#include <DataDef.h>
#include <Modules/Waste/newWHS_init.h>

#include <Drivers/I2C_Communication/WHS_Card/IO_Ports_TCA9555/WHS_IO.h>
//#include <Drivers/I2C_Communication/WHS_Card/IO_Ports_TCA9555/TCA9555_Driver.h>
#include <Drivers/I2C_Communication/WHS_Card/I2C_WHS_Mux.h>
#include <Drivers/I2C_Communication/I2C.h>
#include "Drivers/I2C_Communication/WHS_Card/WHS_data.h"
#include <Drivers/I2C_Communication/WHS_Card/EEPROM/WHS_EEPROM.h>
#include <Drivers/I2C_Communication/WHS_Card/D_EMC2302_Fan/WHS_Fan.h>
#include <Drivers/I2C_Communication/WHS_Card/D_Max5805_ADC/Max_5805.h>
#include <Drivers/I2C_Communication/WHS_Card/D_MAX11614/WHS_MAX11614_A2D.h>
#include <Drivers/I2C_Communication/WHS_Card/D_AD5272/WHS_AD5272_Driver.h>
#include <Drivers/I2C_Communication/WHS_Card/D_ADS122/WHS_PT100_ADC.h>

bool test_9555(void);
bool WHS_I2C_EEprom_Write_Ch_shai_taest(void);

bool newWHS_init(void)
{
    bool status = OK;
    Main_Mux_Flag = 0;

//    delayms(4000);
    status = Select_Main_WHS_Mux_Channel();
    status |= WHS_IO_Init();
    status |= init_WHS_fan();
//    if (Test_WHS_EEPROM()!= OK)
//    {
//        ReportWithPackageFilter(WasteFilter,"------------ Test_WHS_EEPROM U32: test is failed-----------------", __FILE__,__LINE__,0, RpMessage, 0, 0);
//    }
    status = Test_WHS_Fan();
//    status = Test_WHS_blower();
//   status |= Test_WHS_valve();
//    status |= Test_WHS_pump();
//    status |= Test_WHS_max11614();
//    status |= Test_WHS_AD5272_A2D();
//    status |= Test_WHS_PT100_ADC();
//  //test_9555();
//    status |= WHS_I2C_EEprom_Write_Ch_shai_taest();
    return status;
}


bool test_9555(void)
{
    bool status = OK;

    status = WHS_Write_IO(I2CExp1_ADDRESS, D_TCA9555_PORT_0);

    return status;
}

uint8_t WHS_Write_Buf[9];
uint8_t WHS_Read_Buf[9];

bool WHS_I2C_EEprom_Write_Ch_shai_taest()
{
    bool status= OK;

//    uint8_t i = 0;
    uint8_t address_high_byte = 0x00;
    uint8_t address_low_byte  = 0x00;

    status |= Select_Main_WHS_Mux_Channel();

    WHS_Write_Buf[0] = address_high_byte;
    WHS_Write_Buf[1] = address_low_byte;
    WHS_Write_Buf[2] = 0xAA;
    WHS_Write_Buf[4] = 0xAA;
    WHS_Write_Buf[6] = 0xAA;
    WHS_Write_Buf[8] = 0xAA;
    WHS_Write_Buf[3] = 0x55;
    WHS_Write_Buf[5] = 0x55;
    WHS_Write_Buf[7] = 0x55;


    status |= I2C_Write(I2C_ID_WHS_CARD, I2CEEPROM_ADDRESS, WHS_Write_Buf, 9);
    SysCtlDelay(5000000);//Must delay for at least 5 milli. !!!  (See data sheet )
    status |= I2C_Write(I2C_ID_WHS_CARD, I2CEEPROM_ADDRESS, WHS_Write_Buf, 2);
    status |= I2C_Read(I2C_ID_WHS_CARD, I2CEEPROM_ADDRESS + 1, WHS_Read_Buf, 7);
    return status;
}