Skip to content

Commit 5089d1a

Browse files
aykevldeadprogram
authored andcommitted
avr: add atmega1284 chip support
Not tested on actual hardware, only on simavr. The main motivation for adding this chip is to be able to run simulated tests using a much larger memory space (16kB RAM, 128kB flash) without jumping to the XMega devices that may not be as well supported by LLVM.
1 parent 66afcb3 commit 5089d1a

File tree

5 files changed

+41
-1
lines changed

5 files changed

+41
-1
lines changed

Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,8 @@ smoketest:
287287
$(TINYGO) build -size short -o test.hex -target=pca10056-s140v7 examples/blinky1
288288
@$(MD5SUM) test.hex
289289
ifneq ($(AVR), 0)
290+
$(TINYGO) build -size short -o test.hex -target=atmega1284p examples/serial
291+
@$(MD5SUM) test.hex
290292
$(TINYGO) build -size short -o test.hex -target=arduino examples/blinky1
291293
@$(MD5SUM) test.hex
292294
$(TINYGO) build -size short -o test.hex -target=arduino-nano examples/blinky1

src/machine/machine_atmega.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ func (uart UART) Configure(config UARTConfig) {
234234
}
235235

236236
// Register the UART interrupt.
237-
interrupt.New(avr.IRQ_USART_RX, func(intr interrupt.Interrupt) {
237+
interrupt.New(irq_USART0_RX, func(intr interrupt.Interrupt) {
238238
// Read register to clear it.
239239
data := avr.UDR0.Get()
240240

src/machine/machine_atmega1284p.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// +build avr,atmega1284p
2+
3+
package machine
4+
5+
import "device/avr"
6+
7+
const irq_USART0_RX = avr.IRQ_USART0_RX
8+
9+
// Return the current CPU frequency in hertz.
10+
func CPUFrequency() uint32 {
11+
return 20000000
12+
}

src/machine/machine_atmega328p.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// +build avr,atmega328p
2+
3+
package machine
4+
5+
import "device/avr"
6+
7+
const irq_USART0_RX = avr.IRQ_USART_RX

targets/atmega1284p.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"inherits": ["avr"],
3+
"llvm-target": "avr-atmel-none",
4+
"cpu": "atmega1284p",
5+
"build-tags": ["atmega1284p", "atmega"],
6+
"cflags": [
7+
"-mmcu=atmega1284p"
8+
],
9+
"ldflags": [
10+
"-mmcu=avr51",
11+
"-Wl,--defsym=_bootloader_size=0",
12+
"-Wl,--defsym=_stack_size=512"
13+
],
14+
"linkerscript": "src/device/avr/atmega1284p.ld",
15+
"extra-files": [
16+
"targets/avr.S",
17+
"src/device/avr/atmega1284p.s"
18+
]
19+
}

0 commit comments

Comments
 (0)