Also added a sanity check
Signed-off-by: Michel Pollet <buserror@gmail.com>
2 files changed:
R_SREG = 32+0x3f,
// maximum number of IO registers, on normal AVRs
- MAX_IOs = 256 - 32, // minus 32 GP registers
+ MAX_IOs = 256, // Bigger AVRs need more than 256-32 (mega1280)
};
#define AVR_DATA_TO_IO(v) ((v) - 32)
{
avr_io_addr_t a = AVR_DATA_TO_IO(addr);
+ if (a >= MAX_IOs) {
+ fprintf(stderr,
+ "Error: avr_register_io_write(): IO address 0x%04x out of range (max 0x%04x).\n",
+ a, MAX_IOs);
+ abort();
+ }
/*
* Verifying that some other piece of code is not installed to watch write
* on this address. If there is, this code installs a "dispatcher" callback