libdriver / sx1268

SX1268 full function driver library for general MCU and Linux.
https://www.libdriver.com
MIT License
49 stars 31 forks source link

树莓派4B 测试发送无法完成 #12

Open fortunerains opened 1 year ago

fortunerains commented 1 year ago

Description of the issues

硬件平台 树莓派4B 系统为烧录工具推荐的 易佰特 lora模块 E22-400M30S SPI链接 image image

jicunqi寄存器读写都正常 说明通信正常 spi工作了 但是send 例子不正常 image

Additional context

No response

libdriver commented 1 year ago

I'm very sorry to see your question now. Thank you for using our driver. The SX1268 transceiver relies on INT (DIO1) interrupts. Please check whether the interrupts can be triggered normally, including pin connections, pull-up, etc. Under normal interrupt triggering, transmission can be successful. In addition, your module also includes send and receive capabilities. Please ensure that the module is enabled before sending and receiving.

非常抱歉现在才看到您的问题。感谢您使用我们的驱动,SX1268收发都依赖于INT(DIO1)中断,请您检查中断是否能正常触发,包括管脚的连接、上拉等,正常情况下中断正常触发收发是可以成功的。另外您的模组还包括发送和接受使能,请确保收发前模组的收发使能。

fortunerains commented 1 year ago

SX1268收发都依赖于INT(DIO1)中断,我们这边直接按照用的gpiod库 我这边也看到你源代码中有这个操作,我这边感觉就是没有正常触发,您的模组还包括发送和接受使能,请确保收发前模组的收发使能。这个在您的程序里面没有么

libdriver commented 1 year ago

The original SX1268 did not have transceiver enable pin control. The module you used contains additional designs such as PA, and transceiver enable belongs to the module's additional design. Please refer to the module's design to enable your module's transceiver (both TXEN and RXEN are high) before conducting subsequent testing.

原始的SX1268是没有收发使能管脚控制的,您使用的模组含有PA等附加设计,收发使能属于模组附加的设计,请您参考模组的设计使能您模组的收发(TXEN和RXEN都拉高)再进行后面的测试。

fortunerains commented 10 months ago

我们这边确保拉高了,现在问题我们发送完毕后,读那个发送完成中断标志位还是有问题 image 读不到发送完成中断的标志位

libdriver commented 10 months ago

"\The project raspberrypi4b interface src gpio. c" file is the part of the system interrupt processing. You can output necessary printing information in this section to determine the interrupt situation. In addition, this interrupt defaults to using the rising edge trigger and is consistent with the original settings of the chip. Please check if the third-party module is consistent with it. (If there is an inverter, it will become a falling edge trigger)

  /* if the rising edge */
  if (event.event_type == GPIOD_LINE_EVENT_RISING_EDGE)
  {
      /* check the g_gpio_irq */
      if (g_gpio_irq != NULL)
      {
          /* run the callback */
          g_gpio_irq();
      }
  }

\project\raspberrypi4b\interface\src\gpio.c文件是系统中断处理的部分,您可以在该部分输出必要的打印信息判断中断情况,另外该中断默认使用上升沿触发与芯片原始的设置一致,请检查第三方模组是否与其一致。(如果有反相器等会变为下降沿触发)

  /* if the rising edge */
  if (event.event_type == GPIOD_LINE_EVENT_RISING_EDGE)
  {
      /* check the g_gpio_irq */
      if (g_gpio_irq != NULL)
      {
          /* run the callback */
          g_gpio_irq();
      }
  }
libdriver commented 10 months ago

Additionally, if the interrupt cannot be triggered, an interrupt handler can be added to the source code 1259-1263 loop.

    while ((ms != 0) && (handle->tx_done == 0) && (handle->timeout == 0)) 
    {
        handle->delay_ms(1);  
        ms--;       
        /* add this handler */
       sx1268_irq_handler(handle);
    }

另外如果中断无法触发可在源码1259-1263循环中增加中断处理程序

    while ((ms != 0) && (handle->tx_done == 0) && (handle->timeout == 0)) 
    {
        handle->delay_ms(1);  
        ms--;       
        /* add this handler */
       sx1268_irq_handler(handle);
    }
flespark commented 6 months ago

@chunyexixiaoyu 可以尝试不用TXEN和RXEN控制射频开关,而通过sx1268_set_dio2_as_rf_switch_ctrl(&gs_handle, SX1268_BOOL_TRUE);设置DIO2间接控制射频开关。初始化完成最好读取一下状态寄存确认是否初始化成功

    if ((a_sx1268_spi_read(handle, SX1268_COMMAND_GET_STATUS, (uint8_t *)buf, 1) != 0)
        || ((buf[0] & 0xf0) != 0x20)) /* status after reset should be stdby_rc */
    {
        handle->debug_print("sx1268: get status failed or status is not standby_rc after reset.\n");                               /* get status failed */
        (void)handle->spi_deinit();                                                        /* spi deinit */
#ifdef SX1268_HAVE_RESET_PIN
        (void)handle->reset_gpio_deinit();                                                 /* reset gpio deinit */
#endif
        (void)handle->dio1_gpio_deinit();
        (void)handle->busy_gpio_deinit();                                                  /* busy gpio deinit */

        return 6;                                                                          /* return error */
    }
libdriver commented 6 months ago

That sounds like a good idea