mirror of https://github.com/ARMmbed/mbed-os.git
Replace macros
parent
a32b81f7b6
commit
3664ce9b39
|
@ -26,23 +26,25 @@
|
||||||
|
|
||||||
#define mbed_tester_printf(...)
|
#define mbed_tester_printf(...)
|
||||||
|
|
||||||
#define PHYSICAL_PINS 128
|
namespace {
|
||||||
#define LOGICAL_PINS 8
|
const auto physical_pins = 128;
|
||||||
#define FIRMWARE_SIZE 2192012
|
const auto logical_pins = 8;
|
||||||
#define FIRMWARE_REGION_SIZE 0x220000
|
const auto firmware_size_const = 2192012;
|
||||||
#define FIRMWARE_HEADER_SIZE 0x10000
|
const auto firmware_region_size = 0x220000;
|
||||||
#define MBED_TESTER_FLASH_SECTOR_SIZE 0x1000
|
const auto firmware_header_size = 0x10000;
|
||||||
#define LENGTH_SIZE 0x4
|
const auto flash_sector_size = 0x1000;
|
||||||
#define CRC_SIZE 0x4
|
const auto length_size = 0x4;
|
||||||
#define FLASH_SPI_FREQ_HZ 2000000
|
const auto crc_size_const = 0x4;
|
||||||
#define ANALOG_COUNT 4
|
const auto flash_spi_freq_hz = 2000000;
|
||||||
|
const auto analog_count = 4;
|
||||||
|
|
||||||
#define PHYSICAL_NC ((MbedTester::PhysicalIndex)0xFF)
|
const auto physical_nc = (MbedTester::PhysicalIndex)0xFF;
|
||||||
|
|
||||||
static const uint8_t KEY[8] = {
|
const uint8_t key[8] = {
|
||||||
0x92, 0x9d, 0x9a, 0x9b,
|
0x92, 0x9d, 0x9a, 0x9b,
|
||||||
0x29, 0x35, 0xa2, 0x65
|
0x29, 0x35, 0xa2, 0x65
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
template<size_t width>
|
template<size_t width>
|
||||||
class MbedTesterBitMap {
|
class MbedTesterBitMap {
|
||||||
|
@ -102,8 +104,8 @@ static uint8_t spi_transfer(mbed::DigitalInOut *clk, mbed::DigitalInOut *mosi, m
|
||||||
static void mbed_tester_command(mbed::DigitalInOut *clk, mbed::DigitalInOut *mosi, mbed::DigitalInOut *miso, uint8_t miso_index, uint32_t addr, bool write_n_read, uint8_t *data, uint8_t size)
|
static void mbed_tester_command(mbed::DigitalInOut *clk, mbed::DigitalInOut *mosi, mbed::DigitalInOut *miso, uint8_t miso_index, uint32_t addr, bool write_n_read, uint8_t *data, uint8_t size)
|
||||||
{
|
{
|
||||||
// 8 - Start Key
|
// 8 - Start Key
|
||||||
for (uint32_t i = 0; i < sizeof(KEY); i++) {
|
for (uint32_t i = 0; i < sizeof(key); i++) {
|
||||||
spi_transfer(clk, mosi, miso, KEY[i]);
|
spi_transfer(clk, mosi, miso, key[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 1 - Physical pin index for MISO
|
// 1 - Physical pin index for MISO
|
||||||
|
@ -227,7 +229,7 @@ public:
|
||||||
return BD_ERROR_DEVICE_ERROR;
|
return BD_ERROR_DEVICE_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((addr == 0) && (size == MBED_TESTER_FLASH_SECTOR_SIZE)) {
|
if ((addr == 0) && (size == flash_sector_size)) {
|
||||||
// Allow 4K erase only on the first sector. The flash on the basys3 does
|
// Allow 4K erase only on the first sector. The flash on the basys3 does
|
||||||
// not allow sector erases at the higher addresses.
|
// not allow sector erases at the higher addresses.
|
||||||
_write_enable();
|
_write_enable();
|
||||||
|
@ -482,8 +484,8 @@ static bool _firmware_header_valid(BlockDevice &flash, bool &valid)
|
||||||
valid = false;
|
valid = false;
|
||||||
|
|
||||||
// Check that first portion is erased
|
// Check that first portion is erased
|
||||||
while (pos < MBED_TESTER_FLASH_SECTOR_SIZE - sizeof(SYNC_WORD)) {
|
while (pos < flash_sector_size - sizeof(SYNC_WORD)) {
|
||||||
read_size = MBED_TESTER_FLASH_SECTOR_SIZE - pos;
|
read_size = flash_sector_size - pos;
|
||||||
if (read_size > sizeof(buf)) {
|
if (read_size > sizeof(buf)) {
|
||||||
read_size = sizeof(buf);
|
read_size = sizeof(buf);
|
||||||
}
|
}
|
||||||
|
@ -514,8 +516,8 @@ static bool _firmware_header_valid(BlockDevice &flash, bool &valid)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if the rest is 0xFF
|
// Check if the rest is 0xFF
|
||||||
while (pos < FIRMWARE_HEADER_SIZE) {
|
while (pos < firmware_header_size) {
|
||||||
read_size = FIRMWARE_HEADER_SIZE - pos;
|
read_size = firmware_header_size - pos;
|
||||||
if (read_size > sizeof(buf)) {
|
if (read_size > sizeof(buf)) {
|
||||||
read_size = sizeof(buf);
|
read_size = sizeof(buf);
|
||||||
}
|
}
|
||||||
|
@ -539,7 +541,7 @@ static bool _firmware_get_active_bank(BlockDevice &flash, bool &second_bank_acti
|
||||||
{
|
{
|
||||||
uint8_t buf[sizeof(SYNC_WORD)];
|
uint8_t buf[sizeof(SYNC_WORD)];
|
||||||
|
|
||||||
if (flash.read(buf, MBED_TESTER_FLASH_SECTOR_SIZE - sizeof(SYNC_WORD), sizeof(SYNC_WORD)) != BD_ERROR_OK) {
|
if (flash.read(buf, flash_sector_size - sizeof(SYNC_WORD), sizeof(SYNC_WORD)) != BD_ERROR_OK) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -554,14 +556,14 @@ static bool _firmware_set_active_bank(BlockDevice &flash, bool second_bank)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!valid) {
|
if (!valid) {
|
||||||
if (flash.erase(0, FIRMWARE_HEADER_SIZE) != BD_ERROR_OK) {
|
if (flash.erase(0, firmware_header_size) != BD_ERROR_OK) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (flash.program(BANK_B_SELECT, MBED_TESTER_FLASH_SECTOR_SIZE, sizeof(BANK_B_SELECT)) != BD_ERROR_OK) {
|
if (flash.program(BANK_B_SELECT, flash_sector_size, sizeof(BANK_B_SELECT)) != BD_ERROR_OK) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!flash.erase(0, MBED_TESTER_FLASH_SECTOR_SIZE)) {
|
if (!flash.erase(0, flash_sector_size)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -569,7 +571,7 @@ static bool _firmware_set_active_bank(BlockDevice &flash, bool second_bank)
|
||||||
if (second_bank) {
|
if (second_bank) {
|
||||||
// Write the sync word. Before the sync word is written the FPGA will boot from the first bank.
|
// Write the sync word. Before the sync word is written the FPGA will boot from the first bank.
|
||||||
// After the sync word is written the FPGA will boot from the second bank.
|
// After the sync word is written the FPGA will boot from the second bank.
|
||||||
if (flash.program(SYNC_WORD, MBED_TESTER_FLASH_SECTOR_SIZE - sizeof(SYNC_WORD), sizeof(SYNC_WORD)) != BD_ERROR_OK) {
|
if (flash.program(SYNC_WORD, flash_sector_size - sizeof(SYNC_WORD), sizeof(SYNC_WORD)) != BD_ERROR_OK) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -579,7 +581,7 @@ static bool _firmware_set_active_bank(BlockDevice &flash, bool second_bank)
|
||||||
|
|
||||||
MbedTester::MbedTester(const PinList *form_factor, const PinList *exclude_pins)
|
MbedTester::MbedTester(const PinList *form_factor, const PinList *exclude_pins)
|
||||||
: _form_factor(form_factor), _exclude_pins(exclude_pins), _control_auto(true), _control_valid(false),
|
: _form_factor(form_factor), _exclude_pins(exclude_pins), _control_auto(true), _control_valid(false),
|
||||||
_clk_index(PHYSICAL_NC), _mosi_index(PHYSICAL_NC), _miso_index(PHYSICAL_NC), _aux_index(PHYSICAL_NC),
|
_clk_index(physical_nc), _mosi_index(physical_nc), _miso_index(physical_nc), _aux_index(physical_nc),
|
||||||
_clk(NULL), _mosi(NULL), _miso(NULL), _aux(NULL)
|
_clk(NULL), _mosi(NULL), _miso(NULL), _aux(NULL)
|
||||||
{
|
{
|
||||||
_reset();
|
_reset();
|
||||||
|
@ -656,7 +658,7 @@ bool MbedTester::firmware_dump(mbed::FileHandle *dest, mbed::Callback<void(uint8
|
||||||
|
|
||||||
// Mapping intentionally different from control channel to prevent
|
// Mapping intentionally different from control channel to prevent
|
||||||
// unintentional activation (clk and mosi flipped)
|
// unintentional activation (clk and mosi flipped)
|
||||||
MbedTesterBlockDevice flash(*_clk, *_miso, *_mosi, *_aux, FLASH_SPI_FREQ_HZ);
|
MbedTesterBlockDevice flash(*_clk, *_miso, *_mosi, *_aux, flash_spi_freq_hz);
|
||||||
sys_pin_mode_spi_serial_flash(_clk_index, _miso_index, _mosi_index, _aux_index);
|
sys_pin_mode_spi_serial_flash(_clk_index, _miso_index, _mosi_index, _aux_index);
|
||||||
|
|
||||||
progress(0);
|
progress(0);
|
||||||
|
@ -673,29 +675,29 @@ bool MbedTester::firmware_dump(mbed::FileHandle *dest, mbed::Callback<void(uint8
|
||||||
sys_pin_mode_disabled();
|
sys_pin_mode_disabled();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const uint32_t start = FIRMWARE_HEADER_SIZE + (second_bank_active ? FIRMWARE_REGION_SIZE : 0);
|
const uint32_t start = firmware_header_size + (second_bank_active ? firmware_region_size : 0);
|
||||||
|
|
||||||
// Get the firmware size
|
// Get the firmware size
|
||||||
uint32_t offset = 0;
|
uint32_t offset = 0;
|
||||||
uint8_t buf[256];
|
uint8_t buf[256];
|
||||||
uint32_t prev_percent_done = 0;
|
uint32_t prev_percent_done = 0;
|
||||||
if (flash.read(buf, start + offset, LENGTH_SIZE) != BD_ERROR_OK) {
|
if (flash.read(buf, start + offset, length_size) != BD_ERROR_OK) {
|
||||||
sys_pin_mode_disabled();
|
sys_pin_mode_disabled();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (dest->write(buf, LENGTH_SIZE) != LENGTH_SIZE) {
|
if (dest->write(buf, length_size) != length_size) {
|
||||||
sys_pin_mode_disabled();
|
sys_pin_mode_disabled();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
offset += LENGTH_SIZE;
|
offset += length_size;
|
||||||
uint32_t data_size = (buf[0] << (0 * 8)) |
|
uint32_t data_size = (buf[0] << (0 * 8)) |
|
||||||
(buf[1] << (1 * 8)) |
|
(buf[1] << (1 * 8)) |
|
||||||
(buf[2] << (2 * 8)) |
|
(buf[2] << (2 * 8)) |
|
||||||
(buf[3] << (3 * 8));
|
(buf[3] << (3 * 8));
|
||||||
if (data_size > FIRMWARE_REGION_SIZE - LENGTH_SIZE - CRC_SIZE) {
|
if (data_size > firmware_region_size - length_size - crc_size_const) {
|
||||||
data_size = FIRMWARE_REGION_SIZE - LENGTH_SIZE - CRC_SIZE;
|
data_size = firmware_region_size - length_size - crc_size_const;
|
||||||
}
|
}
|
||||||
const uint32_t firmware_size = data_size + LENGTH_SIZE + CRC_SIZE;
|
const uint32_t firmware_size = data_size + length_size + crc_size_const;
|
||||||
|
|
||||||
// Dump firmware
|
// Dump firmware
|
||||||
while (offset < firmware_size) {
|
while (offset < firmware_size) {
|
||||||
|
@ -737,7 +739,7 @@ bool MbedTester::firmware_dump_all(mbed::FileHandle *dest, mbed::Callback<void(u
|
||||||
|
|
||||||
// Mapping intentionally different from control channel to prevent
|
// Mapping intentionally different from control channel to prevent
|
||||||
// unintentional activation (clk and mosi flipped)
|
// unintentional activation (clk and mosi flipped)
|
||||||
MbedTesterBlockDevice flash(*_clk, *_miso, *_mosi, *_aux, FLASH_SPI_FREQ_HZ);
|
MbedTesterBlockDevice flash(*_clk, *_miso, *_mosi, *_aux, flash_spi_freq_hz);
|
||||||
sys_pin_mode_spi_serial_flash(_clk_index, _miso_index, _mosi_index, _aux_index);
|
sys_pin_mode_spi_serial_flash(_clk_index, _miso_index, _mosi_index, _aux_index);
|
||||||
|
|
||||||
progress(0);
|
progress(0);
|
||||||
|
@ -790,7 +792,7 @@ bool MbedTester::firmware_update(mbed::FileHandle *src, mbed::Callback<void(uint
|
||||||
|
|
||||||
// Mapping intentionally different from control channel to prevent
|
// Mapping intentionally different from control channel to prevent
|
||||||
// unintentional activation (clk and mosi flipped)
|
// unintentional activation (clk and mosi flipped)
|
||||||
MbedTesterBlockDevice flash(*_clk, *_miso, *_mosi, *_aux, FLASH_SPI_FREQ_HZ);
|
MbedTesterBlockDevice flash(*_clk, *_miso, *_mosi, *_aux, flash_spi_freq_hz);
|
||||||
sys_pin_mode_spi_serial_flash(_clk_index, _miso_index, _mosi_index, _aux_index);
|
sys_pin_mode_spi_serial_flash(_clk_index, _miso_index, _mosi_index, _aux_index);
|
||||||
|
|
||||||
progress(0);
|
progress(0);
|
||||||
|
@ -802,12 +804,12 @@ bool MbedTester::firmware_update(mbed::FileHandle *src, mbed::Callback<void(uint
|
||||||
|
|
||||||
// Validate file size
|
// Validate file size
|
||||||
const uint32_t file_size = src->size();
|
const uint32_t file_size = src->size();
|
||||||
if (file_size > FIRMWARE_REGION_SIZE) {
|
if (file_size > firmware_region_size) {
|
||||||
// Firmware image too big
|
// Firmware image too big
|
||||||
sys_pin_mode_disabled();
|
sys_pin_mode_disabled();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (file_size < LENGTH_SIZE + CRC_SIZE) {
|
if (file_size < length_size + crc_size_const) {
|
||||||
// Firmware image too small
|
// Firmware image too small
|
||||||
sys_pin_mode_disabled();
|
sys_pin_mode_disabled();
|
||||||
return false;
|
return false;
|
||||||
|
@ -820,7 +822,7 @@ bool MbedTester::firmware_update(mbed::FileHandle *src, mbed::Callback<void(uint
|
||||||
sys_pin_mode_disabled();
|
sys_pin_mode_disabled();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const uint32_t start = FIRMWARE_HEADER_SIZE + (second_bank_active ? 0 : FIRMWARE_REGION_SIZE);
|
const uint32_t start = firmware_header_size + (second_bank_active ? 0 : firmware_region_size);
|
||||||
|
|
||||||
// Setup CRC calculation
|
// Setup CRC calculation
|
||||||
uint32_t crc;
|
uint32_t crc;
|
||||||
|
@ -863,7 +865,7 @@ bool MbedTester::firmware_update(mbed::FileHandle *src, mbed::Callback<void(uint
|
||||||
(buf[1] << (1 * 8)) |
|
(buf[1] << (1 * 8)) |
|
||||||
(buf[2] << (2 * 8)) |
|
(buf[2] << (2 * 8)) |
|
||||||
(buf[3] << (3 * 8));
|
(buf[3] << (3 * 8));
|
||||||
if (data_size != file_size - LENGTH_SIZE - CRC_SIZE) {
|
if (data_size != file_size - length_size - crc_size_const) {
|
||||||
// Invalid data length
|
// Invalid data length
|
||||||
sys_pin_mode_disabled();
|
sys_pin_mode_disabled();
|
||||||
return false;
|
return false;
|
||||||
|
@ -871,13 +873,13 @@ bool MbedTester::firmware_update(mbed::FileHandle *src, mbed::Callback<void(uint
|
||||||
size_valid = true;
|
size_valid = true;
|
||||||
|
|
||||||
// Don't include the length in the checksum
|
// Don't include the length in the checksum
|
||||||
crc_offset += LENGTH_SIZE;
|
crc_offset += length_size;
|
||||||
crc_size -= LENGTH_SIZE;
|
crc_size -= length_size;
|
||||||
}
|
}
|
||||||
if (offset + program_size > file_size - CRC_SIZE) {
|
if (offset + program_size > file_size - crc_size_const) {
|
||||||
// Overlap with the CRC field
|
// Overlap with the CRC field
|
||||||
for (uint32_t i = 0; i < CRC_SIZE; i++) {
|
for (uint32_t i = 0; i < crc_size_const; i++) {
|
||||||
uint32_t byte_offset = file_size - CRC_SIZE + i;
|
uint32_t byte_offset = file_size - crc_size_const + i;
|
||||||
if ((byte_offset >= offset) && (byte_offset < offset + program_size)) {
|
if ((byte_offset >= offset) && (byte_offset < offset + program_size)) {
|
||||||
uint32_t buf_pos = byte_offset - offset;
|
uint32_t buf_pos = byte_offset - offset;
|
||||||
stored_crc |= buf[buf_pos] << (i * 8);
|
stored_crc |= buf[buf_pos] << (i * 8);
|
||||||
|
@ -956,10 +958,10 @@ void MbedTester::pin_map_set(PinName physical, LogicalPin logical)
|
||||||
void MbedTester::pin_map_reset()
|
void MbedTester::pin_map_reset()
|
||||||
{
|
{
|
||||||
for (uint32_t i = 0; i < sizeof(_mapping) / sizeof(_mapping[0]); i++) {
|
for (uint32_t i = 0; i < sizeof(_mapping) / sizeof(_mapping[0]); i++) {
|
||||||
_mapping[i] = PHYSICAL_NC;
|
_mapping[i] = physical_nc;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t pin_buf[PHYSICAL_PINS + LOGICAL_PINS];
|
uint8_t pin_buf[physical_pins + logical_pins];
|
||||||
memset(pin_buf, 0xFF, sizeof(pin_buf));
|
memset(pin_buf, 0xFF, sizeof(pin_buf));
|
||||||
write(TESTER_REMAP, pin_buf, sizeof(pin_buf));
|
write(TESTER_REMAP, pin_buf, sizeof(pin_buf));
|
||||||
}
|
}
|
||||||
|
@ -1165,7 +1167,7 @@ int MbedTester::io_expander_i2c_read(uint8_t i2c_index, uint8_t dev_addr, uint8_
|
||||||
_update_control_pins();
|
_update_control_pins();
|
||||||
//sda_in = _miso_index
|
//sda_in = _miso_index
|
||||||
//sda_val = _aux_index
|
//sda_val = _aux_index
|
||||||
//scl_in = _mosi_index (PHYSICAL_NC)
|
//scl_in = _mosi_index (physical_nc)
|
||||||
//scl_val = _clk_index
|
//scl_val = _clk_index
|
||||||
mbed::DigitalInOut *sda_in = _miso;
|
mbed::DigitalInOut *sda_in = _miso;
|
||||||
mbed::DigitalInOut *sda_val = _aux;
|
mbed::DigitalInOut *sda_val = _aux;
|
||||||
|
@ -1174,7 +1176,7 @@ int MbedTester::io_expander_i2c_read(uint8_t i2c_index, uint8_t dev_addr, uint8_
|
||||||
sda_val->output();
|
sda_val->output();
|
||||||
*sda_val = 1;
|
*sda_val = 1;
|
||||||
scl_val->output();
|
scl_val->output();
|
||||||
sys_pin_mode_i2c_io_expander(i2c_index, _miso_index, _aux_index, PHYSICAL_NC, _clk_index);
|
sys_pin_mode_i2c_io_expander(i2c_index, _miso_index, _aux_index, physical_nc, _clk_index);
|
||||||
|
|
||||||
//start condition
|
//start condition
|
||||||
*scl_val = 1;
|
*scl_val = 1;
|
||||||
|
@ -1304,7 +1306,7 @@ int MbedTester::io_expander_i2c_write(uint8_t i2c_index, uint8_t dev_addr, uint8
|
||||||
_update_control_pins();
|
_update_control_pins();
|
||||||
//sda_in = _miso_index
|
//sda_in = _miso_index
|
||||||
//sda_val = _aux_index
|
//sda_val = _aux_index
|
||||||
//scl_in = _mosi_index (PHYSICAL_NC)
|
//scl_in = _mosi_index (physical_nc)
|
||||||
//scl_val = _clk_index
|
//scl_val = _clk_index
|
||||||
mbed::DigitalInOut *sda_in = _miso;
|
mbed::DigitalInOut *sda_in = _miso;
|
||||||
mbed::DigitalInOut *sda_val = _aux;
|
mbed::DigitalInOut *sda_val = _aux;
|
||||||
|
@ -1313,7 +1315,7 @@ int MbedTester::io_expander_i2c_write(uint8_t i2c_index, uint8_t dev_addr, uint8
|
||||||
sda_val->output();
|
sda_val->output();
|
||||||
*sda_val = 1;
|
*sda_val = 1;
|
||||||
scl_val->output();
|
scl_val->output();
|
||||||
sys_pin_mode_i2c_io_expander(i2c_index, _miso_index, _aux_index, PHYSICAL_NC, _clk_index);
|
sys_pin_mode_i2c_io_expander(i2c_index, _miso_index, _aux_index, physical_nc, _clk_index);
|
||||||
|
|
||||||
//start condition
|
//start condition
|
||||||
*scl_val = 1;
|
*scl_val = 1;
|
||||||
|
@ -1745,7 +1747,7 @@ uint16_t MbedTester::get_analogmuxin_measurement()
|
||||||
uint16_t MbedTester::get_anin_measurement(int index)
|
uint16_t MbedTester::get_anin_measurement(int index)
|
||||||
{
|
{
|
||||||
//check index is in bounds
|
//check index is in bounds
|
||||||
if ((index < 0) || (index >= ANALOG_COUNT)) {
|
if ((index < 0) || (index >= analog_count)) {
|
||||||
error("AnalogIn index is out of bounds");
|
error("AnalogIn index is out of bounds");
|
||||||
}
|
}
|
||||||
//take snapshot of conversion value to make safe for reading
|
//take snapshot of conversion value to make safe for reading
|
||||||
|
@ -1758,7 +1760,7 @@ uint16_t MbedTester::get_anin_measurement(int index)
|
||||||
void MbedTester::get_anin_sum_samples_cycles(int index, uint64_t *sum, uint32_t *samples, uint64_t *cycles)
|
void MbedTester::get_anin_sum_samples_cycles(int index, uint64_t *sum, uint32_t *samples, uint64_t *cycles)
|
||||||
{
|
{
|
||||||
//check index is in bounds
|
//check index is in bounds
|
||||||
if ((index < 0) || (index >= ANALOG_COUNT)) {
|
if ((index < 0) || (index >= analog_count)) {
|
||||||
error("AnalogIn index is out of bounds");
|
error("AnalogIn index is out of bounds");
|
||||||
}
|
}
|
||||||
//take snapshot of the sum/samples/cycles so that all 3 values are correct in relation to each other
|
//take snapshot of the sum/samples/cycles so that all 3 values are correct in relation to each other
|
||||||
|
@ -1944,10 +1946,10 @@ void MbedTester::sys_pin_mode_disabled()
|
||||||
{
|
{
|
||||||
const uint32_t base = LogicalPinTotal;
|
const uint32_t base = LogicalPinTotal;
|
||||||
|
|
||||||
pin_map_index(PHYSICAL_NC, (LogicalPin)(base + 0));
|
pin_map_index(physical_nc, (LogicalPin)(base + 0));
|
||||||
pin_map_index(PHYSICAL_NC, (LogicalPin)(base + 1));
|
pin_map_index(physical_nc, (LogicalPin)(base + 1));
|
||||||
pin_map_index(PHYSICAL_NC, (LogicalPin)(base + 2));
|
pin_map_index(physical_nc, (LogicalPin)(base + 2));
|
||||||
pin_map_index(PHYSICAL_NC, (LogicalPin)(base + 3));
|
pin_map_index(physical_nc, (LogicalPin)(base + 3));
|
||||||
|
|
||||||
uint8_t mode = TESTER_SYS_IO_MODE_DISABLED;
|
uint8_t mode = TESTER_SYS_IO_MODE_DISABLED;
|
||||||
write(TESTER_SYS_IO_MODE, &mode, sizeof(mode));
|
write(TESTER_SYS_IO_MODE, &mode, sizeof(mode));
|
||||||
|
@ -1992,7 +1994,7 @@ void MbedTester::sys_pin_mode_i2c_io_expander(int index, PhysicalIndex sda_in, P
|
||||||
void MbedTester::pin_map_index(PhysicalIndex physical_index, LogicalPin logical)
|
void MbedTester::pin_map_index(PhysicalIndex physical_index, LogicalPin logical)
|
||||||
{
|
{
|
||||||
uint8_t remap;
|
uint8_t remap;
|
||||||
if ((physical_index >= PHYSICAL_PINS) && (physical_index != PHYSICAL_NC)) {
|
if ((physical_index >= physical_pins) && (physical_index != physical_nc)) {
|
||||||
error("Invalid physical pin index %i", physical_index);
|
error("Invalid physical pin index %i", physical_index);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -2002,20 +2004,20 @@ void MbedTester::pin_map_index(PhysicalIndex physical_index, LogicalPin logical)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unmap the previous pin if it had been mapped
|
// Unmap the previous pin if it had been mapped
|
||||||
if (_mapping[logical] < PHYSICAL_PINS) {
|
if (_mapping[logical] < physical_pins) {
|
||||||
remap = PHYSICAL_NC;
|
remap = physical_nc;
|
||||||
write(TESTER_REMAP + _mapping[logical], &remap, sizeof(remap));
|
write(TESTER_REMAP + _mapping[logical], &remap, sizeof(remap));
|
||||||
}
|
}
|
||||||
_mapping[logical] = physical_index;
|
_mapping[logical] = physical_index;
|
||||||
|
|
||||||
// Remap physical pin if it is not PHYSICAL_NC
|
// Remap physical pin if it is not physical_nc
|
||||||
if (physical_index < PHYSICAL_PINS) {
|
if (physical_index < physical_pins) {
|
||||||
remap = logical;
|
remap = logical;
|
||||||
write(TESTER_REMAP + physical_index, &remap, sizeof(remap));
|
write(TESTER_REMAP + physical_index, &remap, sizeof(remap));
|
||||||
}
|
}
|
||||||
// Remap logical pin
|
// Remap logical pin
|
||||||
remap = physical_index;
|
remap = physical_index;
|
||||||
write(TESTER_REMAP + PHYSICAL_PINS + logical, &remap, sizeof(remap));
|
write(TESTER_REMAP + physical_pins + logical, &remap, sizeof(remap));
|
||||||
}
|
}
|
||||||
|
|
||||||
void MbedTester::write(uint32_t addr, const uint8_t *data, uint32_t size)
|
void MbedTester::write(uint32_t addr, const uint8_t *data, uint32_t size)
|
||||||
|
@ -2184,7 +2186,7 @@ bool MbedTester::self_test_control_current()
|
||||||
|
|
||||||
bool MbedTester::_find_control_indexes(PhysicalIndex &clk_out, PhysicalIndex &mosi_out, PhysicalIndex &miso_out, PhysicalIndex &aux_out)
|
bool MbedTester::_find_control_indexes(PhysicalIndex &clk_out, PhysicalIndex &mosi_out, PhysicalIndex &miso_out, PhysicalIndex &aux_out)
|
||||||
{
|
{
|
||||||
MbedTesterBitMap<PHYSICAL_PINS> allowed;
|
MbedTesterBitMap<physical_pins> allowed;
|
||||||
const size_t max_pins = _form_factor.count();
|
const size_t max_pins = _form_factor.count();
|
||||||
const size_t max_controls = max_pins / 2;
|
const size_t max_controls = max_pins / 2;
|
||||||
|
|
||||||
|
@ -2200,7 +2202,7 @@ bool MbedTester::_find_control_indexes(PhysicalIndex &clk_out, PhysicalIndex &mo
|
||||||
}
|
}
|
||||||
for (size_t i = 0; i < LogicalPinTotal; i++) {
|
for (size_t i = 0; i < LogicalPinTotal; i++) {
|
||||||
PhysicalIndex index = _mapping[i];
|
PhysicalIndex index = _mapping[i];
|
||||||
if (index < PHYSICAL_PINS) {
|
if (index < physical_pins) {
|
||||||
allowed.clear(index);
|
allowed.clear(index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2282,25 +2284,25 @@ void MbedTester::_free_control_pins()
|
||||||
delete _clk;
|
delete _clk;
|
||||||
}
|
}
|
||||||
_clk = NULL;
|
_clk = NULL;
|
||||||
_clk_index = PHYSICAL_NC;
|
_clk_index = physical_nc;
|
||||||
if (_mosi) {
|
if (_mosi) {
|
||||||
_mosi->input();
|
_mosi->input();
|
||||||
delete _mosi;
|
delete _mosi;
|
||||||
}
|
}
|
||||||
_mosi = NULL;
|
_mosi = NULL;
|
||||||
_mosi_index = PHYSICAL_NC;
|
_mosi_index = physical_nc;
|
||||||
if (_miso) {
|
if (_miso) {
|
||||||
_miso->input();
|
_miso->input();
|
||||||
delete _miso;
|
delete _miso;
|
||||||
}
|
}
|
||||||
_miso = NULL;
|
_miso = NULL;
|
||||||
_miso_index = PHYSICAL_NC;
|
_miso_index = physical_nc;
|
||||||
if (_aux) {
|
if (_aux) {
|
||||||
_aux->input();
|
_aux->input();
|
||||||
delete _aux;
|
delete _aux;
|
||||||
}
|
}
|
||||||
_aux = NULL;
|
_aux = NULL;
|
||||||
_aux_index = PHYSICAL_NC;
|
_aux_index = physical_nc;
|
||||||
_control_valid = false;
|
_control_valid = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2344,7 +2346,7 @@ bool MbedTester::_update_needed()
|
||||||
void MbedTester::_reset()
|
void MbedTester::_reset()
|
||||||
{
|
{
|
||||||
for (uint32_t i = 0; i < sizeof(_mapping) / sizeof(_mapping[0]); i++) {
|
for (uint32_t i = 0; i < sizeof(_mapping) / sizeof(_mapping[0]); i++) {
|
||||||
_mapping[i] = PHYSICAL_NC;
|
_mapping[i] = physical_nc;
|
||||||
}
|
}
|
||||||
_free_control_pins();
|
_free_control_pins();
|
||||||
_control_auto = true;
|
_control_auto = true;
|
||||||
|
|
Loading…
Reference in New Issue