Skip to content

Commit a4738fa

Browse files
authored
Merge pull request #10540 from c1728p9/fpga_ci_test_shield
Check in files for the FPGA CI Test Shield
2 parents a434583 + e2312c4 commit a4738fa

16 files changed

+5374
-0
lines changed
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
/*
2+
* Copyright (c) 2019, Arm Limited and affiliates.
3+
* SPDX-License-Identifier: Apache-2.0
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
#include "DynamicPinList.h"
19+
20+
DynamicPinList::DynamicPinList()
21+
{
22+
23+
}
24+
25+
DynamicPinList::DynamicPinList(const PinList *pin_list)
26+
{
27+
for (uint32_t i = 0; i < pin_list->count; i++) {
28+
_pins.push_back(pin_list->pins[i]);
29+
}
30+
}
31+
32+
DynamicPinList::DynamicPinList(const DynamicPinList &other)
33+
{
34+
_pins = other._pins;
35+
}
36+
37+
void DynamicPinList::add(PinName pin)
38+
{
39+
_pins.push_back(pin);
40+
}
41+
42+
bool DynamicPinList::has_pin(PinName pin) const
43+
{
44+
for (uint32_t i = 0; i < _pins.size(); i++) {
45+
if (pin == _pins[i]) {
46+
return true;
47+
}
48+
}
49+
return false;
50+
}
51+
52+
void DynamicPinList::clear()
53+
{
54+
_pins.clear();
55+
}
56+
57+
uint32_t DynamicPinList::count() const
58+
{
59+
return _pins.size();
60+
}
61+
62+
PinName DynamicPinList::get(uint32_t index) const
63+
{
64+
return index < _pins.size() ? _pins[index] : NC;
65+
}
66+
67+
int DynamicPinList::index(PinName pin) const
68+
{
69+
for (uint32_t i = 0; i < _pins.size(); i++) {
70+
if (pin == _pins[i]) {
71+
return i;
72+
}
73+
}
74+
return -1;
75+
}
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
/*
2+
* Copyright (c) 2019, Arm Limited and affiliates.
3+
* SPDX-License-Identifier: Apache-2.0
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
#ifndef DYNAMIC_PIN_LIST_H
19+
#define DYNAMIC_PIN_LIST_H
20+
21+
#include "pinmap.h"
22+
#include <vector>
23+
24+
class DynamicPinList {
25+
public:
26+
27+
/**
28+
* Create an empty pin list
29+
*/
30+
DynamicPinList();
31+
32+
/**
33+
* Create a pin list with the given contents
34+
*
35+
* @param pin_list List of pins to create this list from
36+
*/
37+
DynamicPinList(const PinList *pin_list);
38+
39+
/**
40+
* Create a copy of another list
41+
*
42+
* @param other Other object to copy contruct this from
43+
*/
44+
DynamicPinList(const DynamicPinList &other);
45+
46+
/**
47+
* Add a pin to the pin list
48+
*
49+
* @param pin Pin to add to this pin list
50+
*/
51+
void add(PinName pin);
52+
53+
/**
54+
* Check if the given pin is in this list
55+
*
56+
* @param pin Pin to check for in the list
57+
* @return true if the pin is in the list, false otherwise
58+
*/
59+
bool has_pin(PinName pin) const;
60+
61+
/**
62+
* Empty this pin list
63+
*/
64+
void clear();
65+
66+
/**
67+
* Return the number of pins in this list
68+
*
69+
* @return Elements in this list
70+
*/
71+
uint32_t count() const;
72+
73+
/**
74+
* Get the pin at the given index
75+
*
76+
* @return Pin at this position
77+
*/
78+
PinName get(uint32_t index) const;
79+
80+
/**
81+
* Get the location of the given pin
82+
*
83+
* @param pin Pin to get the index of
84+
* @return pin index or -1 if pin is not in the list
85+
*/
86+
int index(PinName pin) const;
87+
88+
private:
89+
std::vector<PinName> _pins;
90+
};
91+
92+
#endif
Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
/*
2+
* Copyright (c) 2019, Arm Limited and affiliates.
3+
* SPDX-License-Identifier: Apache-2.0
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
#include "I2CTester.h"
19+
#include "fpga_config.h"
20+
21+
uint8_t I2CTester::num_starts()
22+
{
23+
uint8_t num_starts = 0;
24+
read(TESTER_I2C_STARTS, &num_starts, sizeof(num_starts));
25+
return num_starts;
26+
}
27+
28+
uint8_t I2CTester::num_stops()
29+
{
30+
uint8_t num_stops = 0;
31+
read(TESTER_I2C_STOPS, &num_stops, sizeof(num_stops));
32+
return num_stops;
33+
}
34+
35+
uint16_t I2CTester::num_acks()
36+
{
37+
uint16_t num_acks = 0;
38+
read(TESTER_I2C_ACKS, (uint8_t *)&num_acks, sizeof(num_acks));
39+
return num_acks;
40+
}
41+
42+
uint16_t I2CTester::num_nacks()
43+
{
44+
uint16_t num_nacks = 0;
45+
read(TESTER_I2C_NACKS, (uint8_t *)&num_nacks, sizeof(num_nacks));
46+
return num_nacks;
47+
}
48+
49+
uint16_t I2CTester::transfer_count()
50+
{
51+
uint16_t transfers = 0;
52+
MBED_ASSERT(sizeof(transfers) == TESTER_I2C_TRANSFERS_SIZE);
53+
read(TESTER_I2C_TRANSFERS, (uint8_t *)&transfers, sizeof(transfers));
54+
return transfers;
55+
}
56+
57+
uint32_t I2CTester::get_receive_checksum()
58+
{
59+
uint32_t to_slave_checksum = 0;
60+
MBED_ASSERT(sizeof(to_slave_checksum) == TESTER_I2C_TO_SLAVE_CHECKSUM_SIZE);
61+
read(TESTER_I2C_TO_SLAVE_CHECKSUM, (uint8_t *)&to_slave_checksum, sizeof(to_slave_checksum));
62+
return to_slave_checksum;
63+
}
64+
65+
uint8_t I2CTester::state_num()
66+
{
67+
uint8_t state_num = 0;
68+
read(TESTER_I2C_STATE_NUM, &state_num, sizeof(state_num));
69+
return state_num;
70+
}
71+
72+
uint8_t I2CTester::num_dev_addr_matches()
73+
{
74+
uint8_t num_correct = 0;
75+
read(TESTER_I2C_NUMBER_DEV_ADDR_MATCHES, &num_correct, sizeof(num_correct));
76+
return num_correct;
77+
}
78+
79+
void I2CTester::set_device_address(uint16_t addr)
80+
{
81+
uint16_t data = addr;
82+
write(TESTER_I2C_DEVICE_ADDRESS, (uint8_t *)&data, sizeof(data));
83+
}
84+
85+
uint16_t I2CTester::get_device_address()
86+
{
87+
uint16_t addr = 0;
88+
read(TESTER_I2C_DEVICE_ADDRESS, (uint8_t *)&addr, sizeof(addr));
89+
return addr;
90+
}
91+
92+
void I2CTester::set_sda(uint8_t value)
93+
{
94+
uint8_t val = value;
95+
write(TESTER_I2C_SET_SDA, &val, sizeof(val));
96+
}
97+
98+
uint8_t I2CTester::get_prev_to_slave_4()
99+
{
100+
uint8_t prev_to_slave_4 = 0;
101+
read(TESTER_I2C_PREV_TO_SLAVE_4, &prev_to_slave_4, sizeof(prev_to_slave_4));
102+
return prev_to_slave_4;
103+
}
104+
uint8_t I2CTester::get_prev_to_slave_3()
105+
{
106+
uint8_t prev_to_slave_3 = 0;
107+
read(TESTER_I2C_PREV_TO_SLAVE_3, &prev_to_slave_3, sizeof(prev_to_slave_3));
108+
return prev_to_slave_3;
109+
}
110+
uint8_t I2CTester::get_prev_to_slave_2()
111+
{
112+
uint8_t prev_to_slave_2 = 0;
113+
read(TESTER_I2C_PREV_TO_SLAVE_2, &prev_to_slave_2, sizeof(prev_to_slave_2));
114+
return prev_to_slave_2;
115+
}
116+
uint8_t I2CTester::get_prev_to_slave_1()
117+
{
118+
uint8_t prev_to_slave_1 = 0;
119+
read(TESTER_I2C_PREV_TO_SLAVE_1, &prev_to_slave_1, sizeof(prev_to_slave_1));
120+
return prev_to_slave_1;
121+
}
122+
void I2CTester::set_next_from_slave(uint8_t value)
123+
{
124+
uint8_t val = value;
125+
write(TESTER_I2C_NEXT_FROM_SLAVE, &val, sizeof(val));
126+
}
127+
uint8_t I2CTester::get_next_from_slave()
128+
{
129+
uint8_t next_from_slave = 0;
130+
read(TESTER_I2C_NEXT_FROM_SLAVE, &next_from_slave, sizeof(next_from_slave));
131+
return next_from_slave;
132+
}
133+
uint16_t I2CTester::num_writes()
134+
{
135+
uint16_t num_writes = 0;
136+
read(TESTER_I2C_NUM_WRITES, (uint8_t *)&num_writes, sizeof(num_writes));
137+
return num_writes;
138+
}
139+
uint16_t I2CTester::num_reads()
140+
{
141+
uint16_t num_reads = 0;
142+
read(TESTER_I2C_NUM_READS, (uint8_t *)&num_reads, sizeof(num_reads));
143+
return num_reads;
144+
}

0 commit comments

Comments
 (0)