updated libraries
This commit is contained in:
parent
d5d5d000b3
commit
3b7e68065a
102 changed files with 3020 additions and 1624 deletions
|
|
@ -462,7 +462,7 @@ m5::hal::error::error_t AdapterGPIOBase::GPIOImpl::read_analog(uint16_t& value,
|
|||
}
|
||||
|
||||
m5::hal::error::error_t AdapterGPIOBase::GPIOImpl::pulse_in(uint32_t& duration, const gpio_num_t pin, const int state,
|
||||
const uint32_t timeout_us = 30000)
|
||||
const uint32_t timeout_us)
|
||||
{
|
||||
duration = 0;
|
||||
auto start = esp_timer_get_time();
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ public:
|
|||
}
|
||||
|
||||
inline virtual m5::hal::error::error_t pulseInRX(uint32_t& duration, const int state,
|
||||
const uint32_t timeout_us) override
|
||||
const uint32_t timeout_us = 30000) override
|
||||
{
|
||||
return pulse_in(duration, rx_pin(), state, timeout_us);
|
||||
}
|
||||
|
|
@ -114,7 +114,7 @@ public:
|
|||
return read_analog(v, tx_pin());
|
||||
}
|
||||
inline virtual m5::hal::error::error_t pulseInTX(uint32_t& duration, const int state,
|
||||
const uint32_t timeout_us) override
|
||||
const uint32_t timeout_us = 30000) override
|
||||
{
|
||||
return pulse_in(duration, tx_pin(), state, timeout_us);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,6 +38,13 @@ bool declrare_use_rmt_channel(const int ch)
|
|||
return false;
|
||||
}
|
||||
|
||||
void clear_use_rmt_channel(const int ch)
|
||||
{
|
||||
if (ch >= 0 && ch < RMT_CHANNEL_MAX) {
|
||||
using_rmt_channel_bits &= ~(1U << ch);
|
||||
}
|
||||
}
|
||||
|
||||
rmt_config_t to_rmt_config_tx(const adapter_config_t& cfg, const uint32_t apb_freq_hz)
|
||||
{
|
||||
rmt_config_t out{};
|
||||
|
|
@ -78,6 +85,16 @@ public:
|
|||
GPIOImplV1(const int8_t rx_pin, const int8_t tx_pin) : AdapterGPIOBase::GPIOImpl(rx_pin, tx_pin)
|
||||
{
|
||||
}
|
||||
virtual ~GPIOImplV1()
|
||||
{
|
||||
rmt_tx_stop(_tx_config.channel);
|
||||
rmt_driver_uninstall(_tx_config.channel);
|
||||
clear_use_rmt_channel(_tx_config.channel);
|
||||
|
||||
rmt_rx_stop(_rx_config.channel);
|
||||
rmt_driver_uninstall(_rx_config.channel);
|
||||
clear_use_rmt_channel(_rx_config.channel);
|
||||
}
|
||||
|
||||
virtual bool begin(const gpio::adapter_config_t& cfg) override
|
||||
{
|
||||
|
|
@ -137,8 +154,8 @@ public:
|
|||
}
|
||||
return err == ESP_OK ? m5::hal::error::error_t::OK : m5::hal::error::error_t::UNKNOWN_ERROR;
|
||||
}
|
||||
M5_LIB_LOGE("Failed invalid config");
|
||||
|
||||
M5_LIB_LOGE("Failed invalid config");
|
||||
return m5::hal::error::error_t::UNKNOWN_ERROR;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -48,6 +48,17 @@ public:
|
|||
GPIOImplV2(const int8_t rx_pin, const int8_t tx_pin) : AdapterGPIOBase::GPIOImpl(rx_pin, tx_pin)
|
||||
{
|
||||
}
|
||||
virtual ~GPIOImplV2()
|
||||
{
|
||||
if (_tx_handle) {
|
||||
rmt_disable(_tx_handle);
|
||||
rmt_del_channel(_tx_handle);
|
||||
}
|
||||
if (_rx_handle) {
|
||||
rmt_disable(_rx_handle);
|
||||
rmt_del_channel(_rx_handle);
|
||||
}
|
||||
}
|
||||
|
||||
bool begin(const gpio::adapter_config_t& cfg)
|
||||
{
|
||||
|
|
@ -88,6 +99,9 @@ public:
|
|||
rmt_transmit_config_t tx_config = {};
|
||||
auto err = rmt_transmit(_tx_handle, copy_encoder, (gpio::m5_rmt_item_t*)data, len * sizeof(gpio::m5_rmt_item_t),
|
||||
&tx_config);
|
||||
if (err != ESP_OK) {
|
||||
M5_LIB_LOGE("Failed to transmit %d:%s", err, esp_err_to_name(err));
|
||||
}
|
||||
if (err == ESP_OK && waitMs) {
|
||||
err = rmt_tx_wait_all_done(_tx_handle, waitMs);
|
||||
if (err != ESP_OK) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue