Sophie Dexter
/
Just4Trionic
Just4Trionic - CAN and BDM FLASH programmer for Saab cars
Diff: bdmcpu32.cpp
- Revision:
- 4:682d96ff6d79
- Parent:
- 2:bf3a2b29259a
- Child:
- 5:1775b4b13232
--- a/bdmcpu32.cpp Tue Jun 07 12:23:28 2011 +0000 +++ b/bdmcpu32.cpp Wed Sep 11 11:55:51 2013 +0000 @@ -1217,6 +1217,7 @@ return (bdm_response == BDM_CMDCMPLTE); } + //----------------------------------------------------------------------------- /** Writes a word to target MCU via BDM line and gets the response. @@ -1254,6 +1255,42 @@ //----------------------------------------------------------------------------- /** Writes a word to target MCU via BDM line and gets the response. + + @param value value to write + @param num_bits value size, bits +*/ +/* +void bdm_clk_fast(uint16_t value, uint8_t num_bits) { +// PIN_BKPT.output(); + PIN_DSI.output(); + // clock the value via BDM + bdm_response = ((uint32_t)value) << (32 - num_bits); +// bool dsi; + while (num_bits--) { + + // falling edge on BKPT/DSCLK + PIN_BKPT.write(0); + // set DSI bit + PIN_DSI.write(bdm_response & 0x80000000); + bdm_response <<= 1; + // read DSO bit + bdm_response |= PIN_DSO.read(); + // short delay +// for (uint8_t c = 1; c; c--); +// wait_us(1); + // rising edge on BKPT/DSCLK + PIN_BKPT.write(1); + // short delay + for (uint8_t c = 1; c; c--); +// wait_us(1); + } + PIN_DSI.input(); +} +//*/ + +//----------------------------------------------------------------------------- +/** + Writes a word to target MCU via BDM line and gets the response. This 'fast' version can be used once the 68332 has been 'prepped' because the BDM interface can go twice as fast once the 68332 clock is increased from 8 MHz to 16 MHz @@ -1261,6 +1298,8 @@ @param value value to write @param num_bits value size, bits */ + +//* void bdm_clk_fast(uint16_t value, uint8_t num_bits) { //Set BKPT @@ -1277,24 +1316,38 @@ while (num_bits--) { // set DSI bit // LPC_GPIO2->FIOPIN = ((bool)(bdm_response & 0x80000000) << 2); - if (bdm_response & 0x80000000) - LPC_GPIO2->FIOSET = (1 << 2); - else - LPC_GPIO2->FIOCLR = (1 << 2); + //if (bdm_response & 0x80000000) + // LPC_GPIO2->FIOSET = (1 << 2); + //else + // LPC_GPIO2->FIOCLR = (1 << 2); + + (bdm_response & 0x80000000) ? LPC_GPIO2->FIOSET = (1 << 2) : LPC_GPIO2->FIOCLR = (1 << 2); + + //*((volatile unsigned int *)0x23380a88) = (bool)(bdm_response & 0x80000000); + //*((volatile unsigned int *)0x23380a88) = bdm_response >> 31; + //*((volatile unsigned int *)0x23380a9c) = 1; + //used to set the P2.7 pin is slower (about 3 cycles) than this one + //GPIO2->FIOPIN=0x80 // falling edge on BKPT/DSCLK LPC_GPIO2->FIOCLR = (1 << 4); + //*((volatile unsigned int *)0x23380a90) = 0; // for (uint8_t c = 1; c; c--); // // read DSO bit // (bdm_response <<= 1) |= (bool)((LPC_GPIO0->FIOPIN) & (1 << 11)); -- OLD CONNECTION to PIN 27 (bdm_response <<= 1) |= (bool)((LPC_GPIO2->FIOPIN) & (1 << 1)); + //(bdm_response <<= 1) |= *((volatile unsigned int *)0x23380a84); // rising edge on BKPT/DSCLK LPC_GPIO2->FIOSET = (1 << 4); + //*((volatile unsigned int *)0x23380a90) = 1; for (uint8_t c = 1; c; c--); } //Make DSI an input LPC_GPIO2->FIODIR &= ~(1 << 2); // LPC_GPIO2->FIOMASK = mask; } + +//*/ + //----------------------------------------------------------------------------- /** Clears the BDM interface after errors.