Skip to content

Commit 5889376

Browse files
committed
Add support for atxmega128a4u
1 parent a63c4b2 commit 5889376

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed

sim/aviron/src/lib/mcu.zig

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,3 +170,28 @@ pub const atmega2560 = Config{
170170
.io_window_base = 0x20,
171171
.io_window_end = 0x00FF,
172172
};
173+
174+
/// ATxmega128A4U configuration (XMEGA A-series)
175+
pub const xmega128a4u = Config{
176+
.name = "ATxmega128A4U",
177+
.flash_size = 131072, // 128 KiB
178+
.sram_size = 8192, // 8 KiB
179+
.sram_base = 0x2000, // XMEGA SRAM typically starts at 0x2000
180+
.eeprom_size = 2048, // 2 KiB
181+
.code_model = .code22,
182+
.instruction_set = .avrxmega,
183+
.special_io = .{
184+
// XMEGA provides RAMP registers; EIND is present on parts with >128 KiB, but define for completeness.
185+
.ramp_x = 0x39,
186+
.ramp_y = 0x3A,
187+
.ramp_z = 0x3B,
188+
.ramp_d = 0x38,
189+
.e_ind = 0x3C,
190+
.sp_l = 0x3D,
191+
.sp_h = 0x3E,
192+
.sreg = 0x3F,
193+
},
194+
// XMEGA extended I/O space up to 0x0FFF (12-bit I/O addresses)
195+
.io_window_base = 0x20,
196+
.io_window_end = 0x0FFF,
197+
};

sim/aviron/src/main.zig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ pub fn main() !u8 {
2626
.atmega328p => aviron.mcu.atmega328p,
2727
.attiny816 => aviron.mcu.attiny816,
2828
.atmega2560 => aviron.mcu.atmega2560,
29+
.xmega128a4u => aviron.mcu.xmega128a4u,
2930
};
3031

3132
// Allocate memory based on MCU configuration
@@ -165,6 +166,7 @@ pub const MCU = enum {
165166
atmega328p,
166167
attiny816,
167168
atmega2560,
169+
xmega128a4u,
168170
};
169171

170172
pub const FileFormat = enum {

sim/aviron/src/testrunner.zig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ fn run_test_with_mcu(
3636
try run_test(allocator, aviron.mcu.attiny816, test_config, options, elf_paths);
3737
} else if (std.ascii.eqlIgnoreCase(mcu_name, "ATmega2560")) {
3838
try run_test(allocator, aviron.mcu.atmega2560, test_config, options, elf_paths);
39+
} else if (std.ascii.eqlIgnoreCase(mcu_name, "ATxmega128A4U")) {
40+
try run_test(allocator, aviron.mcu.xmega128a4u, test_config, options, elf_paths);
3941
} else {
4042
std.debug.print("MCU '{s}' not yet supported in test runner\n", .{mcu_name});
4143
return error.UnsupportedMCU;

0 commit comments

Comments
 (0)