Commit Graph

10 Commits

Author SHA1 Message Date
Phil Hord 592df2c73f Drop redundant "simulator.h" includes.
simulator.h is already included in config.h/arduino.h, so it doesn't
need to be included again most of the time. In some cases it was
included twice on purpose to undo some intervening include file, but
these intervening includes were unnecessary. Remove some related
include file redundancy by re-ordering the include files and relocating
some nested includes up to the parent .c file.
2016-06-11 15:12:40 +02:00
Markus Hitter e633222cd3 Make message/text sending aware of the sending destination.
Point of this change is to allow using these functions for
writing to the display, too, without duplicating all the code.

To reduce confusion, functions were renamed (they're no longer
'serial', after all:

  serwrite_xxx() -> write_xxx()
  sersendf_P()   -> sendf_P()

To avoid changing all the existing code, a couple of macros
with the old names are provided. They might even be handy as
convenience macros.

Nicely, this addition costs no additional RAM. Not surprising, it
costs quite some binary size, 278 bytes. Sizes now:

Program:  24058 bytes      168%       79%       38%       19%
   Data:   1525 bytes      149%       75%       38%       19%
 EEPROM:     32 bytes        4%        2%        2%        1%

Regarding USB Serial: code was adjusted without testing on
hardware.
2016-04-26 15:23:15 +02:00
Phil Hord 21e5343552 Add config.h wrapper to simplify test automation
Test code which wants to customize config.h can do so without
touching config.h itself by wrapping config.h in a macro variable
which is passed in to the compiler.  It defaults to "config.h" if
no override is provided.

This change would break makefile dependency checking since the selection
of a different header file on the command line is not noticed by make
as a build-trigger.  To solve this, we add a layer to the BUILDDIR path
so build products are now specific to the USER_CONFIG choice if it is
not "config.h".
2014-03-04 19:56:23 +01:00
Phil Hord 452e2e5cd9 Restore simulation build target.
This code was accidentally removed long ago in a botched merge. This
patch recovers it and makes it build again. I've done minimal testing
and some necessary cleanup. It compiles and runs, but it probably still
has a few dust bunnies here and there.

I added registers and pin definitions to simulator.h and
simulator/simulator.c which I needed to match my Gen7-based config.
Other configs or non-AVR ports will need to define more or different
registers. Some registers are 16-bits, some are 8-bit, and some are just
constant values (enums). A more clever solution would read in the
chip-specific header and produce saner definitions which covered all
GPIOs. But this commit just takes the quick and easy path to support my
own hardware.

Most of this code originated in these commits:

	commit cbf41dd4ad
	Author: Stephan Walter <stephan@walter.name>
	Date:   Mon Oct 18 20:28:08 2010 +0200

	    document simulation

	commit 3028b297f3
	Author: Stephan Walter <stephan@walter.name>
	Date:   Mon Oct 18 20:15:59 2010 +0200

	    Add simulation code: use "make sim"

Additional tweaks:

Revert va_args processing for AVR, but keep 'int' generalization
for simulation. gcc wasn't lying. The sim really aborts without this.

Remove delay(us) from simulator (obsolete).

Improve the README.sim to demonstrate working pronterface connection
to sim. Also fix the build instructions.

Appease all stock configs.

Stub out intercom and shush usb_serial when building simulator.

Pretend to be all chip-types for config appeasement.

Replace sim_timer with AVR-simulator timer:

The original sim_timer and sim_clock provided direct replacements
for timer/clock.c in the main code. But when the main code changed,
simcode did not. The main clock.c was dropped and merged into timer.c.
Also, the timer.c now has movement calculation code in it in some
cases (ACCELERATION_TEMPORAL) and it would be wrong to teach the
simulator to do the same thing. Instead, teach the simulator to
emulate the AVR Timer1 functionality, reacting to values written to
OCR1A and OCR1B timer comparison registers.

Whenever OCR1A/B are changed, the sim_setTimer function needs to be
called. It is called automatically after a timer event, so changes
within the timer ISRs do not need to bother with this.

A C++ class could make this requirement go away by noticing the
assignment. On the other hand, a chip-agnostic timer.c would help
make the main code more portable. The latter cleanup is probably
better for us in the long run.
2013-12-06 19:24:58 +01:00
David Forrest aefd4b6596 usb_serial.c: eliminate type punning compiler warnings 2013-07-11 22:03:01 +02:00
Markus Hitter f065f26aff usb_serial.c: make variables residing in PROGMEM constant.
Newer avr-gccs complain about that and even without this, it's
the right thing to do.

Patch by DaveX, thanks Dave. See also:
http://forums.reprap.org/read.php?147,33082,182021#msg-182021
2013-03-24 16:17:34 +01:00
Markus Hitter 9b018b7433 Make USB_SERIAL fit for the Arduino IDE.
This also includes renaming of USE_USB to USB_SERIAL for more
consistency.
2012-12-03 19:49:58 +01:00
Markus Hitter b4bf8144fc Protect usb_serial.c from Arduino IDE.
This silly "IDE" simply processes every source code file it can find ...
2012-11-08 16:38:14 +01:00
Markus Hitter 7d6ffdae17 usb_serial.c: adjust USB strings for Teacup. 2012-11-08 16:37:03 +01:00
Markus Hitter c4fc138f7e Import USB Serial from http://www.pjrc.com/teensy/usb_serial.html 2012-11-08 16:36:48 +01:00