资源简介
STM32智能家居项目源代码,基于ZigBee和STM32的智能家居控制系统(IP柜)的设计与实现。
代码片段和文件信息
#include “CS.h“
#include “gpio.h“
#include “usart1.h“
extern uint8_t beginflag;
uint8_t count[8][8] = {0};
extern u8 USART_RX_BUF[8];
void Data_Collect(int timesuint32_t chip) //数据收集函数
{
int k;
int m = 0;
static int i = 0;
//控制输入使能端EN-1(ON5-ON7为000)
TIM3_US_DELAY(15); //定时器3延时15微秒
GPIOA->BRR = GPIO_Pin_7; //PA7置0
TIM3_US_DELAY(15);
GPIOA->BRR = GPIO_Pin_6;
TIM3_US_DELAY(15);
GPIOA->BRR = GPIO_Pin_5;
//控制输入OA1-OA4控制电缆的位数
GPIOE->BRR = GPIO_Pin_15|GPIO_Pin_14|GPIO_Pin_13|GPIO_Pin_12;//E15、14、13、12端置0 (OA1-OA4)
for(k=times; k {
GPIOE->ODR&=0X0FFF; //PE15-PE12清零
GPIOE->ODR|=k<<12; //i的值左移12位
TIM3_US_DELAY(10);
if(GPIO_ReadInputDataBit(GPIOA GPIO_Pin_3) == Bit_SET) //采集PA3的高低电平,放入矩阵count中
{
count[i][m++] = 0x01;
}
else
{
count[i][m++] = 0x00;
}
}
i++;
TIM3_US_DELAY(5);
}
void TIME2_Init(void)
{
TIM_TimebaseInitTypeDef TIM_TimebaseStructure;
NVIC_InitTypeDef NVIC_InitStructure;
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2 ENABLE);
TIM_DeInit(TIM2);
/* Time base configuration */
TIM_TimebaseStructure.TIM_Period = 1999; //80us
TIM_TimebaseStructure.TIM_Prescaler = 71; //1us
TIM_TimebaseStructure.TIM_ClockDivision = 0;
TIM_TimebaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
TIM_TimebaseInit(TIM2 &TIM_TimebaseStructure);
TIM_ARRPreloadConfig(TIM2ENABLE);
TIM_ClearFlag(TIM2TIM_FLAG_Update);
TIM_ITConfig(TIM2TIM_IT_UpdateENABLE); /* Enable the TIM_IT_Update Interrupt Request */
TIM_Cmd(TIM2 DISABLE);
NVIC_InitStructure.NVIC_IRQChannel = TIM2_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
}
void TIME3_Init(void)
{
TIM_TimebaseInitTypeDef TIM_TimebaseStructure;
NVIC_InitTypeDef NVIC_InitStructure;
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM3 ENABLE);
TIM_DeInit(TIM3);
/* Time base configuration */
TIM_TimebaseStructure.TIM_Period = 1; //1us
TIM_TimebaseStructure.TIM_Prescaler = 71; //1us
TIM_TimebaseStructure.TIM_ClockDivision = 0;
TIM_TimebaseStructure.TIM_CounterMode = TIM_CounterMode_Down;
TIM_TimebaseInit(TIM3 &TIM_TimebaseStructure);
TIM_ARRPreloadConfig(TIM3ENABLE);
TIM_ClearFlag(TIM3TIM_FLAG_Update);
TIM_ITConfig(TIM3 TIM_IT_Update ENABLE); /* Enable the TIM_IT_Update Interrupt Request */
TIM_Cmd(TIM3 DISABLE);
NVIC_InitStructure.NVIC_IRQChannel = TIM3_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;
NVIC_InitStructure.NVIC_IRQChannelS
相关资源
- STM8和STM32F103原理图库AD
- 基于STM32的空气颗粒PM2.5与温湿度检测
- STM32最小系统 使用BMP180取得大气压值
- stm32 delay.h 延时文件
- mma8451 stm32代码.rar.rar
- robomaster 开发板A型板原理图
- h743_adc_8ch_dma_timer.ioc
- ZigBee技术在智能插座设计中的应用_徐
- STM32F103X SPI2 DMA 驱动LCD.zip
- stm32f4_6通道串口收发
- 基于STM32的心率传感器设计代码
- STM32F207 串口1 2 DMA源码34普通串口
- STM32F030/SX1278扩频Lora无线模块收发测试
- 基于ZigBee的细粒度电量智能无线监控
- IAR kegen PartA810 IAR for ZigBee8.10版注册机
- STM32使用FIR滤波器的详细过程
- PID算法控制电机转速
- STM32F103的LoRa模块驱动源代码
- 思岚激光雷达小车程序stm32程序
- zigbee-cc2530 串口收发
- STM32F207 串口通讯程序
- OLED 091 12832 I2C STM32 驱动
- 基于STM32F4xx,MS5611气压传感器使用S
- STM32库函数代码生成器V1.2 无限制版
- STM32F103C8T6+ENC28J60+UIP1.0整个工程打包
- STM32F103C8T6移植OV7670带FIFO摄像头
- Keil.STM32L4xx_DFP.2.3.0.pack
- STM32F407贪吃蛇游戏程序
- STM32文件系统 SD卡U盘等读写程序
- 基于STM32的SIM800程序
评论
共有 条评论