## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
##
-SOURCES = \
- main.c \
- ../fx2lafw.c \
- ../debug.c
+SOURCES = main.c ../fx2lafw.c ../debug.c
A51_SOURCES = ../dscr.a51
BASENAME = fx2lafw-cwav-usbeeax
{
fx2lafw_init();
- while(1)
+ while (1)
fx2lafw_run();
}
-
#include <stdarg.h>
#include <stdio.h>
-
#include <delay.h>
#include <fx2regs.h>
#include <fx2macros.h>
-
#include "debug.h"
#define MESSAGE_LENGTH_MAX 64
-void debugf(const char *format, ...) {
+void debugf(const char *format, ...)
+{
va_list arg;
int count;
- // Format the string
- va_start (arg, format);
+ /* Format the string. */
+ va_start(arg, format);
count = vsprintf(EP6FIFOBUF, format, arg);
- va_end (arg);
+ va_end(arg);
- // Zero out the rest of the buffer
- while(count < MESSAGE_LENGTH_MAX)
+ /* Zero out the rest of the buffer. */
+ while (count < MESSAGE_LENGTH_MAX)
EP6FIFOBUF[count++] = '\0';
- // Send the buffer
+ /* Send the buffer. */
count = 32;
EP6BCH = MSB(count);
SYNCDELAY4;
EP6BCL = LSB(count);
+ SYNCDELAY4;
}
-void _assert(char *expr, const char *filename, unsigned int linenumber) {
+void _assert(char *expr, const char *filename, unsigned int linenumber)
+{
debugf("Assert(%s) failed at line %u in file %s.\n",
- expr, linenumber, filename);
- while(1);
+ expr, linenumber, filename);
+ while (1);
}
#endif
; Endpoint 6 (IN)
.db DSCR_ENDPOINT_LEN
.db DSCR_ENDPOINT_TYPE
- .db 0x86 ; EP number (6), direction (IN)
+ .db 0x86 ; EP number (6), direction (IN)
.db ENDPOINT_TYPE_BULK ; Endpoint type (bulk)
- .db 0x00 ; Max. packet size, LSB (64 bytes)
- .db 0x02 ; Max. packet size, MSB (64 bytes)
+ .db 0x00 ; Max. packet size, LSB (512 bytes)
+ .db 0x02 ; Max. packet size, MSB (512 bytes)
.db 0x00 ; Polling interval
highspd_dscr_realend:
; Endpoint 6 (IN)
.db DSCR_ENDPOINT_LEN
.db DSCR_ENDPOINT_TYPE
- .db 0x86 ; EP number (6), direction (IN)
+ .db 0x86 ; EP number (6), direction (IN)
.db ENDPOINT_TYPE_BULK ; Endpoint type (bulk)
.db 0x40 ; Max. packet size, LSB (64 bytes)
.db 0x00 ; Max. packet size, MSB (64 bytes)
#endif
SYNCDELAY();
- /* Disable all other EPs (EP4 and EP8). */
+ /* Disable all other EPs (EP1, EP4, and EP8). */
EP1INCFG &= ~bmVALID;
SYNCDELAY();
EP1OUTCFG &= ~bmVALID;
/* (2) Reset data toggles of the EPs in the interface. */
/* Note: RESETTOGGLE() gets the EP number WITH bit 7 set/cleared. */
RESETTOGGLE(0x82);
- RESETTOGGLE(0x76);
+#ifdef DEBUG
+ RESETTOGGLE(0x86);
+#endif
/* (3) Restore EPs to their default conditions. */
/* Note: RESETFIFO() gets the EP number WITHOUT bit 7 set/cleared. */
RESETFIFO(0x02);
/* TODO */
-
+#ifdef DEBUG
RESETFIFO(0x06);
+#endif
/* (4) Clear the HSNAK bit. Not needed, fx2lib does this. */
SDCCFLAGS += -I../include/
include $(FX2LIBDIR)/lib/fx2.mk
+
#ifdef DEBUG
-#define ERRF(fmt, ...) \
- do { debugf("E " fmt, __VA_ARGS__); \
- while(1); } while(0)
-#define ERR(msg) \
- ERRF("%s", msg)
-
-#define WARNF(fmt, ...) \
- debugf("W " fmt, __VA_ARGS__)
-#define WARN(msg) \
- WARNF("%s", msg)
-
-#define INFOF(fmt, ...) \
- debugf("I " fmt, __VA_ARGS__)
-#define INFO(msg) \
- INFOF("%s", msg)
+#define ERRF(fmt, ...) do { debugf("E " fmt, __VA_ARGS__); \
+ while(1); } while(0)
+#define ERR(msg) ERRF("%s", msg)
+
+#define WARNF(fmt, ...) debugf("W " fmt, __VA_ARGS__)
+#define WARN(msg) WARNF("%s", msg)
+
+#define INFOF(fmt, ...) debugf("I " fmt, __VA_ARGS__)
+#define INFO(msg) INFOF("%s", msg)
/**
- * A printf the prints messages through the UART
- * EP6.
+ * A printf that prints messages through EP6.
*/
void debugf(const char *format, ...);
#else
-#define ERRF(fmt, ...) \
- ((void) 0)
-#define ERR(msg) \
- ((void) 0)
+#define ERRF(fmt, ...) ((void)0)
+#define ERR(msg) ((void)0)
-#define WARNF(fmt, ...) \
- ((void) 0)
-#define WARN(msg) \
- ((void) 0)
+#define WARNF(fmt, ...) ((void)0)
+#define WARN(msg) ((void)0)
-#define INFOF(fmt, ...) \
- ((void) 0)
-#define INFO(msg) \
- ((void) 0)
+#define INFOF(fmt, ...) ((void)0)
+#define INFO(msg) ((void)0)
#endif
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-import struct
+import struct
from fx2load import *
-# Connect to the device
+# Connect to the device.
openfx2(0x6666, 0x0019)
-# Read debug messages
+# Read debug messages.
while 1:
- buf='\x00'*200
- f.ep_bulk( buf, 0x86, 1000)
- print buf
+ buf = '\x00' * 200
+ f.ep_bulk(buf, 0x86, 1000)
+ print(buf)