|
看程序吧,測試過可以發(fā)送的。MDK的
單片機(jī)源程序如下:
- /**
- ******************************** STM32F0xx *********************************
- * @文件名 : LoraUsart.c
- * @作者 : sun
- * @庫版本 : V1.5.0
- * @文件版本 : V1.0.0
- * @摘要 :Lorausart源文件
- ******************************************************************************/
-
- #include "LoraUsart.h"
-
- #include "LoraComm.h"
- #include "usart.h"
- #include "radio.h"
- #include "stdio.h"
- #include "usart.h"
- #include "sx1276-Hal.h"
- #include "sx1276.h"
- #include "sx1276-LoRaMisc.h"
- #include "sx1276-LoRa.h"
- #include "LoraComm.h"
-
- //#include "debug.h"
- typedef enum LORAUSART_t
- {
- LORA_USART_START,
- LORA_USART_RECEIVE,
- LORA_USART_SEND,
- }LORAUSART;
-
-
- /************************************************
- 函數(shù)名稱 : 應(yīng)用層函數(shù),UsartToLora(非阻塞函數(shù))
- 功 能 : 串口與LOra透出啊數(shù)據(jù)
- 參 數(shù) :
- 返 回 值 :
- 作 者 : sun
- *************************************************/
-
- void UsartToLora(void )
- {
- uint8_t BUFFER[MAXLOADLEN] ;
- uint32_t result = 0;
- uint16_t bufferLen = 0;
- static LORAUSART t_LoraUsart = LORA_USART_START;
- if(USART1_ready_buf_ok == 1)
- {
- USART1_ready_buf_ok = 0;
- t_LoraUsart = LORA_USART_SEND;
-
- }
- switch(t_LoraUsart)
- {
- case LORA_USART_START:
- LoraReadInit(0,UPLINK_FREQUENCY ,100 ,SHORT_PREAMBLE_LENGTH);
- t_LoraUsart = LORA_USART_RECEIVE;
- break;
- case LORA_USART_RECEIVE:
- result = Radio->Process( );
- if(result == RF_RX_DONE)
- {
- Radio->GetRxPacket( BUFFER, ( uint16_t* )&bufferLen );
-
- USART1_SendNByte(BUFFER,bufferLen);
- }
- else if(result ==RF_RX_TIMEOUT)
- {
- t_LoraUsart = LORA_USART_START;
- }
- break;
- case LORA_USART_SEND:
- LoraWrite(USART1_ready_buf,USART1_ready_buf_len,UPLINK_FREQUENCY ,SHORT_PREAMBLE_LENGTH,3000);
- t_LoraUsart = LORA_USART_START;
- break;
- }
- }
復(fù)制代碼
所有資料51hei提供下載:
STM32F103_SX127x_USART_LoRa.rar
(336.84 KB, 下載次數(shù): 453)
2018-7-3 11:21 上傳
點(diǎn)擊文件名下載附件
LORA 下載積分: 黑幣 -5
STM32F103_SX127x.rar
(342.43 KB, 下載次數(shù): 343)
2018-7-3 11:21 上傳
點(diǎn)擊文件名下載附件
LORA 下載積分: 黑幣 -5
|
評分
-
查看全部評分
|