signed char fProgramTargetBlock(unsigned char bBankNumber, unsigned char bBlockNumber) { SendVector(set_block_num, num_bits_set_block_num); /* Set the drive here because SendByte() does not.*/ SetSDATAStrong(); SendByte(bBlockNumber, 8); SendByte(set_block_num_end, 3); /*Send the program-block vector. */ SendVector(program, num_bits_program); /*wait for acknowledge from target. */ fIsError = fDetectHiLoTransition(); if (fIsError != 0) return BLOCK_ERROR; /*Send the Wait-For-Poll-End vector*/ SendVector(wait_and_poll_end, num_bits_wait_and_poll_end); return PASS; /* PTJ: Don't do READ-STATUS here because that will PTJ: require that we return multiple error values, if error occurs */ }
// ============================================================================ // fProgramTargetBlock() // Program one block with data that has been loaded into a RAM buffer in the // target device. // Returns: // 0 if successful // BLOCK_ERROR if timed out on handshake to the device. // ============================================================================ signed char fProgramTargetBlock(unsigned char bBankNumber, unsigned char bBlockNumber) { SendVector(tsync_enable, num_bits_tsync_enable); SendVector(set_block_num, num_bits_set_block_num); // Set the drive here because SendByte() does not. SetSDATAStrong(); SendByte(bBlockNumber, 8); SendByte(set_block_num_end, 3); SendVector(tsync_disable, num_bits_tsync_disable); //PTJ: // Send the program-block vector. SendVector(program_and_verify, num_bits_program_and_verify); //PTJ: PROGRAM-AND-VERIFY // wait for acknowledge from target. if ((fIsError = fDetectHiLoTransition())) { return (BLOCK_ERROR); } // Send the Wait-For-Poll-End vector SendVector(wait_and_poll_end, num_bits_wait_and_poll_end); return (PASS); //PTJ: Don't do READ-STATUS here because that will //PTJ: require that we return multiple error values, if error occurs }
/*============================================================================ LoadTarget() Transfers data from array in Host to RAM buffer in the target. Returns the checksum of the data. ============================================================================*/ unsigned int iLoadTarget(void) { unsigned char bTemp; unsigned int iChecksumData = 0; /*Set SDATA to Strong Drive here because SendByte() does not */ SetSDATAStrong(); bTargetAddress = 0x00; bTargetDataPtr = 0x00; while (bTargetDataPtr < TargetDatabufLen) { bTemp = abTargetDataOUT[bTargetDataPtr]; iChecksumData += bTemp; SendByte(write_byte_start, 5); SendByte(bTargetAddress, 6); SendByte(bTemp, 8); SendByte(write_byte_end, 3); bTargetAddress += 4; bTargetDataPtr++; } return iChecksumData; }
/*============================================================================ LoadTarget() Transfers data from array in Host to RAM buffer in the target. Returns the checksum of the data. ============================================================================*/ unsigned int iLoadTarget(void) { unsigned char bTemp; unsigned int iChecksumData = 0; /*Set SDATA to Strong Drive here because SendByte() does not */ SetSDATAStrong(); bTargetAddress = 0x00; bTargetDataPtr = 0x00; while (bTargetDataPtr < TargetDatabufLen) { bTemp = abTargetDataOUT[bTargetDataPtr]; iChecksumData += bTemp; SendByte(write_byte_start, 4); /*PTJ: we need to be able to write 128 bytes from address 0x80 to 0xFF*/ SendByte(bTargetAddress, 7); /*PTJ: we need to be able to write 128 bytes from address 0x80 to 0xFF*/ SendByte(bTemp, 8); SendByte(write_byte_end, 3); bTargetAddress += 2; /*PTJ: inc by 2 in order to support a 128 byte address space, MSB~1 for address*/ bTargetDataPtr++; } return iChecksumData; }
// ============================================================================ // fSecureTargetFlash() // Before calling, load the array, abTargetDataOUT, with the desired security // settings using LoadArrayWithSecurityData(StartAddress,Length,SecurityType). // The can be called multiple times with different SecurityTypes as needed for // particular Flash Blocks. Or set them all the same using the call below: // LoadArrayWithSecurityData(0,SECURITY_BYTES_PER_BANK, 0); // Returns: // 0 if successful // SECURITY_ERROR if timed out on handshake to the device. // ============================================================================ signed char fSecureTargetFlash(void) { unsigned char bTemp; // Transfer the temporary RAM array into the target bTargetAddress = 0x00; bTargetDataPtr = 0x00; SetSDATAStrong(); while(bTargetDataPtr < SECURITY_BYTES_PER_BANK) { bTemp = abTargetDataOUT[bTargetDataPtr]; SendByte(write_byte_start,4); SendByte(bTargetAddress, 7); SendByte(bTemp, 8); SendByte(write_byte_end, 3); // SendBytes() uses MSBits, so increment the address by '2' to put // the 0..n address into the seven MSBit locations bTargetAddress += 2; //PTJ: inc by 2 in order to support a 128 byte address space bTargetDataPtr++; } SendVector(secure, num_bits_secure); //PTJ: if ((fIsError = fDetectHiLoTransition()) != PASS) { return(SECURITY_ERROR); } SendVector(wait_and_poll_end, num_bits_wait_and_poll_end); return(PASS); }
/* ============================================================================ // fProgramTargetBlock() // Program one block with data that has been loaded into a RAM buffer in the // target device. // Returns: // 0 if successful // BLOCK_ERROR if timed out on handshake to the device. ============================================================================*/ signed char fProgramTargetBlock(unsigned char bBankNumber, unsigned char bBlockNumber) { /* TSYNC should still be set when entering this function so this call is not necessary but added for insurance // SendVector(tsync_enable, num_bits_tsync_enable); // t */ SendVector(set_block_num, num_bits_set_block_num); /* Set the drive here because SendByte() does not. */ SetSDATAStrong(); SendByte(bBlockNumber, 8); SendByte(set_block_num_end, 3); SendVector(tsync_disable, num_bits_tsync_disable); /* Send the program-and-verify vector. */ SendVector(program_and_verify, num_bits_program_and_verify); /* wait for acknowledge from target. */ fIsError = fDetectHiLoTransition(); if (fIsError) return BLOCK_ERROR; /* Send the Wait-For-Poll-End vector */ SendVector(wait_and_poll_end, num_bits_wait_and_poll_end); return PASS; /* Don't do READ-STATUS here because that will // require that we return multiple error values, if error occurs */ }
signed char fSecureTargetFlash(void) { unsigned char bTemp; bTargetAddress = 0x00; bTargetDataPtr = 0x00; SetSDATAStrong(); while (bTargetDataPtr < SecurityBytesPerBank) { bTemp = abTargetDataOUT[bTargetDataPtr]; SendByte(write_byte_start, 5); SendByte(bTargetAddress, 6); SendByte(bTemp, 8); SendByte(write_byte_end, 3); bTargetAddress += 4; bTargetDataPtr++; } SendVector(secure, num_bits_secure); fIsError = fDetectHiLoTransition(); if (fIsError != 0) return SECURITY_ERROR; SendVector(wait_and_poll_end, num_bits_wait_and_poll_end); return PASS; }
// ============================================================================ // fVerifyTargetBlock() // Verify the block just written to. This can be done byte-by-byte before the // protection bits are set. // Returns: // 0 if successful // BLOCK_ERROR if timed out on handshake to the device. // ============================================================================ signed char fVerifyTargetBlock(unsigned char bBankNumber, unsigned char bBlockNumber) { SendVector(set_block_number, 11); //Set the drive here because SendByte() does not SetSDATAStrong(); SendByte(bBlockNumber, 8); SendByte(set_block_number_end, 3); SendVector(verify_setup_v, num_bits_verify_setup); if ((fIsError = fDetectHiLoTransition())) { return (BLOCK_ERROR); } SendVector(wait_and_poll_end, num_bits_wait_and_poll_end); bTargetAddress = 0; bTargetDataPtr = 0; while (bTargetDataPtr < TARGET_DATABUFF_LEN) { //Send Read Byte vector and then get a byte from Target SendVector(read_byte_v, 4); //PTJ 308: this was changed from sending the first 5 bits to sending the first 4 // Set the drive here because SendByte() does not SetSDATAStrong(); SendByte(bTargetAddress, 6); RunClock(2); // Run two SCLK cycles between writing and reading SetSDATAHiZ(); // Set to HiZ so Target can drive SDATA bTargetDataIN = bReceiveByte(); RunClock(1); SendVector(read_byte_v + 1, 1); // Send the ReadByte Vector End // Test the Byte that was read from the Target against the original // value (already in the 128-Byte array "abTargetDataOUT[]"). If it // matches, then bump the address & pointer,loop-back and continue. // If it does NOT match abort the loop and return an error. if (bTargetDataIN != abTargetDataOUT[bTargetDataPtr]) return (BLOCK_ERROR); bTargetDataPtr++; // Increment the address by four to accomodate 6-Bit addressing // (puts the 6-bit address into MSBit locations for "SendByte()"). bTargetAddress += 4; } return (PASS); }
/* ============================================================================ // SetBankNumber() // Set the bank number in the target device. // Returns: // none // ==========================================================================*/ void SetBankNumber(unsigned char bBankNumber) { /*Send the bank-select vector.*/ SendVector(set_bank_number, 33); /* Set the drive here because SendByte() does not.*/ SetSDATAStrong(); SendByte(bBankNumber, 8); SendVector(set_bank_number_end, 25); }
/* PTJ: ======================================================================= // fReadCalRegisters() // PTJ: use this to read some cal registers that should be loaded by Calibrate1 in id_setup_1 // Returns: // 0 if successful // _____ if timed out on handshake to the device. // ==========================================================================*/ signed char fReadCalRegisters(void) { SendVector(tsync_enable, num_bits_tsync_enable); SendVector(Switch_Bank1, 22); SendVector(read_IMOtrim, 11);/* Read-MSB Vector is the first 11-Bits*/ RunClock(2);/* Two SCLK cycles between write & read*/ bTargetStatus[0] = bReceiveByte(); RunClock(1); /*Set SDATA to Strong Drive here because SendByte() does not*/ SetSDATAStrong(); SendByte(read_reg_end, 1); SendVector(read_SPCtrim, 11);/* Read-MSB Vector is the first 11-Bits*/ RunClock(2);/* Two SCLK cycles between write & read*/ bTargetStatus[1] = bReceiveByte(); RunClock(1); /* Set SDATA to Strong Drive here because SendByte() does not*/ SetSDATAStrong(); SendByte(read_reg_end, 1); SendVector(read_VBGfinetrim, 11);/* Read-MSB Vector is the first 11-Bits*/ RunClock(2);/* Two SCLK cycles between write & read*/ bTargetStatus[2] = bReceiveByte(); RunClock(1); /*Set SDATA to Strong Drive here because SendByte() does not*/ SetSDATAStrong(); SendByte(read_reg_end, 1); SendVector(Switch_Bank0, 22); SendVector(tsync_disable, num_bits_tsync_disable); if (bTargetStatus[0] == target_status00_v) { return PASS; /*PTJ: Status = 00 means Success, the SROM function did what it was supposed to*/ } return PASS; }
/*============================================================================ SendVector() This routine sends the vector specifed. All vectors constant strings found in ISSP_Vectors.h. The data line is returned to HiZ after the vector is sent. bVect a pointer to the vector to be sent. nNumBits the number of bits to be sent. bCurrByte scratch var to keep the byte to be sent. There is no returned value. ============================================================================ */ void SendVector(const unsigned char *bVect, unsigned int iNumBits) { SetSDATAStrong(); while (iNumBits > 0) { if (iNumBits >= 8) { SendByte(*(bVect), 8); iNumBits -= 8; bVect++; } else { SendByte(*(bVect), iNumBits); iNumBits = 0; } } SetSDATAHiZ(); }
signed char fReadByteLoop(unsigned int blknum) { bTargetAddress = 0; bTargetDataPtr = 0; while(bTargetDataPtr < TARGET_DATABUFF_LEN) { //Send Read Byte vector and then get a byte from Target SendVector(read_byte_v, 4); // Set the drive here because SendByte() does not SetSDATAStrong(); SendByte(bTargetAddress,7); RunClock(2); // Run two SCLK cycles between writing and reading SetSDATAHiZ(); // Set to HiZ so Target can drive SDATA bTargetDataIN = bReceiveByte(); RunClock(1); SendVector(read_byte_v + 1, 1); // Send the ReadByte Vector End // Test the Byte that was read from the Target against the original // value (already in the 128-Byte array "abTargetDataOUT[]"). If it // matches, then bump the address & pointer,loop-back and continue. // If it does NOT match abort the loop and return and error. //if (bTargetDataIN != abTargetDataOUT[bTargetDataPtr]) if (bTargetDataIN != pSocData[blknum*TARGET_DATABUFF_LEN + bTargetDataPtr]) { #ifdef TX_ON UART_PutCRLF(); UART_CPutString("bTargetDataIN : "); UART_PutHexByte(bTargetDataIN); UART_CPutString(" abTargetDataOUT : "); UART_PutHexByte(pSocData[blknum*TARGET_DATABUFF_LEN + bTargetDataPtr]); #endif return(BLOCK_ERROR); } bTargetDataPtr++; // Increment the address by 2 to accomodate 7-Bit addressing // (puts the 7-bit address into MSBit locations for "SendByte()"). bTargetAddress += 2; } return(PASS); }
signed char fVerifySetup(unsigned char bBankNumber, unsigned char bBlockNumber) { SendVector(set_block_num, num_bits_set_block_num); /* Set the drive here because SendByte() does not */ SetSDATAStrong(); SendByte(bBlockNumber, 8); SendByte(set_block_num_end, 3); SendVector(verify_setup, num_bits_my_verify_setup); fIsError = fDetectHiLoTransition(); if (fIsError != 0) return VERIFY_ERROR; SendVector(wait_and_poll_end, num_bits_wait_and_poll_end); return PASS; }
/* ============================================================================ // LoadTarget() // Transfers data from array in Host to RAM buffer in the target. // Returns the checksum of the data. ============================================================================*/ unsigned int iLoadTarget(void) { unsigned char bTemp; unsigned int iChecksumData = 0; SendVector(tsync_enable, num_bits_tsync_enable); SendVector(read_write_setup, num_bits_read_write_setup); /* Set SDATA to Strong Drive here because SendByte() does not */ SetSDATAStrong(); /* Transfer the temporary RAM array into the target. // In this section, a 128-Byte array was specified by #define, so the entire // 128-Bytes are written in this loop. */ bTargetAddress = 0x00; bTargetDataPtr = 0x00; while (bTargetDataPtr < TARGET_DATABUFF_LEN) { bTemp = abTargetDataOUT[bTargetDataPtr]; /* PROGRAM_DATA; */ iChecksumData += bTemp; SendByte(write_byte_start, 4); /* we need to be able to write 128 bytes from address 0x80 to 0xFF */ SendByte(bTargetAddress, 7); /* we need to be able to write 128 bytes from address 0x80 to 0xFF */ SendByte(bTemp, 8); SendByte(write_byte_end, 3); /* !!!NOTE: // SendByte() uses MSbits, so inc by '2' to put the 0..128 address into // the seven MSBit locations. // // This can be confusing, but check the logic: // The address is only 7-Bits long. The SendByte() subroutine will // send however-many bits, BUT...always reads them bits from left-to- // right. So in order to pass a value of 0..128 as the address using // SendByte(), we have to left justify the address by 1-Bit. // This can be done easily by incrementing the address each time by // '2' rather than by '1'. */ bTargetAddress += 2; /* inc by 2 in order to support a 128 byte address space */ bTargetDataPtr++; } return iChecksumData; }
signed char fReadByteLoop(void) { /* char x = 0; //wly */ bTargetAddress = 0; bTargetDataPtr = 0; /* pr_info("wly: fReadByteLoop"); */ SendVector(tsync_enable, num_bits_tsync_enable); SendVector(read_write_setup, num_bits_read_write_setup); while (bTargetDataPtr < TARGET_DATABUFF_LEN) { /* Send Read Byte vector and then get a byte from Target */ SendVector(read_byte_v, 4); /* Set the drive here because SendByte() does not */ SetSDATAStrong(); SendByte(bTargetAddress, 7); RunClock(2); /* Run two SCLK cycles between writing and reading */ SetSDATAHiZ(); /* Set to HiZ so Target can drive SDATA */ bTargetDataIN = bReceiveByte(); RunClock(1); SendVector(read_byte_v + 1, 1); /* Send the ReadByte Vector End */ /* Test the Byte that was read from the Target against the original // value (already in the 128-Byte array "abTargetDataOUT[]"). If it // matches, then bump the address & pointer,loop-back and continue. // If it does NOT match abort the loop and return and error. //pr_info("wly: bTargetDataIN=%x, %x\n", bTargetDataIN, abTargetDataOUT[bTargetDataPtr]); */ if (bTargetDataIN != abTargetDataOUT[bTargetDataPtr]) return BLOCK_ERROR; bTargetDataPtr++; /* Increment the address by 2 to accomodate 7-Bit addressing // (puts the 7-bit address into MSBit locations for "SendByte()"). */ bTargetAddress += 2; } SendVector(tsync_disable, num_bits_tsync_disable); return PASS; }
// ============================================================================ // fVerifySetup() // Verify the block just written to. This can be done byte-by-byte before the // protection bits are set. // Returns: // 0 if successful // BLOCK_ERROR if timed out on handshake to the device. // ============================================================================ signed char fVerifySetup(unsigned char bBankNumber, unsigned char bBlockNumber) { SendVector(tsync_enable, num_bits_tsync_enable); SendVector(set_block_num, num_bits_set_block_num); //Set the drive here because SendByte() does not SetSDATAStrong(); SendByte(bBlockNumber, 8); SendByte(set_block_num_end, 3); //PTJ: SendVector(tsync_disable, num_bits_tsync_disable); //PTJ: SendVector(verify_setup, num_bits_my_verify_setup); //PTJ: if ((fIsError = fDetectHiLoTransition())) { return (BLOCK_ERROR); } SendVector(wait_and_poll_end, num_bits_wait_and_poll_end); return (PASS); }
signed char fReadByteLoop(void) { bTargetAddress = 0; bTargetDataPtr = 0; while (bTargetDataPtr < TargetDatabufLen) { /* Send Read Byte vector and then get a byte from Target */ SendVector(read_byte_v, 5); /* Set the drive here because SendByte() does not */ SetSDATAStrong(); SendByte(bTargetAddress, 6); /* Run two SCLK cycles between writing and reading */ RunClock(2); /* Set to HiZ so Target can drive SDATA */ SetSDATAHiZ(); bTargetDataIN = bReceiveByte(); RunClock(1); /* Send the ReadByte Vector End */ SendVector(read_byte_v + 1, 1); if (bTargetDataIN != abTargetDataOUT[bTargetDataPtr]) { #ifdef TX_ON TX8SW_PutCRLF(); TX8SW_CPutString("bTargetDataIN : "); TX8SW_PutSHexByte(bTargetDataIN); TX8SW_CPutString(" abTargetDataOUT : "); TX8SW_PutSHexByte(abTargetDataOUT[bTargetDataPtr]); #endif return BLOCK_ERROR; } bTargetDataPtr++; bTargetAddress += 4; } return PASS; }
/* ============================================================================ // fSecureTargetFlash() // Before calling, load the array, abTargetDataOUT, with the desired security // settings using LoadArrayWithSecurityData(StartAddress,Length,SecurityType). // The can be called multiple times with different SecurityTypes as needed for // particular Flash Blocks. Or set them all the same using the call below: // LoadArrayWithSecurityData(0,SECURITY_BYTES_PER_BANK, 0); // Returns: // 0 if successful // SECURITY_ERROR if timed out on handshake to the device. ============================================================================*/ signed char fSecureTargetFlash(void) { unsigned char bTemp; /* Transfer the temporary RAM array into the target */ bTargetAddress = 0x00; bTargetDataPtr = 0x00; SendVector(tsync_enable, num_bits_tsync_enable); SendVector(read_write_setup, num_bits_read_write_setup); SetSDATAStrong(); while (bTargetDataPtr < SECURITY_BYTES_PER_BANK) { bTemp = abTargetDataOUT[bTargetDataPtr]; SendByte(write_byte_start, 4); SendByte(bTargetAddress, 7); SendByte(bTemp, 8); SendByte(write_byte_end, 3); /* SendBytes() uses MSBits, so increment the address by '2' to put // the 0..n address into the seven MSBit locations */ bTargetAddress += 2; /* inc by 2 in order to support a 128 byte address space */ bTargetDataPtr++; } SendVector(tsync_disable, num_bits_tsync_disable); SendVector(secure, num_bits_secure); fIsError = fDetectHiLoTransition(); if (fIsError) return SECURITY_ERROR; SendVector(wait_and_poll_end, num_bits_wait_and_poll_end); return PASS; }
/* ============================================================================ // fEraseBlock() // Perform a block erase of the target device. // Returns: // 0 if successful // ERASE_ERROR if timed out on handshake to the device. ============================================================================*/ signed char fEraseBlock(unsigned char bBlockNumber) { unsigned char bTargetDataPtr = 0; SendVector(tsync_enable, num_bits_tsync_enable); SendVector(read_write_setup, num_bits_read_write_setup); /* Set SDATA to Strong Drive here because SendByte() does not */ SetSDATAStrong(); /* Transfer the temporary RAM array into the target. // In this section, a 128-Byte array was specified by #define, so the entire // 128-Bytes are written in this loop. */ bTargetAddress = 0x00; while (bTargetDataPtr < TARGET_DATABUFF_LEN) { SendByte(write_byte_start, 4); /* we need to be able to write 128 bytes from address 0x80 to 0xFF*/ SendByte(bTargetAddress, 7); /* we need to be able to write 128 bytes from address 0x80 to 0xFF*/ SendByte(0, 8); /* load 0x00 */ SendByte(write_byte_end, 3); /* !!!NOTE: // SendByte() uses MSbits, so inc by '2' to put the 0..128 address into // the seven MSBit locations. // // This can be confusing, but check the logic: // The address is only 7-Bits long. The SendByte() subroutine will // send however-many bits, BUT...always reads them bits from left-to- // right. So in order to pass a value of 0..128 as the address using // SendByte(), we have to left justify the address by 1-Bit. // This can be done easily by incrementing the address each time by // '2' rather than by '1'. */ bTargetAddress += 2; /* inc by 2 in order to support a 128 byte address space */ bTargetDataPtr++; } SendVector(set_block_num, num_bits_set_block_num); /* Set the drive here because SendByte() does not. */ SetSDATAStrong(); SendByte(bBlockNumber, 8); SendByte(set_block_num_end, 3); SendVector(tsync_disable, num_bits_tsync_disable); /* Send the program-and-verify vector. */ SendVector(program_and_verify, num_bits_program_and_verify); /* wait for acknowledge from target. */ fIsError = fDetectHiLoTransition(); if (fIsError) return BLOCK_ERROR; /* Send the Wait-For-Poll-End vector */ SendVector(wait_and_poll_end, num_bits_wait_and_poll_end); /*---------------------------------------------------------------- // XCH: the lines below actually implement the erase SROM function // however, Product Engineering recommends using the WRITE SROM // function instead and write all '0' to the block. The function // below is saved for possible future implementation */ /* SendVector(tsync_enable, num_bits_tsync_enable); // SendVector(set_block_num, num_bits_set_block_num); // Set the drive here because SendByte() does not. // SetSDATAStrong(); // SendByte(bBlockNumber,8); // SendByte(set_block_num_end, 3); // SendVector(tsync_disable, num_bits_tsync_disable); // Send the erase-block vector. // SendVector(erase_block, num_bits_erase_block); // wait for acknowledge from target. // if (fIsError == fDetectHiLoTransition()) { // return(BLOCK_ERROR); // } // Send the Wait-For-Poll-End vector // SendVector(wait_and_poll_end, num_bits_wait_and_poll_end); //----------------------------------------------------------------- */ return PASS; }
// ============================================================================ // PTJ: fReadSecurity() // This reads from SM0 with Read Supervisory SPC command. // Need to have SPC Test Mode enabled before using these commands? // Returns: // 0 if successful // __________ if timed out on handshake to the device. // ============================================================================ signed char fReadSecurity(void) { SendVector(ReadSecuritySetup, num_bits_ReadSecuritySetup); // SendVector(SPCTestMode_enable, num_bits_SPCTestMode_enable); bTargetAddress = 0x00; while (bTargetAddress < (SECURITY_BYTES_PER_BANK * 2)) { //PTJ: we do SECURITY_BYTES_PER_BANK * 2 because we bTargetAddress += 2 //PTJ: TSYNC Enable SendVector(tsync_enable, num_bits_tsync_enable); SendVector(read_security_pt1, num_bits_read_security_pt1); //PTJ: // Set the drive here because SendByte() does not. SetSDATAStrong(); SendByte(bTargetAddress, 7); //PTJ: hardcode MSb of address as 0 in bit stream SendVector(read_security_pt1_end, num_bits_read_security_pt1_end); //PTJ: TSYNC Disable SendVector(tsync_disable, num_bits_tsync_disable); SendVector(read_security_pt2, num_bits_read_security_pt2); SendVector(wait_and_poll_end, num_bits_wait_and_poll_end); SendVector(read_security_pt3, num_bits_read_security_pt3); SetSDATAStrong(); SendByte(bTargetAddress, 7); SendVector(read_security_pt3_end, num_bits_read_security_pt3_end); SendVector(wait_and_poll_end, num_bits_wait_and_poll_end); bTargetAddress += 2; } bTargetAddress = 0x00; bTargetDataPtr = 0x00; SendVector(tsync_enable, num_bits_tsync_enable); //PTJ: 307, added for tsync testing while (bTargetAddress < (SECURITY_BYTES_PER_BANK * 2)) { //PTJ: we do SECURITY_BYTES_PER_BANK * 2 because we bTargetAddress += 2 //Send Read Byte vector and then get a byte from Target SendVector(read_byte_v, 4); // Set the drive here because SendByte() does not SetSDATAStrong(); SendByte(bTargetAddress, 7); RunClock(2); // Run two SCLK cycles between writing and reading SetSDATAHiZ(); // Set to HiZ so Target can drive SDATA bTargetDataIN = bReceiveByte(); RunClock(1); SendVector(read_byte_v + 1, 1); // Send the ReadByte Vector End // Test the Byte that was read from the Target against the original // value (already in the 128-Byte array "abTargetDataOUT[]"). If it // matches, then bump the address & pointer,loop-back and continue. // If it does NOT match abort the loop and return and error. if (bTargetDataIN != abTargetDataOUT[bTargetDataPtr]) // return(BLOCK_ERROR); // Increment the address by two to accomodate 7-Bit addressing // (puts the 7-bit address into MSBit locations for "SendByte()"). bTargetDataPtr++; bTargetAddress += 2; } SendVector(tsync_disable, num_bits_tsync_disable); //PTJ: 307, added for tsync testing return (PASS); }
/* ============================================================================ // XCH: fVerifySecurity() // This step is optional. Verifies that the security bits have been written correctly ============================================================================ */ signed char fVerifySecurity(void) { /* unsigned char bBlockNumber = 0;//wly */ bTargetAddress = 0x00; #ifdef USE_TP SetTPHigh(); /* Only used of Test Points are enabled */ #endif #ifdef USE_TP SetTPLow(); /* Only used of Test Points are enabled */ #endif SendVector(verify_security, num_bits_verify_security); fIsError = fDetectHiLoTransition(); if (fIsError) return INIT_ERROR; #ifdef USE_TP SetTPHigh(); /* Only used of Test Points are enabled */ #endif #ifdef USE_TP SetTPLow(); /* Only used of Test Points are enabled */ #endif SendVector(wait_and_poll_end, num_bits_wait_and_poll_end); bTargetAddress = 0x00; bTargetDataPtr = 0x00; SendVector(tsync_enable, num_bits_tsync_enable); SendVector(read_write_setup, num_bits_read_write_setup); /* fReadWriteSetup(); */ /* we do SECURITY_BYTES_PER_BANK * 2 because we bTargetAddress += 2 */ while (bTargetAddress < (SECURITY_BYTES_PER_BANK * 2)) { /* Send Read Byte vector and then get a byte from Target */ SendVector(read_byte_v, 4); /* Set the drive here because SendByte() does not */ SetSDATAStrong(); SendByte(bTargetAddress, 7); SetSDATAHiZ(); /* Set to HiZ so Target can drive SDATA */ RunClock(2); /* Run two SCLK cycles between writing and reading */ bTargetDataIN = bReceiveByte(); RunClock(1); SendVector(read_byte_v + 1, 1); /* Send the ReadByte Vector End */ /* Test the Byte that was read from the Target against the original // value (already in the 128-Byte array "abTargetDataOUT[]"). If it // matches, then bump the address & pointer,loop-back and continue. // If it does NOT match abort the loop and return and error. */ if (bTargetDataIN != abTargetDataOUT[bTargetDataPtr]) return BLOCK_ERROR; /* Increment the address by two to accomodate 7-Bit addressing (puts the 7-bit address into MSBit locations for "SendByte()"). */ bTargetDataPtr++; bTargetAddress += 2; } SendVector(tsync_disable, num_bits_tsync_disable); return PASS; }