Exemplo n.º 1
0
void mcsdl_delay_test(INT32 nCount)
{
	INT16 i;

	MELFAS_DISABLE_BASEBAND_ISR();					// Disable Baseband touch interrupt ISR.
	MELFAS_DISABLE_WATCHDOG_TIMER_RESET();			// Disable Baseband watchdog timer

	//--------------------------------
	//	Repeating 'nCount' times
	//--------------------------------

	MCSDL_SET_GPIO_I2C();
	MCSDL_GPIO_SCL_SET_OUTPUT(0);
	MCSDL_GPIO_SDA_SET_OUTPUT(0);
	MCSDL_RESETB_SET_OUTPUT(0);

	MCSDL_GPIO_SCL_SET_HIGH();

	for( i=0; i<nCount; i++ ){

		#if 1

		MCSDL_GPIO_SCL_SET_LOW();

		mcsdl_delay(MCSDL_DELAY_20US);

		MCSDL_GPIO_SCL_SET_HIGH();

		mcsdl_delay(MCSDL_DELAY_100US);

		#elif 0

		MCSDL_GPIO_SCL_SET_LOW();

	   	mcsdl_delay(MCSDL_DELAY_500US);

		MCSDL_GPIO_SCL_SET_HIGH();

    	mcsdl_delay(MCSDL_DELAY_1MS);

		#else

		MCSDL_GPIO_SCL_SET_LOW();

    	mcsdl_delay(MCSDL_DELAY_25MS);

		TKEY_INTR_SET_LOW();

    	mcsdl_delay(MCSDL_DELAY_45MS);

		TKEY_INTR_SET_HIGH();

    	#endif
	}

	MCSDL_GPIO_SCL_SET_HIGH();

	MELFAS_ROLLBACK_BASEBAND_ISR();					// Roll-back Baseband touch interrupt ISR.
	MELFAS_ROLLBACK_WATCHDOG_TIMER_RESET();			// Roll-back Baseband watchdog timer
}
Exemplo n.º 2
0
//--------------------------------------------
//
//   Write ISP Mode entering signal
//
//--------------------------------------------
static void mcsdl_write_download_mode_signal(void)
{
    int    i;

    UINT8 enter_code[14] = { 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 0, 0, 1, 1 };

    //---------------------------
    // ISP mode signal 0
    //---------------------------

    for(i=0; i<14; i++){

        if( enter_code[i] )    {

            TKEY_RESETB_SET_HIGH();
            TKEY_INTR_SET_HIGH();

        }else{

            TKEY_RESETB_SET_LOW();
            TKEY_INTR_SET_LOW();
        }

        TKEY_I2C_SCL_SET_HIGH();

        mcsdl_delay(MCSDL_DELAY_15US);

        TKEY_I2C_SCL_SET_LOW();

        TKEY_RESETB_SET_LOW();
        TKEY_INTR_SET_LOW();

        mcsdl_delay(MCSDL_DELAY_100US);

   }

    TKEY_I2C_SCL_SET_HIGH();

    mcsdl_delay(MCSDL_DELAY_100US);

    TKEY_INTR_SET_HIGH();
    TKEY_RESETB_SET_HIGH();
}
//------------------------------------------------------------------
//
//   Enter Download mode ( MDS ISP or I2C ISP )
//
//------------------------------------------------------------------
static int mcsdl_enter_download_mode(void)
{
    BOOLEAN    bRet;
    int        nRet = MCSDL_RET_ENTER_DOWNLOAD_MODE_FAILED;

    UINT8     cData=0;

    //--------------------------------------------
    // Tkey module reset
    //--------------------------------------------

//    TKEY_VDD_SET_LOW();
    TKEY_CE_SET_LOW();
//    TKEY_CE_SET_OUTPUT();

    TKEY_I2C_CLOSE();

	TKEY_INTR_SET_OUTPUT();
    TKEY_INTR_SET_LOW();

//    TKEY_RESETB_SET_LOW();
//   TKEY_RESETB_SET_OUTPUT();

    mcsdl_delay(MCSDL_DELAY_45MS);                        // Delay for Stable VDD
    mcsdl_delay(MCSDL_DELAY_45MS);

//    TKEY_VDD_SET_HIGH();

    TKEY_CE_SET_HIGH();

    TKEY_I2C_SDA_SET_HIGH();

    mcsdl_delay(MCSDL_DELAY_25MS);                         // Delay '25 msec'

    //-------------------------------
    // Write 1st signal
    //-------------------------------
    mcsdl_write_download_mode_signal();

    mcsdl_delay(MCSDL_DELAY_1MS);                         // Delay '2 msec'
    mcsdl_delay(MCSDL_DELAY_1MS);

    //-------------------------------
    // Check response
    //-------------------------------

    bRet = _i2c_read_( MCSDL_I2C_SLAVE_ADDR_ORG, &cData, 1 );

    if( bRet != TRUE || cData != MCSDL_I2C_SLAVE_READY_STATUS ){

        printk("mcsdl_enter_download_mode() returns - ret : 0x%x & cData : 0x%x\n", nRet, cData);
        goto MCSDL_ENTER_DOWNLOAD_MODE_FINISH;
    }

    nRet = MCSDL_RET_SUCCESS;

    //-----------------------------------
    // Entering MDS ISP mode finished.
    //-----------------------------------

MCSDL_ENTER_DOWNLOAD_MODE_FINISH:

   return nRet;
}