Commit Graph

20 Commits

Author SHA1 Message Date
Markus Hitter 7be5212f06 ARM: introduce sei() and cli().
No test, because it's tricky to test, but it compiles and the
firmware still works as before.
2015-08-12 14:26:36 +02:00
Markus Hitter 370bb9f93c Move pin I/O macros from arduino.h to pinio.h.
arduino.h is now free of function definitions.
2015-08-12 14:26:34 +02:00
Phil Hord 22b640697b Replace SIMULATOR with __AVR__ in several places.
Previously some features were excluded based on whether SIMULATOR
was defined. But in fact these should have been included when __AVR__
was defined. These used to be the same thing, but now with ARM coming
into the picture, they are not. Fix the situation so AVR includes are
truly only used when __AVR__ is defined.

The _crc16_update function appears to be specific to AVR; I've kept the
alternate implementation limited to AVR in that case in crc.c. I think
this is the right thing to do, but I am not sure. Maybe ARM has some
equivalent function in their libraries.
2015-07-29 21:05:38 +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
Markus Hitter 0c100fe5f8 According to avr-libc documentation, ISR() handles SREG its self. 2013-10-27 20:01:51 +01:00
Markus Hitter 3c5d9d8950 Replace #define HOST by #define MOTHERBOARD.
Apparently, HOST conflicts with some AVR headers for the
USB-equipped ATmegas.

Patch by DaveX, thank you Dave. See also:
http://forums.reprap.org/read.php?147,33082,182021#msg-182021
2013-03-24 16:17:14 +01:00
Markus Hitter b1fa6a1eee Make intercom recognize memory barriers. 2012-03-28 12:39:10 +02:00
Markus Hitter 7528037d4e Save status register on each interrupt.
Costs 28 bytes binary size and two CPU cycles per interrupt,
at the advantage of getting rid of possible well hidden bugs.
2012-03-04 19:02:38 +01:00
Michael Moon 0dc7d77885 Massive Doxygen documentation addition
'make doc' then point your browser at doc/html/

Needs plenty of cleanup and polishing, but the main bulk is here

even documents your configuration! ;)
2011-03-22 01:34:36 +11:00
Michael Moon 2340808695 start implementing intercom protocol rehash 2011-03-05 13:38:12 +11:00
Michael Moon d0601716e8 reorganise intercom to send packets from extruder main loop, also generalise protocol as discussed in forum 2011-03-05 13:38:12 +11:00
Markus Amsler bfae6ff97f intercom: Reduce sections with disabled interrupts. 2011-02-21 15:52:17 +11:00
Markus Amsler fa2a4389fc intercom: Transmit/receive from/to temporary packets.
Fixes that the packet could be changed during transmit. And only values from packets with correct checksum are used.
2011-02-21 15:52:16 +11:00
Markus Amsler 959bae2f4a intercom: Add delay before slave replies. Without it the first byte gets lost. 2011-02-14 11:08:08 +11:00
Markus Amsler a3b1529607 intercom: don't store start byte twice. 2011-02-14 11:08:08 +11:00
Markus Amsler e6a137d5f1 intercom: Init start byte. 2011-02-14 11:08:08 +11:00
Michael Moon b1a48994dd preliminary untested implementation of Markus Amsler's new extruder comms protocol 2011-02-12 23:59:19 +11:00
Michael Moon e4fc55289b use constants for conditional compilation since preprocessor can't work out enums and we can't define in macros 2011-02-06 21:34:44 +11:00
Michael Moon 266c6ee0e2 merge release-candidate-triffid 2011-01-07 23:29:32 +11:00