Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

One source of JTAG mode bits

  • Loading branch information...
commit 193a19801762b52b1b76ab40e612a205a6f97003 1 parent a117078
Chris McClelland authored
Showing with 45 additions and 43 deletions.
  1. +1 −6 firmware/fx2/jtag.h
  2. +17 −37 nero.c
  3. +27 −0 prog.h
7 firmware/fx2/jtag.h
View
@@ -18,6 +18,7 @@
#define JTAG_H
#include <makestuff.h>
+#include "../../prog.h"
// Default TDO=PD0, TDI=PD1, TMS=PD2 & TCK=PD3. In reality this is overwritten
// at runtime by jtagPatch().
@@ -36,12 +37,6 @@ sbit at (0x80 + 16*JTAG_PORT + TCK_BIT) TCK; // Port bit to use for TCK
// Macros for NeroJTAG implementation
#define ENDPOINT_SIZE 64
-#define bmNEEDRESPONSE (1<<0)
-#define bmISLAST (1<<1)
-#define bmSENDZEROS (0<<2)
-#define bmSENDONES (1<<2)
-#define bmSENDDATA (2<<2)
-#define bmSENDMASK (3<<2)
// Error codes for jtagCsvfPlay(void);
#define ERROR_CSVF_FAILED_COMPARE 1
54 nero.c
View
@@ -21,27 +21,14 @@
#include "vendorCommands.h"
#include "private.h"
#include "nero.h"
+#include "prog.h"
// -------------------------------------------------------------------------------------------------
// Declaration of private types & functions
// -------------------------------------------------------------------------------------------------
-typedef enum {
- SEND_ZEROS,
- SEND_ONES,
- SEND_DATA,
- SEND_MASK
-} SendType;
-
-enum {
- IS_RESPONSE_NEEDED = 0,
- IS_LAST = 1,
- SEND_TYPE = 2
-};
-
static NeroStatus beginShift(
- struct FLContext *handle, uint32 numBits, SendType sendType, bool isLast,
- bool isResponseNeeded, const char **error
+ struct FLContext *handle, uint32 numBits, uint8 mode, const char **error
) WARN_UNUSED_RESULT;
static NeroStatus doSend(
@@ -230,32 +217,34 @@ NeroStatus neroShift(
NeroStatus returnCode, nStatus;
uint32 numBytes;
uint16 chunkSize;
- SendType sendType;
- bool isResponseNeeded;
+ uint8 mode = 0x00;
+ bool sendData = false;
if ( inData == ZEROS ) {
- sendType = SEND_ZEROS;
+ mode |= bmSENDZEROS;
} else if ( inData == ONES ) {
- sendType = SEND_ONES;
+ mode |= bmSENDONES;
} else {
- sendType = SEND_DATA;
+ mode |= bmSENDDATA;
+ sendData = true;
}
if ( outData ) {
- isResponseNeeded = true;
- } else {
- isResponseNeeded = false;
+ mode |= bmNEEDRESPONSE;
+ }
+ if ( isLast ) {
+ mode |= bmISLAST;
}
- nStatus = beginShift(handle, numBits, sendType, isLast, isResponseNeeded, error);
+ nStatus = beginShift(handle, numBits, mode, error);
CHECK_STATUS(nStatus, "neroShift()", NERO_BEGIN_SHIFT);
numBytes = bitsToBytes(numBits);
while ( numBytes ) {
chunkSize = (numBytes>=handle->endpointSize) ? handle->endpointSize : (uint16)numBytes;
- if ( sendType == SEND_DATA ) {
+ if ( sendData ) {
nStatus = doSend(handle, inData, chunkSize, error);
CHECK_STATUS(nStatus, "neroShift()", NERO_SEND);
inData += chunkSize;
}
- if ( isResponseNeeded ) {
+ if ( outData ) {
nStatus = doReceive(handle, outData, chunkSize, error);
CHECK_STATUS(nStatus, "neroShift()", NERO_RECEIVE);
outData += chunkSize;
@@ -367,28 +356,19 @@ static NeroStatus portMap(
// Kick off a shift operation on the micro. This will be followed by a bunch of sends and receives.
//
static NeroStatus beginShift(
- struct FLContext *handle, uint32 numBits, SendType sendType, bool isLast,
- bool isResponseNeeded, const char **error)
+ struct FLContext *handle, uint32 numBits, uint8 mode, const char **error)
{
NeroStatus returnCode = NERO_SUCCESS;
- uint16 wValue = 0x0000;
int uStatus;
union {
uint32 u32;
uint8 bytes[4];
} leNumBits;
leNumBits.u32 = littleEndian32(numBits);
- if ( isLast ) {
- wValue |= (1<<IS_LAST);
- }
- if ( isResponseNeeded ) {
- wValue |= (1<<IS_RESPONSE_NEEDED);
- }
- wValue |= sendType << SEND_TYPE;
uStatus = usbControlWrite(
handle->device,
CMD_JTAG_CLOCK_DATA, // bRequest
- wValue, // wValue
+ (uint8)mode, // wValue
0x0000, // wIndex
leNumBits.bytes, // send bit count
4, // wLength
27 prog.h
View
@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) 2009-2012 Chris McClelland
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+#ifndef PROG_H
+#define PROG_H
+
+#define bmNEEDRESPONSE (1<<0)
+#define bmISLAST (1<<1)
+#define bmSENDZEROS (0<<2)
+#define bmSENDONES (1<<2)
+#define bmSENDDATA (2<<2)
+#define bmSENDMASK (3<<2)
+
+#endif
Please sign in to comment.
Something went wrong with that request. Please try again.