Skip to content

Commit b333212

Browse files
committed
Check in files for the FPGA CI Test Shield
Bring all the FPGA CI Test Shield C and C++ driver files into mbed-os as the component FPGA_CI_TEST_SHIELD. When this component is enabled all the files that are needed to communicate with, update firmware on and run testing with the FPGA are built.
1 parent 42a9a7a commit b333212

16 files changed

+5236
-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: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
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 "mbed.h"
22+
#include "pinmap.h"
23+
#include <vector>
24+
25+
class DynamicPinList {
26+
public:
27+
28+
/**
29+
* Create an empty pin list
30+
*/
31+
DynamicPinList();
32+
33+
/**
34+
* Create a pin list with the given contents
35+
*
36+
* @param pin_list List of pins to create this list from
37+
*/
38+
DynamicPinList(const PinList *pin_list);
39+
40+
/**
41+
* Create a copy of another list
42+
*
43+
* @param other Other object to copy contruct this from
44+
*/
45+
DynamicPinList(const DynamicPinList &other);
46+
47+
/**
48+
* Add a pin to the pin list
49+
*
50+
* @param pin Pin to add to this pin list
51+
*/
52+
void add(PinName pin);
53+
54+
/**
55+
* Check if the given pin is in this list
56+
*
57+
* @param pin Pin to check for in the list
58+
* @return true if the pin is in the list, false otherwise
59+
*/
60+
bool has_pin(PinName pin) const;
61+
62+
/**
63+
* Empty this pin list
64+
*/
65+
void clear();
66+
67+
/**
68+
* Return the number of pins in this list
69+
*
70+
* @return Elements in this list
71+
*/
72+
uint32_t count() const;
73+
74+
/**
75+
* Get the pin at the given index
76+
*
77+
* @return Pin at this position
78+
*/
79+
PinName get(uint32_t index) const;
80+
81+
/**
82+
* Get the location of the given pin
83+
*
84+
* @param pin Pin to get the index of
85+
* @return pin index or -1 if pin is not in the list
86+
*/
87+
int index(PinName pin) const;
88+
89+
private:
90+
vector<PinName> _pins;
91+
};
92+
93+
#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)