Commit 8636d5ec8b8c66a1d46dc87681e66df5e5b452d9
authorcskarai <cskarai@freemail.hu>
Tue, 6 Jan 2015 20:32:01 +0000 (21:32 +0100)
committercskarai <cskarai@freemail.hu>
Tue, 6 Jan 2015 20:32:01 +0000 (21:32 +0100)
11 files changed:
simavr/cores/sim_mega1280.c
simavr/cores/sim_mega1281.c
simavr/cores/sim_mega128rfa1.c
simavr/cores/sim_mega128rfr2.c
simavr/cores/sim_mega169.c
simavr/cores/sim_mega2560.c
simavr/cores/sim_megax8.h
simavr/cores/sim_megaxm1.h
simavr/cores/sim_tinyx4.h
simavr/cores/sim_tinyx5.h
simavr/sim/avr_adc.h

index 63232d5575ea8ec03e6946701244e01e9185bfc3..f5c0cfd55bca50aeca99d4fb8831b57c3f5901a0 100644 (file)
@@ -246,6 +246,16 @@ const struct mcu_t {
 
                .r_adcsrb = ADCSRB,
                .adts = { AVR_IO_REGBIT(ADCSRB, ADTS0), AVR_IO_REGBIT(ADCSRB, ADTS1), AVR_IO_REGBIT(ADCSRB, ADTS2),},
+               .adts_op = {
+                       [0] = avr_adts_free_running,
+                       [1] = avr_adts_analog_comparator_0,
+                       [2] = avr_adts_external_interrupt_0,
+                       [3] = avr_adts_timer_0_compare_match_a,
+                       [4] = avr_adts_timer_0_overflow,
+                       [5] = avr_adts_timer_1_compare_match_b,
+                       [6] = avr_adts_timer_1_overflow,
+                       [7] = avr_adts_timer_1_capture_event,
+               },
 
                .muxmode = {
                        [0] = AVR_ADC_SINGLE(0), [1] = AVR_ADC_SINGLE(1),
index 6048375402b1e1d6c0a4761de83981c62aee39a2..866e58d3ba88bf4889cd8c5937d05825ca9bee19 100644 (file)
@@ -174,6 +174,16 @@ const struct mcu_t {
 
                .r_adcsrb = ADCSRB,
                .adts = { AVR_IO_REGBIT(ADCSRB, ADTS0), AVR_IO_REGBIT(ADCSRB, ADTS1), AVR_IO_REGBIT(ADCSRB, ADTS2),},
+               .adts_op = {
+                       [0] = avr_adts_free_running,
+                       [1] = avr_adts_analog_comparator_0,
+                       [2] = avr_adts_external_interrupt_0,
+                       [3] = avr_adts_timer_0_compare_match_a,
+                       [4] = avr_adts_timer_0_overflow,
+                       [5] = avr_adts_timer_1_compare_match_b,
+                       [6] = avr_adts_timer_1_overflow,
+                       [7] = avr_adts_timer_1_capture_event,
+               },
 
                .muxmode = {
                        [0] = AVR_ADC_SINGLE(0), [1] = AVR_ADC_SINGLE(1),
index 5619380238939f63128655c9d6124a710593b0e9..6a2937adde8391f7e69d34b680b42f1bc9744706 100644 (file)
@@ -188,6 +188,16 @@ const struct mcu_t {
 
                .r_adcsrb = ADCSRB,
                .adts = { AVR_IO_REGBIT(ADCSRB, ADTS0), AVR_IO_REGBIT(ADCSRB, ADTS1), AVR_IO_REGBIT(ADCSRB, ADTS2),},
+               .adts_op = {
+                       [0] = avr_adts_free_running,
+                       [1] = avr_adts_analog_comparator_0,
+                       [2] = avr_adts_external_interrupt_0,
+                       [3] = avr_adts_timer_0_compare_match_a,
+                       [4] = avr_adts_timer_0_overflow,
+                       [5] = avr_adts_timer_1_compare_match_b,
+                       [6] = avr_adts_timer_1_overflow,
+                       [7] = avr_adts_timer_1_capture_event,
+               },
 
                .muxmode = {
                        [0] = AVR_ADC_SINGLE(0), [1] = AVR_ADC_SINGLE(1),
index 1a7e6c412ebd92fd1ea94d0c43943fe3952eecd9..0fe003506add9d3e0f447fa63948416d652dce8d 100644 (file)
@@ -214,6 +214,16 @@ const struct mcu_t {
 
                .r_adcsrb = ADCSRB,
                .adts = { AVR_IO_REGBIT(ADCSRB, ADTS0), AVR_IO_REGBIT(ADCSRB, ADTS1), AVR_IO_REGBIT(ADCSRB, ADTS2),},
+               .adts_op = {
+                       [0] = avr_adts_free_running,
+                       [1] = avr_adts_analog_comparator_0,
+                       [2] = avr_adts_external_interrupt_0,
+                       [3] = avr_adts_timer_0_compare_match_a,
+                       [4] = avr_adts_timer_0_overflow,
+                       [5] = avr_adts_timer_1_compare_match_b,
+                       [6] = avr_adts_timer_1_overflow,
+                       [7] = avr_adts_timer_1_capture_event,
+               },
 
                .muxmode = {
                        [0] = AVR_ADC_SINGLE(0), [1] = AVR_ADC_SINGLE(1),
index e7aeef3c373e7187e6b532310bd316d762cec6c5..30b387d3b53776b5f4cd08a5d1c1e8476b25f16a 100644 (file)
@@ -128,6 +128,16 @@ const struct mcu_t {
 
                .r_adcsrb = ADCSRB,
                .adts = { AVR_IO_REGBIT(ADCSRB, ADTS0), AVR_IO_REGBIT(ADCSRB, ADTS1), AVR_IO_REGBIT(ADCSRB, ADTS2),},
+               .adts_op = {
+                       [0] = avr_adts_free_running,
+                       [1] = avr_adts_analog_comparator_0,
+                       [2] = avr_adts_external_interrupt_0,
+                       [3] = avr_adts_timer_0_compare_match_a,
+                       [4] = avr_adts_timer_0_overflow,
+                       [5] = avr_adts_timer_1_compare_match_b,
+                       [6] = avr_adts_timer_1_overflow,
+                       [7] = avr_adts_timer_1_capture_event,
+               },
 
                .muxmode = {
                        [0] = AVR_ADC_SINGLE(0), [1] = AVR_ADC_SINGLE(1),
index 4e333fdbd22e21cb5912477c85ebd53bfd37a1f0..2d22b4f2c693bde6c44899796e30091c3bfd2baf 100644 (file)
@@ -248,6 +248,16 @@ const struct mcu_t {
 
                .r_adcsrb = ADCSRB,
                .adts = { AVR_IO_REGBIT(ADCSRB, ADTS0), AVR_IO_REGBIT(ADCSRB, ADTS1), AVR_IO_REGBIT(ADCSRB, ADTS2),},
+               .adts_op = {
+                       [0] = avr_adts_free_running,
+                       [1] = avr_adts_analog_comparator_0,
+                       [2] = avr_adts_external_interrupt_0,
+                       [3] = avr_adts_timer_0_compare_match_a,
+                       [4] = avr_adts_timer_0_overflow,
+                       [5] = avr_adts_timer_1_compare_match_b,
+                       [6] = avr_adts_timer_1_overflow,
+                       [7] = avr_adts_timer_1_capture_event,
+               },
 
                .muxmode = {
                         [0] = AVR_ADC_SINGLE(0), [1] = AVR_ADC_SINGLE(1),
index 28d4def384502d915a59d71a1896dbc140cd034a..d7d08b8c0031b131731c54eeba35d77cac058603 100644 (file)
@@ -168,6 +168,16 @@ const struct mcu_t SIM_CORENAME = {
 
                .r_adcsrb = ADCSRB,
                .adts = { AVR_IO_REGBIT(ADCSRB, ADTS0), AVR_IO_REGBIT(ADCSRB, ADTS1), AVR_IO_REGBIT(ADCSRB, ADTS2),},
+               .adts_op = {
+                       [0] = avr_adts_free_running,
+                       [1] = avr_adts_analog_comparator_0,
+                       [2] = avr_adts_external_interrupt_0,
+                       [3] = avr_adts_timer_0_compare_match_a,
+                       [4] = avr_adts_timer_0_overflow,
+                       [5] = avr_adts_timer_1_compare_match_b,
+                       [6] = avr_adts_timer_1_overflow,
+                       [7] = avr_adts_timer_1_capture_event,
+               },
 
                .muxmode = {
                        [0] = AVR_ADC_SINGLE(0), [1] = AVR_ADC_SINGLE(1),
index fdb929d7947fd8123637c1978bd3d532da05961c..cebceeaefafdcf9bc117388052f2afe91b58eb40 100644 (file)
@@ -171,7 +171,23 @@ const struct mcu_t SIM_CORENAME = {
                .r_adcl = ADCL,
 
                .r_adcsrb = ADCSRB,
-               .adts = { AVR_IO_REGBIT(ADCSRB, ADTS0), AVR_IO_REGBIT(ADCSRB, ADTS1), AVR_IO_REGBIT(ADCSRB, ADTS2),},
+               .adts = { AVR_IO_REGBIT(ADCSRB, ADTS0), AVR_IO_REGBIT(ADCSRB, ADTS1), AVR_IO_REGBIT(ADCSRB, ADTS2), AVR_IO_REGBIT(ADCSRB, ADTS3),},
+               .adts_op = {
+                       [0] = avr_adts_free_running,
+                       [1] = avr_adts_external_interrupt_0,
+                       [2] = avr_adts_timer_0_compare_match_a,
+                       [3] = avr_adts_timer_0_overflow,
+                       [4] = avr_adts_timer_1_compare_match_b,
+                       [5] = avr_adts_timer_1_overflow,
+                       [6] = avr_adts_timer_1_capture_event,
+                       [7] = avr_adts_psc_module_0_sync_signal,
+                       [8] = avr_adts_psc_module_1_sync_signal,
+                       [9] = avr_adts_psc_module_2_sync_signal,
+                       [10] = avr_adts_analog_comparator_0,
+                       [11] = avr_adts_analog_comparator_1,
+                       [12] = avr_adts_analog_comparator_2,
+                       [13] = avr_adts_analog_comparator_3,
+               },
 
                .muxmode = {
                        [0] = AVR_ADC_SINGLE(0), [1] = AVR_ADC_SINGLE(1),
index 2ce12b34388e172cacf7334e61c96b6510713bb4..879239b1e630e1ccf2d4ef278e1b4163522ee816 100644 (file)
@@ -110,6 +110,16 @@ const struct mcu_t SIM_CORENAME = {
 
         .r_adcsrb = ADCSRB,
         .adts = { AVR_IO_REGBIT(ADCSRB, ADTS0), AVR_IO_REGBIT(ADCSRB, ADTS1), AVR_IO_REGBIT(ADCSRB, ADTS2),},
+        .adts_op = {
+          [0] = avr_adts_free_running,
+          [1] = avr_adts_analog_comparator_0,
+          [2] = avr_adts_external_interrupt_0,
+          [3] = avr_adts_timer_0_compare_match_a,
+          [4] = avr_adts_timer_0_overflow,
+          [5] = avr_adts_timer_1_compare_match_b,
+          [6] = avr_adts_timer_1_overflow,
+          [7] = avr_adts_timer_1_capture_event,
+        },
         .bin = AVR_IO_REGBIT(ADCSRB, BIN),
 
         .muxmode = {
index 44dbd06b88b2fd83b4e9a55fba05cb39e32fb342..cc88196259c68aab2b7d2202a6d177b0e9d9e235 100644 (file)
@@ -102,6 +102,16 @@ const struct mcu_t SIM_CORENAME = {
 
                .r_adcsrb = ADCSRB,
                .adts = { AVR_IO_REGBIT(ADCSRB, ADTS0), AVR_IO_REGBIT(ADCSRB, ADTS1), AVR_IO_REGBIT(ADCSRB, ADTS2),},
+               .adts_op = {
+                       [0] = avr_adts_free_running,
+                       [1] = avr_adts_analog_comparator_0,
+                       [2] = avr_adts_external_interrupt_0,
+                       [3] = avr_adts_timer_0_compare_match_a,
+                       [4] = avr_adts_timer_0_overflow,
+                       [5] = avr_adts_timer_0_compare_match_b,
+                       [6] = avr_adts_pin_change_interrupt,
+               },
+               
                .bin = AVR_IO_REGBIT(ADCSRB, BIN),
                .ipr = AVR_IO_REGBIT(ADCSRA, IPR),
 
index e1e75d18d94ab0dbd8d0343a380cc48dd21ea269..4257312e3b56e9705c07b5f310886b5026864f56 100644 (file)
@@ -80,6 +80,27 @@ enum {
        ADC_VREF_V256   = 2560,
 };
 
+// ADC trigger sources
+typedef enum {
+       avr_adrs_invalid = 0,
+       avr_adts_free_running,
+       avr_adts_analog_comparator_0,
+       avr_adts_analog_comparator_1,
+       avr_adts_analog_comparator_2,
+       avr_adts_analog_comparator_3,
+       avr_adts_external_interrupt_0,
+       avr_adts_timer_0_compare_match_a,
+       avr_adts_timer_0_compare_match_b,
+       avr_adts_timer_0_overflow,
+       avr_adts_timer_1_compare_match_b,
+       avr_adts_timer_1_overflow,
+       avr_adts_timer_1_capture_event,
+       avr_adts_pin_change_interrupt,
+       avr_adts_psc_module_0_sync_signal,
+       avr_adts_psc_module_1_sync_signal,
+       avr_adts_psc_module_2_sync_signal,
+} avr_adts_type;
+
 typedef struct avr_adc_t {
        avr_io_t                io;
 
@@ -101,7 +122,8 @@ typedef struct avr_adc_t {
        uint8_t                 r_adcl, r_adch; // Data Registers
 
        uint8_t                 r_adcsrb;       // ADC Control and Status Register B
-       avr_regbit_t    adts[3];        // Timing Source
+       avr_regbit_t    adts[4];        // Timing Source
+       avr_adts_type   adts_op[16];    // ADTS type
        avr_regbit_t    bin;            // Bipolar Input Mode (tinyx5 have it)
        avr_regbit_t    ipr;            // Input Polarity Reversal (tinyx5 have it)