@@ -1660,21 +1660,24 @@ int MbedTester::set_mux_addr(PinName pin)
1660
1660
1661
1661
int MbedTester::set_mux_addr_index (int index)
1662
1662
{
1663
- int addr_pin = (int )AnalogMuxAddr0;
1664
- for (int i = 0 ; i < 8 ; i += 1 ) {
1665
- sys_pin_write ((SystemPin)addr_pin, (((1 << i) & index) >> i), true );
1666
- addr_pin += 1 ;
1667
- }
1663
+ sys_pin_write (AnalogMuxAddr0, index & 0x01 , true );
1664
+ sys_pin_write (AnalogMuxAddr1, (index & 0x02 ) >> 1 , true );
1665
+ sys_pin_write (AnalogMuxAddr2, (index & 0x04 ) >> 2 , true );
1666
+ sys_pin_write (AnalogMuxAddr3, (index & 0x08 ) >> 3 , true );
1667
+ sys_pin_write (AnalogMuxAddr4, (index & 0x10 ) >> 4 , true );
1668
+ sys_pin_write (AnalogMuxAddr5, (index & 0x20 ) >> 5 , true );
1669
+ sys_pin_write (AnalogMuxAddr6, (index & 0x40 ) >> 6 , true );
1670
+ sys_pin_write (AnalogMuxAddr7, (index & 0x80 ) >> 7 , true );
1668
1671
1669
1672
return 0 ;
1670
1673
}
1671
1674
1672
1675
void MbedTester::set_mux_enable (bool val)
1673
1676
{
1674
1677
if (val == true ) {
1675
- sys_pin_write (AnalogMuxEnable, 1 , true );
1678
+ sys_pin_write (AnalogMuxEnable, 0 , true );// enable analog MUXes
1676
1679
} else if (val == false ) {
1677
- sys_pin_write (AnalogMuxEnable, 0 , true );
1680
+ sys_pin_write (AnalogMuxEnable, 1 , true );// disable analog MUXes
1678
1681
}
1679
1682
wait_us (10 );
1680
1683
}
@@ -1734,7 +1737,7 @@ uint16_t MbedTester::get_analogmuxin_measurement()
1734
1737
// take snapshot of conversion value to make safe for reading
1735
1738
set_snapshot ();
1736
1739
uint16_t an_mux_analogin_measurement = 0 ;
1737
- read (TESTER_SYS_AN_MUX_ANALOGIN_MEASUREMENT , (uint8_t *)&an_mux_analogin_measurement, sizeof (an_mux_analogin_measurement));
1740
+ read (TESTER_SYS_IO_AN_MUX_ANALOGIN_MEASUREMENT , (uint8_t *)&an_mux_analogin_measurement, sizeof (an_mux_analogin_measurement));
1738
1741
return an_mux_analogin_measurement;
1739
1742
}
1740
1743
@@ -1747,7 +1750,7 @@ uint16_t MbedTester::get_anin_measurement(int index)
1747
1750
// take snapshot of conversion value to make safe for reading
1748
1751
set_snapshot ();
1749
1752
uint16_t anin_measurement = 0 ;
1750
- read ((TESTER_SYS_ANIN0_MEASUREMENT + (index * 10 )), (uint8_t *)&anin_measurement, sizeof (anin_measurement)); // 10 because sizeof measurement + sizeof measurements_sum = 10
1753
+ read ((TESTER_SYS_IO_ANIN0_MEASUREMENT + (index * 10 )), (uint8_t *)&anin_measurement, sizeof (anin_measurement)); // 10 because sizeof measurement + sizeof measurements_sum = 10
1751
1754
return anin_measurement;
1752
1755
}
1753
1756
@@ -1759,15 +1762,15 @@ void MbedTester::get_anin_sum_samples_cycles(int index, uint64_t *sum, uint32_t
1759
1762
}
1760
1763
// take snapshot of the sum/samples/cycles so that all 3 values are correct in relation to each other
1761
1764
set_snapshot ();
1762
- read ((TESTER_SYS_ANIN0_MEASUREMENTS_SUM + (index * 10 )), (uint8_t *)sum, sizeof (*sum)); // 10 because sizeof measurement + sizeof measurements_sum = 10
1763
- read (TESTER_SYS_NUM_POWER_SAMPLES , (uint8_t *)samples, sizeof (*samples));
1764
- read (TESTER_SYS_NUM_POWER_CYCLES , (uint8_t *)cycles, sizeof (*cycles));
1765
+ read ((TESTER_SYS_IO_ANIN0_MEASUREMENTS_SUM + (index * 10 )), (uint8_t *)sum, sizeof (*sum)); // 10 because sizeof measurement + sizeof measurements_sum = 10
1766
+ read (TESTER_SYS_IO_NUM_POWER_SAMPLES , (uint8_t *)samples, sizeof (*samples));
1767
+ read (TESTER_SYS_IO_NUM_POWER_CYCLES , (uint8_t *)cycles, sizeof (*cycles));
1765
1768
}
1766
1769
1767
1770
void MbedTester::set_snapshot ()
1768
1771
{
1769
1772
uint8_t data = 1 ;
1770
- write (TESTER_SYS_ADC_SNAPSHOT , &data, sizeof (data));
1773
+ write (TESTER_SYS_IO_ADC_SNAPSHOT , &data, sizeof (data));
1771
1774
wait_us (1 );
1772
1775
}
1773
1776
@@ -1779,7 +1782,7 @@ void MbedTester::set_sample_adc(bool val)
1779
1782
} else if (val == false ) {
1780
1783
data = 0 ;
1781
1784
}
1782
- write (TESTER_SYS_SAMPLE_ADC , &data, sizeof (data));
1785
+ write (TESTER_SYS_IO_SAMPLE_ADC , &data, sizeof (data));
1783
1786
}
1784
1787
1785
1788
float MbedTester::get_analog_in ()
0 commit comments