AVR_MMCU_TAG = 0,
AVR_MMCU_TAG_NAME,
AVR_MMCU_TAG_FREQUENCY,
+ AVR_MMCU_TAG_VCC,
+ AVR_MMCU_TAG_AVCC,
+ AVR_MMCU_TAG_AREF,
AVR_MMCU_TAG_LFUSE,
AVR_MMCU_TAG_HFUSE,
AVR_MMCU_TAG_EFUSE,
AVR_MCU_STRING(AVR_MMCU_TAG_NAME, _name);\
AVR_MCU_LONG(AVR_MMCU_TAG_FREQUENCY, _speed)
+#define AVR_MCU_VOLTAGES(_vcc, _avcc, _aref) \
+ AVR_MCU_LONG(AVR_MMCU_TAG_VCC, (_vcc));\
+ AVR_MCU_LONG(AVR_MMCU_TAG_AVCC, (_avcc));\
+ AVR_MCU_LONG(AVR_MMCU_TAG_AREF, (_aref));
+
#endif /* __AVR__ */
int state; // stopped, running, sleeping
uint32_t frequency; // frequency we are running at
+ // mostly used by the ADC for now
+ uint32_t vcc,avcc,aref; // (optional) voltages
// cycles gets incremented when sleeping and when running; it corresponds
// not only to "cycles that runs" but also "cycles that might have run"
void avr_load_firmware(avr_t * avr, elf_firmware_t * firmware)
{
avr->frequency = firmware->frequency;
+ avr->vcc = firmware->vcc;
+ avr->avcc = firmware->avcc;
+ avr->aref = firmware->aref;
#if CONFIG_SIMAVR_TRACE
avr->codeline = firmware->codeline;
#endif
avr_eeprom_desc_t d = { .ee = firmware->eeprom, .offset = 0, .size = firmware->eesize };
avr_ioctl(avr, AVR_IOCTL_EEPROM_SET, &d);
}
+
avr_set_command_register(avr, firmware->command_register_addr);
if (firmware->tracecount == 0)
return;
case AVR_MMCU_TAG_NAME:
strcpy(firmware->mmcu, (char*)src);
break;
+ case AVR_MMCU_TAG_VCC:
+ firmware->vcc =
+ src[0] | (src[1] << 8) | (src[2] << 16) | (src[3] << 24);
+ break;
+ case AVR_MMCU_TAG_AVCC:
+ firmware->avcc =
+ src[0] | (src[1] << 8) | (src[2] << 16) | (src[3] << 24);
+ break;
+ case AVR_MMCU_TAG_AREF:
+ firmware->aref =
+ src[0] | (src[1] << 8) | (src[2] << 16) | (src[3] << 24);
+ break;
case AVR_MMCU_TAG_VCD_TRACE: {
uint8_t mask = src[0];
uint16_t addr = src[1] | (src[2] << 8);
typedef struct elf_firmware_t {
char mmcu[64];
uint32_t frequency;
+ uint32_t vcc,avcc,aref;
char tracename[128]; // trace filename
uint32_t traceperiod;