Skip to content

Commit e2312c4

Browse files
committed
Bring in more changes from FPGA repo
Bring in updates the the FPGA CI Test Shield repo.
1 parent 166ff13 commit e2312c4

File tree

5 files changed

+68
-27
lines changed

5 files changed

+68
-27
lines changed

components/testing/COMPONENT_FPGA_CI_TEST_SHIELD/MbedTester.cpp

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1660,21 +1660,24 @@ int MbedTester::set_mux_addr(PinName pin)
16601660

16611661
int MbedTester::set_mux_addr_index(int index)
16621662
{
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);
16681671

16691672
return 0;
16701673
}
16711674

16721675
void MbedTester::set_mux_enable(bool val)
16731676
{
16741677
if (val == true) {
1675-
sys_pin_write(AnalogMuxEnable, 1, true);
1678+
sys_pin_write(AnalogMuxEnable, 0, true);//enable analog MUXes
16761679
} else if (val == false) {
1677-
sys_pin_write(AnalogMuxEnable, 0, true);
1680+
sys_pin_write(AnalogMuxEnable, 1, true);//disable analog MUXes
16781681
}
16791682
wait_us(10);
16801683
}
@@ -1734,7 +1737,7 @@ uint16_t MbedTester::get_analogmuxin_measurement()
17341737
//take snapshot of conversion value to make safe for reading
17351738
set_snapshot();
17361739
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));
17381741
return an_mux_analogin_measurement;
17391742
}
17401743

@@ -1747,7 +1750,7 @@ uint16_t MbedTester::get_anin_measurement(int index)
17471750
//take snapshot of conversion value to make safe for reading
17481751
set_snapshot();
17491752
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
17511754
return anin_measurement;
17521755
}
17531756

@@ -1759,15 +1762,15 @@ void MbedTester::get_anin_sum_samples_cycles(int index, uint64_t *sum, uint32_t
17591762
}
17601763
//take snapshot of the sum/samples/cycles so that all 3 values are correct in relation to each other
17611764
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));
17651768
}
17661769

17671770
void MbedTester::set_snapshot()
17681771
{
17691772
uint8_t data = 1;
1770-
write(TESTER_SYS_ADC_SNAPSHOT, &data, sizeof(data));
1773+
write(TESTER_SYS_IO_ADC_SNAPSHOT, &data, sizeof(data));
17711774
wait_us(1);
17721775
}
17731776

@@ -1779,7 +1782,7 @@ void MbedTester::set_sample_adc(bool val)
17791782
} else if (val == false) {
17801783
data = 0;
17811784
}
1782-
write(TESTER_SYS_SAMPLE_ADC, &data, sizeof(data));
1785+
write(TESTER_SYS_IO_SAMPLE_ADC, &data, sizeof(data));
17831786
}
17841787

17851788
float MbedTester::get_analog_in()

components/testing/COMPONENT_FPGA_CI_TEST_SHIELD/UARTTester.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,12 @@ void UARTTester::tx_stop()
114114
write(TESTER_UART_TX_CONTROL, (uint8_t *)&control, sizeof(control));
115115
}
116116

117+
void UARTTester::tx_set_delay(uint32_t delay_ns)
118+
{
119+
uint32_t delay_clks = (delay_ns + TESTER_CLOCK_PERIOD_NS - 1) / TESTER_CLOCK_PERIOD_NS;
120+
write(TESTER_UART_TX_DELAY, (uint8_t *)&delay_clks, sizeof(delay_clks));
121+
}
122+
117123
void UARTTester::tx_set_count(uint32_t count)
118124
{
119125
write(TESTER_UART_TX_COUNT, (uint8_t *)&count, sizeof(count));

components/testing/COMPONENT_FPGA_CI_TEST_SHIELD/UARTTester.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,14 @@ class UARTTester: public MbedTester {
126126
*/
127127
void tx_stop();
128128

129+
/**
130+
* Set the delay after the tx_start() call and before the actual start
131+
* of UART transmission
132+
*
133+
* @param delay in nanoseconds
134+
*/
135+
void tx_set_delay(uint32_t delay_ns);
136+
129137
/**
130138
* Set the number of bytes to send
131139
*

components/testing/COMPONENT_FPGA_CI_TEST_SHIELD/fpga_config.h

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -35,19 +35,19 @@
3535
#define TESTER_SYS_IO_PWM_ENABLE (0x001 + 0x00002C00)
3636
#define TESTER_SYS_IO_PWM_PERIOD (0x002 + 0x00002C00)
3737
#define TESTER_SYS_IO_PWM_CYCLES_HIGH (0x006 + 0x00002C00)
38-
#define TESTER_SYS_AN_MUX_ANALOGIN_MEASUREMENT (0x00A + 0x00002C00)
39-
#define TESTER_SYS_NUM_POWER_SAMPLES (0x00C + 0x00002C00)
40-
#define TESTER_SYS_NUM_POWER_CYCLES (0x010 + 0x00002C00)
41-
#define TESTER_SYS_ADC_SNAPSHOT (0x018 + 0x00002C00)
42-
#define TESTER_SYS_SAMPLE_ADC (0x019 + 0x00002C00)
43-
#define TESTER_SYS_ANIN0_MEASUREMENT (0x030 + 0x00002C00)
44-
#define TESTER_SYS_ANIN0_MEASUREMENTS_SUM (0x032 + 0x00002C00)
45-
#define TESTER_SYS_ANIN1_MEASUREMENT (0x03A + 0x00002C00)
46-
#define TESTER_SYS_ANIN1_MEASUREMENTS_SUM (0x03C + 0x00002C00)
47-
#define TESTER_SYS_ANIN2_MEASUREMENT (0x044 + 0x00002C00)
48-
#define TESTER_SYS_ANIN2_MEASUREMENTS_SUM (0x046 + 0x00002C00)
49-
#define TESTER_SYS_ANIN3_MEASUREMENT (0x04E + 0x00002C00)
50-
#define TESTER_SYS_ANIN3_MEASUREMENTS_SUM (0x050 + 0x00002C00)
38+
#define TESTER_SYS_IO_AN_MUX_ANALOGIN_MEASUREMENT (0x00A + 0x00002C00)
39+
#define TESTER_SYS_IO_NUM_POWER_SAMPLES (0x00C + 0x00002C00)
40+
#define TESTER_SYS_IO_NUM_POWER_CYCLES (0x010 + 0x00002C00)
41+
#define TESTER_SYS_IO_ADC_SNAPSHOT (0x018 + 0x00002C00)
42+
#define TESTER_SYS_IO_SAMPLE_ADC (0x019 + 0x00002C00)
43+
#define TESTER_SYS_IO_ANIN0_MEASUREMENT (0x030 + 0x00002C00)
44+
#define TESTER_SYS_IO_ANIN0_MEASUREMENTS_SUM (0x032 + 0x00002C00)
45+
#define TESTER_SYS_IO_ANIN1_MEASUREMENT (0x03A + 0x00002C00)
46+
#define TESTER_SYS_IO_ANIN1_MEASUREMENTS_SUM (0x03C + 0x00002C00)
47+
#define TESTER_SYS_IO_ANIN2_MEASUREMENT (0x044 + 0x00002C00)
48+
#define TESTER_SYS_IO_ANIN2_MEASUREMENTS_SUM (0x046 + 0x00002C00)
49+
#define TESTER_SYS_IO_ANIN3_MEASUREMENT (0x04E + 0x00002C00)
50+
#define TESTER_SYS_IO_ANIN3_MEASUREMENTS_SUM (0x050 + 0x00002C00)
5151
#define TESTER_PERIPHERAL 0x00100000
5252
#define TESTER_PERIPHERAL_SELECT 0x00100000
5353
#define TESTER_GPIO 0x00101000
@@ -169,6 +169,8 @@
169169
#define TESTER_UART_TX_NEXT_SIZE 2
170170
#define TESTER_UART_CTS_DEACTIVATE_DELAY (0x210 + 0x00104000)
171171
#define TESTER_UART_CTS_DEACTIVATE_DELAY_SIZE 4
172+
#define TESTER_UART_TX_DELAY (0x214 + 0x00104000)
173+
#define TESTER_UART_TX_DELAY_SIZE 4
172174
#define TESTER_I2C_STARTS (0x000 + 0x00105000)
173175
#define TESTER_I2C_STOPS (0x001 + 0x00105000)
174176
#define TESTER_I2C_ACKS (0x002 + 0x00105000)

components/testing/COMPONENT_FPGA_CI_TEST_SHIELD/test_utils.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -510,4 +510,26 @@ const char *const AnalogoutMaps::name = "DAC";
510510
typedef Port<1, AnalogoutMaps, DefaultFormFactor, TF1> AnalogoutPort;
511511
#endif
512512

513+
#if DEVICE_SERIAL
514+
struct UARTMaps {
515+
static const PinMap *maps[];
516+
static const char *const pin_type_names[];
517+
static const char *const name;
518+
};
519+
const PinMap *UARTMaps::maps[] = { serial_tx_pinmap(), serial_rx_pinmap(), serial_cts_pinmap(), serial_rts_pinmap() };
520+
const char *const UARTMaps::pin_type_names[] = { "TX", "RX", "CLS", "RTS" };
521+
const char *const UARTMaps::name = "UART";
522+
typedef Port<4, UARTMaps, DefaultFormFactor, TF4> UARTPort;
523+
524+
struct UARTNoFCMaps {
525+
static const PinMap *maps[];
526+
static const char *const pin_type_names[];
527+
static const char *const name;
528+
};
529+
const PinMap *UARTNoFCMaps::maps[] = { serial_tx_pinmap(), serial_rx_pinmap() };
530+
const char *const UARTNoFCMaps::pin_type_names[] = { "TX", "RX" };
531+
const char *const UARTNoFCMaps::name = "UART-no-FC";
532+
typedef Port<2, UARTNoFCMaps, DefaultFormFactor, TF2> UARTNoFCPort;
533+
#endif
534+
513535
#endif

0 commit comments

Comments
 (0)