Commit 55bbf1a9a25e034524d8581a2e1e104d03101e1f
authorMichel Pollet <buserror@gmail.com>
Wed, 14 Sep 2011 08:07:07 +0000 (09:07 +0100)
committerMichel Pollet <buserror@gmail.com>
Wed, 14 Sep 2011 08:07:07 +0000 (09:07 +0100)
For mega16m1

Signed-off-by: Markus Lampert <mlampert@telus.net>
Signed-off-by: Michel Pollet <buserror@gmail.com>
2 files changed:
simavr/sim/avr_adc.c
simavr/sim/avr_adc.h

index f2b2606690f85ee99237bf5339f985712d31efc5..e771ff63aff99b9d7280678729fecd2297bbe793 100644 (file)
@@ -68,6 +68,12 @@ static uint8_t avr_adc_read_l(struct avr_t * avr, avr_io_addr_t addr, void * par
                case ADC_MUX_REF:
                        reg = mux.src; // reference voltage
                        break;
+               case ADC_MUX_VCC4:
+                       if ( !avr->vcc) {
+                               printf("ADC Warning : missing VCC analog voltage\n");
+                       } else
+                               reg = avr->vcc / 4;
+                       break;
        }
        uint32_t vref = 3300;
        switch (ref) {
index 85f82cfec4479d42e3d7fe36b6802ecd65d7b74e..c453f87cdebbf71f5ea4dee802cb6d7d0de4000c 100644 (file)
@@ -60,6 +60,7 @@ enum {
        ADC_MUX_DIFF,                   // differencial channels (src-diff)
        ADC_MUX_TEMP,                   // internal temp sensor
        ADC_MUX_REF,                    // reference voltage (in src * 100)
+       ADC_MUX_VCC4,                   // VCC/4
 };
 typedef struct avr_adc_mux_t {
        unsigned long kind : 3, gain : 8, diff : 8, src : 13;
@@ -135,4 +136,8 @@ void avr_adc_init(avr_t * avr, avr_adc_t * port);
                .kind = ADC_MUX_TEMP, \
        }
 
+#define AVR_ADC_VCC4() { \
+               .kind = ADC_MUX_VCC4, \
+       }
+
 #endif /* __AVR_ADC_H___ */