From 9b6d4fe5b8148bf183b17475d1f376b2f8743cfb Mon Sep 17 00:00:00 2001 From: jaseg Date: Fri, 13 Dec 2013 00:56:12 +0100 Subject: Initial commit --- .gitignore | 2 + .gitmodules | 3 + README.rst | 23 +++ firmware/LICENSE | 18 +++ firmware/Makefile | 94 ++++++++++++ firmware/main.c | 268 +++++++++++++++++++++++++++++++++ firmware/startup_gcc.c | 350 ++++++++++++++++++++++++++++++++++++++++++++ firmware/usb_bulk_structs.c | 179 ++++++++++++++++++++++ firmware/usb_bulk_structs.h | 44 ++++++ firmware/usb_dev_bulk.ld | 57 ++++++++ stellaris | 1 + 11 files changed, 1039 insertions(+) create mode 100644 .gitignore create mode 100644 .gitmodules create mode 100644 README.rst create mode 100644 firmware/LICENSE create mode 100644 firmware/Makefile create mode 100644 firmware/main.c create mode 100644 firmware/startup_gcc.c create mode 100644 firmware/usb_bulk_structs.c create mode 100644 firmware/usb_bulk_structs.h create mode 100644 firmware/usb_dev_bulk.ld create mode 160000 stellaris diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..cce6215 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +firmware/gcc/* +*.swp diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..501e36d --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "stellaris"] + path = stellaris + url = https://github.com/yuvadm/stellaris.git diff --git a/README.rst b/README.rst new file mode 100644 index 0000000..9f835ec --- /dev/null +++ b/README.rst @@ -0,0 +1,23 @@ +Mate Light +========== + +Objective +--------- + + +Hardware Setup +-------------- + + +Software +-------- + + +Architecture +~~~~~~~~~~~~ + + +Setup +~~~~~ + + diff --git a/firmware/LICENSE b/firmware/LICENSE new file mode 100644 index 0000000..a8ef53c --- /dev/null +++ b/firmware/LICENSE @@ -0,0 +1,18 @@ +Copyright (c) 2012 Texas Instruments Incorporated. All rights reserved. +Copyright (c) 2013 jaseg . All rights reserved. +Software License Agreement + +Texas Instruments (TI) is supplying this software for use solely and +exclusively on TI's microcontroller products. The software is owned by +TI and/or its suppliers, and is protected under applicable copyright +laws. You may not combine this software with "viral" open-source +software in order to form a larger program. + +THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS. +NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT +NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY +CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL +DAMAGES, FOR ANY REASON WHATSOEVER. + +This was part of revision 9453 of the EK-LM4F120XL Firmware Package. diff --git a/firmware/Makefile b/firmware/Makefile new file mode 100644 index 0000000..3aa39e1 --- /dev/null +++ b/firmware/Makefile @@ -0,0 +1,94 @@ +#****************************************************************************** +# +# Makefile - Rules for building the USB device bulk example. +# +# Copyright (c) 2012 Texas Instruments Incorporated. All rights reserved. +# Software License Agreement +# +# Texas Instruments (TI) is supplying this software for use solely and +# exclusively on TI's microcontroller products. The software is owned by +# TI and/or its suppliers, and is protected under applicable copyright +# laws. You may not combine this software with "viral" open-source +# software in order to form a larger program. +# +# THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS. +# NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT +# NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY +# CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL +# DAMAGES, FOR ANY REASON WHATSOEVER. +# +# This is part of revision 9453 of the EK-LM4F120XL Firmware Package. +# +#****************************************************************************** + +# +# Defines the part type that this project uses. +# +PART=LM4F120H5QR + +# +# Set the processor variant. +# +VARIANT=cm4f + +# +# The base directory for StellarisWare. +# +ROOT=../stellaris + +# +# Include the common make definitions. +# +include ${ROOT}/makedefs + +# +# Where to find source files that do not live in this directory. +# +VPATH= +VPATH+=../stellaris/utils + +# +# Where to find header files that do not live in the source directory. +# +IPATH=../stellaris + +# +# The default rule, which causes the USB device bulk example to be built. +# +all: ${COMPILER} +all: ${COMPILER}/main.axf + +# +# The rule to clean out all the build products. +# +clean: + @rm -rf ${COMPILER} ${wildcard *~} + +# +# The rule to create the target directory. +# +${COMPILER}: + @mkdir -p ${COMPILER} + +# +# Rules for building the USB device bulk example. +# +${COMPILER}/main.axf: ${COMPILER}/startup_${COMPILER}.o +${COMPILER}/main.axf: ${COMPILER}/uartstdio.o +${COMPILER}/main.axf: ${COMPILER}/usb_bulk_structs.o +${COMPILER}/main.axf: ${COMPILER}/main.o +${COMPILER}/main.axf: ${COMPILER}/ustdlib.o +${COMPILER}/main.axf: ${ROOT}/usblib/${COMPILER}-cm4f/libusb-cm4f.a +${COMPILER}/main.axf: ${ROOT}/driverlib/${COMPILER}-cm4f/libdriver-cm4f.a +${COMPILER}/main.axf: usb_dev_bulk.ld +SCATTERgcc_main=usb_dev_bulk.ld +ENTRY_main=ResetISR +CFLAGSgcc=-DTARGET_IS_BLIZZARD_RA1 -DUART_BUFFERED + +# +# Include the automatically generated dependency files. +# +ifneq (${MAKECMDGOALS},clean) +-include ${wildcard ${COMPILER}/*.d} __dummy__ +endif diff --git a/firmware/main.c b/firmware/main.c new file mode 100644 index 0000000..b1af4a5 --- /dev/null +++ b/firmware/main.c @@ -0,0 +1,268 @@ +/* Copyright (c) 2012 Texas Instruments Incorporated. All rights reserved. + * Software License Agreement + * + * Texas Instruments (TI) is supplying this software for use solely and + * exclusively on TI's microcontroller products. The software is owned by + * TI and/or its suppliers, and is protected under applicable copyright + * laws. You may not combine this software with "viral" open-source + * software in order to form a larger program. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS. + * NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT + * NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY + * CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL + * DAMAGES, FOR ANY REASON WHATSOEVER. + * + * This is part of revision 9453 of the EK-LM4F120XL Firmware Package. + */ + +#include "inc/hw_ints.h" +#include "inc/hw_memmap.h" +#include "inc/hw_types.h" +#include "inc/hw_ssi.h" +#include "driverlib/debug.h" +#include "driverlib/fpu.h" +#include "driverlib/gpio.h" +#include "driverlib/interrupt.h" +#include "driverlib/pin_map.h" +#include "driverlib/sysctl.h" +#include "driverlib/systick.h" +#include "driverlib/timer.h" +#include "driverlib/uart.h" +#include "driverlib/rom.h" +#include "driverlib/udma.h" +#include "driverlib/ssi.h" +#include "usblib/usblib.h" +#include "usblib/usb-ids.h" +#include "usblib/device/usbdevice.h" +#include "usblib/device/usbdbulk.h" +#include "utils/uartstdio.h" +#include "utils/ustdlib.h" +#include "usb_bulk_structs.h" + +#define CRATE_WIDTH 5 +#define CRATE_HEIGHT 4 +#define CRATES_X 4 +#define CRATES_Y 2 +#define BUS_COUNT 4 +#define BYTES_PER_PIXEL 3 +#define BUS_ROWS (CRATES_Y*CRATE_HEIGHT) +#define BUS_COLUMNS (CRATES_X*CRATE_WIDTH) +#define CRATES_PER_BUS (CRATES_X*CRATES_Y) +#define CRATE_SIZE (CRATE_WIDTH*CRATE_HEIGHT) +#define BUS_SIZE (CRATES_PER_BUS*CRATE_SIZE*BYTES_PER_PIXEL) +unsigned const char const BOTTLE_MAP[CRATE_SIZE] = { + 0, 1, 2, 3, 4, + 19, 8, 7, 6, 5, + 18, 9, 10, 11, 12, + 17, 16, 15, 14, 13 +}; + +unsigned const char const CRATE_MAP[CRATES_PER_BUS] = { + 6, 4, 2, 0, + 7, 5, 3, 1 +}; + +#define SYSTICKS_PER_SECOND 100 +#define SYSTICK_PERIOD_MS (1000 / SYSTICKS_PER_SECOND) + +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 char ucControlTable[1024] __attribute__ ((aligned(1024))); + +volatile unsigned long g_ulSysTickCount = 0; + +#ifdef DEBUG +unsigned long g_ulUARTRxErrors = 0; +#endif + +//Debug output is available via UART0 if DEBUG is defined during build. +#ifdef DEBUG +//Map all debug print calls to UARTprintf in debug builds. +#define DEBUG_PRINT UARTprintf +#else +//Compile out all debug print calls in release builds. +#define DEBUG_PRINT while(0) ((int (*)(char *, ...))0) +#endif + +volatile unsigned long g_ulFlags = 0; +char *g_pcStatus; +static volatile tBoolean g_bUSBConfigured = false; + +void SysTickIntHandler(void){ + g_ulSysTickCount++; +} + +unsigned long RxHandler(void *pvCBData, unsigned long ulEvent, unsigned long ulMsgValue, void *pvMsgData) { + switch(ulEvent) { + case USB_EVENT_CONNECTED: + g_bUSBConfigured = true; + UARTprintf("Host connected.\n"); + USBBufferFlush(&g_sRxBuffer); + break; + case USB_EVENT_DISCONNECTED: + g_bUSBConfigured = false; + UARTprintf("Host disconnected.\n"); + break; + case USB_EVENT_RX_AVAILABLE: + UARTprintf("Handling host data.\n\n"); + return framebuffer_read(pvMsgData, ulMsgValue); + case USB_EVENT_SUSPEND: + case USB_EVENT_RESUME: + break; + default: + break; + } + 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; bus FLASH + + .data : AT(ADDR(.text) + SIZEOF(.text)) + { + _data = .; + *(vtable) + *(.data*) + _edata = .; + } > SRAM + + .bss : + { + _bss = .; + *(.bss*) + *(COMMON) + _ebss = .; + } > SRAM +} diff --git a/stellaris b/stellaris new file mode 160000 index 0000000..81a4be3 --- /dev/null +++ b/stellaris @@ -0,0 +1 @@ +Subproject commit 81a4be30dd1f008c7df6bd853b4d93c292fdc7c9 -- cgit