mirror of
https://github.com/ArduPilot/ardupilot.git
synced 2026-10-02 10:23:25 +08:00
colcon build/test / build-test (push) Has been cancelled
Cygwin Build / build (push) Has been cancelled
ESP32 Build / build (esp32buzz, 10) (push) Has been cancelled
ESP32 Build / build (esp32s3empty, 10) (push) Has been cancelled
Macos Build / build (CubeOrange) (push) Has been cancelled
Macos Build / build (sitl) (push) Has been cancelled
QURT Build / build (push) Has been cancelled
test ccache / build (10, chibios) (push) Has been cancelled
test chibios / build (CubeOrange-EKF2, 10, chibios) (push) Has been cancelled
test chibios / build (CubeOrange-ODID, 10, chibios) (push) Has been cancelled
test chibios / build (CubeOrange-PPP, 10, chibios) (push) Has been cancelled
test chibios / build (CubeOrange-bootloader, 10, chibios) (push) Has been cancelled
test chibios / build (CubeRedPrimary-bootloader, 10, chibios) (push) Has been cancelled
test chibios / build (MatekF405-Wing, 10, chibios) (push) Has been cancelled
test chibios / build (Pixhawk6X-PPPGW, 10, chibios) (push) Has been cancelled
test chibios / build (SOHW, 10, chibios) (push) Has been cancelled
test chibios / build (build-options-defaults-test, 10, chibios) (push) Has been cancelled
test chibios / build (configure-all, 10, chibios) (push) Has been cancelled
test chibios / build (fmuv2-plane, 10, chibios) (push) Has been cancelled
test chibios / build (fmuv3, 10, chibios) (push) Has been cancelled
test chibios / build (fmuv3-bootloader, 10, chibios) (push) Has been cancelled
test chibios / build (iofirmware, 10, chibios) (push) Has been cancelled
test chibios / build (new-check, 10, chibios) (push) Has been cancelled
test chibios / build (periph-build, 10, chibios) (push) Has been cancelled
test chibios / build (revo-bootloader, 10, chibios) (push) Has been cancelled
test chibios / build (revo-mini, 10, chibios) (push) Has been cancelled
test chibios / build (signing, 10, chibios) (push) Has been cancelled
test chibios / build (stm32f7, 10, chibios) (push) Has been cancelled
test chibios / build (stm32h7, 10, chibios) (push) Has been cancelled
test chibios / build (stm32h7-debug, 10, chibios) (push) Has been cancelled
test dds / build (sitl) (push) Has been cancelled
test dds / build (stm32h7) (push) Has been cancelled
test Linux SBC / build (bbbmini, armhf) (push) Has been cancelled
test Linux SBC / build (bebop, armhf) (push) Has been cancelled
test Linux SBC / build (bhat, armhf) (push) Has been cancelled
test Linux SBC / build (canzero, armhf) (push) Has been cancelled
test Linux SBC / build (erlebrain2, armhf) (push) Has been cancelled
test Linux SBC / build (linux, base) (push) Has been cancelled
test Linux SBC / build (navigator, armhf-musl) (push) Has been cancelled
test Linux SBC / build (navigator64, aarch64) (push) Has been cancelled
test Linux SBC / build (navio, armhf) (push) Has been cancelled
test Linux SBC / build (navio2, armhf) (push) Has been cancelled
test Linux SBC / build (pxf, armhf) (push) Has been cancelled
test Linux SBC / build (pxfmini, armhf) (push) Has been cancelled
test replay / build (replay, base) (push) Has been cancelled
test replay / build (replay, clang) (push) Has been cancelled
test scripts / build (astyle-cleanliness) (push) Has been cancelled
test scripts / build (check_autotest_options) (push) Has been cancelled
test scripts / build (logger_metadata) (push) Has been cancelled
test scripts / build (param_parse) (push) Has been cancelled
test scripts / build (python-cleanliness) (push) Has been cancelled
test scripts / build (validate_board_list) (push) Has been cancelled
test blimp / build (base) (push) Has been cancelled
test blimp / build (clang) (push) Has been cancelled
test blimp / autotest (sitltest-blimp) (push) Has been cancelled
test copter / build (base) (push) Has been cancelled
test copter / build (clang) (push) Has been cancelled
test copter / autotest (sitltest-copter-tests1a) (push) Has been cancelled
test copter / autotest (sitltest-copter-tests1b) (push) Has been cancelled
test copter / autotest (sitltest-copter-tests1c) (push) Has been cancelled
test copter / autotest (sitltest-copter-tests1d) (push) Has been cancelled
test copter / autotest (sitltest-copter-tests1e) (push) Has been cancelled
test copter / autotest (sitltest-copter-tests2a) (push) Has been cancelled
test copter / autotest (sitltest-copter-tests2b) (push) Has been cancelled
test copter / build-gcc-heli (push) Has been cancelled
test copter / autotest-heli (sitltest-heli) (push) Has been cancelled
test ap_periph / build-gcc-ap_periph (push) Has been cancelled
test ap_periph / autotest-can (sitltest-can) (push) Has been cancelled
test plane / build (base) (push) Has been cancelled
test plane / build (clang) (push) Has been cancelled
test plane / autotest (sitltest-plane-tests1a) (push) Has been cancelled
test plane / autotest (sitltest-plane-tests1b) (push) Has been cancelled
test plane / autotest (sitltest-quadplane) (push) Has been cancelled
test rover / build (base) (push) Has been cancelled
test rover / build (clang) (push) Has been cancelled
test rover / autotest (sitltest-balancebot) (push) Has been cancelled
test rover / autotest (sitltest-rover) (push) Has been cancelled
test rover / autotest (sitltest-sailboat) (push) Has been cancelled
test sub / build (base) (push) Has been cancelled
test sub / build (clang) (push) Has been cancelled
test sub / autotest (sitltest-sub) (push) Has been cancelled
test tracker / build (base) (push) Has been cancelled
test tracker / build (clang) (push) Has been cancelled
test tracker / autotest (sitltest-tracker) (push) Has been cancelled
test unit tests and sitl building / build (examples, base) (push) Has been cancelled
test unit tests and sitl building / build (examples, clang) (push) Has been cancelled
test unit tests and sitl building / build (sitl, base) (push) Has been cancelled
test unit tests and sitl building / build (sitl, clang) (push) Has been cancelled
test unit tests and sitl building / build (unit-tests, base) (push) Has been cancelled
test unit tests and sitl building / build (unit-tests, clang) (push) Has been cancelled
test environment setup / build (bookworm, debian) (push) Has been cancelled
test environment setup / build (bullseye, debian) (push) Has been cancelled
test environment setup / build (focal, ubuntu) (push) Has been cancelled
test environment setup / build (jammy, ubuntu) (push) Has been cancelled
test environment setup / build (latest, archlinux) (push) Has been cancelled
test environment setup / build (noble, ubuntu) (push) Has been cancelled
test environment setup / build-alpine (push) Has been cancelled
these often make their way in when moving from some other printf-style debugging...
111 lines
2.9 KiB
C++
111 lines
2.9 KiB
C++
/*
|
|
This program is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
/*
|
|
Simulated spi buses and devices
|
|
*/
|
|
|
|
|
|
#include <GCS_MAVLink/GCS.h>
|
|
#include <SITL/SITL.h>
|
|
|
|
#include "SIM_SPI.h"
|
|
#include "SIM_SPIDevice.h"
|
|
|
|
#include "SIM_RAMTRON_FM25V02.h"
|
|
#include "SIM_JEDEC_MX25L3206E.h"
|
|
|
|
#include <signal.h>
|
|
|
|
using namespace SITL;
|
|
|
|
#if AP_SIM_RAMTRON_FM25V02_ENABLED
|
|
static RAMTRON_FM25V02 ramtron_FM25V02; // 32kB 2-byte-addressing
|
|
#endif
|
|
#if AP_SIM_JEDEC_MX25L3206E_ENABLED
|
|
static JEDEC_MX25L3206E jedec_MX25L3206E;
|
|
#endif
|
|
|
|
struct spi_device_at_cs_pin {
|
|
uint8_t bus;
|
|
uint8_t cs_pin;
|
|
SPIDevice &device;
|
|
} spi_devices[] {
|
|
#if AP_SIM_RAMTRON_FM25V02_ENABLED
|
|
{ 0, 0, ramtron_FM25V02 },
|
|
#endif
|
|
#if AP_SIM_JEDEC_MX25L3206E_ENABLED
|
|
{ 1, 0, jedec_MX25L3206E },
|
|
#endif
|
|
};
|
|
|
|
void SPI::init()
|
|
{
|
|
for (auto &i : spi_devices) {
|
|
i.device.init();
|
|
}
|
|
|
|
// sanity check the spi_devices structure to ensure we don't have
|
|
// two devices at the same address on the same bus:
|
|
for (uint8_t i=0; i<ARRAY_SIZE(spi_devices)-1; i++) {
|
|
const auto &dev_i = spi_devices[i];
|
|
for (uint8_t j=i+1; j<ARRAY_SIZE(spi_devices); j++) {
|
|
const auto &dev_j = spi_devices[j];
|
|
if (dev_i.bus == dev_j.bus &&
|
|
dev_i.cs_pin == dev_j.cs_pin) {
|
|
AP_HAL::panic("Two devices on the same cs_pin on the same bus");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
void SPI::update(const class Aircraft &aircraft)
|
|
{
|
|
for (auto daa : spi_devices) {
|
|
daa.device.update(aircraft);
|
|
}
|
|
}
|
|
|
|
int SPI::ioctl_transaction(uint8_t bus, uint8_t cs_pin, uint8_t count, spi_ioc_transfer *data)
|
|
{
|
|
for (auto &dev_at_cs_pin : spi_devices) {
|
|
if (dev_at_cs_pin.cs_pin != cs_pin) {
|
|
continue;
|
|
}
|
|
if (dev_at_cs_pin.bus != bus) {
|
|
continue;
|
|
}
|
|
return dev_at_cs_pin.device.rdwr(count, data);
|
|
}
|
|
GCS_SEND_TEXT(MAV_SEVERITY_WARNING, "Unhandled spi message: bus=%u cs_pin=%u", bus, cs_pin);
|
|
return -1;
|
|
}
|
|
|
|
int SPI::ioctl(uint8_t bus, uint8_t cs_pin, uint8_t ioctl_type, void *data)
|
|
{
|
|
uint8_t count;
|
|
switch (ioctl_type) {
|
|
case SPI_TRANSACTION_1LONG:
|
|
count = 1;
|
|
break;
|
|
case SPI_TRANSACTION_2LONG:
|
|
count = 2;
|
|
break;
|
|
default:
|
|
AP_HAL::panic("Bad transaction type");
|
|
}
|
|
|
|
return ioctl_transaction(bus, cs_pin, count, (spi_ioc_transfer*)data);
|
|
}
|