mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-23 00:23:34 +08:00
Updated PX4 use / API of low level GPIO and other hardware-centric system facilities
This commit is contained in:
@@ -339,14 +339,14 @@ void
|
||||
CDev::poll_notify(pollevent_t events)
|
||||
{
|
||||
/* lock against poll() as well as other wakeups */
|
||||
irqstate_t state = irqsave();
|
||||
irqstate_t state = px4_enter_critical_section();
|
||||
|
||||
for (unsigned i = 0; i < _max_pollwaiters; i++)
|
||||
if (nullptr != _pollset[i]) {
|
||||
poll_notify_one(_pollset[i], events);
|
||||
}
|
||||
|
||||
irqrestore(state);
|
||||
px4_leave_critical_section(state);
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -75,7 +75,7 @@ I2C::I2C(const char *name,
|
||||
I2C::~I2C()
|
||||
{
|
||||
if (_dev) {
|
||||
up_i2cuninitialize(_dev);
|
||||
px4_i2cbus_uninitialize(_dev);
|
||||
_dev = nullptr;
|
||||
}
|
||||
}
|
||||
@@ -105,7 +105,7 @@ I2C::init()
|
||||
unsigned bus_index;
|
||||
|
||||
// attach to the i2c bus
|
||||
_dev = up_i2cinitialize(_bus);
|
||||
_dev = px4_i2cbus_initialize(_bus);
|
||||
|
||||
if (_dev == nullptr) {
|
||||
DEVICE_DEBUG("failed to init I2C");
|
||||
@@ -120,7 +120,7 @@ I2C::init()
|
||||
// abort if the max frequency we allow (the frequency we ask)
|
||||
// is smaller than the bus frequency
|
||||
if (_bus_clocks[bus_index] > _frequency) {
|
||||
(void)up_i2cuninitialize(_dev);
|
||||
(void)px4_i2cbus_uninitialize(_dev);
|
||||
_dev = nullptr;
|
||||
DEVICE_LOG("FAIL: too slow for bus #%u: %u KHz, device max: %u KHz)",
|
||||
_bus, _bus_clocks[bus_index] / 1000, _frequency / 1000);
|
||||
@@ -168,7 +168,7 @@ I2C::init()
|
||||
out:
|
||||
|
||||
if ((ret != OK) && (_dev != nullptr)) {
|
||||
up_i2cuninitialize(_dev);
|
||||
px4_i2cbus_uninitialize(_dev);
|
||||
_dev = nullptr;
|
||||
}
|
||||
|
||||
|
||||
@@ -95,7 +95,7 @@ SPI::init()
|
||||
|
||||
/* attach to the spi bus */
|
||||
if (_dev == nullptr) {
|
||||
_dev = up_spiinitialize(_bus);
|
||||
_dev = px4_spibus_initialize(_bus);
|
||||
}
|
||||
|
||||
if (_dev == nullptr) {
|
||||
@@ -152,9 +152,9 @@ SPI::transfer(uint8_t *send, uint8_t *recv, unsigned len)
|
||||
switch (mode) {
|
||||
default:
|
||||
case LOCK_PREEMPTION: {
|
||||
irqstate_t state = irqsave();
|
||||
irqstate_t state = px4_enter_critical_section();
|
||||
result = _transfer(send, recv, len);
|
||||
irqrestore(state);
|
||||
px4_leave_critical_section(state);
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user