Skip to content

lora issues with lora_send_packet* in FreeRTOS #15

Open
@sausagejohnson

Description

There appears to be an issue with this driver when used in FreeRTOS which stops the interrupts from firing again when a lora_send_packet* function is being used. At first I thought it was because it was blocking if not using DMA. I have switched to DMA but the same issue persists. I might be missing an issue perhaps with clearing out an RX interrupt before sending or setting a mode but the docs are not clear on steps.

Here is some brief code that receives lora packets and transmits acknowledgement packets:

/* FreeRTOS task that checks the state machine if the RX buffer is full */
void StartDefaultTask(void *argument)
{

  lora_mode_receive_continuous(&lora);
  lora_enable_interrupt_rx_done(&lora);

  for(;;)
  {
	
	// Receive buffer state machine
	if (RXBufferStatus == 1){
		HAL_USART_Transmit(&husart2, (uint8_t*)RXBuffer, 32U, 10U);
		
		//acknowledge
		lora_send_packet_dma_start(&lora, (uint8_t *)"acknowledge-from-system", 23);

		RXBufferStatus = 0; //clear: ready for interrupt to accept the next LoRa packet.
		osDelay(200);
	}

  }
}

/* DMA callback that successfully works after transmission */
void HAL_SPI_TxCpltCallback(SPI_HandleTypeDef *hspi){
	lora_send_packet_dma_complete(&lora);
	lora_mode_receive_continuous(&lora); //this makes no difference if included
}

/* Interrupt that successfully fires when DIO0 is high */
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin){
	if (GPIO_Pin == DIO0_EXTI5_Pin){

		if (RXBufferStatus == 1)
			return; //don't accept another packet until the first is taken and processed.

		uint8_t len = lora_receive_packet(&lora, RXBuffer, sizeof(RXBuffer), NULL); //no storing error info yet
		if (len > 0) {
			RXBufferStatus = 1;
		}
		lora_clear_interrupt_rx_all(&lora); //should I do this? Removing or including is the same
	}
}

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions