Documentation
  • Coverage
  • 9.91%
    23 out of 232 items documented0 out of 121 items with examples
  • Size
  • Source code size: 48.45 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 6.54 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 10s Average build duration of successful builds.
  • all releases: 10s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • dylanmckay/avr
    17 1 1
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • dylanmckay

AVR emulator

Build Status Crates.io MIT licensed

This program emulates an 8-bit AVR microcontroller. It supports the trivial C "Hello World!" program.

NOTE: This emulator isn't quite complete. One notable thing is that not all status register updates are implemented for all instructions (#2).

Given some C++ source.

#include <avr/io.h>
#include <util/delay.h>

int main() {
  DDRB |= _BV(PB6);

  for(uint8_t i=0; i<5; i++) {
    PORTB |= _BV(PB6);
    _delay_ms(500);

    PORTB &= ~_BV(PB6);
    _delay_ms(500);
  }

  return 0;
}
# Generate an ELF object file for the Atmega328p
avr-g++ hello_world.c -DF_CPU=8000000 -mmcu=atmega328p -O2 -o hello_world.o

# Generate a raw binary
avr-objcopy -I elf32-avr -O binary hello_world.o hello_world.bin

cargo run hello_world.bin