123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- /************************************************************************************************/
- /**
- * @file main.c
- * @author MCU Ecosystem Development Team
- * @brief 该示例展示的SN模块用法。
- *
- *
- **************************************************************************************************
- * @attention
- * Copyright (c) CEC Huada Electronic Design Co.,Ltd. All rights reserved.
- *
- **************************************************************************************************
- */
- /*------------------------------------------includes--------------------------------------------*/
- #include "main.h"
- #include "common.h"
- #include "SN_GPIO.h"
- #include "SN_ADC.h"
- #include "SN_PWM.h"
- #include "SN_EXIT.h"
- #include "SN_TIM3_INIT.h"
- #include "SN_TIM1_INIT.h"
- #include "SN_UART.h"
- #include "SN_FLASH.h"
- #include "SN_RCC.h"
- #include "SN_SPI.h"
- #include "SN_DDQ.h"
- #include "i2c_bsp.h"
- #include "SN_STOP.h"
- #include <stdio.h>
- #include "myRadio.h"
- /*------------------------------------------functions-------------------------------------------*/
-
- uint16_t ADC_VAL = 0;
- float MCU_VDD = 0;
- void rfRx_callback(uint8_t status, rfRxPacket_ts packet)
- {
- printf("status:%d\r\n", status);
- switch (status)
- {
- case RX_STA_SECCESS:
- {
- printf("receive data:%s\r\n", packet.payload);
- // RF_StopCad();
- // myRadio_receiver();
- // myRadio_restartCadReceiver();
- }
- break;
- case RX_STA_TIMEOUT:
- {
- // myRadio_receiver();
- myRadio_restartCadReceiver();
- }
- break;
- case RX_STA_PAYLOAD_ERROR:
- {
- // myRadio_receiver();
- myRadio_restartCadReceiver();
- }
- break;
- case TX_STA_SECCESS:
- {
- // myRadio_receiver();
- myRadio_cadReceiver(300, 1000);
- }
- break;
- default:
- break;
- }
- }
- uint32_t sendTimeout = 0;
- int main(void)
- {
- SN_SYSCLK_set(SYSCLK_48MHZ); //设置系统时钟为48MHZ
- std_delay_init(); //初始化延时(该延时是使用滴答定时器实现的)
- std_delayms(500);
- SN_UART_init(UART1,921600, UART1_RX_PA2, UART1_TX_PB6); //初始化串口
- myRadio_init(0, rfRx_callback);
- myRadio_cadReceiver(500, 2000);
- // myRadio_receiver();
- printf("power on");
- while(1){
- std_delayms(1);
- // SN_ADC_start(); //此时编译的SN_ADC_star()是轮询处理
- // ADC_VAL = SN_ADC_Get_float(0); //PA7通道电压值
- // MCU_VDD = SN_ADC_MCU_VDD(); //获取MCU的当前vdd电压
- if (sendTimeout++ > 1000)
- {
- sendTimeout = 0;
- // myRadio_transmitArray("hello world", 10);
- }
-
- myRadio_process();
- }
- }
-
|