Пример #1
0
void test_i2c_at24c256_flash(void)
{
  U8 i=0;
  U8 status=1;
  U8 buf[128];

  for(i=0;i<sizeof(buf);i++)
    buf[i] = i;
  
  m24xx_write(EEPROM_24XX256, 0 , 0 , (char *)buf , sizeof(buf));

  for(i=0;i<sizeof(buf);i++)
    buf[i] = 0;

  m24xx_read(EEPROM_24XX256, 0 , 0 , (char *)buf , sizeof(buf));

  for(i=0;i<sizeof(buf);i++)
  {
    if(buf[i] != i)
    {
      status = 0;
      break;
    }    
  }

  if(status == 1)
  {
    lcd_putstring(LINE2,"I2C FLASH PASS");
  }
  else
  {
    lcd_putstring(LINE2,"I2C FLASH FAIL");
  }
}
Пример #2
0
void test_i2c_at24c256_flash(void)
{
  int i=0;

  char status=1;
  unsigned char buf[128];

  for(i=0;i<sizeof(buf);i++)

    buf[i] = i;

  m24xx_write(EEPROM_24XX256, 0 , 0 , (char *)buf , sizeof(buf));

  for(i=0;i<sizeof(buf);i++)
    buf[i] = 0;

  m24xx_read(EEPROM_24XX256, 0 , 0 , (char *)buf , sizeof(buf));

  for(i=0;i<sizeof(buf);i++)
  {
    if(buf[i] != i)
    {
      status = 0;
      break;
    }
  }

  if(status == 1)
   {

		 
	 	 	_DBG("I2C EEPROM PASS \n\t");
    }
  else
   {
	    	_DBG("I2C EEPROM FAIL\n\t");
   }
 }
Пример #3
0
void DimIns_Fade_area_to_off(uint8_t *UARTBuffer, uint8_t *PresetValue, uint8_t *ALvalue)
{
    uint8_t indx;
    uint8_t AreaLink[4];
    uint32_t dimTime;
    for(indx=0;indx<CHANNELNUMS;indx++)											   //寻找场景偏移量
    {
        if(IsAreaAccept(indx))
        {
            if(IsAppendAreaAccept(indx))
            {
                UARTBuffer[4] = UARTBuffer[4]+ChannelData[indx].PresetOffset;
                break;
            }
        }							
    }
        
    if(UARTBuffer[4]>95)
    {
        return;
    }
    
    for(indx=0;indx<CHANNELNUMS;indx++)
    {
        if(IsAreaAccept(indx))
        {
            if(IsAppendAreaAccept(indx))
            {
                if((ChannelData[indx].OringalLevel!=0)&&(ChannelData[indx].OringalLevel!=0xff))
                {
                    dimTime = (uint32_t) (((UARTBuffer[6]<<8)|UARTBuffer[5])+2);	//调光时间
                    if(dimTime>0xffff)
                    {
                        dimTime=0xffff;
                    }
                    if(ChannelData[indx].timeToGoal!=1)
                        ChannelData[indx].OringalLevel=(ChannelData[indx].OringalLevel+ChannelData[indx].GoalLevel)*ChannelData[indx].PastedTime*ChannelData[indx].timeToGoal;
                    ChannelData[indx].GoalLevel = 0xff;
                    ChannelData[indx].timeToGoal= (uint16_t) dimTime;
                    ChannelData[indx].PastedTime = 1;
                }
            }
         }
         else
         {
            if((UARTBuffer[1] >= ChannelData[indx].AreaLink)
                &&(UARTBuffer[1] <= (ChannelData[indx].AreaLink+24))
                &&(ChannelData[indx].AreaLink != 0xff))
            {
                if(m24xx_read(EEPROM_24XX256,AreaLink_addr+indx*4,0,AreaLink,4)==I2C_NO_ERR)
                {
                    dimTime = (uint32_t) ((AreaLink[1]<<16)|(AreaLink[2]<<8)|(AreaLink[3]));
                    if(
                        (dimTime>>(24-(UARTBuffer[1]-ChannelData[indx].AreaLink)))==0x01 
                      )
                    {
                        dimTime = (uint32_t) (((UARTBuffer[6]<<8)|UARTBuffer[5])+2);	//调光时间
                        
                        if(dimTime>0xffff)
                        {
                            dimTime=0xffff;
                        }
                        
                        if(ChannelData[indx].timeToGoal!=1)
                        {
                            ChannelData[indx].OringalLevel=(ChannelData[indx].OringalLevel+ChannelData[indx].GoalLevel)*ChannelData[indx].PastedTime*ChannelData[indx].timeToGoal;
                        }
                        ChannelData[indx].GoalLevel = 0xff;
                        ChannelData[indx].timeToGoal= (uint16_t) dimTime;
                        ChannelData[indx].PastedTime = 1;	

                        }

                }
            }																	
        }
    }
Пример #4
0
void DimIns_Preset(uint8_t *UARTBuffer, uint8_t *PresetValue, uint8_t *ALvalue)
{
    uint8_t indx;
    uint32_t dimTime;
    
    if((NULL_PTR == UARTBuffer)
        ||(NULL_PTR == PresetValue)
        ||(NULL_PTR == ALvalue))
        return;
    
    for(indx=0;indx<CHANNELNUMS;indx++)											   //寻找场景偏移量
    {
        if(IsAreaAccept(indx))
        {
            if(IsAppendAreaAccept(indx))
            {
                UARTBuffer[4] = UARTBuffer[4]+ChannelData[indx].PresetOffset;
                break;
            }
        }							
    }

    if(UARTBuffer[4]>95)
    {
        return;
    }
    
    if(m24xx_read(EEPROM_24XX256,Preset_addr+UARTBuffer[4]*CHANNELNUMS,0,PresetValue,CHANNELNUMS) != I2C_NO_ERR)
    {
		return;        
    }
    
    dimTime =(uint32_t) (((UARTBuffer[6]<<8)|UARTBuffer[5])+2);	//调光时间,借用dimTime
    
    if(dimTime>0xffff)
    {
        dimTime=0xffff;
    }
    
    for(indx=0;indx<CHANNELNUMS;indx++)
    {
        if(PresetValue[indx]!=0)
        {
            if(IsAreaAccept(indx))
            {
                if(IsAppendAreaAccept(indx))
                {
                    if((ChannelData[indx].OringalLevel!=0)&&(ChannelData[indx].OringalLevel!=PresetValue[indx]))
                    {
                        if(ChannelData[indx].timeToGoal!=1)
                            ChannelData[indx].OringalLevel=(ChannelData[indx].OringalLevel+ChannelData[indx].GoalLevel)*ChannelData[indx].PastedTime*ChannelData[indx].timeToGoal;
                        ChannelData[indx].GoalLevel = PresetValue[indx];
                        ChannelData[indx].timeToGoal= (uint16_t) dimTime;
                        ChannelData[indx].PrePreset = UARTBuffer[4];
                        ChannelData[indx].PastedTime = 1;
                    }
                }
             }													
        }
        PresetValue[indx] = ChannelData[indx].GoalLevel;
    }
    
    m24xx_write(EEPROM_24XX256,Preset_addr+(xcode+2)*CHANNELNUMS,0,PresetValue,CHANNELNUMS);
    
    for(indx=0;indx<CHANNELNUMS;indx++)
    {
        PresetValue[indx]=ChannelData[indx].PrePreset;
    }
    
    m24xx_write(EEPROM_24XX256,0X6c29,0,PresetValue,CHANNELNUMS);    
    return;
}