avr: add Arduino Mega 2560

This commit is contained in:
Travis McLane
2020-03-24 16:24:47 -05:00
committed by GitHub
parent 26aba72729
commit 83426edcdc
7 changed files with 341 additions and 48 deletions
+14 -1
View File
@@ -2,7 +2,10 @@
package machine
import "device/avr"
import (
"device/avr"
"runtime/volatile"
)
const irq_USART0_RX = avr.IRQ_USART0_RX
@@ -10,3 +13,13 @@ const irq_USART0_RX = avr.IRQ_USART0_RX
func CPUFrequency() uint32 {
return 20000000
}
func (p Pin) getPortMask() (*volatile.Register8, uint8) {
if p < 8 {
return avr.PORTD, 1 << uint8(p)
} else if p < 14 {
return avr.PORTB, 1 << uint8(p-8)
} else {
return avr.PORTC, 1 << uint8(p-14)
}
}