-
Notifications
You must be signed in to change notification settings - Fork 85
Open
Labels
questionFurther information is requestedFurther information is requested
Description
As part of the discussion in #67, I started working on creating a simpler API for using the simulator.
For instance, creating an ATmega328p simulation, will look something like:
import { createAVR, ATmega328p } from 'avr8js';
const { cpu } = createAVR(ATmega328p);
// Microcontroller loop
while (...) {
avrInstruction(cpu);
cpu.tick();
}The idea is that createAVR() will return an object that contains the CPU and all the peripherals:
{
cpu: CPU;
timers: AVRTimer[];
clock: AVRClock[];
eeprom: AVREEPROM;
spi: AVRSPI;
usart: AVRUSART[];
twi: AVRTWI;
gpio: { [key: string]: AVRIOPort };
};e.g. if you need accept to GPIO port B and the first hardware USART peripheral you could do something like:
const { cpu, gpio, usart } = createAVR(ATmega328p);
gpio.B.addListener(() => {
// listener code
});
usart[0].onLineTransmit = () => {
// listener code
};
I've created a prototype in the simpler-api branch, and would love to hear your thoughts - especially from people who worked with the current API in the past, e.g. @gfeun, @elliottkember, @ricardojlrufino, @SebastianZug, @tawjaw, @yiivon.
Should we keep the API the way it is? Do you like the proposed API better? What can we improve?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
questionFurther information is requestedFurther information is requested