找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 5015|回复: 3
收起左侧

SX1278驱动源码资料下载

[复制链接]
ID:168408 发表于 2018-5-8 22:26 | 显示全部楼层 |阅读模式
    SX1278源码资料,这是网从公司下的SX1278驱动。

单片机源程序如下:
  1. /*
  2. * THE FOLLOWING FIRMWARE IS PROVIDED: (1) "AS IS" WITH NO WARRANTY; AND
  3. * (2)TO ENABLE ACCESS TO CODING INFORMATION TO GUIDE AND FACILITATE CUSTOMER.
  4. * CONSEQUENTLY, SEMTECH SHALL NOT BE HELD LIABLE FOR ANY DIRECT, INDIRECT OR
  5. * CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE CONTENT
  6. * OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING INFORMATION
  7. * CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
  8. *
  9. * Copyright (C) SEMTECH S.A.
  10. */
  11. /*!
  12. * \file       main.c
  13. * \brief      Ping-Pong example application on how to use Semtech's Radio
  14. *             drivers.
  15. *
  16. * \version    2.0
  17. * \date       Nov 21 2012
  18. * \author     Miguel Luis
  19. */
  20. #include <string.h>
  21. #include <stdint.h>
  22. #include <stdbool.h>
  23. #include "platform.h"
  24. #include "led.h"

  25. #if USE_UART
  26. #include "uart.h"
  27. #endif

  28. #include "radio.h"


  29. #define BUFFER_SIZE                                 9 // Define the payload size here


  30. static uint16_t BufferSize = BUFFER_SIZE;                        // RF buffer size
  31. static uint8_t Buffer[BUFFER_SIZE];                                        // RF buffer

  32. static uint8_t EnableMaster = true;                                 // Master/Slave selection

  33. tRadioDriver *Radio = NULL;

  34. const uint8_t PingMsg[] = "PING";
  35. const uint8_t PongMsg[] = "PONG";

  36. /*
  37. * Manages the master operation
  38. */
  39. void OnMaster( void )
  40. {
  41.     uint8_t i;
  42.    
  43.     switch( Radio->Process( ) )
  44.     {
  45.     case RF_RX_TIMEOUT:
  46.         // Send the next PING frame
  47.         Buffer[0] = 'P';
  48.         Buffer[1] = 'I';
  49.         Buffer[2] = 'N';
  50.         Buffer[3] = 'G';
  51.         for( i = 4; i < BufferSize; i++ )
  52.         {
  53.             Buffer[i] = i - 4;
  54.         }
  55.         Radio->SetTxPacket( Buffer, BufferSize );
  56.         break;
  57.     case RF_RX_DONE:
  58.         Radio->GetRxPacket( Buffer, ( uint16_t* )&BufferSize );
  59.    
  60.         if( BufferSize > 0 )
  61.         {
  62.             if( strncmp( ( const char* )Buffer, ( const char* )PongMsg, 4 ) == 0 )
  63.             {
  64.                 // Indicates on a LED that the received frame is a PONG
  65.                 LedToggle( LED_GREEN );

  66.                 // Send the next PING frame            
  67.                 Buffer[0] = 'P';
  68.                 Buffer[1] = 'I';
  69.                 Buffer[2] = 'N';
  70.                 Buffer[3] = 'G';
  71.                 // We fill the buffer with numbers for the payload
  72.                 for( i = 4; i < BufferSize; i++ )
  73.                 {
  74.                     Buffer[i] = i - 4;
  75.                 }
  76.                 Radio->SetTxPacket( Buffer, BufferSize );
  77.             }
  78.             else if( strncmp( ( const char* )Buffer, ( const char* )PingMsg, 4 ) == 0 )
  79.             { // A master already exists then become a slave
  80.                 EnableMaster = false;
  81.                 LedOff( LED_RED );
  82.             }
  83.         }            
  84.         break;
  85.     case RF_TX_DONE:
  86.         // Indicates on a LED that we have sent a PING
  87.         LedToggle( LED_RED );
  88.         Radio->StartRx( );
  89.         break;
  90.     default:
  91.         break;
  92.     }
  93. }

  94. /*
  95. * Manages the slave operation
  96. */
  97. void OnSlave( void )
  98. {
  99.     uint8_t i;

  100.     switch( Radio->Process( ) )
  101.     {
  102.     case RF_RX_DONE:
  103.         Radio->GetRxPacket( Buffer, ( uint16_t* )&BufferSize );
  104.    
  105.         if( BufferSize > 0 )
  106.         {
  107.             if( strncmp( ( const char* )Buffer, ( const char* )PingMsg, 4 ) == 0 )
  108.             {
  109.                 // Indicates on a LED that the received frame is a PING
  110.                 LedToggle( LED_GREEN );

  111.                // Send the reply to the PONG string
  112.                 Buffer[0] = 'P';
  113.                 Buffer[1] = 'O';
  114.                 Buffer[2] = 'N';
  115.                 Buffer[3] = 'G';
  116.                 // We fill the buffer with numbers for the payload
  117.                 for( i = 4; i < BufferSize; i++ )
  118.                 {
  119.                     Buffer[i] = i - 4;
  120.                 }

  121.                 Radio->SetTxPacket( Buffer, BufferSize );
  122.             }
  123.         }
  124.         break;
  125.     case RF_TX_DONE:
  126.         // Indicates on a LED that we have sent a PONG
  127.         LedToggle( LED_RED );
  128.         Radio->StartRx( );
  129.         break;
  130.     default:
  131.         break;
  132.     }
  133. }


  134. /*
  135. * Main application entry point.
  136. */
  137. int main( void )
  138. {
  139.     BoardInit( );
  140.    
  141.     Radio = RadioDriverInit( );
  142.    
  143.     Radio->Init( );

  144.     Radio->StartRx( );
  145.    
  146.     while( 1 )
  147.     {
  148.         if( EnableMaster == true )
  149.         {
  150.             OnMaster( );
  151.         }
  152.         else
  153. ……………………

  154. …………限于本文篇幅 余下代码请从51黑下载附件…………
复制代码

所有资料51hei提供下载:
sx12xxdrivers-v2.1.0.zip (1.85 MB, 下载次数: 107)
回复

使用道具 举报

ID:370019 发表于 2019-6-7 11:24 | 显示全部楼层
那么问题来了,这个驱动是51驱动?
回复

使用道具 举报

ID:201953 发表于 2020-4-15 19:35 | 显示全部楼层
先下来看看,再说
。谢谢分享。
回复

使用道具 举报

ID:962485 发表于 2024-4-4 16:14 | 显示全部楼层
tcjsjxx123 发表于 2019-6-7 11:24
那么问题来了,这个驱动是51驱动?

是51的吗,老哥
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表