Ejemplo n.º 1
0
rtk_int32 smi_reset(rtk_uint32 port, rtk_uint32 pinRST)
{
#if defined(MDC_MDIO_OPERATION) || defined(SPI_OPERATION)

#else
    gpioID gpioId;
    rtk_int32 res;

    /* Initialize GPIO port A, pin 7 as SMI RESET */
    gpioId = GPIO_ID(port, pinRST);
    res = _rtl865x_initGpioPin(gpioId, GPIO_PERI_GPIO, GPIO_DIR_OUT, GPIO_INT_DISABLE);
    if (res != RT_ERR_OK)
        return res;
    smi_RST = gpioId;

    _rtl865x_setGpioDataBit(smi_RST, 1);
    CLK_DURATION(1000000);
    _rtl865x_setGpioDataBit(smi_RST, 0);
    CLK_DURATION(1000000);
    _rtl865x_setGpioDataBit(smi_RST, 1);
    CLK_DURATION(1000000);

    /* change GPIO pin to Input only */
    _rtl865x_initGpioPin(smi_RST, GPIO_PERI_GPIO, GPIO_DIR_IN, GPIO_INT_DISABLE);
#endif
    return RT_ERR_OK;
}
Ejemplo n.º 2
0
void _smi_stop(void)
{

	CLK_DURATION(DELAY);
	_rtl865x_setGpioDataBit(smi_SDA, 0);	
	_rtl865x_setGpioDataBit(smi_SCK, 1);	
	CLK_DURATION(DELAY);
	_rtl865x_setGpioDataBit(smi_SDA, 1);	
	CLK_DURATION(DELAY);
	_rtl865x_setGpioDataBit(smi_SCK, 1);
	CLK_DURATION(DELAY);
	_rtl865x_setGpioDataBit(smi_SCK, 0);
	CLK_DURATION(DELAY);
	_rtl865x_setGpioDataBit(smi_SCK, 1);

    /* add a click */
	CLK_DURATION(DELAY);
	_rtl865x_setGpioDataBit(smi_SCK, 0);
	CLK_DURATION(DELAY);
	_rtl865x_setGpioDataBit(smi_SCK, 1);


	/* change GPIO pin to Output only */
	_rtl865x_initGpioPin(smi_SDA, GPIO_PERI_GPIO, GPIO_DIR_IN, GPIO_INT_DISABLE);
	_rtl865x_initGpioPin(smi_SCK, GPIO_PERI_GPIO, GPIO_DIR_IN, GPIO_INT_DISABLE);


}
Ejemplo n.º 3
0
Archivo: smi.c Proyecto: janfj/dd-wrt
void _smi_stop(void)
{

    CLK_DURATION(DELAY);
    _rt2880_setGpioDataBit(smi_SDA, 0);
    _rt2880_setGpioDataBit(smi_SCK, 1);
    CLK_DURATION(DELAY);
    _rt2880_setGpioDataBit(smi_SDA, 1);
    CLK_DURATION(DELAY);
    _rt2880_setGpioDataBit(smi_SCK, 1);
    CLK_DURATION(DELAY);
    _rt2880_setGpioDataBit(smi_SCK, 0);
    CLK_DURATION(DELAY);
    _rt2880_setGpioDataBit(smi_SCK, 1);

    /* add a click */
    CLK_DURATION(DELAY);
    _rt2880_setGpioDataBit(smi_SCK, 0);
    CLK_DURATION(DELAY);
    _rt2880_setGpioDataBit(smi_SCK, 1);


    /* change GPIO pin to Output only */
    _rt2880_initGpioPin(smi_SDA, RT2880GPIO_DIR_IN);
    _rt2880_initGpioPin(smi_SCK, RT2880GPIO_DIR_IN);


}
Ejemplo n.º 4
0
static void _smi_stop(void)
{

    CLK_DURATION(DELAY);
    GPIO_DATA_SET(smi_SDA, 0);
    GPIO_DATA_SET(smi_SCK, 1);
    CLK_DURATION(DELAY);
    GPIO_DATA_SET(smi_SDA, 1);
    CLK_DURATION(DELAY);
    GPIO_DATA_SET(smi_SCK, 1);
    CLK_DURATION(DELAY);
    GPIO_DATA_SET(smi_SCK, 0);
    CLK_DURATION(DELAY);
    GPIO_DATA_SET(smi_SCK, 1);

    /* add a click */
    CLK_DURATION(DELAY);
    GPIO_DATA_SET(smi_SCK, 0);
    CLK_DURATION(DELAY);
    GPIO_DATA_SET(smi_SCK, 1);


    /* change GPIO pin to Input only */
    GPIO_DIRECTION_SET(smi_SDA, GPIO_DIR_IN);
    GPIO_DIRECTION_SET(smi_SCK, GPIO_DIR_IN);
}
Ejemplo n.º 5
0
void _smi_writeBit(uint16 signal, uint32 bitLen)
{
	for( ; bitLen > 0; bitLen--)
	{
		CLK_DURATION(DELAY);

		/* prepare data */
		if ( signal & (1<<(bitLen-1)) ) 
			_rtl865x_setGpioDataBit(smi_SDA, 1);	
		else 
			_rtl865x_setGpioDataBit(smi_SDA, 0);	
		CLK_DURATION(DELAY);

		/* clocking */
		_rtl865x_setGpioDataBit(smi_SCK, 1);
		CLK_DURATION(DELAY);
		_rtl865x_setGpioDataBit(smi_SCK, 0);
	}
}
Ejemplo n.º 6
0
static void _smi_writeBit(rtk_uint16 signal, rtk_uint32 bitLen)
{
    for( ; bitLen > 0; bitLen--)
    {
        CLK_DURATION(DELAY);

        /* prepare data */
        if ( signal & (1<<(bitLen-1)) )
            GPIO_DATA_SET(smi_SDA, 1);
        else
            GPIO_DATA_SET(smi_SDA, 0);
        CLK_DURATION(DELAY);

        /* clocking */
        GPIO_DATA_SET(smi_SCK, 1);
        CLK_DURATION(DELAY);
        GPIO_DATA_SET(smi_SCK, 0);
    }
}
Ejemplo n.º 7
0
void _smi_start(void)
{

	/* change GPIO pin to Output only */
	_rtl865x_initGpioPin(smi_SDA, GPIO_PERI_GPIO, GPIO_DIR_OUT, GPIO_INT_DISABLE);
	_rtl865x_initGpioPin(smi_SCK, GPIO_PERI_GPIO, GPIO_DIR_OUT, GPIO_INT_DISABLE);
	
	/* Initial state: SCK: 0, SDA: 1 */
	_rtl865x_setGpioDataBit(smi_SCK, 0);
	_rtl865x_setGpioDataBit(smi_SDA, 1);
	CLK_DURATION(DELAY);

	/* CLK 1: 0 -> 1, 1 -> 0 */
	_rtl865x_setGpioDataBit(smi_SCK, 1);
	CLK_DURATION(DELAY);
	_rtl865x_setGpioDataBit(smi_SCK, 0);
	CLK_DURATION(DELAY);

	/* CLK 2: */
	_rtl865x_setGpioDataBit(smi_SCK, 1);
	CLK_DURATION(DELAY);
	_rtl865x_setGpioDataBit(smi_SDA, 0);
	CLK_DURATION(DELAY);
	_rtl865x_setGpioDataBit(smi_SCK, 0);
	CLK_DURATION(DELAY);
	_rtl865x_setGpioDataBit(smi_SDA, 1);

}
Ejemplo n.º 8
0
Archivo: smi.c Proyecto: janfj/dd-wrt
void _smi_start(void)
{
    /* change GPIO pin to Output only */
    _rt2880_initGpioPin(smi_SDA, RT2880GPIO_DIR_OUT);
    _rt2880_initGpioPin(smi_SCK, RT2880GPIO_DIR_OUT);

    /* Initial state: SCK: 0, SDA: 1 */
    _rt2880_setGpioDataBit(smi_SCK, 0);
    _rt2880_setGpioDataBit(smi_SDA, 1);
    CLK_DURATION(DELAY);

    /* CLK 1: 0 -> 1, 1 -> 0 */
    _rt2880_setGpioDataBit(smi_SCK, 1);
    CLK_DURATION(DELAY);
    _rt2880_setGpioDataBit(smi_SCK, 0);
    CLK_DURATION(DELAY);

    /* CLK 2: */
    _rt2880_setGpioDataBit(smi_SCK, 1);
    CLK_DURATION(DELAY);
    _rt2880_setGpioDataBit(smi_SDA, 0);
    CLK_DURATION(DELAY);
    _rt2880_setGpioDataBit(smi_SCK, 0);
    CLK_DURATION(DELAY);
    _rt2880_setGpioDataBit(smi_SDA, 1);
}
Ejemplo n.º 9
0
static void _smi_start(void)
{

    /* change GPIO pin to Output only */
    //GPIO_DIRECTION_SET(smi_SDA, GPIO_DIR_OUT);
    GPIO_DIRECTION_SET(smi_SCK, GPIO_DIR_OUT);
    GPIO_DIRECTION_SET(smi_SDA, GPIO_DIR_OUT);

    /* Initial state: SCK: 0, SDA: 1 */
    GPIO_DATA_SET(smi_SCK, 0);
    GPIO_DATA_SET(smi_SDA, 1);
    CLK_DURATION(DELAY);

    /* CLK 1: 0 -> 1, 1 -> 0 */
    GPIO_DATA_SET(smi_SCK, 1);
    CLK_DURATION(DELAY);
    GPIO_DATA_SET(smi_SCK, 0);
    CLK_DURATION(DELAY);

    /* CLK 2: */
    GPIO_DATA_SET(smi_SCK, 1);
    CLK_DURATION(DELAY);
    GPIO_DATA_SET(smi_SDA, 0);
    CLK_DURATION(DELAY);
    GPIO_DATA_SET(smi_SCK, 0);
    CLK_DURATION(DELAY);
    GPIO_DATA_SET(smi_SDA, 1);

}
Ejemplo n.º 10
0
Archivo: smi.c Proyecto: janfj/dd-wrt
void _smi_readBit(uint32 bitLen, uint32 *rData)
{
    uint32 u;

    /* change GPIO pin to Input only */
    _rt2880_initGpioPin(smi_SDA,RT2880GPIO_DIR_IN);

    for (*rData = 0; bitLen > 0; bitLen--)
    {
        CLK_DURATION(DELAY);

        /* clocking */
        _rt2880_setGpioDataBit(smi_SCK, 1);
        CLK_DURATION(DELAY);
        _rt2880_getGpioDataBit(smi_SDA, &u);
        _rt2880_setGpioDataBit(smi_SCK, 0);
        *rData |= (u << (bitLen - 1));
    }

    /* change GPIO pin to Output only */
    _rt2880_initGpioPin(smi_SDA, RT2880GPIO_DIR_OUT);
}
Ejemplo n.º 11
0
void _smi_readBit(uint32 bitLen, uint32 *rData) 
{
	uint32 u;

	/* change GPIO pin to Input only */
	_rtl865x_initGpioPin(smi_SDA, GPIO_PERI_GPIO, GPIO_DIR_IN, GPIO_INT_DISABLE);

	for (*rData = 0; bitLen > 0; bitLen--)
	{
		CLK_DURATION(DELAY);

		/* clocking */
		_rtl865x_setGpioDataBit(smi_SCK, 1);
		CLK_DURATION(DELAY);
		_rtl865x_getGpioDataBit(smi_SDA, &u);
		_rtl865x_setGpioDataBit(smi_SCK, 0);

		*rData |= (u << (bitLen - 1));
	}

	/* change GPIO pin to Output only */
	_rtl865x_initGpioPin(smi_SDA, GPIO_PERI_GPIO, GPIO_DIR_OUT, GPIO_INT_DISABLE);
}
Ejemplo n.º 12
0
static void _smi_readBit(rtk_uint32 bitLen, rtk_uint32 *rData)
{
    rtk_uint32 u;

    /* change GPIO pin to Input only */
    GPIO_DIRECTION_SET(smi_SDA, GPIO_DIR_IN);

    for (*rData = 0; bitLen > 0; bitLen--)
    {
        CLK_DURATION(DELAY);

        /* clocking */
        GPIO_DATA_SET(smi_SCK, 1);
        CLK_DURATION(DELAY);
        GPIO_DATA_GET(smi_SDA, &u);
        GPIO_DATA_SET(smi_SCK, 0);

        *rData |= (u << (bitLen - 1));
    }

    /* change GPIO pin to Output only */
    GPIO_DIRECTION_SET(smi_SDA, GPIO_DIR_OUT);
}
Ejemplo n.º 13
0
int32 smi_reset(uint32 port, uint32 pinRST)
{
	gpioID gpioId;
	int32 res;

	/* Initialize GPIO port A, pin 7 as SMI RESET */
	gpioId = GPIO_ID(port, pinRST);
	res = _rtl865x_initGpioPin(gpioId, GPIO_PERI_GPIO, GPIO_DIR_OUT, GPIO_INT_DISABLE);
	if (res != SUCCESS)
		return res;
	smi_RST = gpioId;

	_rtl865x_setGpioDataBit(smi_RST, 1);
	CLK_DURATION(1000000);
	_rtl865x_setGpioDataBit(smi_RST, 0);	
	CLK_DURATION(1000000);
	_rtl865x_setGpioDataBit(smi_RST, 1);
	CLK_DURATION(1000000);

	/* change GPIO pin to Input only */
	_rtl865x_initGpioPin(smi_RST, GPIO_PERI_GPIO, GPIO_DIR_IN, GPIO_INT_DISABLE);

	return SUCCESS;
}
Ejemplo n.º 14
0
void test_smi_signal_and_wait()
{
        int i;
        for (i=0; i<100; i++)
        {
                rtk_uint32 data;
                rtk_api_ret_t retVal;

            if((retVal = rtl8367b_getAsicReg(0x1202, &data)) != RT_ERR_OK)
            {
                        printf("error = %d\n", retVal);
                }
                printf("data = %x\n", data);
                if (data == 0x88a8) break;

            CLK_DURATION(50000);
        }
}