diff --git a/external_mem.c b/external_mem.c index 0c0a35d..409dcde 100644 --- a/external_mem.c +++ b/external_mem.c @@ -97,6 +97,11 @@ void ExternalMem_AssertOE(void) Ports_SetOEOut(0); } +void ExternalMem_DeassertOE(void) +{ + Ports_SetOEOut(1); +} + void ExternalMem_Read(uint32_t startAddress, uint32_t *buf, uint32_t len) { ExternalMem_AssertCS(); @@ -108,11 +113,14 @@ void ExternalMem_Read(uint32_t startAddress, uint32_t *buf, uint32_t len) // Shouldn't need to wait here. Each clock cycle at 16 MHz is 62.5 nanoseconds, so by the time the SPI // read has been signaled with the SPI chip, there will DEFINITELY be good data on the data bus. // (Considering these chips will be in the 70 ns or 140 ns range, that's only a few clock cycles at most) - *buf++ = ExternalMem_ReadData(); + + // TODO: Change the read data routines to put them in the correct order as is so I don't have to do this + // (Might shave a second or so off the read time) + uint32_t tmp = ExternalMem_ReadData(); + tmp = (tmp & 0xFF) << 24 | + ((tmp >> 8) & 0xFF) << 16 | + ((tmp >> 16) & 0xFF) << 8 | + ((tmp >> 24) & 0xFF) << 0; + *buf++ = tmp; } } - -void ExternalMem_DeassertOE(void) -{ - Ports_SetOEOut(1); -} diff --git a/external_mem.h b/external_mem.h index 9137844..09bcd6a 100644 --- a/external_mem.h +++ b/external_mem.h @@ -41,4 +41,7 @@ void ExternalMem_DeassertWE(void); void ExternalMem_AssertOE(void); void ExternalMem_DeassertOE(void); +// Reads a set of data... +void ExternalMem_Read(uint32_t startAddress, uint32_t *buf, uint32_t len); + #endif /* EXTERNAL_MEM_H_ */ diff --git a/usb_serial/usb_serial.c b/usb_serial/usb_serial.c index d628d24..3eb3e1b 100644 --- a/usb_serial/usb_serial.c +++ b/usb_serial/usb_serial.c @@ -43,9 +43,10 @@ void USBSerial_Check(void) if (CDC_Device_BytesReceived(&VirtualSerial_CDC_Interface)) { CDC_Device_ReceiveByte(&VirtualSerial_CDC_Interface); + //CDC_Device_SendString(&VirtualSerial_CDC_Interface, "Reading..."); + //CDC_Device_Flush(&VirtualSerial_CDC_Interface); - - uint32_t mem = ExternalMem_ReadData(); + /*uint32_t mem = ExternalMem_ReadData(); char dataString[11]; @@ -63,7 +64,39 @@ void USBSerial_Check(void) sprintf(dataString, "%02X %02X %02X\r\n", DDRA, DDRC, DDRD); - CDC_Device_SendString(&VirtualSerial_CDC_Interface, dataString); + CDC_Device_SendString(&VirtualSerial_CDC_Interface, dataString);*/ + +#define BUFSIZE 128UL + static uint32_t readBuf[BUFSIZE]; + int x; + for (x = 0; x < 512UL * 1024UL / BUFSIZE; x++) + { + ExternalMem_Read(x*BUFSIZE, readBuf, BUFSIZE); + + if (CDC_Device_SendData(&VirtualSerial_CDC_Interface, (const char *)readBuf, BUFSIZE*4) != ENDPOINT_RWSTREAM_NoError) + { + PORTD |= (1 << 7); + } + + //int y; + //for (y = 0; y < BUFSIZE; y++) + //{ + //if ((y % 4) == 0) CDC_Device_SendString(&VirtualSerial_CDC_Interface, ".\r\n"); + + //char tmpBuf[20]; + //sprintf(tmpBuf, "%02X %02X %02X %02X ", + // (uint8_t)(readBuf[y] >> 24), + // (uint8_t)(readBuf[y] >> 16), + // (uint8_t)(readBuf[y] >> 8), + // (uint8_t)(readBuf[y] >> 0)); + //CDC_Device_SendString(&VirtualSerial_CDC_Interface, tmpBuf); + //} + //if ((x % 64) == 0) CDC_Device_SendString(&VirtualSerial_CDC_Interface, "\r\n"); + //CDC_Device_SendString(&VirtualSerial_CDC_Interface, "."); + //CDC_Device_Flush(&VirtualSerial_CDC_Interface); + } + + //CDC_Device_SendString(&VirtualSerial_CDC_Interface, "\r\nDone\r\n"); } /*int16_t rb = CDC_Device_ReceiveByte(&VirtualSerial_CDC_Interface);