Skip to content
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

lora issues with lora_send_packet* in FreeRTOS #15

Open
sausagejohnson opened this issue Oct 28, 2024 · 0 comments
Open

lora issues with lora_send_packet* in FreeRTOS #15

sausagejohnson opened this issue Oct 28, 2024 · 0 comments

Comments

@sausagejohnson
Copy link

sausagejohnson commented Oct 28, 2024

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
	}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant