From 2bc61f41aa4af721c4cc84a5bebb4ecccc8c0fe9 Mon Sep 17 00:00:00 2001 From: Doug Brown Date: Sat, 10 Dec 2011 10:35:41 -0800 Subject: [PATCH] Continued playing with USB serial stuff. I think it's working well now, but I'm running into problems reading from the SIMM, so I need to figure out why I'm not getting the data I expect. --- Descriptors.h | 2 +- external_mem.c | 17 ++++++----- main.c | 5 ++++ usb_serial/usb_serial.c | 64 +++++++++++++++++++++++++++++++++++++---- 4 files changed, 73 insertions(+), 15 deletions(-) diff --git a/Descriptors.h b/Descriptors.h index ad6f1e7..da7553d 100644 --- a/Descriptors.h +++ b/Descriptors.h @@ -55,7 +55,7 @@ #define CDC_NOTIFICATION_EPSIZE 8 /** Size in bytes of the CDC data IN and OUT endpoints. */ - #define CDC_TXRX_EPSIZE 16 + #define CDC_TXRX_EPSIZE 64 /* Type Defines: */ /** Type define for the device configuration descriptor structure. This must be defined in the diff --git a/external_mem.c b/external_mem.c index ccea4d7..3ed844c 100644 --- a/external_mem.c +++ b/external_mem.c @@ -20,21 +20,20 @@ void ExternalMem_Init(void) // Initialize the ports connected to address/data/control lines Ports_Init(); - // Disable all pull-ups, on both the address and data lines. They aren't needed - // for normal operation. - Ports_AddressPullups_RMW(0, (1UL << (HIGHEST_ADDRESS_LINE + 1)) - 1); - Ports_DataPullups_RMW(0, 0xFFFFFFFFUL); - // Configure all address lines as outputs Ports_SetAddressDDR((1UL << (HIGHEST_ADDRESS_LINE - 1)) - 1); - // Sensible defaults for address and data lines: + // Set all data lines as inputs + Ports_SetDataDDR(0); + + // Disable all pull-ups on the data lines. They aren't needed + // for normal operation. + Ports_DataPullups_RMW(0, 0xFFFFFFFFUL); + + // Sensible defaults for address lines: // Write out address zero Ports_SetAddressOut(0); - // Set all data lines as inputs (with no pullups! we turned them off) - Ports_SetDataDDR(0); - // Control lines Ports_SetCSDDR(1); Ports_SetOEDDR(1); diff --git a/main.c b/main.c index ffc1a78..d2424cb 100644 --- a/main.c +++ b/main.c @@ -8,6 +8,7 @@ #include #include #include +#include "external_mem.h" #include "tests/simm_electrical_test.h" #include "usb_serial/usb_serial.h" @@ -18,6 +19,10 @@ int main(void) DDRD |= (1 << 7); PORTD &= ~(1 << 7); + ExternalMem_Init(); + ExternalMem_SetAddress(0); + ExternalMem_AssertCS(); + ExternalMem_AssertOE(); USBSerial_Init(); sei(); diff --git a/usb_serial/usb_serial.c b/usb_serial/usb_serial.c index 7d56715..299d9cc 100644 --- a/usb_serial/usb_serial.c +++ b/usb_serial/usb_serial.c @@ -8,6 +8,7 @@ #include "usb_serial.h" #include "../LUFA/Drivers/USB/USB.h" #include "../Descriptors.h" +#include "../external_mem.h" USB_ClassInfo_CDC_Device_t VirtualSerial_CDC_Interface = { @@ -39,7 +40,24 @@ void USBSerial_Check(void) { if (USB_DeviceState == DEVICE_STATE_Configured) { - int16_t rb = CDC_Device_ReceiveByte(&VirtualSerial_CDC_Interface); + if (CDC_Device_BytesReceived(&VirtualSerial_CDC_Interface)) + { + CDC_Device_ReceiveByte(&VirtualSerial_CDC_Interface); + + uint32_t mem = ExternalMem_ReadData(); + + char dataString[11]; + + sprintf(dataString, "%02X%02X%02X%02X\r\n", + (mem>>24) & 0xFF, + (mem>>16) & 0xFF, + (mem>>8) & 0xFF, + (mem>>0) & 0xFF); + + CDC_Device_SendString(&VirtualSerial_CDC_Interface, dataString); + } + + /*int16_t rb = CDC_Device_ReceiveByte(&VirtualSerial_CDC_Interface); if (rb >= 0) { if (rb == '.') @@ -53,14 +71,50 @@ void USBSerial_Check(void) } if (gotChar) - { + {*/ //if (CDC_Device_SendByte(&VirtualSerial_CDC_Interface, 'A') != ENDPOINT_READYWAIT_NoError) - if (CDC_Device_SendData(&VirtualSerial_CDC_Interface, - "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", 64) != ENDPOINT_RWSTREAM_NoError) + /*if (CDC_Device_SendData(&VirtualSerial_CDC_Interface, + "ASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDF" + "ASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDF" + "ASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDF" + "ASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDF" + "ASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDF" + "ASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDF" + "ASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDF" + "ASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDF" + "ASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDF" + "ASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDF" + "ASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDF" + "ASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDF" + "ASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDF" + "ASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDF" + "ASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDF" + "ASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDF" + "ASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDF" + "ASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDF" + "ASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDF" + "ASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDF" + "ASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDF" + "ASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDF" + "ASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDF" + "ASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDF" + "ASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDF" + "ASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDF" + "ASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDF" + "ASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDF" + "ASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDF" + "ASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDF" + "ASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDF" + "ASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDF" + , 2048) != ENDPOINT_RWSTREAM_NoError) { PORTD |= (1 << 7); } - } + else + { + PORTD &= ~(1 << 7); + }*/ + //} } CDC_Device_USBTask(&VirtualSerial_CDC_Interface);