• 大小: 4KB
    文件类型: .rar
    金币: 2
    下载: 1 次
    发布日期: 2021-06-18
  • 语言: C/C++
  • 标签: STM32  433  射频  

资源简介

433射频收发程序C语言(STM32),GPIO和RF都有的。学习或者物联网开发都是非常不错的参考资源。

资源截图

代码片段和文件信息

#include“main.h“

unsigned char rf_ok=0;
unsigned char rf_start=0rf_data[4]={0};
unsigned char rf_fun=0;
unsigned short rf_time[2]={0}rf_id=0;

void rf_init(void)
{
    GPIO_InitTypeDef GPIO_InitStructure;
    NVIC_InitTypeDef NVIC_InitStructure;
    EXTI_InitTypeDef EXTI_InitStructure;
    
    RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOEENABLE);
    GPIO_InitStructure.GPIO_Pin=GPIO_Pin_3;
    GPIO_InitStructure.GPIO_Mode=GPIO_Mode_IPU;
    GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;
    GPIO_Init(GPIOE&GPIO_InitStructure);
    
    GPIO_EXTILineConfig(GPIO_PortSourceGPIOEGPIO_PinSource3);
    
    EXTI_InitStructure.EXTI_Line=EXTI_Line3;
    EXTI_InitStructure.EXTI_Mode=EXTI_Mode_Interrupt;
    EXTI_InitStructure.EXTI_Trigger=EXTI_Trigger_Rising_Falling;
    EXTI_InitStructure.EXTI_LineCmd=ENABLE;
    EXTI_Init(&EXTI_InitStructure);
    
    NVIC_InitStructure.NVIC_IRQChannel=EXTI3_IRQn;
    NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority=0x03;
    NVIC_InitStructure.NVIC_IRQChannelSubPriority=0x01;
    NVIC_InitStructure.NVIC_IRQChannelCmd=ENABLE;
    NVIC_Init(&NVIC_InitStructure);
}

void rf_ctrl(void)
{
    if(key_press&K_SET)
    {
        if(menu==MASTER)
        {
            menu=TIME;
            if(*(unsigned short*)&eeprom_buffer[0]) save=1;
        }
        else
        {
            menu=MASTER;
            rf_id=0;
            *(unsigned short*)&eeprom_buffer[0]=0;
        }
    }
    if(rf_ok)
    {
        if(menu!=MASTER&&rf_id==*(unsigned short*)&eeprom_buffer[0]&&rf_fun==0x78)
        {
            if(menu==TIME)
            {
                menu=BIG_KEY;
            }
            else if(menu==BIG_KEY)
            {
                if(menu_sub==0) menu=DIFFICULT;
                if(menu_sub==1)
                {
                    if(*(unsigned short*)&eeprom_buffer[2]) save=1;
                    menu=TIME;
                    menu_sub=0;
                }
            }
            else if(menu==DIFFICULT)
            {
                if(menu_sub==0) menu=COLLECT;
                if(menu_sub==1)
                {
                    eeprom_buffer[8]=difficult;
                    save=1;
                    menu=TIME;
                    menu_sub=0;
                }
            }
            else if(menu==COLLECT)
            {
                menu=LIGHT;
            }
            else if(menu==LIGHT)
            {
                if(menu_sub==0) menu=SET_TIME;
                if(menu_sub==1)
                {
                    eeprom_buffer[9]=light;
                    save=1;
                    menu=TIME;
                    menu_sub=0;
                }
            }
            else if(menu==SET_TIME)
            {
                if(menu_sub==0) menu=SET_TIMER;
            }
            else if(menu==SET_TIMER)
            {
                if(menu_sub==0) menu=TIME;
                if(menu_sub)
 

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       6327  2018-08-23 11:57  GPIO.C

     文件        336  2018-08-23 11:57  GPIO.h

     文件      11610  2018-08-23 11:55  rf.c

     文件        183  2018-08-23 11:55  rf.h

----------- ---------  ---------- -----  ----

                18456                    4


评论

共有 条评论