-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Interest in supporting async
?
#15
Comments
Hi James, yes, I would certainly welcome an async version here. It might be possible to keep the same The ugly thing is that basically the whole code is duplicated. Do you have any experience with What would be nice would be to keep one central |
Hey! So, in respect of "how" to do this, I also added async support to the MAX31855 crate in this PR, where I isolated the I/O and non-I/O part, so that everything could be shared. This is a much simpler driver than the current ads1x1x, but maybe enough to see the "vibe" of how I'd recommend doing it. The public interface is duplicated, but most of the "guts" are shared, outside of how you read/write the actual data. However, I also realized three things after working on this today:
Since I'm doing this for a client project, it seemed to make the most sense to implement the minimal functionality I needed, which I've done here. Happy to discuss upstreaming these bits tho, as well as the maybe-async approach. |
I see. Yes, I think it does not make much sense to abstract over this. |
I am also looking to use ads1115 with Embassy. The crate works without Embassy but the use of Embassy introduces a lifetime ('static) which causes this issue. Below is the code block and then the resulting build error. I hope that this provides some help. CODE: #[main]
async fn main(spawner: Spawner) {
static SIGNAL: StaticCell<Signal<NoopRawMutex, [u8; 32]>> = StaticCell::new();
let signal = &*SIGNAL.init(Signal::new());
esp_println::println!("Init!");
let peripherals = Peripherals::take();
let system = SystemControl::new(peripherals.SYSTEM);
let clocks = ClockControl::boot_defaults(system.clock_control).freeze();
let timg0 = TimerGroup::new_async(peripherals.TIMG0, &clocks);
esp_hal_embassy::init(&clocks, timg0);
const ADDRESS: u8 = 0x48;
let io = Io::new(peripherals.GPIO, peripherals.IO_MUX);
// Default pins for Uart/Serial communication
//let tx_pin = io.pins.gpio21;
//let rx_pin = io.pins.gpio20;
let pins = TxRxPins::new_tx_rx(io.pins.gpio21, io.pins.gpio20);
let config = Config::default();
config
.baudrate(115_200)
.data_bits(DataBits::DataBits8)
.stop_bits(StopBits::STOP1)
.parity_none();
//config.rx_fifo_full_threshold(READ_BUF_SIZE as u16);
//
let i2c_var = I2C::new(
peripherals.I2C0,
io.pins.gpio4,
io.pins.gpio5,
400.kHz(),
&clocks,
None
);
let c = ads1x1x::Ads1x1x::new_ads1115(i2c_var, ads1x1x::SlaveAddr::Default); ERROR:
Apologies for commenting on an issue from over a year ago, I don't know if this counts as necro posting. If there is more information I can give please let me know. |
@Jasperlooney That is an unrelated issue possibly caused by your esp-hal version using |
@eldruin Thank you so much! I have been wrestling with this issue for about a month. The code compiles now and you are an absolute legend. Thank you for addressing my issue even though it turned out to be unrelated. |
Hey there! I have a project where I'll need to use an ADS1110 inside of an
embassy
based project.I'll certainly base my work off of this crate, but I'm not sure the best way of supporting both sync and async approaches. From a first guess, I'd likely keep all the constants and register definitions shared, but have two separate types and I/O impls for blocking and async interfaces.
I'll plan to do this async conversion in a fork to start off, but if I get it to a reasonable place, would you be interested in having me upstream those changes?
Thanks!
The text was updated successfully, but these errors were encountered: