-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10540 from c1728p9/fpga_ci_test_shield
Check in files for the FPGA CI Test Shield
- Loading branch information
Showing
16 changed files
with
5,374 additions
and
0 deletions.
There are no files selected for viewing
75 changes: 75 additions & 0 deletions
75
components/testing/COMPONENT_FPGA_CI_TEST_SHIELD/DynamicPinList.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/* | ||
* Copyright (c) 2019, Arm Limited and affiliates. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#include "DynamicPinList.h" | ||
|
||
DynamicPinList::DynamicPinList() | ||
{ | ||
|
||
} | ||
|
||
DynamicPinList::DynamicPinList(const PinList *pin_list) | ||
{ | ||
for (uint32_t i = 0; i < pin_list->count; i++) { | ||
_pins.push_back(pin_list->pins[i]); | ||
} | ||
} | ||
|
||
DynamicPinList::DynamicPinList(const DynamicPinList &other) | ||
{ | ||
_pins = other._pins; | ||
} | ||
|
||
void DynamicPinList::add(PinName pin) | ||
{ | ||
_pins.push_back(pin); | ||
} | ||
|
||
bool DynamicPinList::has_pin(PinName pin) const | ||
{ | ||
for (uint32_t i = 0; i < _pins.size(); i++) { | ||
if (pin == _pins[i]) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
|
||
void DynamicPinList::clear() | ||
{ | ||
_pins.clear(); | ||
} | ||
|
||
uint32_t DynamicPinList::count() const | ||
{ | ||
return _pins.size(); | ||
} | ||
|
||
PinName DynamicPinList::get(uint32_t index) const | ||
{ | ||
return index < _pins.size() ? _pins[index] : NC; | ||
} | ||
|
||
int DynamicPinList::index(PinName pin) const | ||
{ | ||
for (uint32_t i = 0; i < _pins.size(); i++) { | ||
if (pin == _pins[i]) { | ||
return i; | ||
} | ||
} | ||
return -1; | ||
} |
92 changes: 92 additions & 0 deletions
92
components/testing/COMPONENT_FPGA_CI_TEST_SHIELD/DynamicPinList.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
/* | ||
* Copyright (c) 2019, Arm Limited and affiliates. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#ifndef DYNAMIC_PIN_LIST_H | ||
#define DYNAMIC_PIN_LIST_H | ||
|
||
#include "pinmap.h" | ||
#include <vector> | ||
|
||
class DynamicPinList { | ||
public: | ||
|
||
/** | ||
* Create an empty pin list | ||
*/ | ||
DynamicPinList(); | ||
|
||
/** | ||
* Create a pin list with the given contents | ||
* | ||
* @param pin_list List of pins to create this list from | ||
*/ | ||
DynamicPinList(const PinList *pin_list); | ||
|
||
/** | ||
* Create a copy of another list | ||
* | ||
* @param other Other object to copy contruct this from | ||
*/ | ||
DynamicPinList(const DynamicPinList &other); | ||
|
||
/** | ||
* Add a pin to the pin list | ||
* | ||
* @param pin Pin to add to this pin list | ||
*/ | ||
void add(PinName pin); | ||
|
||
/** | ||
* Check if the given pin is in this list | ||
* | ||
* @param pin Pin to check for in the list | ||
* @return true if the pin is in the list, false otherwise | ||
*/ | ||
bool has_pin(PinName pin) const; | ||
|
||
/** | ||
* Empty this pin list | ||
*/ | ||
void clear(); | ||
|
||
/** | ||
* Return the number of pins in this list | ||
* | ||
* @return Elements in this list | ||
*/ | ||
uint32_t count() const; | ||
|
||
/** | ||
* Get the pin at the given index | ||
* | ||
* @return Pin at this position | ||
*/ | ||
PinName get(uint32_t index) const; | ||
|
||
/** | ||
* Get the location of the given pin | ||
* | ||
* @param pin Pin to get the index of | ||
* @return pin index or -1 if pin is not in the list | ||
*/ | ||
int index(PinName pin) const; | ||
|
||
private: | ||
std::vector<PinName> _pins; | ||
}; | ||
|
||
#endif |
144 changes: 144 additions & 0 deletions
144
components/testing/COMPONENT_FPGA_CI_TEST_SHIELD/I2CTester.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
/* | ||
* Copyright (c) 2019, Arm Limited and affiliates. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#include "I2CTester.h" | ||
#include "fpga_config.h" | ||
|
||
uint8_t I2CTester::num_starts() | ||
{ | ||
uint8_t num_starts = 0; | ||
read(TESTER_I2C_STARTS, &num_starts, sizeof(num_starts)); | ||
return num_starts; | ||
} | ||
|
||
uint8_t I2CTester::num_stops() | ||
{ | ||
uint8_t num_stops = 0; | ||
read(TESTER_I2C_STOPS, &num_stops, sizeof(num_stops)); | ||
return num_stops; | ||
} | ||
|
||
uint16_t I2CTester::num_acks() | ||
{ | ||
uint16_t num_acks = 0; | ||
read(TESTER_I2C_ACKS, (uint8_t *)&num_acks, sizeof(num_acks)); | ||
return num_acks; | ||
} | ||
|
||
uint16_t I2CTester::num_nacks() | ||
{ | ||
uint16_t num_nacks = 0; | ||
read(TESTER_I2C_NACKS, (uint8_t *)&num_nacks, sizeof(num_nacks)); | ||
return num_nacks; | ||
} | ||
|
||
uint16_t I2CTester::transfer_count() | ||
{ | ||
uint16_t transfers = 0; | ||
MBED_ASSERT(sizeof(transfers) == TESTER_I2C_TRANSFERS_SIZE); | ||
read(TESTER_I2C_TRANSFERS, (uint8_t *)&transfers, sizeof(transfers)); | ||
return transfers; | ||
} | ||
|
||
uint32_t I2CTester::get_receive_checksum() | ||
{ | ||
uint32_t to_slave_checksum = 0; | ||
MBED_ASSERT(sizeof(to_slave_checksum) == TESTER_I2C_TO_SLAVE_CHECKSUM_SIZE); | ||
read(TESTER_I2C_TO_SLAVE_CHECKSUM, (uint8_t *)&to_slave_checksum, sizeof(to_slave_checksum)); | ||
return to_slave_checksum; | ||
} | ||
|
||
uint8_t I2CTester::state_num() | ||
{ | ||
uint8_t state_num = 0; | ||
read(TESTER_I2C_STATE_NUM, &state_num, sizeof(state_num)); | ||
return state_num; | ||
} | ||
|
||
uint8_t I2CTester::num_dev_addr_matches() | ||
{ | ||
uint8_t num_correct = 0; | ||
read(TESTER_I2C_NUMBER_DEV_ADDR_MATCHES, &num_correct, sizeof(num_correct)); | ||
return num_correct; | ||
} | ||
|
||
void I2CTester::set_device_address(uint16_t addr) | ||
{ | ||
uint16_t data = addr; | ||
write(TESTER_I2C_DEVICE_ADDRESS, (uint8_t *)&data, sizeof(data)); | ||
} | ||
|
||
uint16_t I2CTester::get_device_address() | ||
{ | ||
uint16_t addr = 0; | ||
read(TESTER_I2C_DEVICE_ADDRESS, (uint8_t *)&addr, sizeof(addr)); | ||
return addr; | ||
} | ||
|
||
void I2CTester::set_sda(uint8_t value) | ||
{ | ||
uint8_t val = value; | ||
write(TESTER_I2C_SET_SDA, &val, sizeof(val)); | ||
} | ||
|
||
uint8_t I2CTester::get_prev_to_slave_4() | ||
{ | ||
uint8_t prev_to_slave_4 = 0; | ||
read(TESTER_I2C_PREV_TO_SLAVE_4, &prev_to_slave_4, sizeof(prev_to_slave_4)); | ||
return prev_to_slave_4; | ||
} | ||
uint8_t I2CTester::get_prev_to_slave_3() | ||
{ | ||
uint8_t prev_to_slave_3 = 0; | ||
read(TESTER_I2C_PREV_TO_SLAVE_3, &prev_to_slave_3, sizeof(prev_to_slave_3)); | ||
return prev_to_slave_3; | ||
} | ||
uint8_t I2CTester::get_prev_to_slave_2() | ||
{ | ||
uint8_t prev_to_slave_2 = 0; | ||
read(TESTER_I2C_PREV_TO_SLAVE_2, &prev_to_slave_2, sizeof(prev_to_slave_2)); | ||
return prev_to_slave_2; | ||
} | ||
uint8_t I2CTester::get_prev_to_slave_1() | ||
{ | ||
uint8_t prev_to_slave_1 = 0; | ||
read(TESTER_I2C_PREV_TO_SLAVE_1, &prev_to_slave_1, sizeof(prev_to_slave_1)); | ||
return prev_to_slave_1; | ||
} | ||
void I2CTester::set_next_from_slave(uint8_t value) | ||
{ | ||
uint8_t val = value; | ||
write(TESTER_I2C_NEXT_FROM_SLAVE, &val, sizeof(val)); | ||
} | ||
uint8_t I2CTester::get_next_from_slave() | ||
{ | ||
uint8_t next_from_slave = 0; | ||
read(TESTER_I2C_NEXT_FROM_SLAVE, &next_from_slave, sizeof(next_from_slave)); | ||
return next_from_slave; | ||
} | ||
uint16_t I2CTester::num_writes() | ||
{ | ||
uint16_t num_writes = 0; | ||
read(TESTER_I2C_NUM_WRITES, (uint8_t *)&num_writes, sizeof(num_writes)); | ||
return num_writes; | ||
} | ||
uint16_t I2CTester::num_reads() | ||
{ | ||
uint16_t num_reads = 0; | ||
read(TESTER_I2C_NUM_READS, (uint8_t *)&num_reads, sizeof(num_reads)); | ||
return num_reads; | ||
} |
Oops, something went wrong.