eeManager_Interface.c 4.75 KB
Newer Older
李俭双's avatar
李俭双 committed
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
#include "Components.h"
#include "RTE.h"

#define EE_SDA RTE_GPIO_PORT06_PIN01
#define EE_SCL RTE_GPIO_PORT06_PIN00

/*-------------------------------------------------------------------------
* Function Name  : eeprom_StoreInfo_Init
* Description    :
* Input          :
* Output         : None
* Return         : None
* onther         :
--------------------------------------------------------------------------*/
void eeprom_StoreInfo_Init(void)
{
    eeprom_SetParameter(AT24C16, distance_100m);
    EE_SCL_OutConfig();
    EE_SDA_OutConfig();
}

/*-------------------------------------------------------------------------
* Function Name  : eeprom_comm_DelayUs
* Description    :
* Input          : None
* Output         : None
* Return         : None
* onther         :
--------------------------------------------------------------------------*/
void eeprom_comm_DelayUs(ee_uint32_t time)
{
    ee_uint32_t i;
    ee_uint32_t dalayCnt = 0;
    dalayCnt = time;
    EE_FeedDog();
    for (i = 0; i < dalayCnt; i++)
    {
38 39 40 41 42 43 44 45 46 47 48
        //EE_NOP();
        __NOP();
        __NOP();
        __NOP();
        __NOP();
        __NOP();
        __NOP();
        __NOP();
        __NOP();
        __NOP();      
        __NOP();
49 50 51 52 53 54 55 56 57 58 59
        __NOP();
        __NOP();
        __NOP();
        __NOP();      
        __NOP();
        __NOP();
        __NOP();
        __NOP();
        __NOP();
        __NOP();      
        __NOP();
60
     
李俭双's avatar
李俭双 committed
61
    }
62
    //EE_FeedDog();
李俭双's avatar
李俭双 committed
63 64 65 66 67 68 69 70 71 72 73 74
}

/*-------------------------------------------------------------------------
* Function Name  : EE_SDA_InConfig
* Description    :
* Input          : None
* Output         : None
* Return         : None
* onther         :
--------------------------------------------------------------------------*/
void EE_SDA_InConfig(void)
{
75 76
    //RTE_GPIO_Config(EE_SDA, RTE_GPIO_DIR_IN);
    PORT->PM6 |= (1<<1);
李俭双's avatar
李俭双 committed
77 78 79 80 81 82 83 84 85 86 87
}
/*-------------------------------------------------------------------------
* Function Name  : EE_SDA_OutConfig
* Description    :
* Input          : None
* Output         : None
* Return         : None
* onther         :
--------------------------------------------------------------------------*/
void EE_SDA_OutConfig(void)
{
88 89
    //RTE_GPIO_Config(EE_SDA, RTE_GPIO_DIR_OUT);
    PORT->PM6 &= ~(1<<1);
李俭双's avatar
李俭双 committed
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
}
/*-------------------------------------------------------------------------
* Function Name  : EE_SDA_GetValue
* Description    :
* Input          : None
* Output         : None
* Return         : None
* onther         :
--------------------------------------------------------------------------*/
ee_uint8_t EE_SDA_GetValue(void)
{
    uint8_t SDA_INPUT = 2;
    SDA_INPUT = RTE_GPIO_Get_Level(EE_SDA);
    return SDA_INPUT;
}

/*-------------------------------------------------------------------------
* Function Name  : EE_SDA_OUT
* Description    :
* Input          : None
* Output         : None
* Return         : None
* onther         :
--------------------------------------------------------------------------*/
void EE_SDA_OUT(ee_uint8_t data)
{
116
    // RTE_GPIO_Config(EE_SDA, RTE_GPIO_DIR_OUT | data);
117 118 119 120 121 122 123 124 125 126
    //RTE_GPIO_Set_Level(EE_SDA, data);
    if(data)
    {
        PORT->P6 |= (1<<1);
    }
    else
    {
        PORT->P6 &= ~(1<<1);
    }
    
李俭双's avatar
李俭双 committed
127 128 129 130 131 132 133 134 135 136 137 138
}

/*-------------------------------------------------------------------------
* Function Name  : EE_SDA_OutConfig
* Description    :
* Input          : None
* Output         : None
* Return         : None
* onther         :
--------------------------------------------------------------------------*/
void EE_SCL_OutConfig(void)
{
139 140
    //RTE_GPIO_Config(EE_SCL, RTE_GPIO_DIR_OUT);
    PORT->PM6 &= ~(1<<0);
李俭双's avatar
李俭双 committed
141 142 143 144 145 146 147 148 149 150 151
}
/*-------------------------------------------------------------------------
* Function Name  : EE_SCL_OUT
* Description    :
* Input          : None
* Output         : None
* Return         : None
* onther         :
--------------------------------------------------------------------------*/
void EE_SCL_OUT(ee_uint8_t data)
{
152
    // RTE_GPIO_Config(EE_SCL, RTE_GPIO_DIR_OUT | data);
153 154 155 156 157 158 159 160 161 162
    //RTE_GPIO_Set_Level(EE_SCL, data);
    if(data)
    {
        PORT->P6 |= (1<<0);
    }
    else
    {
        PORT->P6 &= ~(1<<0);
    }
    
李俭双's avatar
李俭双 committed
163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189
}

/*-------------------------------------------------------------------------
* Function Name  : EE_FeedDog
* Description    : 清零 DOG
* Input          : None
* Output         : None
* Return         : None
* onther         :
--------------------------------------------------------------------------*/
void EE_FeedDog(void)
{
    RTE_WDT_Clear();
}

/*-------------------------------------------------------------------------
* Function Name  : EE_NOP
* Description    : nop 指令
* Input          : None
* Output         : None
* Return         : None
* onther         :
--------------------------------------------------------------------------*/
void EE_NOP(void)
{
    __NOP();
}