设定#define TX 1,可以让ML51控制LoRa模块作为TX传送数据。
设定#define TX 0,可以让ML51控制LoRa模块作为RX传送数据。
范例中先呼叫BoardInit()与Radio_Init()进行GPIO与SPI等硬件的初始化,然后开始进行LoRa数据传输测试。
- /*---------------------------------------------------------------------------------------------------------*/
- /* */
- /* Copyright(c) 2019 Nuvoton Technology Corp. All rights reserved. */
- /* */
- /*---------------------------------------------------------------------------------------------------------*/
- //***********************************************************************************************************
- // Website: http://www.nuvoton.com
- // E-Mail : MicroC-8bit@nuvoton.com
- // Date : Jan/21/2019
- //***********************************************************************************************************
- #include <stdio.h>
- #include "platform.h"
- #include "ML51.h"
- #include "Operation.h"
- /*---------------------------------------------------------------------------------------------------------*/
- /*Define */
- /*---------------------------------------------------------------------------------------------------------*/
- #define TX 1
- /*---------------------------------------------------------------------------------------------------------*/
- /*Global variables */
- /*---------------------------------------------------------------------------------------------------------*/
- extern unsigned char F_RxStart;
- extern unsigned char F_TxStart;
- /*---------------------------------------------------------------------------------------------------------*/
- /* Functions. */
- /*---------------------------------------------------------------------------------------------------------*/
- int main(void)
- {
- BoardInit();
- Radio_Init();
- #if TX
- TxStart();
- #else
- RX_Init();
- #endif
- while (1)
- {
- if (F_RxStart)
- {
- F_RxStart = FALSE;
- RX_Done();
- RxDoneAction();
- RX_Init();
- }
- if (F_TxStart)
- {
- F_TxStart = FALSE;
- TX_Done();
- TxDoneAction();
- TxStart();
- }
- }
- }
|