Esempio n. 1
0
File: init.c Progetto: cpizano/lk
void target_early_init(void)
{
	// UART1 on P6.4 (TX) and P2.1 (RX)
	// LpcXpresso4337 P4 FTDI header
	pin_config(PIN(6,4), PIN_MODE(2) | PIN_PLAIN);
	pin_config(PIN(2,1), PIN_MODE(1) | PIN_PLAIN | PIN_INPUT);
}
Esempio n. 2
0
static void ispDetachFromDevice()
{
    /* ensure we have no pull-ups active */
    PIN_MODE(ISP_SCK, INPUT);
    PIN_MODE(ISP_MOSI, INPUT);
    PIN_MODE(ISP_RST, INPUT);

    DIGITAL_WRITE(ISP_SCK, LOW);
    DIGITAL_WRITE(ISP_MOSI, LOW);
   
    LED_TX_OFF();
}
Esempio n. 3
0
static void ispAttachToDevice(_u8 stk500Delay, _u8 stabDelay)
{

    if(stk500Delay == 0){ /* 1.8 MHz nominal */
        ispClockDelay = 0;
    }else if(stk500Delay == 1){ /* 460 kHz nominal */
        ispClockDelay = 0;
    }else if(stk500Delay == 2){ /* 115 kHz nominal */
        ispClockDelay = 1;
    }else if(stk500Delay == 3){ /* 58 kHz nominal */
        ispClockDelay = 2;
    }else{
        /* from STK500v2 spec: stk500Delay = 1/(24 * SCK / 7.37 MHz) - 10/12
         * definition of ispClockDelay = 1 + 1/(SCK/MHz * 2 * TIMER_TICK_US)
         * ispClockDelay = 1 + (stk500Delay + 10/12) * 12 / (TIMER_TICK_US * 7.37)
         */
#if F_CPU > 14000000L    /* ~ 16 MHz */
        ispClockDelay = (stk500Delay + 1)/2 - (stk500Delay + 1)/8 + (stk500Delay + 1)/32;
#else   /* must be 12 MHz */
        ispClockDelay = (stk500Delay + 1)/4 + (stk500Delay + 1)/16;
#endif
    }

    LED_TX_ON();
    /* turn on power for programming sockets: */
    PIN_MODE(ISP_SCK, OUTPUT);
    PIN_MODE(ISP_MOSI,OUTPUT);

//    delay(200);   /* allow device to power up */
    PIN_MODE(ISP_RST,OUTPUT);

    delay(stabDelay);
    
    timerTicksDelay(ispClockDelay); /* stabDelay may have been 0 */
    DIGITAL_WRITE(ISP_RST, HIGH);   /* give positive RESET pulse */
    timerTicksDelay(ispClockDelay);
    DIGITAL_WRITE(ISP_RST, LOW);   /* bring RESET back low */
}
Esempio n. 4
0
File: jtag.c Progetto: 0xBADCA7/lk
static void gpio_init(void) {
	pin_config(PIN_LED, PIN_MODE(0) | PIN_PLAIN);
	pin_config(PIN_RESET, PIN_MODE(4) | PIN_PLAIN);
	pin_config(PIN_RESET_TXEN, PIN_MODE(4) | PIN_PLAIN);
	pin_config(PIN_TMS_TXEN, PIN_MODE(0) | PIN_PLAIN);

	pin_config(PIN_TDO, PIN_MODE(6) | PIN_PLAIN | PIN_INPUT | PIN_FAST);
	pin_config(PIN_TCK, PIN_MODE(6) | PIN_PLAIN | PIN_FAST);
	pin_config(PIN_TDI, PIN_MODE(6) | PIN_PLAIN | PIN_FAST);
	pin_config(PIN_TMS, PIN_MODE(6) | PIN_PLAIN | PIN_FAST);

	gpio_set(GPIO_LED, 0);
	gpio_set(GPIO_RESET, 1);
	gpio_set(GPIO_RESET_TXEN, 0);
	gpio_set(GPIO_TMS_TXEN, 1);

	gpio_config(GPIO_LED, GPIO_OUTPUT);
	gpio_config(GPIO_RESET, GPIO_OUTPUT);
	gpio_config(GPIO_RESET_TXEN, GPIO_OUTPUT);
	gpio_config(GPIO_TMS_TXEN, GPIO_OUTPUT);
}