Ejemplo n.º 1
0
int ProcessSearchProductHistory(int new_sock) 
{
	int 	ErrorCode=NO_ERROR;

	PRODUCTID_T Request;
	PRODUCTHISTORY_RES_T Result;

	printLog(HEAD, "==[MSG_GET_PRODUCT_HISTORY_INFO_REQ]==\n");

	memset(&Request, 0, sizeof(PRODUCTID_T));
	memset(&Result, 0, sizeof(PRODUCTHISTORY_RES_T));

	if((ErrorCode = ReadProductID(&Request, new_sock)) != NO_ERROR)	{
		return	ErrorCode;
	}
	printLog(HEAD, "GET : Productid(%s)\n", Request.ProductID);

	if( strlen(Request.ProductID) != PRODUCT_SIZE ) {
		ErrorCode = INVALID_PRODUCTID;
	}
	else {
		ErrorCode = processProductHistoryInfoGet(Request, &Result);
	}

	WriteProductHistory(Result, ErrorCode, new_sock);

	if(Result.ResCount > 0 && Result.ResultData != (PRODUCTHISTORY_DATA_T *)NULL)
		free(Result.ResultData);

	return	ErrorCode;
}
BOOL __section(SectionForFlashOperations) AM29DL_32_BS_Driver::ChipInitialize( void* context )
{
    NATIVE_PROFILE_HAL_DRIVERS_FLASH();

    MEMORY_MAPPED_NOR_BLOCK_CONFIG* config = (MEMORY_MAPPED_NOR_BLOCK_CONFIG*)context;
    
    // first setup the memory for wait states, read only, etc.
    CPU_EBIU_ConfigMemoryBlock( config->Memory );

    ChipReadOnly( config, FALSE, FLASH_PROTECTION_KEY );
    
    // the flash are now not write protected
    {
        FLASH_WORD ManufacturerCode = 0;
        FLASH_WORD DeviceCode       = 0;

        if(ReadProductID(config, ManufacturerCode, DeviceCode ))
        {
            debug_printf( "Flash product Manufacturer Code = 0x%08x, Device Code = 0x%08x\r\n", ManufacturerCode, DeviceCode );

            if(ManufacturerCode != config->ManufacturerCode) 
            {
                debug_printf( "ERROR: Unsupported Flash Manufacturer code: 0x%08x\r\n", ManufacturerCode );
            }

            if(DeviceCode != config->DeviceCode) 
            {
                debug_printf( "ERROR: Unsupported Flash Device code: 0x%08x\r\n", DeviceCode );
            }
        }
        else
        {
            debug_printf( "Flash_ReadProductID() failed.\r\n" );
        }
    }

    ChipReadOnly(config, TRUE, FLASH_PROTECTION_KEY );
    // the flash are now write protected

    return TRUE;
}
Ejemplo n.º 3
0
int	ProcessErrorInfo(int new_sock)
{
    ERRORINFO_T	ErrorInfo[MAX_RETURN_NUM];
    PRODUCTID_T	ProductID;
    int	ErrorCount = 0;
    int	ErrorCode = 0;

    memset(ErrorInfo, 0, sizeof(ERRORINFO_T) * MAX_RETURN_NUM);

    if((ErrorCode = ReadProductID(&ProductID, new_sock)) != NO_ERROR)	{
        printLog(HEAD, "ERR: read error! ErroCode(%d)\n", ErrorCode) ;
        return	ErrorCode;
    }

    ErrorCode = GetErrorInfo(ProductID, &ErrorCount, ErrorInfo) ;
    printLog(HEAD, "work_errorInfo_get(): ret(%d) count(%d)\n", ErrorCode, ErrorCount) ;

    ErrorCode = WriteErrorInfo(ErrorInfo, ErrorCode, ErrorCount, new_sock);

    return	ErrorCode;
}
Ejemplo n.º 4
0
/*
  main routine

  Program entry point
*/
int main(void)
{
  Uint8   TxBuf[BCMsgSize];
  Uint8   RxBuf[BCMsgSize];
  Uint8   Address;            // Address of device in bay
  Uint8   Destination;        // Address we will reply to
  Uint8   Param,Param2;


  MainInit();

  UART_TxStr("\r\nPower up\r\n");

  UART_Rx(RxData, 9);             // Input register setting command

  Address = BCAOutput + ReadPosition();
  BCMessageInit(Address);         // Set up the UART
  BCMessageReceive(RxBuf);        // Kick off receive

  // Enter the main loop

  for( ; ; ) {                              // Run forever
    DelayMS(LoopRate);
    SettingsControl();

    if (BCRXAvail) {                        // We have a new message
      if ((RxBuf[BCPAddr] & 0b1111) == Address)  { // Check it is for us
        Destination = RxBuf[BCPAddr] >> 4;  // Pre-setup assuming we will reply
        Destination &= 0b1111;
        Destination |= Address << 4;
        TxBuf[BCPAddr] = Destination;
        DelayMS(2);                         // Allow line turn around delay
        switch (RxBuf[BCPType]) {
          case BCTInquire:                  // Master request of slave ID
            TxBuf[BCPType] = BCTInquireAnswer;
            TxBuf[BCPParam1] = ReadProductID();
            TxBuf[BCPParam2] = 0;
            BCMessageSend(TxBuf,true);      // Send the reply
            BCMessageReceive(RxBuf);        // Kick off receive of next frame
            break;

          case BCTVolume:                   // Volume set
            TxBuf[BCPType] = BCTAck;
            TxBuf[BCPParam1] = 0;
            TxBuf[BCPParam2] = 0;
            BCMessageSend(TxBuf,true);      // Send the reply
            Param = RxBuf[BCPParam1];       // Save parameter so we can receive next frame while processing this request
            BCMessageReceive(RxBuf);        // Kick off receive of next frame
//            Timer_Clear();
            Volume_Set(Param);
//            UART_TxStr("Volume_Set took ");
//            UART_TxNum(Timer_Read());
//            UART_TxStr("mS\r\n");
            break;

          case BCTHeadphoneChGain:                   // Volume set
            TxBuf[BCPType] = BCTAck;
            TxBuf[BCPParam1] = 0;
            TxBuf[BCPParam2] = 0;
            BCMessageSend(TxBuf,true);      // Send the reply
            Param = RxBuf[BCPParam1];       // Save parameter so we can receive next frame while processing this request
            Param2 = RxBuf[BCPParam2];       // Save parameter so we can receive next frame while processing this request
            BCMessageReceive(RxBuf);        // Kick off receive of next frame
//            Timer_Clear();
            SetChannelAdjust(Param,Param2);
//            UART_TxStr("Volume_Set took ");
//            UART_TxNum(Timer_Read());
//            UART_TxStr("mS\r\n");
            break;

          case BCTHeadphoneChMax:                   // Volume set
            TxBuf[BCPType] = BCTAck;
            TxBuf[BCPParam1] = 0;
            TxBuf[BCPParam2] = 0;
            BCMessageSend(TxBuf,true);      // Send the reply
            Param = RxBuf[BCPParam1];       // Save parameter so we can receive next frame while processing this request
            Param2 = RxBuf[BCPParam2];       // Save parameter so we can receive next frame while processing this request
            BCMessageReceive(RxBuf);        // Kick off receive of next frame
            SetChMaxVolume(Param, Param2);
            break;

          case BCTAudioFormat:              // Audio format set
            TxBuf[BCPType] = BCTAck;
            TxBuf[BCPParam1] = 0;
            TxBuf[BCPParam2] = 0;
            BCMessageSend(TxBuf,true);      // Send the reply
            Param = RxBuf[BCPParam1];       // Save parameter so we can receive next frame while processing this request
            BCMessageReceive(RxBuf);        // Kick off receive of next frame
//            Timer_Clear();
            WM8960_SetAudioFormat(Param);
//            UART_TxStr("WM8960_SetAudioFormat took ");
//            UART_TxNum(Timer_Read());
//            UART_TxStr("mS\r\n");
            break;

          default:  // Unknown command
            TxBuf[BCPType] = BCTNAck;
            TxBuf[BCPParam1] = BCNUnkownType;
            TxBuf[BCPParam2] = RxBuf[BCPType];
            BCMessageSend(TxBuf,true);      // Send the reply
            BCMessageReceive(RxBuf);        // Kick off receive of next frame
            break;
        }
      }
    }
  }
Ejemplo n.º 5
0
BOOL __section("SectionForFlashOperations")I28F_16_BS_Driver::ChipInitialize( void* context )
{
    NATIVE_PROFILE_HAL_DRIVERS_FLASH();
    
    int i;

    MEMORY_MAPPED_NOR_BLOCK_CONFIG* config = (MEMORY_MAPPED_NOR_BLOCK_CONFIG*)context;
   
    // first setup the memory for wait states, read only, etc.
    CPU_EBIU_ConfigMemoryBlock( config->Memory );

    // the flash are now not write protected

    {
        FLASH_WORD ManufacturerCode = 0;
        FLASH_WORD DeviceCode       = 0;

        if(ReadProductID( config, ManufacturerCode, DeviceCode ))
        {
            debug_printf( "Flash product Manufacturer Code = 0x%08x, Device Code = 0x%08x\r\n", ManufacturerCode, DeviceCode );

            if(ManufacturerCode != config->ManufacturerCode )
            {
                debug_printf( "ERROR: Unsupported Flash Manufacturer code: 0x%08x\r\n", ManufacturerCode );
            }

            if(DeviceCode != config->DeviceCode)
            {
                debug_printf( "ERROR: Unsupported Flash Device code: 0x%08x\r\n", DeviceCode );
            }
        }
        else
        {
            debug_printf( "Flash_ReadProductID() failed.\r\n" );
        }
    }

    // verify that all partitions are good by checking manufacturing/device codes (per spec)

    const BlockRegionInfo *pRegion;
    CHIP_WORD * ChipAddress;
    
    ChipReadOnly( config, FALSE, FLASH_PROTECTION_KEY );

    for(i = 0; i < config->BlockConfig.BlockDeviceInformation->NumRegions;  i++)
    {

        pRegion = &(config->BlockConfig.BlockDeviceInformation->Regions[i]);

        ChipAddress = (CHIP_WORD *) pRegion->Start;

        for (int j=0; j<pRegion->NumBlocks; j++)
        {
            FLASH_WORD ManufacturerCode;
            FLASH_WORD DeviceCode;


            Action_ReadID( ChipAddress, ManufacturerCode, DeviceCode );
   
            if(config->ManufacturerCode != ManufacturerCode)
            {
                debug_printf( "Flash_ChipInitialize: ManufacturerCode failure 0x%08x != 0x%08x at 0x%08x\r\n", ManufacturerCode, config->ManufacturerCode, (UINT32)ChipAddress);
            }

            if(config->DeviceCode != DeviceCode)
            {
                debug_printf( "Flash_ChipInitialize: DeviceCode failure 0x%08x != 0x%08x at 0x%08x\r\n", DeviceCode, config->DeviceCode, (UINT32)ChipAddress );
            }

            ChipAddress = (CHIP_WORD *) ( (UINT32)ChipAddress + (UINT32) pRegion->BytesPerBlock);

        }
        
    }

    // unlock all the blocks (sectors) that are locked
    // the default is to have the sectors locked upon powerup, undo that here


    for(i = 0; i < config->BlockConfig.BlockDeviceInformation->NumRegions;  i++)
    {

        pRegion = &(config->BlockConfig.BlockDeviceInformation->Regions[i]);

        // XIP 
        ChipAddress = (CHIP_WORD *)pRegion->Start ;

        for (int j=0; j<pRegion->NumBlocks; j++)
        {
            CHIP_WORD BlockLockStatus = Action_ReadLockStatus( ChipAddress );

            if(BlockLockStatus & LOCK_STATUS_LOCKED)
            {
                debug_printf( "Flash_ChipInitialize: Block at 0x%08x is locked, unlocking now.\r\n", (UINT32)ChipAddress );

                Action_Unlock( ChipAddress );
            }

            Action_ClearStatusRegister( ChipAddress );

            if(BlockLockStatus & LOCK_STATUS_LOCKED_DOWN)
            {
                debug_printf( "Flash_ChipInitialize: Block at 0x%08x is locked down, must reset or powerdown to remove lock-down\r\n", (UINT32)ChipAddress );
            }

            ChipAddress = (CHIP_WORD *) ( (UINT32)ChipAddress + pRegion->BytesPerBlock);
        }
    }

    ChipReadOnly( config, TRUE, FLASH_PROTECTION_KEY );
    
    return TRUE;
}
Ejemplo n.º 6
0
/*
  main routine

  Program entry point
*/
int main(void)
{
  Uint8   TxBuf[BCMsgSize];
  Uint8   RxBuf[BCMsgSize];
  Uint8   Address;            // Address of device in bay
  Uint8   Destination;        // Address we will reply to
  Uint8   Param,Param2;
  Uint8   Volume = 0;
  Uint8   TempInt;
#ifdef CTRL_LED
  Uint8   TempInt;
  Uint8   RceiveAddress;
  Uint8   i;
  i = 0;
#endif
  MainInit();

  UART_TxStr("\r\nPower up\r\n");

  UART_Rx(RxData, 9);             // Input register setting command

  Address = BCAOutput + ReadPosition();
  BCMessageInit(Address);         // Set up the UART
  BCMessageReceive(RxBuf);        // Kick off receive

  if(ReadProductID()) // 1:pill 2:beats box 3:rave
    ChannelNumbers = 1;
  else
    ChannelNumbers = 5;//0:5 position headphone
  // Enter the main loop
  LED1_ON();
  LED2_ON();
  LED_GRAPHICAL_ON();
  SetLamps(3);
  for( ; ; ) {                              // Run forever
    Timer_Clear();
    DelayMS(LoopRate);
    TempInt++;
    SettingsControl();
    if (BCRXAvail)
    {                        // We have a new message
      //send data
#ifdef  SecondUART
#ifdef DumpComms
      UART_TxStr("Receive: ");
      for (TempInt = BCPSOH; TempInt <= BCPChecksum; TempInt++)
      {
        UART_TxUint8(RxBuf[TempInt]);
        UART_TxChar(' ');
      }
      UART_TxStr("\r\n");
#endif
#endif

      if ((RxBuf[BCPAddr] & 0b1111) == Address) // Check it is for us
      {
        Destination = RxBuf[BCPAddr] >> 4;  // Pre-setup assuming we will reply
        Destination &= 0b1111;
        Destination |= Address << 4;
        TxBuf[BCPAddr] = Destination;
        DelayMS(2);                         // Allow line turn around delay
        switch (RxBuf[BCPType])
        {
          case BCTInquire:                  // Master request of slave ID
            TxBuf[BCPType] = BCTInquireAnswer;
            TxBuf[BCPParam1] = ReadProductID();
            TxBuf[BCPParam2] = 0;
            BCMessageSend(TxBuf,true);      // Send the reply
            break;
          case BCTLamps: // Set lamps
            TxBuf[BCPType]   = BCTAck;
            TxBuf[BCPParam1] = 0;
            TxBuf[BCPParam2] = 0;
            BCMessageSend(TxBuf, true);           // Send the reply
            Param =  RxBuf[BCPParam1];
            SetLamps(Param);
            break;

          case BCTVolume:                   // Volume set
            TxBuf[BCPType] = BCTAck;
            TxBuf[BCPParam1] = 0;
            TxBuf[BCPParam2] = 0;
            BCMessageSend(TxBuf,true);      // Send the reply
            Volume = RxBuf[BCPParam1];       // Save parameter so we can receive next frame while processing this request
            Param2 = RxBuf[BCPParam2];       // Save parameter so we can receive next frame while processing this request
            Volume_Set(Volume,Param2);
            break;

          case BCTHeadphoneChGain:                   // Volume set
            TxBuf[BCPType] = BCTAck;
            TxBuf[BCPParam1] = 0;
            TxBuf[BCPParam2] = 0;
            BCMessageSend(TxBuf,true);      // Send the reply
            Param = RxBuf[BCPParam1];       // Save parameter so we can receive next frame while processing this request
            Param2 = RxBuf[BCPParam2];       // Save parameter so we can receive next frame while processing this request
            SetChannelAdjust(Param,Param2);
            break;

          case BCTHeadphoneChMax:                   // Volume set
            TxBuf[BCPType] = BCTAck;
            TxBuf[BCPParam1] = 0;
            TxBuf[BCPParam2] = 0;
            BCMessageSend(TxBuf,true);      // Send the reply
            Param = RxBuf[BCPParam1];       // Save parameter so we can receive next frame while processing this request
            Param2 = RxBuf[BCPParam2];       // Save parameter so we can receive next frame while processing this request
            SetChMaxVolume(Param, Param2);
            break;

          case BCTAudioFormat:              // Audio format set
            TxBuf[BCPType] = BCTAck;
            TxBuf[BCPParam1] = 0;
            TxBuf[BCPParam2] = 0;
            BCMessageSend(TxBuf,true);      // Send the reply
            Param = RxBuf[BCPParam1];       // Save parameter so we can receive next frame while processing this request
            WM8960_SetAudioFormat(Param);
            break;


          case BCTBrightness: // Set lamp brightness
            TxBuf[BCPType] = BCTAck;
            TxBuf[BCPParam1] = 0;
            TxBuf[BCPParam2] = 0;
            BCMessageSend(TxBuf, true);           // Send the reply
            Param = RxBuf[BCPParam1];       // Save parameter so we can receive next frame while processing this request
            Param2 = RxBuf[BCPParam2];       // Save parameter so we can receive next frame while processing this request
            if (Param == 1)
              LED1 = Param2;
            else if(Param == 2)
              LED2 = Param2;
            break;

          case BCTReset:                   // Volume set
            TxBuf[BCPType] = BCTAck;
            TxBuf[BCPParam1] = 0;
            TxBuf[BCPParam2] = 0;
            BCMessageSend(TxBuf,true);      // Send the reply
            Param = RxBuf[BCPParam1];       // Save parameter so we can receive next frame while processing this request
            BCMessageReceive(RxBuf);        // Kick off receive of next frame
            asm("jmp 0x0000");//reset
            break;

          default:  // Unknown command
            TxBuf[BCPType] = BCTNAck;
            TxBuf[BCPParam1] = BCNUnkownType;
            TxBuf[BCPParam2] = RxBuf[BCPType];
            BCMessageSend(TxBuf,true);      // Send the reply
           // BCMessageReceive(RxBuf);        // Kick off receive of next frame
            break;
        }

        //this send command tv change to 031-517-209 board
#if VideoTrackCtrl
        Uint8   VideoTrack;
        Uint8   SendVideoFlag;
        if(Volume > 47)
        {
          if(SendVideoFlag)
          {
            SendVideoFlag = false;

            if(Address == BCARightBay)
            {
              VideoTrack = 1;
            }
            else if(Address == BCALeftBay)
            {
              VideoTrack = 2;
            }

            TxBuf[BCPAddr] = Address << 4;
            TxBuf[BCPAddr] |= BDCLCD;
            TxBuf[BCPType]   = BCTPlayTrack;
            TxBuf[BCPParam1] = VideoTrack;
            TxBuf[BCPParam2] = 0;
            BCMessageSend(TxBuf, true);           // Send the reply
          }
        }
        else
        {
          SendVideoFlag = 1;
        }
#endif
      }


      //this for ctrl LED it itself
#ifdef CTRL_LED
      if(RxBuf[BCPType] == BCTVolume)
      {
        RceiveAddress = RxBuf[BCPAddr] & 0b1111;
        a_Volume[RceiveAddress-BCAOutput] = RxBuf[BCPParam1];

        if((a_Volume[RceiveAddress-BCAOutput] > 47) && (LastVolume[RceiveAddress-BCAOutput] > 47))//have volume
        {
          if((RceiveAddress) == Address)
          {
            LED1_ON();
          }
          else
          {
            LED1_OFF();
          }
        }

        i = 0;
        for(TempInt = 0; TempInt < 4; ) //all  volume off
        {
          if((a_Volume[TempInt] <= 47) && (LastVolume[TempInt] <= 47))
            i++;
          TempInt++;
        }

        if(i >= TempInt)
        {
          LED1_ON();
        }

        LastVolume[RceiveAddress-BCAOutput] = a_Volume[RceiveAddress-BCAOutput];
      }
#endif
      BCMessageReceive(RxBuf);        // Kick off receive of next frame
    }

  }