⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 l2_global.c

📁 dz3000_51.0.0.4.rar
💻 C
📖 第 1 页 / 共 4 页
字号:
  //PRINT_L2("        L2_ConfigGPIOByte: Exit\n");

  return(status);
}

//-----------------------------------------------------------------------------
//L2_SetGPIOBit
//-----------------------------------------------------------------------------
/*
routine description:
    Set the value of one GPIO. The function is used in the GPIO pins of output
  type and only controls one GPIO pin when the function is called once. There
  is a table to map the GPIO index to the pin number on SPCA533.

arguments:
  Index: the index of a GPIO pin
  Value: when it is zero, the corresponding GPIO will be cleared;
         otherwise the GPIO will be set.

return value:
  0x00   - success
  0x01   - general error
  0x02   - parameter error
  others - error
*/

UCHAR L2_SetGPIOBit(UCHAR Index, UCHAR Value) USING_0
{
  UCHAR BitNum;
  USHORT Addr;
  UCHAR tmp0, tmp1;
  UCHAR status;

  status = L2K_SUCCESS;

  //body
  //PRINT_L2("        L2_SetGPIOBit: Enter\n");

  BitNum = Index&0x07;
  Addr = 0x2030|(USHORT)(Index>>3);
  tmp0 = XBYTE[Addr];
  
  if(Addr == 0x2030)
  {
  
    //UI_PrintOSDString("way 2", 7, 2 , 2);       
  
   if((BitNum == 0x06)&&(Value ==0))
       { 
       	//UI_PrintOSDNumber(BitNum, 7, 3 , 2);
         return(status);
       }  
  }       
         
  tmp1 = 0x01<<BitNum;
  if(Value)
         XBYTE[Addr] = tmp0|tmp1;
  else
         XBYTE[Addr] = tmp0&(~tmp1);
  // return
  //PRINT_L2("        L2_SetGPIOBit: Exit\n");

  return(status);
}

//-----------------------------------------------------------------------------
//L2_SetGPIOByte
//-----------------------------------------------------------------------------
/*
routine description:
    Set the value of eight GPIOs.  There is a table to map the GPIO index to
  the pin number on SPCA533.

arguments:
  Index: the index of eight GPIO pins
  Value: when it is zero, the corresponding GPIO will be cleared;
         otherwise the GPIO will be set.

return value:
  0x00   - success
  0x01   - general error
  0x02   - parameter error
  others - error
*/

UCHAR L2_SetGPIOByte(UCHAR Index, UCHAR Value) USING_0
{
  USHORT Addr;
  UCHAR status;

  status = L2K_SUCCESS;

  //body
  //PRINT_L2("        L2_SetGPIOByte: Enter\n");

  Addr = 0x2030|(USHORT)(Index>>3);
  XBYTE[Addr] = Value;

  // return
  //PRINT_L2("        L2_SetGPIOByte: Exit\n");

  return(status);
}

//-----------------------------------------------------------------------------
//L2_GetGPIOBit
//-----------------------------------------------------------------------------
/*
routine description:
    Get the value of one GPIO. The function only controls one GPIO pin when
  the function is called once.

arguments:
  Index: the index of a GPIO pin
  *ValuePt: when it is zero, the corresponding GPIO is cleared;
            otherwise the GPIO is set.

return value:
  0x00   - success
  0x01   - general error
  0x02   - parameter error
  others - error
*/

UCHAR L2_GetGPIOBit(UCHAR Index, PUCHAR GPIOBitValPt) USING_0
{
  UCHAR BitNum;
  USHORT Addr;
  UCHAR tmp0, tmp1;
  UCHAR status;

  status = L2K_SUCCESS;

  //PRINT_L2("        L2_GetGPIOBit: Enter\n");

  BitNum = Index&0x07;
  Addr = 0x2040|(USHORT)(Index>>3);
  tmp0 = XBYTE[Addr];
  tmp1 = 0x01<<BitNum;
  *GPIOBitValPt = tmp0&tmp1;

  //PRINT_L2("        L2_GetGPIOBit: GPIO Bit Value = %bx\n", *GPIOBitValPt);
  //PRINT_L2("        L2_GetGPIOBit: Exit\n");

  return(status);
}

//-----------------------------------------------------------------------------
//L2_GetGPIOByte
//-----------------------------------------------------------------------------
/*
routine description:
    Get value of one group GPIOs. The function controls a group of GPIO pins
  whose number is not greater than eight when the function is called once.

arguments:
  *ValuePt: each bit is responded to the state of one GPIO. If the bit value is
            zero, the corresponding GPIO is cleared; otherwise the GPIO is set.

return value:
  0x00   - success
  0x01   - general error
  0x02   - parameter error
  others - error
*/

UCHAR L2_GetGPIOByte (UCHAR Index, UCHAR *GPIOByteValPt) USING_0
{
  USHORT Addr;
  UCHAR status;

  status = L2K_SUCCESS;

  //PRINT_L2("        L2_GetGPIOByte: Enter\n");

  Addr = 0x2040|(USHORT)(Index>>3);
  *GPIOByteValPt = XBYTE[Addr];

  //PRINT_L2("        L2_GetGPIOByte: GPIO Bit Value = %bx\n", *GPIOByteValPt);
  //PRINT_L2("        L2_GetGPIOByte: Exit\n");

  return(status);
}

//-----------------------------------------------------------------------------
//L2_InitGlobal
//-----------------------------------------------------------------------------
/*
routine description:
  Intialize the global module.

arguments:
  CamMode:
    	0: power-on mode initialization
        1: for preview mode initialization
        2: for still camera mode initialization (snap a still image)
        3: for video clip mode initialization
        4: for PC-camera mode initialization
        5: for playback mode initialization

return value:
  0x00   - success
  0x01   - general error
  0x02   - parameter error
  others - error
*/

UCHAR L2_InitGlobal(UCHAR CamMode) USING_0
{
  UCHAR status;
  //struct DATESTC RTC, Alarm;

  status = L2K_SUCCESS;

  //PRINT_L2("        L2_InitGlobal: Enter\n");

  switch(CamMode)
  {
    case 0:
    {
      L2_Resume(); //resume with CPU reset

      XBYTE[0x2005] = 0x01; //enable internal transceiver
      XBYTE[0x2006] = 0x01; //enable normal operation of DRAM signal output
      XBYTE[0x2056] = 0x00; //enable normal operation of internal SRAM clock control

/*
      XBYTE[0x2048] = 0x00; //GPIO rising event interrupt
      XBYTE[0x2049] = 0x00;
      XBYTE[0x204A] = 0x00;
      XBYTE[0x204B] = 0x00;
      XBYTE[0x204C] = 0x00;
      XBYTE[0x204D] = 0x00;
      XBYTE[0x2050] = 0xFF;
      XBYTE[0x2051] = 0xFF;
      XBYTE[0x2052] = 0xFF;
      XBYTE[0x2053] = 0xFF;
      XBYTE[0x2054] = 0xFF;
      XBYTE[0x2055] = 0xFF;

      XBYTE[0x2078] = 0x00; //GPIO falling event interrupt
      XBYTE[0x2079] = 0x00;
      XBYTE[0x207A] = 0x00;
      XBYTE[0x207B] = 0x00;
      XBYTE[0x207C] = 0x00;
      XBYTE[0x207D] = 0x00;
      XBYTE[0x2058] = 0xFF;
      XBYTE[0x2059] = 0xFF;
      XBYTE[0x205A] = 0xFF;
      XBYTE[0x205B] = 0xFF;
      XBYTE[0x205C] = 0xFF;
      XBYTE[0x205D] = 0xFF;

      XBYTE[0x20C0] = 0x00; //VD rising/falling interrupt
      XBYTE[0x20D0] = 0x30;

      XBYTE[0x20C0] = 0x00; //Timer interrupt
      XBYTE[0x20D0] = 0x04;

      RTC.Second = 30;
      RTC.Minute = 05;
      RTC.Hour = 21;
      RTC.Day = 6;
      RTC.Month = 12;
      RTC.Year = 1;
      status = L2_WriteRTC(&RTC);

      Alarm.Second = 00;
      Alarm.Minute = 06;
      Alarm.Hour = 21;
      Alarm.Day = 6;
      Alarm.Month = 12;
      Alarm.Year = 1;
      status = L2_WriteAlarm(&Alarm);

      status = L3_WriteRTCData(0xC0, 0x00);
      status = L3_WriteRTCData(0xD0, 0x02);
*/

    }
    break;

    default:  break;
  }

  //PRINT_L2("        L2_InitGlobal: Exit\n");

  return(status);
}

//-----------------------------------------------------------------------------
//L2_SetTGPll
//-----------------------------------------------------------------------------
/*
routine description:
  Set the TG PLL to change TG PLL clock

arguments:
  FreqSel: The frequency selection of TG PLL clock
        0: disable
	1: 144 MHz
        2: 168 MHz

return value:
  0x00   - success
  0x01   - general error
  0x02   - parameter error
  others - error
*/

UCHAR L2_SetTGPll(UCHAR FreqSel) USING_0
{
  UCHAR status;

  status = L2K_SUCCESS;

  //body
  //PRINT_L2("        L2_SetTGPll: Enter\n");

  if(FreqSel==0)
  {
    XBYTE[0x2080] = 0x00;
  }
  else
  {
    XBYTE[0x2080] = 0x01;
    if(FreqSel==1)
    {
      XBYTE[0x2081] = 0x00;
      XBYTE[0x2082] = 0x53;
    }
    else
    {
      XBYTE[0x2081] = 0x00;
      XBYTE[0x2082] = 0x63;
    }
  }
  // return
  //PRINT_L2("        L2_SetTGPll: Exit\n");

  return(status);
}

//-----------------------------------------------------------------------------
//L2_ReadRevID
//-----------------------------------------------------------------------------
/*
routine description:
  Read the revision ID.

arguments:
  The revision ID:
                0: version "A"

return value:
  none
*/

void L2_ReadRevID(PUCHAR RevIDPt) USING_0
{
  //PRINT_L2("        L2_ReadRevID: Enter\n");

  *RevIDPt = XBYTE[0x20FF];

  //PRINT_L2("        L2_ReadRevID: RevID = %bx\n", *RevIDPt);

  //PRINT_L2("        L2_ReadRevID: Exit\n");

  return;
}

//-----------------------------------------------------------------------------
//L2_SetCamMode
//-----------------------------------------------------------------------------
/*
routine description:
    Set camera operation mode, the related initialization must be done before
  calling this function.

arguments:
  CamMode: the camera operation mode
        0: idle mode
        1: preview mode
        2: still camera mode
        3: video clip mode
        4: PC-camera mode
        5: playback mode

return value:
  0x00	 - success
  others - error
*/

UCHAR L2_SetCamMode(UCHAR CamMode) USING_0
{
  UCHAR status;

  status = L2K_SUCCESS;

  //body
  //PRINT_L2("        L2_SetCamMode: Enter\n");

	//Joe@2003.3.12 9:21 add begin
	XBYTE[0x2000] = 0x00;
	//Joe@2003.3.12 9:22 add end

  XBYTE[0x2000] = CamMode;

  // return
  //PRINT_L2("        L2_SetCamMode: Exit\n");

  return(status);
}

//-----------------------------------------------------------------------------
//L2_GetCamMode
//-----------------------------------------------------------------------------
/*
routine description:
  Get camera operation mode.

arguments:
  *CamModePt: The camera operation mode

return value:
  0x00   - success
  0x01   - general error
  0x02   - parameter error
  others - error
*/

void L2_GetCamMode(PUCHAR CamModePt) USING_0
{
  //body
  //PRINT_L2("        L2_GetCamMode: Enter\n");

  *CamModePt = XBYTE[0x2000];

  // return
  //PRINT_L2("        L2_GetCamMode: Exit\n");

  return;
}

//-----------------------------------------------------------------------------
//L2_WaitVD
//-----------------------------------------------------------------------------
/*
routine description:
  Wait the vertical sync.

arguments:
  Mode: the selection of falling or rising edge
     0: the falling
     1: the rising edge
  Number: the number of vertical sync to wait

return value:
  0x00   - success
  0x01   - general error
  0x02   - parameter error
  others - error
*/

UCHAR L2_WaitVD(UCHAR Mode, UCHAR Number) USING_0
{
  UCHAR i;
  UCHAR status;

  status = L2K_SUCCESS;

  //body
  //PRINT_L2("        L2_WaitVD: Enter\n");

  if(Mode)
  {
    for(i=0;i<Number;i++)
    {
      while(XBYTE[0x20B0]==0x01);
      while(XBYTE[0x20B0]==0x00);
    }
  }
  else
  {
    for(i=0;i<Number;i++)
    {
      while(XBYTE[0x20B0]==0x00);
      while(XBYTE[0x20B0]==0x01);
    }
  }

  // return
  //PRINT_L2("        L2_WaitVD: Exit\n");

  return(status);
}

//-----------------------------------------------------------------------------
//L2_ReadIOTrap
//-----------------------------------------------------------------------------
/*
routine description:
  Read the IO trap value.

arguments:
  *IOTrapPt: the IO trap value

return value:
  none
*/

void L2_ReadIOTrap(PUCHAR IOTrapPt) USING_0
{
  //body
  //PRINT_L2("        L2_ReadIOTrap: Enter\n");

  *IOTrapPt = XBYTE[0x20B1];

  // return
  //PRINT_L2("        L2_ReadIOTrap: Exit\n");

  return;
}

//-----------------------------------------------------------------------------
//L2_RTCTransferText
//-----------------------------------------------------------------------------
//patch4.2@ada@0527 for timer
void L2_RTCTransferText(PDATE DateTime,PUCHAR TimeString) USING_0
{
     //year
     *TimeString = '2';
     *(TimeString + 1) = '0';
     *(TimeString + 2) = (DateTime->Year / 10) + '0';
     *(TimeString + 3) = (DateTime->Year % 10) + '0';

     //month
     //Joe@2003.3.12 19:50 add begin
     *(TimeString + 4) = ':';
     //Joe@2003.3.12 19:50 add end
     *(TimeString + 5) = (DateTime->Month / 10) + '0';
     *(TimeString + 6) = (DateTime->Month % 10) + '0';

     //day
     //Joe@2003.3.12 19:50 add begin
     *(TimeString + 7) = ':';
     //Joe@2003.3.12 19:50 add end
     *(TimeString + 8) = (DateTime->Day / 10) + '0';
     *(TimeString + 9) = (DateTime->Day % 10) + '0';

     //hour
     //Joe@2003.3.12 19:50 add begin
     *(TimeString + 10) = ' ';
     //Joe@2003.3.12 19:50 add end
     *(TimeString + 11) = (DateTime->Hour / 10) + '0';
     *(TimeString + 12) = (DateTime->Hour % 10) + '0';

     //minute
     //Joe@2003.3.12 19:50 add begin
     *(TimeString + 13) = ':';
     //Joe@2003.3.12 19:50 add end
     *(TimeString + 14) = (DateTime->Minute / 10) + '0';
     *(TimeString + 15) = (DateTime->Minute % 10) + '0';

     //second
     //Joe@2003.3.12 19:50 add begin
     *(TimeString + 16) = ':';
     //Joe@2003.3.12 19:50 add end
     *(TimeString + 17) = (DateTime->Second / 10) + '0';
     *(TimeString + 18) = (DateTime->Second % 10) + '0';

     //Joe@2003.3.12 19:50 add begin
     *(TimeString + 19) = '\0';
     //Joe@2003.3.12 19:50 add end
}

#ifdef TestModeEn

//-----------------------------------------------------------------------------
//L2_TestGlobal
//-----------------------------------------------------------------------------
/*
routine description:
  Test global module.

arguments:
  TestLevel: the level of test
          0: all test
          1: register read/write test
          2: SRAM test

return value:
  0x00   - success
  0x01   - general error
  0x02   - parameter error
  others - error
*/

UCHAR L2_TestGlobal(UCHAR TestLevel) USING_0
{
  UCHAR status;
  UCHAR Temp0;

  status = L2K_SUCCESS;

  //avoid warning
  Temp0 = TestLevel;

  //body
  //PRINT_L2("        L2_TestGlobal: Enter\n");

  // return
  //PRINT_L2("        L2_TestGlobal: Exit\n");

  return(status);
}

#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -