Skip to content

CreateAVR: Refactor ATmega328p #165

@atluft

Description

@atluft

I would like to refactor the existing ATmega328p implementation to utilize the implementation mentioned in pull request 138: Add ATmega32

Definition of done:

  1. Refactor the existing ATmega328p chip details in a single file named src/chips/ATmega328p.ts
  2. Implement the CreateAVR function as provided in the ATMega32 effort
  3. npm test reports all tests passed
  4. npm start demo shows a blinking led

My ultimate goal is to add the ATtiny841 and believe this is a solid step towards adding any new chip, ATtiny841, ATmega32, and so on.

Here is a GIST for ADC testing. Created this section to convey one possible approach. Open to other ideas.

import { ATmega328p } from '../chips/ATmega328p';
import { createAVR } from '../create-avr';

. . . SNIP . . .

    const avr = createAVR(ATmega328p, { program: program });
    const cpu = avr.cpu;
    const adc = avr.adc;
    const runner = new TestProgramRunner(cpu);

Notice:

  • createAVR is being utilized
  • New / refactored ATmega328p configuration is provided as input argument
  • program remains unchanged from existing
  • cpu and adc are instantiated by createAVR using the ATmega328p configuration
  • in the future new Chip configurations could be utilized and tested as needed

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions