TobleMiner / lmic-esp-idf

A good port of the LMIC LoRaWAN library to esp-idf
42 stars 15 forks source link

Failure asserting when using VSPI #1

Closed dmamalis closed 5 years ago

dmamalis commented 5 years ago

I am trying to use the lib with RFM96 and VSPI.

    ret = spi_bus_initialize(VSPI_HOST, &buscfg, 1);
    assert(ret == ESP_OK);

    ret = spi_bus_add_device(VSPI_HOST, &devcfg, &spi_handle);
    assert(ret == ESP_OK);

The pin configuration is as follows but the assertion fails when trying to read the device address.

// Pin mapping
const lmic_pinmap lmic_pins = {
    .nss = 5,
    .rxtx = LMIC_UNUSED_PIN,
    .rst = 21,
    .dio = {4,2,LMIC_UNUSED_PIN},
    .spi = {19,23,18 } //MISO,MOSI,SCKL
};

Any hints?

TobleMiner commented 5 years ago

Hey,

Your code looks fine to me. There might be some trick to it though. I've not tried using the library with the VSPI interface yet.

I do not own any RFM96 modules but I'll try replicating your setup using an RFM95W later this day.

dmamalis commented 5 years ago

It actually looks like there might be something with the esp device and esp-idf pin muxing. When using the above pin mapping in arduino-lmic things work as expected. Apparently, the esp-idf works with both HSPI and VSPI when you apply the following pin mapping:

const lmic_pinmap lmic_pins = {
    .nss = 15,
    .rxtx = LMIC_UNUSED_PIN,
    .rst = 21,
    .dio = {4,2,LMIC_UNUSED_PIN},
    .spi = {12,13,14 } //MISO,MOSI,SCKL
};

I will also try to pin this down as soon as I got some robust communication (getting some RX issues...could be the clock...I will open another issue when the time comes)

TobleMiner commented 5 years ago

Hey, sorry for the delay. I didn't manage to do more testing on that day and was a little busy during Easter. I'll try it tomorrow though.

TobleMiner commented 5 years ago

Hey,

I've just tested your first pinmap on the VSPI interface and it seems to be working just fine with a RFM95w. Please feel free to check out the code I used to replicate your setup: ttn-vspi-test.zip

TobleMiner commented 5 years ago

By now I've added a VSPI option to Menuconfig. I'll close this issue for now since I could not replicate it. Please feel free to reopen if the issue persists.