From 61aac6a7b9b35dc4c1c43c1c0ac23486b7cfe5f5 Mon Sep 17 00:00:00 2001 From: jaseg Date: Sun, 15 Dec 2013 00:16:26 +0100 Subject: USB is working now. --- firmware/main.c | 46 ++++++++++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 20 deletions(-) (limited to 'firmware') diff --git a/firmware/main.c b/firmware/main.c index b1af4a5..7f44313 100644 --- a/firmware/main.c +++ b/firmware/main.c @@ -70,7 +70,7 @@ unsigned const char const CRATE_MAP[CRATES_PER_BUS] = { unsigned char framebuffer[BUS_COUNT*BUS_SIZE]; /* Kick off DMA from RAM to SPI interfaces */ void start_dma(void); -unsigned long framebuffer_read(void *fb, unsigned long len); +unsigned long framebuffer_read(void *data, unsigned long len); unsigned char ucControlTable[1024] __attribute__ ((aligned(1024))); @@ -109,8 +109,8 @@ unsigned long RxHandler(void *pvCBData, unsigned long ulEvent, unsigned long ulM UARTprintf("Host disconnected.\n"); break; case USB_EVENT_RX_AVAILABLE: - UARTprintf("Handling host data.\n\n"); - return framebuffer_read(pvMsgData, ulMsgValue); + UARTprintf("Handling host data.\n"); + USBBufferDataRemoved(&g_sRxBuffer, framebuffer_read(pvMsgData, ulMsgValue)); case USB_EVENT_SUSPEND: case USB_EVENT_RESUME: break; @@ -120,25 +120,31 @@ unsigned long RxHandler(void *pvCBData, unsigned long ulEvent, unsigned long ulM return 0; } -unsigned long framebuffer_read(void *fb, unsigned long len){ - if(len != BUS_COUNT*BUS_COLUMNS*BUS_ROWS) - return 0; - for(unsigned int bus=0; buscrate_x/4; + for(unsigned int x=0; xcrate_x + fb->crate_y*CRATES_X]; + unsigned int bottle = BOTTLE_MAP[x%CRATE_WIDTH + (y%CRATE_HEIGHT)*CRATE_WIDTH]; + unsigned int src = (bus*BUS_SIZE + crate*CRATE_SIZE + bottle)*3; + unsigned int dst = (bus*BUS_SIZE + y*BUS_COLUMNS + x)*3; + //Copy r, g and b data + framebuffer[src] = fb->rgb_data[dst]; + framebuffer[src + 1] = fb->rgb_data[dst + 1]; + framebuffer[src + 2] = fb->rgb_data[dst + 2]; } } - UARTprintf("Starting DMA.\n\n"); + UARTprintf("Starting DMA.\n"); start_dma(); return len; } -- cgit