avr_timer: roll up cancelation of timers into single function.
modified: sim/avr_timer.c
Merge pull request #59 from bsekisser/ld-st-rXYZ-bugfix
sim_core: Fix for issue #46, correction to ld {rXYZ}
cores: Fix mega2560
Added EIND, as per nnayo's. Also renamed the file to match the other
cores
Signed-off-by: Michel Pollet <buserror@gmail.com>
test: Fix coroutine on old gcc
Removed traling colon. Fix issue #34
Signed-off-by: Michel Pollet <buserror@gmail.com>
make: Allow override of root path
Allows inclusion of Makefile.common from out of tree.
Signed-off-by: Michel Pollet <buserror@gmail.com>
Merge pull request #53 from nnayo/gdb_fault
fix gdb error message: Cannot remove breakpoints because program is no l...
Merge pull request #45 from cardoe/prototype-warning
Fix avr_global_logger_get() decl to not warn.
Fix avr_global_logger_get() decl to not warn
When using sim_avr.h with a project that uses -Wstrict-prototypes, you
will get a warning that the prototype for avr_global_logger_get() is not
valid. Functions that take no args must explicitly use void to not warn.
Merge pull request #56 from bsekisser/avr-timer-comp-write-ocr
avr_timer: changed avr_timer_write_ocr as part of larger avr_timer refac...
avr_timer: changed avr_timer_write_ocr as part of larger avr_timer refactor.
- changed avr_timer_write_ocr code to take pointer of relevant
comparator structure rather than its parent timer.
- added _timer_get_comp_ocr which the modified avr_timer_write_ocr
function uses.
modified: simavr/sim/avr_timer.c
modified: simavr/sim/avr_timer.h
Merge pull request #54 from bsekisser/uart-udr-write-changes
uart: refactor uart udr write operation outside generic uart write.
core: Handle EIND register
Parts with more than 128KB of flash need an extra byte on the stack
Rework from nnayo branch for the atmega2560
Signed-off-by: Michel Pollet <buserror@gmail.com>
core: Removed trace crash macro
Made it a function instead.
Reworked from nnayo's commit
uart: refactor uart udr write operation outside generic uart write.
modified: simavr/sim/avr_uart.c
fix gdb error message: Cannot remove breakpoints because program is no longer writable.
Merge pull request #50 from cardoe/atmega128rfa1
cores: add ATmega128RFA1 core
timers: Reformat
Cleanup the macros
Signed-off-by: Michel Pollet <buserror@gmail.com>
cores: add ATmega128RFA1 core
This core is based on the ATmega1281 core per Atmel's documentation so
that was used as a starting point. No guarentees that the radio is wired
up correctly.
timers: Real fix
There were a couple of logic error in the previous commit, fixed,
hopefully.
simduino: Small fix
Not sure how this got commited, it was not compiling.
timers: New, faster implementation
Bullied by bsekisser into making this one ;-)
Signed-off-by: Michel Pollet <buserror@gmail.com>
gdb: cleanup
Formatting, nothing functional.
Signed-off-by: Michel Pollet <buserror@gmail.com>
Merge pull request #39 from ppd1990/makefile-threaded
Make Makefile safe for parallel compilation.
sim_core: correction to ld {rXYZ}
User supplied test seems to indicate that the avr writes data to
the destination register AFTER updating the index register.
whereas the core originally read the index register and
immediately stored the result into the register and then wrote
back the index register.
If the code used: LD XH, X test indicated XH would return the
value loaded from the indirect load operation versus the updated
XH:XL value as the core originally assumed.
modified: sim/sim_core.c
Merge pull request #43 from cardoe/special-init-api
Extend special_init/special_deinit API
Extend special_init/special_deinit API
Its pretty common for callback style APIs to include a private pointer
to allow the user to pass in contextual data through the callback API
(see pthread_create for an example). This change adds that for
special_init() and special_deinit() which are designed as callbacks.
Effectively this behavior was used in the only two examples that used
those callbacks by having global variables, however globals are of
limited use for programs that might instantiate multiple avr cores.
Merge pull request #41 from nnayo/segfault
correct a segfault
Merge pull request #42 from nnayo/typo
fix typo
Make Makefile safe for parallel compilation.
Merge pull request #38 from ppd1990/megax-timer
Fix timer0 on megax MCUs. Stick to lowest common denominator (atmega8) i...
Fix timer0 on megax MCUs. Stick to lowest common denominator (atmega8) in terms of functionality.
Merge pull request #37 from ppd1990/atmega-icp
Correctly set timer1's ICP on atmega8, atmega16 and atmega32.
Correctly set timer1's ICP on atmega8, atmega16 and atmega32.
cores: m16 and m32 fix
Core struct declaration had a problem when the 'porta' was not declared.
Now declare it last, so it doesnt clash anymore.
core: renamed MCU section variable name
This was clashing with the command register
Signed-off-by: Michel Pollet <buserror@gmail.com>
uart_pty: Fix the race condition
There had been a race condition in there for a rather long while,
I've finaly tracked it down to a small idiotic change of trying to
flush a buffer from the wrong thread.
Removing that flush makes it works properly as intended, without the
mutex.
Signed-off-by: Michel Pollet <buserror@gmail.com>
twi: Fix a clang error
clang doesn't like unused static functions at all.
Signed-off-by: Michel Pollet <buserror@gmail.com>
fifo: cleaned warnings and removed volatile
Should not need the volatile declaration anymore.
Also use the "unused" designation to prevent clang to complain
about unused static functions.
Signed-off-by: Michel Pollet <buserror@gmail.com>
Merge remote-tracking branch 'thomasa88/feature/detect_avr_root' into dev-home
cores: Added atmega1284.c
That one has an extra timer, it seems.
Signed-off-by: Michel Pollet <buserror@gmail.com>
spi: Clear SPIF when writing to SPDR
The manual says the SPIF bit is cleared when accessing (i.e. reading _or_
writing) the SPDR register after an interrupt is raised. By clearing SPIF
on a write to SPDR, the following code starts to work:
SPDR = 0xff; loop_until_bit_is_set (SPSR, SPIF);
SPDR = 0x00; loop_until_bit_is_set (SPSR, SPIF);
(where the bytes are arbitrarily chosen). This didn’t work before as the
SPIF bit wasn’t cleared by the second write to SPDR, so the second loop
turned into a no-op. This caused the write timer for the first byte to be
overwritten by the write timer for the second. Consequently, the first byte
never got transmitted.
Signed-off-by: Michel Pollet <buserror@gmail.com>
Merge remote-tracking branch 'pwithnalls/warning-fixes' into dev-home
core: Declare avr_pending_sleep_usec
This was meant to be declared for 'boards' to use
Signed-off-by: Michel Pollet <buserror@gmail.com>
timer: Tweak traces
Display the period in uS as well as cycles
Signed-off-by: Michel Pollet <buserror@gmail.com>
Makefile: Test multiple AVR roots for Linux and error out if none found
Inspired by thors@github.
This should find correct paths for at least Arch, Debian, Fedora, Gentoo, OpenSUSE, Ubuntu.
avr: Make vector trace work
Somehow the vector list was erased at avr_reset time, luckily only the
trace code in run_avr was using it.
Signed-off-by: Michel Pollet <buserror@gmail.com>
simavr: Removed the avr_global_logger global
It was not very clean; Instead there is a new accessor for
setting/getting a global logging function pointer.
Also made sure it is not compiled for the cores, since they use AVR
headers and have no stdarg.h anyway
Signed-off-by: Michel Pollet <buserror@gmail.com>
core: Fix a possible buffer overrun
From bsekisser@github
Signed-off-by: Michel Pollet <buserror@gmail.com>
cores: Added mega16
No idea why it wasn't there already. Uncommon part.
Signed-off-by: Michel Pollet <buserror@gmail.com>
cores: Added PORTA to atmega32
Inspired by sealibora@github
Signed-off-by: Michel Pollet <buserror@gmail.com>
Merge pull request #33 from bsekisser/uart-u2x-bugfix
avr_uart.c: fix to prevent overwriting readonly flags when setting u2x.
avr_uart.c: fix to prevent overwriting readonly flags when setting u2x.
modified: simavr/sim/avr_uart.c
tests: Added a coroutine example
Slapped together test, but demonstrates a nice trick that works
on AVR for havbing multiple tasks concurently (coorperatively)
Signed-off-by: Michel Pollet <buserror@gmail.com>
mmcu: Tweak to the macros to allow multiple declarations
This trick adds the line number in the declaration of the fake
'variable' to allows multiple declarations to coexists, it is used
for the pullup/down declaration in particular
Signed-off-by: Michel Pollet <buserror@gmail.com>
Merge pull request #30 from bsekisser/sim-core-muls-bugfix
sim_core.c: fix implimentation of muls instruction
Merge pull request #29 from bsekisser/sim-core-ror-bugfix
sim_core.c: fix implimentation of ror instruction
Merge pull request #28 from bsekisser/sim-core-bld-bugfix
sim_core.c: fix implimentation of bld instruction
Merge pull request #27 from bsekisser/sim-core-inc-dec-bugfix
sim_core.c: fix implimentation of inc/dec to match specification
sim_core.c: fix implimentation of muls instruction
specification for muls insruction states 2 cycles, not one as implimented.
bug find credit goes to: Shay Green <gblargg@gmail.com>
modified: sim_core.c
sim_core.c: fix implimentation of ror instruction
prior implimentation just cleared n flag while specification states n should be set or cleared according to the most significant bit of the result.
bug find credit goes to: Shay Green <gblargg@gmail.com>
modified: simavr/sim/sim_core.c
sim_core.c: fix implimentation of bld instruction
prior implimentation of the bld insruction was ORing bit with T, rather than replacing.
bug find credit goes to: Shay Green <gblargg@gmail.com>
sim_core.c: fix implimentation of inc/dec to match specification
the avr instruction manual states that overflow be set _before_ the operation takes place, however the core tests based on the result. values checked adjusted accordingly.
bug find credit goes to: Shay Green <gblargg@gmail.com>
elf: Added support for external pullup/down
Added a new "mmcu" section to allow firmwares to specify what
IRQ value should be set when a pin is marked as input
Signed-off-by: Michel Pollet <buserror@gmail.com>
ioports: Redid the DDR handling logic
Now supports an "external" simulation of a pullup/down, this
resets the outgoing IRQ for pins to a default that can be
specified.
Signed-off-by: Michel Pollet <buserror@gmail.com>
fifo: Updated to latest version
This version was lagging quite a bit; this one has memory barriers, and
an updated write()
Signed-off-by: Michel Pollet <buserror@gmail.com>
Merge pull request #24 from sealibora/master
cores: Added atmega32
twi: Prototype support for slave mode
This is not working fully right now.
Also changed the MOSI/MISO names for the IRQ, as they make no sense when
using the master/slave TWI.
Signed-off-by: Michel Pollet <buserror@gmail.com>
elf: Redone the symbol loader
Old symbol loader had been geared for the 'trace' functionality, and was
partitularly bad since it didnt know the size of the code it was
loading.
New version loads a (sorted) array of symbols, and let the firmware
loader code deal with the old 'codeline' array. The new loaded symbol
table can be used separately (board code can look into it).
Also changed the avr_symbol_t to inline the symbol name, instead of
using a separate pointer.
Signed-off-by: Michel Pollet <buserror@gmail.com>
misc: Traces updates
Applies naming convention to globals, types etc.
twi: Added first bit of slave support
Need the slave support for TWI, will add bits as I go along
Signed-off-by: Michel Pollet <buserror@gmail.com>
megax8: Added a couple of timer modes
Pretty obvious timer modes were missing...
Signed-off-by: Michel Pollet <buserror@gmail.com>
Merge pull request #21 from bsekisser/sim_core_eicall_eijmp_bugfix
sim_core.c: extended data type to 32 bits for eicall/eijmp instruction.
sim_core.c: extended data type to 32 bits for eicall/eijmp instruction.
modified: simavr/sim/sim_core.c
core: Add an overridable logging function
AVR_LOG() now uses a logging function which can be overridden as
necessary. By default, it logs to stdout/stderr.
Fixed-up-by: schuay <jakob.gruber@gmail.com>
Merge pull request #12 from ponty/logger2
new global_logger, used in AVR_LOG(), default is stdout/stderr
io,elf: pass the trace section name to getirq
avr_iomem_getirq() now takes a 'name' for the IRQs. The elf loader now
passes down the trace name so the irq gets named properly.
Signed-off-by: Michel Pollet <buserror@gmail.com>
irq: Add a warning if the name is NULL
Names are not getting important, for the scripting project
Signed-off-by: Michel Pollet <buserror@gmail.com>
vcd: Initializes IRQs when needed only
Also manufacture an IRQ name with the one passed in add_signal
Signed-off-by: Michel Pollet <buserror@gmail.com>
io: Create irq names for io addresses
Set names for the io address IRQ when they are created
Signed-off-by: Michel Pollet <buserror@gmail.com>
ioport: Tweak IRQ names
Names should include the size in bits, if not 1
Signed-off-by: Michel Pollet <buserror@gmail.com>
Makefile: Removed uname -o
This break on BSDs (aka OSX), this commit will break windows build, it
will need a proper fix
Signed-off-by: Michel Pollet <buserror@gmail.com>
core: larger data type to store extended z-pointer value
misc: Add a Contributing section to README.md
misc: Add a Documentation section to README.md
misc: Remove outdated README
There's no point in keeping two similar README's around, and README.md
is better maintained.
new global_logger, used in AVR_LOG(), default is stdout/stderr
Merge pull request #10 from the-real-orca/mingw
MinGW merge, thanks!
mingw: make simavr compilable with MinGW
- patch makefiles to work with MinGW
- compile to run_avr.exe on windows, otherwise run_avr cannot be started from the normal windows command prompt
- add sim_network.h to encapsulate the network functions of different platforms
(use winsock2 for Windows network functions)
- make network helper functions static
- force open() to use binary mode (on Windows default is text mode)
- do not change stderr on Windows
- exclude simduino example on Windows
- add MinGW README
Signed-off-by: Stephan Veigl <veigl@gmx.net>
uart: default to 8-bit word length on reset
megax4/uart: implement u2x (double uart transmission speed)
cores: No standard include paths
There are problems with standard includes since the paths are ambiguous
between host and AVR. Using absolute includes does not work for multi-platform
projects.
The solution is to remove all standard includes of the host system for the
core files since there is no reason why a core definition should require
standard includes from the host system. User interaction (status messages)
is the job of the simulator and not the core definitions.
- add CORE_CFLAGS (-nostdinc) to Makefile.common
- remove <stdio.h> from core definition files
- move init message from core definition files to avr_init() in sim_avr.c
Signed-off-by: Stephan Veigl <veigl@gmx.net>
watchdog: Fix register naming
MCUSR is called MCUCSR in atmega128
Signed-off-by: Stephan Veigl <veigl@gmx.net>
tests: Remove vcd files on clean
Remove the vcd files generated by test cases on: make clean
Signed-off-by: Stephan Veigl <veigl@gmx.net>
tests: Fix number of successful tests calculation
Signed-off-by: Stephan Veigl <veigl@gmx.net>