コード例 #1
0
ファイル: rpjtag_stateMachine.c プロジェクト: sstans/RpiJtag
//Entire file needs a rewrite, maybe routing table, for easy of transition in TAP controller
void UpdateState(int j_state, int iTMS)
{
    switch(j_state)
    {
    case JTAG_RESET:
        GPIO_SET(JTAG_TMS);
        for(i=0; i<5; i++) //make sure we are in run-test/idle
        {
            nop_sleep(WAIT);
            GPIO_CLR(JTAG_TCK);
            nop_sleep(WAIT);
            GPIO_SET(JTAG_TCK);
            nop_sleep(WAIT);
        }
        GPIO_CLR(JTAG_TCK);
        nop_sleep(WAIT);
        jtag_state=JTAG_RESET;
        break;
    case JTAG_AUTO: //auto called when TMS is high, this one does no TMS=1,TCK=1
        if((jtag_state & 0xFFE) < 15)
        {
            jtag_state++;
            if(jtag_state > 5)
                jtag_state = JTAG_RESET;
        }
        else if((jtag_state | 0x116) == 0x116) //if we are in UPDATE-IR/
            jtag_state = JTAG_DR_SCAN;
        break;
    }
}
コード例 #2
0
ファイル: rpjtag_stateMachine.c プロジェクト: sstans/RpiJtag
void syncJTAGs()
{
    GPIO_SET(JTAG_TMS);
    for(i=0; i<5; i++) //make sure we are in run-test/idle
    {
        nop_sleep(WAIT);
        GPIO_CLR(JTAG_TCK);
        nop_sleep(WAIT);
        GPIO_SET(JTAG_TCK);
        nop_sleep(WAIT);
    }
    GPIO_CLR(JTAG_TCK);
    nop_sleep(WAIT);

    send_cmd(0,0); //Idle clock
    send_cmd(0,1); //SELECT-DR-SCAN
    jtag_state = JTAG_DR_SCAN;
}
コード例 #3
0
ファイル: rpjtag_io.c プロジェクト: jack-h/RpiJtag
int setup_io()
{
    /* open /dev/mem */
    if ((mem_fd = open("/dev/mem", O_RDWR|O_SYNC) ) < 0)
    {
        printf("can't open /dev/mem \n");
        return -1;
    }
    
    /* mmap GPIO */
    gpio_map = mmap(
        NULL,                //Any adddress in our space will do
        BLOCK_SIZE,          //Map length
        PROT_READ|PROT_WRITE,// Enable reading & writting to mapped memory
        MAP_SHARED,          //Shared with other processes
        mem_fd,              //File to map
        GPIO_BASE);

    close(mem_fd); //No need to keep mem_fd open after mmap
    
    if (gpio_map == MAP_FAILED)
    {
        printf("mmap error %d\n", (int)gpio_map);
        return -2;
    }
    
    // Always use volatile pointer!
    gpio = (volatile unsigned *)gpio_map;
    
    INP_GPIO(JTAG_TCK);
    INP_GPIO(JTAG_TMS);
    INP_GPIO(JTAG_TDI);
    INP_GPIO(JTAG_TDO); //Receive output from Device to rpi

    nop_sleep(WAIT);

    OUT_GPIO(JTAG_TDI); //Send data from rpi to Device
    OUT_GPIO(JTAG_TMS);
    OUT_GPIO(JTAG_TCK);
    nop_sleep(WAIT);

    return 0;
}