Files
tinygo/src/machine/machine_attiny1616.go
T
Ayke van Laethem 2fb866ca86 avr: add attiny1616 support
This is just support for the chip, no boards are currently supported.
However, you can use this target on a custom board.

Notes:

  - This required a new runtime and machine implementation, because the
    hardware is actually very different (and much nicer than older
    AVRs!).
  - I had to update gen-device-avr to support this chip. This also
    affects the generated output of other AVRs, but I checked all chips
    we support and there shouldn't be any backwards incompatible
    changes.
  - I did not implement peripherals like UART, I2C, SPI, etc because I
    don't need them. That is left to do in the future.

You can flash these chips with only a UART and a 1kOhm resistor, which
is really nice (no special hardware needed). Here is the program I've
used for this purpose: https://pypi.org/project/pymcuprog/
2023-05-20 21:18:02 +02:00

53 lines
881 B
Go

//go:build attiny1616
package machine
import (
"device/avr"
)
const (
portA Pin = iota * 8
portB
portC
)
const (
PA0 = portA + 0
PA1 = portA + 1
PA2 = portA + 2
PA3 = portA + 3
PA4 = portA + 4
PA5 = portA + 5
PA6 = portA + 6
PA7 = portA + 7
PB0 = portB + 0
PB1 = portB + 1
PB2 = portB + 2
PB3 = portB + 3
PB4 = portB + 4
PB5 = portB + 5
PB6 = portB + 6
PB7 = portB + 7
PC0 = portC + 0
PC1 = portC + 1
PC2 = portC + 2
PC3 = portC + 3
PC4 = portC + 4
PC5 = portC + 5
PC6 = portC + 6
PC7 = portC + 7
)
// getPortMask returns the PORT peripheral and mask for the pin.
func (p Pin) getPortMask() (*avr.PORT_Type, uint8) {
switch {
case p >= PA0 && p <= PA7: // port A
return avr.PORTA, 1 << uint8(p-portA)
case p >= PB0 && p <= PB7: // port B
return avr.PORTB, 1 << uint8(p-portB)
default: // port C
return avr.PORTC, 1 << uint8(p-portC)
}
}