From: Joseph Coffland Date: Wed, 30 Dec 2015 02:43:03 +0000 (-0800) Subject: Updated build system X-Git-Url: https://git.buildbotics.com/?a=commitdiff_plain;h=6af234a4b87e31516ecb98a9573837f7c4d14f90;p=bbctrl-firmware Updated build system --- diff --git a/.gitignore b/.gitignore index 0554769..d9316da 100755 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,5 @@ -firmware/tinyg/Debug -firmware/tinyg/default/path -firmware/tinyg/Release/Makefile -firmware/tinyg/Release/makedep.mk -firmware/tinyg/default/path -tinyg.hex +# Backup files +*~ +\#* + +build diff --git a/Makefile b/Makefile index c117388..11de606 100755 --- a/Makefile +++ b/Makefile @@ -1,211 +1,97 @@ -############################################################################### -# Makefile for the project tinyg -############################################################################### - -## General Flags +# Makefile for the project TinyG firmware PROJECT = tinyg -MCU = atxmega192a3 -TARGET = tinyg.elf -CC = avr-gcc +MCU = atxmega192a3 +CLOCK = 32000000 +TARGET = $(PROJECT).elf + +# Compile falgs +CC = avr-gcc CPP = avr-g++ -## Options common to compile, link and assembly rules COMMON = -mmcu=$(MCU) -## Compile options common for all C compilation units. -CFLAGS = $(COMMON) -<<<<<<< HEAD:firmware/tinyg/default/Makefile -CFLAGS += -gdwarf-2 -std=gnu99 -Wall -DF_CPU=32000000UL -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -======= -CFLAGS += -gdwarf-2 -std=gnu99 -Wall -DF_CPU=32000000UL -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums ->>>>>>> refs/heads/edge:firmware/tinyg/default/Makefile -CFLAGS += -MD -MP -MT $(*F).o -MF dep/$(@F).d - -## Assembly specific flags -ASMFLAGS = $(COMMON) -ASMFLAGS += $(CFLAGS) -ASMFLAGS += -x assembler-with-cpp -Wa,-gdwarf2 - -## Linker flags -LDFLAGS = $(COMMON) -LDFLAGS += -Wl,-u,vfprintf -lprintf_flt -lm -Wl,-Map=tinyg.map - - -## Intel Hex file production flags -HEX_FLASH_FLAGS = -R .eeprom -R .fuse -R .lock -R .signature - -HEX_EEPROM_FLAGS = -j .eeprom -HEX_EEPROM_FLAGS += --set-section-flags=.eeprom="alloc,load" -HEX_EEPROM_FLAGS += --change-section-lma .eeprom=0 --no-change-warnings - - -## Libraries -LIBS = -lm - -## Objects that must be built in order to link -<<<<<<< HEAD:firmware/tinyg/default/Makefile -OBJECTS = util.o canonical_machine.o config.o controller.o cycle_homing.o gcode_parser.o gpio.o help.o json_parser.o kinematics.o main.o planner.o report.o spindle.o stepper.o system.o test.o xmega_rtc.o xmega_eeprom.o xmega_init.o xmega_interrupts.o xio_usb.o xio.o xio_pgm.o xio_rs485.o xio_usart.o pwm.o plan_line.o plan_arc.o xio_spi.o xio_file.o network.o -======= -OBJECTS = util.o canonical_machine.o config.o controller.o cycle_homing.o gcode_parser.o gpio.o help.o json_parser.o kinematics.o main.o planner.o report.o spindle.o stepper.o hardware.o test.o xmega_rtc.o xmega_eeprom.o xmega_init.o xmega_interrupts.o xio_usb.o xio_pgm.o xio_rs485.o xio_usart.o pwm.o plan_line.o plan_arc.o xio_spi.o xio_file.o network.o config_app.o text_parser.o switch.o cycle_probing.o xio.o cycle_jogging.o plan_exec.o encoder.o plan_zoid.o persistence.o ->>>>>>> refs/heads/edge:firmware/tinyg/default/Makefile - -## Objects explicitly added by the user -LINKONLYOBJECTS = - -## Build -all: $(TARGET) tinyg.hex tinyg.eep tinyg.lss - -## Compile -util.o: ../util.c - $(CC) $(INCLUDES) $(CFLAGS) -c $< - -canonical_machine.o: ../canonical_machine.c - $(CC) $(INCLUDES) $(CFLAGS) -c $< - -config.o: ../config.c - $(CC) $(INCLUDES) $(CFLAGS) -c $< - -controller.o: ../controller.c - $(CC) $(INCLUDES) $(CFLAGS) -c $< - -cycle_homing.o: ../cycle_homing.c - $(CC) $(INCLUDES) $(CFLAGS) -c $< - -gcode_parser.o: ../gcode_parser.c - $(CC) $(INCLUDES) $(CFLAGS) -c $< - -gpio.o: ../gpio.c - $(CC) $(INCLUDES) $(CFLAGS) -c $< - -help.o: ../help.c - $(CC) $(INCLUDES) $(CFLAGS) -c $< - -json_parser.o: ../json_parser.c - $(CC) $(INCLUDES) $(CFLAGS) -c $< - -kinematics.o: ../kinematics.c - $(CC) $(INCLUDES) $(CFLAGS) -c $< - -main.o: ../main.c - $(CC) $(INCLUDES) $(CFLAGS) -c $< - -planner.o: ../planner.c - $(CC) $(INCLUDES) $(CFLAGS) -c $< - -report.o: ../report.c - $(CC) $(INCLUDES) $(CFLAGS) -c $< - -spindle.o: ../spindle.c - $(CC) $(INCLUDES) $(CFLAGS) -c $< - -stepper.o: ../stepper.c - $(CC) $(INCLUDES) $(CFLAGS) -c $< - -hardware.o: ../hardware.c - $(CC) $(INCLUDES) $(CFLAGS) -c $< +CFLAGS += $(COMMON) +CFLAGS += -gdwarf-2 -std=gnu99 -Wall -DF_CPU=$(CLOCK)UL -Os -funsigned-char +CFLAGS += -funsigned-bitfields -fpack-struct -fshort-enums +CFLAGS += -MD -MP -MT $(*F).o -MF build/dep/$(@F).d + +# Linker flags +LDFLAGS += $(COMMON) -Wl,-u,vfprintf -lprintf_flt -lm -Wl,-Map=$(PROJECT).map +LIBS += -lm + +# EEPROM flags +EEFLAGS += -j .eeprom +EEFLAGS += --set-section-flags=.eeprom="alloc,load" +EEFLAGS += --change-section-lma .eeprom=0 --no-change-warnings + +# Programming flags +PROGRAMMER = avrispmkII +PDEV = usb +AVRDUDE_OPTS = -c $(PROGRAMMER) -p $(MCU) -P $(PDEV) + +FUSE0=0xff +FUSE1=0x00 +FUSE2=0xfe +FUSE4=0xfe +FUSE5=0xeb + +# SRC +SRC = $(wildcard src/*.c) +SRC += $(wildcard src/xio/*.c) +SRC += $(wildcard src/xmega/*.c) +OBJ = $(patsubst src/%.c,build/%.o,$(SRC)) + +# Build +all: $(TARGET) $(PROJECT).hex $(PROJECT).eep $(PROJECT).lss + +# Compile +build/%.o: src/%.c + @mkdir -p $(shell dirname $@) + $(CC) $(INCLUDES) $(CFLAGS) -c -o $@ $< + +# Link +$(TARGET): $(OBJ) + $(CC) $(LDFLAGS) $(OBJ) $(LIBS) -o $(TARGET) -test.o: ../test.c - $(CC) $(INCLUDES) $(CFLAGS) -c $< - -xmega_rtc.o: ../xmega/xmega_rtc.c - $(CC) $(INCLUDES) $(CFLAGS) -c $< - -xmega_eeprom.o: ../xmega/xmega_eeprom.c - $(CC) $(INCLUDES) $(CFLAGS) -c $< - -xmega_init.o: ../xmega/xmega_init.c - $(CC) $(INCLUDES) $(CFLAGS) -c $< - -xmega_interrupts.o: ../xmega/xmega_interrupts.c - $(CC) $(INCLUDES) $(CFLAGS) -c $< - -xio_usb.o: ../xio/xio_usb.c - $(CC) $(INCLUDES) $(CFLAGS) -c $< - -xio_pgm.o: ../xio/xio_pgm.c - $(CC) $(INCLUDES) $(CFLAGS) -c $< - -xio_rs485.o: ../xio/xio_rs485.c - $(CC) $(INCLUDES) $(CFLAGS) -c $< - -xio_usart.o: ../xio/xio_usart.c - $(CC) $(INCLUDES) $(CFLAGS) -c $< - -pwm.o: ../pwm.c - $(CC) $(INCLUDES) $(CFLAGS) -c $< - -plan_line.o: ../plan_line.c - $(CC) $(INCLUDES) $(CFLAGS) -c $< - -plan_arc.o: ../plan_arc.c - $(CC) $(INCLUDES) $(CFLAGS) -c $< - -xio_spi.o: ../xio/xio_spi.c - $(CC) $(INCLUDES) $(CFLAGS) -c $< - -xio_file.o: ../xio/xio_file.c - $(CC) $(INCLUDES) $(CFLAGS) -c $< - -network.o: ../network.c -<<<<<<< HEAD:firmware/tinyg/default/Makefile -======= - $(CC) $(INCLUDES) $(CFLAGS) -c $< - -config_app.o: ../config_app.c - $(CC) $(INCLUDES) $(CFLAGS) -c $< - -text_parser.o: ../text_parser.c - $(CC) $(INCLUDES) $(CFLAGS) -c $< - -switch.o: ../switch.c - $(CC) $(INCLUDES) $(CFLAGS) -c $< - -cycle_probing.o: ../cycle_probing.c - $(CC) $(INCLUDES) $(CFLAGS) -c $< - -xio.o: ../xio.c - $(CC) $(INCLUDES) $(CFLAGS) -c $< - -cycle_jogging.o: ../cycle_jogging.c - $(CC) $(INCLUDES) $(CFLAGS) -c $< - -plan_exec.o: ../plan_exec.c - $(CC) $(INCLUDES) $(CFLAGS) -c $< +%.hex: $(TARGET) + avr-objcopy -O ihex -R .eeprom -R .fuse -R .lock -R .signature $< $@ -encoder.o: ../encoder.c - $(CC) $(INCLUDES) $(CFLAGS) -c $< +%.eep: $(TARGET) + avr-objcopy $(EEFLAGS) -O ihex $< $@ -plan_zoid.o: ../plan_zoid.c - $(CC) $(INCLUDES) $(CFLAGS) -c $< +%.lss: $(TARGET) + avr-objdump -h -S $< > $@ -persistence.o: ../persistence.c ->>>>>>> refs/heads/edge:firmware/tinyg/default/Makefile - $(CC) $(INCLUDES) $(CFLAGS) -c $< +size: $(TARGET) + avr-size -C --mcu=$(MCU) $(TARGET) -##Link -$(TARGET): $(OBJECTS) - $(CC) $(LDFLAGS) $(OBJECTS) $(LINKONLYOBJECTS) $(LIBDIRS) $(LIBS) -o $(TARGET) +# Program +erase: + avrdude $(AVRDUDE_OPTS) -e -%.hex: $(TARGET) - avr-objcopy -O ihex $(HEX_FLASH_FLAGS) $< $@ +program: $(PROJECT).hex + avrdude $(AVRDUDE_OPTS) -U flash:w:$(PROJECT).hex:i -%.eep: $(TARGET) - -avr-objcopy $(HEX_EEPROM_FLAGS) -O ihex $< $@ || exit 0 +fuses: + avrdude $(AVRDUDE_OPTS) -U fuse0:w:$(FUSE0):m -U fuse1:w:$(FUSE1):m \ + -U fuse2:w:$(FUSE2):m -U fuse4:w:$(FUSE4):m -U fuse5:w:$(FUSE5):m -%.lss: $(TARGET) - avr-objdump -h -S $< > $@ +read_fuses: + avrdude $(AVRDUDE_OPTS) -U fuse0:r:fuse0.hex:h -U fuse1:r:fuse1.hex:h \ + -U fuse2:r:fuse2.hex:h -U fuse4:r:fuse4.hex:h -U fuse5:r:fuse5.hex:h + @ cat fuse?.hex -size: ${TARGET} - @echo - @avr-size -C --mcu=${MCU} ${TARGET} +# Clean +tidy: + rm -f *~ \#* -## Clean target -.PHONY: clean -clean: - -rm -rf $(OBJECTS) tinyg.elf dep/* tinyg.hex tinyg.eep tinyg.lss tinyg.map +clean: tidy + rm -rf $(PROJECT).elf $(PROJECT).hex $(PROJECT).eep $(PROJECT).lss \ + $(PROJECT).map build +.PHONY: tidy clean size all erase program fuses read_fuses -## Other dependencies --include $(shell mkdir dep 2>NUL) $(wildcard dep/*) +# Dependencies +-include $(shell mkdir -p build/dep) $(wildcard build/dep/*) diff --git a/src/system.c b/src/system.c index c7c5de9..48434f8 100755 --- a/src/system.c +++ b/src/system.c @@ -47,7 +47,7 @@ void sys_init() { xmega_init(); // set system clock - sys_port_bindings(TINYG_HARDWARE_VERSION); + sys_port_bindings(8); } void sys_port_bindings(float hw_version) diff --git a/src/tinyg.h b/src/tinyg.h index 3660e34..98ad637 100755 --- a/src/tinyg.h +++ b/src/tinyg.h @@ -62,8 +62,8 @@ #define __TEXT_MODE // enables text mode (~10Kb) #define __HELP_SCREENS // enables help screens (~3.5Kb) -#define __CANNED_TESTS // enables $tests (~12Kb) -#define __TEST_99 // enables diagnostic test 99 (independent of other tests) +//#define __CANNED_TESTS // enables $tests (~12Kb) +//#define __TEST_99 // enables diagnostic test 99 (independent of other tests) /****** DEVELOPMENT SETTINGS ******/ diff --git a/src/xio/xio.c b/src/xio/xio.c deleted file mode 100755 index 8ed5458..0000000 --- a/src/xio/xio.c +++ /dev/null @@ -1,346 +0,0 @@ -/* - * xio.c - Xmega IO devices - common code file - * Part of TinyG project - * - * Copyright (c) 2010 - 2013 Alden S. Hart Jr. - * - * This file ("the software") is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License, version 2 as published by the - * Free Software Foundation. You should have received a copy of the GNU General Public - * License, version 2 along with the software. If not, see . - * - * THE SOFTWARE IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, BUT WITHOUT ANY - * WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT - * SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF - * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -/* ----- XIO - Xmega Device System ---- - * - * XIO provides common access to native and derived xmega devices (see table below) - * XIO devices are compatible with avr-gcc stdio and also provide some special functions - * that are not found in stdio. - * - * Stdio support: - * - http://www.nongnu.org/avr-libc/user-manual/group__avr__stdio.html - * - Stdio compatible putc() and getc() functions provided for each device - * - This enables fgets, printf, scanf, and other stdio functions - * - Full support for formatted printing is provided (including floats) - * - Assignment of a default device to stdin, stdout & stderr is provided - * - printf() and printf_P() send to stdout, so use fprintf() to stderr - * for things that should't go over RS485 in SLAVE mode - * - * Facilities provided beyond stdio: - * - Supported devices include: - * - USB (derived from USART) - * - RS485 (derived from USART) - * - SPI devices and slave channels - * - Program memory "files" (read only) - * - Stdio FILE streams are managed as bindings to the above devices - * - Additional functions provided include: - * - open() - initialize parameters, addresses and flags - * - gets() - non-blocking input line reader - extends fgets - * - ctrl() - ioctl-like knockoff for setting device parameters (flags) - * - signal handling: interrupt on: feedhold, cycle_start, ctrl-x software reset - * - interrupt buffered RX and TX functions - * - XON/XOFF software flow control - */ -/* ----- XIO - Some Internals ---- - * - * XIO layers are: (1) xio virtual device (root), (2) xio device type, (3) xio devices - * - * The virtual device has the following methods: - * xio_init() - initialize the entire xio system - * xio_open() - open a device indicated by the XIO_DEV number - * xio_ctrl() - set control flags for XIO_DEV device - * xio_gets() - get a string from the XIO_DEV device (non blocking line reader) - * xio_getc() - read a character from the XIO_DEV device (not stdio compatible) - * xio_putc() - write a character to the XIO_DEV device (not stdio compatible) - * xio_set_baud() - set baud rates for devices for which this is meaningful - * - * The device type layer currently knows about USARTS, SPI, and File devices. Methods are: - * xio_init_() - initializes the devices of that type - * - * The device layer currently supports: USB, RS485, SPI channels, PGM file reading. methods: - * xio_open() - set up the device for use or reset the device - * xio_ctrl() - change device flag controls - * xio_gets() - get a string from the device (non-blocking) - * xio_getc() - read a character from the device (stdio compatible) - * xio_putc() - write a character to the device (stdio compatible) - * - * The virtual level uses XIO_DEV_xxx numeric device IDs for reference. - * Lower layers are called using the device structure pointer xioDev_t *d - * The stdio compatible functions use pointers to the stdio FILE structs. - */ -#include // for memset() -#include // precursor for xio.h -#include // precursor for xio.h - -#include "xio.h" // all device includes are nested here -#include "../tinyg.h" // needed by init() for default source -#include "../config.h" // needed by init() for default source -#include "../controller.h" // needed by init() for default source - -// -typedef struct xioSingleton { - FILE * stderr_shadow; // used for stack overflow / memory integrity checking -} xioSingleton_t; -xioSingleton_t xio; - -/* - * xio_init() - initialize entire xio sub-system - * xio_reset_working_flags() - */ -void xio_init() -{ - // set memory integrity check - xio_set_stderr(0); // set a bogus value; may be overwritten with a real value - - // setup device types - xio_init_usart(); - xio_init_spi(); - xio_init_file(); - - // open individual devices (file device opens occur at time-of-use) - xio_open(XIO_DEV_USB, 0, USB_FLAGS); - xio_open(XIO_DEV_RS485,0, RS485_FLAGS); - xio_open(XIO_DEV_SPI1, 0, SPI_FLAGS); - xio_open(XIO_DEV_SPI2, 0, SPI_FLAGS); -} - -void xio_reset_working_flags(xioDev_t *d) -{ - d->signal = 0; - d->flag_in_line = 0; - d->flag_eol = 0; - d->flag_eof = 0; -} - -/* - * xio_init_device() - generic initialization function for any device - * - * This binds the main fucntions and sets up the stdio FILE structure - * udata is used to point back to the device struct so it can be gotten - * from getc() and putc() functions. - * - * Requires device open() to be run prior to using the device - */ -void xio_open_generic(uint8_t dev, x_open_t x_open, - x_ctrl_t x_ctrl, - x_gets_t x_gets, - x_getc_t x_getc, - x_putc_t x_putc, - x_flow_t x_flow) -{ - xioDev_t *d = &ds[dev]; - memset (d, 0, sizeof(xioDev_t)); - d->magic_start = MAGICNUM; - d->magic_end = MAGICNUM; - d->dev = dev; - - // bind functions to device structure - d->x_open = x_open; - d->x_ctrl = x_ctrl; - d->x_gets = x_gets; - d->x_getc = x_getc; // you don't need to bind getc & putc unless you are going to use them directly - d->x_putc = x_putc; // they are bound into the fdev stream struct - d->x_flow = x_flow; - - // setup the stdio FILE struct and link udata back to the device struct - fdev_setup_stream(&d->file, x_putc, x_getc, _FDEV_SETUP_RW); - fdev_set_udata(&d->file, d); // reference yourself for udata -} - -/* - * PUBLIC ENTRY POINTS - acces the functions via the XIO_DEV number - * xio_open() - open function - * xio_gets() - entry point for non-blocking get line function - * xio_getc() - entry point for getc (not stdio compatible) - * xio_putc() - entry point for putc (not stdio compatible) - * - * It might be prudent to run an assertion such as below, but we trust the callers: - * if (dev < XIO_DEV_COUNT) blah blah blah - * else return (_FDEV_ERR); // XIO_NO_SUCH_DEVICE - */ -FILE *xio_open(uint8_t dev, const char *addr, flags_t flags) -{ - return (ds[dev].x_open(dev, addr, flags)); -} - -int xio_gets(const uint8_t dev, char *buf, const int size) -{ - return (ds[dev].x_gets(&ds[dev], buf, size)); -} - -int xio_getc(const uint8_t dev) -{ - return (ds[dev].x_getc(&ds[dev].file)); -} - -int xio_putc(const uint8_t dev, const char c) -{ - return (ds[dev].x_putc(c, &ds[dev].file)); -} - -/* - * xio_ctrl() - PUBLIC set control flags (top-level XIO_DEV access) - * xio_ctrl_generic() - PRIVATE but generic set-control-flags - */ -int xio_ctrl(const uint8_t dev, const flags_t flags) -{ - return (xio_ctrl_generic(&ds[dev], flags)); -} - -#define SETFLAG(t,f) if ((flags & t) != 0) { d->f = true; } -#define CLRFLAG(t,f) if ((flags & t) != 0) { d->f = false; } - -int xio_ctrl_generic(xioDev_t *d, const flags_t flags) -{ - SETFLAG(XIO_BLOCK, flag_block); - CLRFLAG(XIO_NOBLOCK, flag_block); - SETFLAG(XIO_XOFF, flag_xoff); - CLRFLAG(XIO_NOXOFF, flag_xoff); - SETFLAG(XIO_ECHO, flag_echo); - CLRFLAG(XIO_NOECHO, flag_echo); - SETFLAG(XIO_CRLF, flag_crlf); - CLRFLAG(XIO_NOCRLF, flag_crlf); - SETFLAG(XIO_IGNORECR, flag_ignorecr); - CLRFLAG(XIO_NOIGNORECR, flag_ignorecr); - SETFLAG(XIO_IGNORELF, flag_ignorelf); - CLRFLAG(XIO_NOIGNORELF, flag_ignorelf); - SETFLAG(XIO_LINEMODE, flag_linemode); - CLRFLAG(XIO_NOLINEMODE, flag_linemode); - return (XIO_OK); -} - -/* - * xio_set_baud() - PUBLIC entry to set baud rate - * Currently this only works on USART devices - */ -int xio_set_baud(const uint8_t dev, const uint8_t baud) -{ - xioUsart_t *dx = (xioUsart_t *)&us[dev - XIO_DEV_USART_OFFSET]; - xio_set_baud_usart(dx, baud); - return (XIO_OK); -} - -/* - * xio_fc_null() - flow control null function - */ -void xio_fc_null(xioDev_t *d) -{ - return; -} - -/* - * xio_set_stdin() - set stdin from device number - * xio_set_stdout() - set stdout from device number - * xio_set_stderr() - set stderr from device number - * - * stderr is defined in stdio as __iob[2]. Turns out stderr is the last RAM - * allocated by the linker for this project. We usae that to keep a shadow - * of __iob[2] for stack overflow detection and other memory corruption. - */ -void xio_set_stdin(const uint8_t dev) { stdin = &ds[dev].file; } -void xio_set_stdout(const uint8_t dev) { stdout = &ds[dev].file; } -void xio_set_stderr(const uint8_t dev) -{ - stderr = &ds[dev].file; - xio.stderr_shadow = stderr; // this is the last thing in RAM, so we use it as a memory corruption canary -} - -/* - * xio_assertions() - validate operating state - * - * Returns status code (0 if everything is OK) - * and sets a value if there is a failure. - */ -uint8_t xio_assertions(uint8_t *value) -{ - if (ds[XIO_DEV_USB].magic_start != MAGICNUM) { *value = 100; } - if (ds[XIO_DEV_USB].magic_end != MAGICNUM) { *value = 101; } - if (ds[XIO_DEV_RS485].magic_start != MAGICNUM) { *value = 102; } - if (ds[XIO_DEV_RS485].magic_end != MAGICNUM) { *value = 103; } - if (ds[XIO_DEV_SPI1].magic_start != MAGICNUM) { *value = 104; } - if (ds[XIO_DEV_SPI1].magic_end != MAGICNUM) { *value = 105; } - if (ds[XIO_DEV_SPI2].magic_start != MAGICNUM) { *value = 106; } - if (ds[XIO_DEV_SPI2].magic_end != MAGICNUM) { *value = 107; } - if (ds[XIO_DEV_PGM].magic_start != MAGICNUM) { *value = 108; } - if (ds[XIO_DEV_PGM].magic_end != MAGICNUM) { *value = 109; } - if (stderr != xio.stderr_shadow) { *value = 200; } - - if (*value != 0) { return (STAT_MEMORY_FAULT); } - return (STAT_OK); -} - -/***************************************************************************** - * UNIT TESTS - *****************************************************************************/ - -#if defined (__UNIT_TESTS) && defined (__UNIT_TEST_XIO) - -static void _spi_putc(void); -static void _spi_loopback(void); -static void _pgm_test(void); - -void xio_unit_tests() -{ -// _spi_putc(); - _spi_loopback(); -// _pgm_test(); -} - -static void _spi_putc() -{ - FILE * fdev; - char buf[12]; -// char c; - - - fdev = xio_open(XIO_DEV_SPI1, 0, SPI_FLAGS); - while (true) { -// xio_putc_spi(0x55, fdev); -// c = xio_getc_spi(fdev); - xio_gets(XIO_DEV_SPI1, buf, 12); - } -} - -#define DELAY 1000 // approx delay in uSec in -O0 mode - -static void _spi_loopback() -{ - FILE * fdev; - char buf[10] = "tester\n"; -// uint8_t i=0; - uint32_t j=0; - - fdev = xio_open(XIO_DEV_SPI1, 0, SPI_FLAGS); - xio_set_stdout(XIO_DEV_SPI1); - while (true) { -// for (i=0; i<7; i++) { xio_putc_spi(buf[i], fdev);} - printf("%s",buf); - for (j=(DELAY*0.76); j>0; j--); - } -} - -static void _pgm_test() -{ - FILE * fdev; - - fdev = xio_open(XIO_DEV_PGM, 0, PGM_FLAGS); -// xio_puts_pgm("ABCDEFGHIJKLMNOP\n", fdev); - xio_putc_pgm('A', fdev); - xio_putc_pgm('B', fdev); - xio_putc_pgm('C', fdev); - xio_getc_pgm(fdev); - xio_getc_pgm(fdev); - xio_getc_pgm(fdev); - -} - -// fdev = xio_open(XIO_DEV_USB, 0, USB_FLAGS); -// xio_getc_usart(fdev); - - -#endif diff --git a/src/xmega/xmega_wdt.c b/src/xmega/xmega_wdt.c deleted file mode 100755 index 00866b0..0000000 --- a/src/xmega/xmega_wdt.c +++ /dev/null @@ -1,27 +0,0 @@ -//#include "compiler.h" -//#include "ccp.h" -#include - -void wdt_reset_mcu(void) -{ -/* - uint8_t temp; - - // WDT enabled (minimum timeout period for max. security) - temp = WDT_PER_8CLK_gc | (1 << WDT_ENABLE_bp) | (1 << WDT_CEN_bp); - ccp_write_io((void *)&WDT.CTRL, temp); - wdt_wait_while_busy(); - - // WDT enabled (maximum window period for max. security) - temp = WDT_WPER_8KCLK_gc | (1 << WDT_WEN_bp) | (1 << WDT_WCEN_bp); - ccp_write_io((void *)&WDT.WINCTRL, temp); - wdt_wait_while_busy(); - - // WDT Reset during window => WDT generates an Hard Reset. - wdt_reset(); - - // No exit to prevent the execution of the following instructions. - while (1) {} -*/ - -}