标签:default 软件时间 使用 串口 模块 efi i++ 控制 频率
#include "user_usart.h" #include "stm32f10x_usart.h" #include "user_adc.h" #include "user_74_595.h" #include "user_74_165.h" #include "user_gpio.h" /*使用microLib的方法*/ /* int fputc(int ch, FILE *f) { USART_SendData(USART1, (uint8_t) ch); while (USART_GetFlagStatus(USART1, USART_FLAG_TC) == RESET) {} return ch; } int GetKey (void) { while (!(USART1->SR & USART_FLAG_RXNE)); return ((int)(USART1->DR & 0x1FF)); } */ //#if EN_USART1_RX //如果使能了接收 //#if EN_USART1_RX //如果使能了接收 //串口1中断服务程序 //注意,读取USARTx->SR能避免莫名其妙的错误 //u8 USART_RX_BUF[USART_REC_LEN]; //接收缓冲,最大USART_REC_LEN个字节. //接收状态 //bit15, 接收完成标志 //bit14, 接收到0x0d //bit13~0, 接收到的有效字节数目 u16 USART_RX_STA=0; //接收状态标记 //串口1队列定义 u8 UART1SendBuff[UART1BuffSize]; //发送数据 u8 UART1ReceBuff[UART1BuffSize]; //接收数据? u16 UART1ReceIn = 0;//接收状态标记数据位 u8 UART1ReceFullFlag = 0;//接收完数据标志位 //串口2队列定义 u8 UART2SendBuff[UART2BuffSize]; u8 UART2ReceBuff[UART2BuffSize]; u16 UART2ReceIn = 0; u8 UART2ReceFullFlag = 0; //串口3队列定义 u8 UART3SendBuff[UART3BuffSize]; u8 UART3ReceBuff[UART3BuffSize]; u16 UART3ReceIn = 0; u8 UART3ReceFullFlag = 0; //串口1初始化 void USART1_Configuration(u32 bound) { GPIO_InitTypeDef GPIO_InitStructure; NVIC_InitTypeDef NVIC_InitStructure; USART_InitTypeDef USART_InitStructure;; RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA|RCC_APB2Periph_USART1,ENABLE);//开启GPIOA和USART1时钟 //USART1_TX GPIOA.9 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9; //PA.9 GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; //复用推挽输出 GPIO_Init(GPIOA, &GPIO_InitStructure);//初始化GPIOA.9 //USART1_RX GPIOA.10初始化 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10;//PA10 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;//浮空输入 GPIO_Init(GPIOA, &GPIO_InitStructure);//初始化GPIOA.10 //Usart1 NVIC 配置 NVIC_InitStructure.NVIC_IRQChannel = USART1_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority=2 ;//抢占优先级3 NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; //子优先级3 NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; //IRQ通道使能 NVIC_Init(&NVIC_InitStructure); //根据指定的参数初始化VIC寄存器 //USART 初始化设置 USART_InitStructure.USART_BaudRate = bound;//串口波特率 USART_InitStructure.USART_WordLength = USART_WordLength_8b;//字长为8位数据格式 USART_InitStructure.USART_StopBits = USART_StopBits_1;//一个停止位 USART_InitStructure.USART_Parity = USART_Parity_No;//无奇偶校验位 USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;//无硬件数据流控制 USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx; //收发模式 USART_Init(USART1, &USART_InitStructure); //初始化串口1 USART_ITConfig(USART1,USART_IT_RXNE,ENABLE); //开启串口接收中断 USART_Cmd(USART1, ENABLE); //使能串口1 } //串口2初始化 void USART2_Configuration(u32 bound) { GPIO_InitTypeDef GPIO_InitStructure; NVIC_InitTypeDef NVIC_InitStructure; USART_InitTypeDef USART_InitStructure;; RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2,ENABLE); RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA,ENABLE);//开启GPIOA和USART1时钟 //USART2_TX GPIOA.2 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2; //PA.2 GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; //复用推挽输出 GPIO_Init(GPIOA, &GPIO_InitStructure);//初始化GPIOA.2 //USART2_RX GPIOA.3初始化 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3;//PA3 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;//浮空输入 GPIO_Init(GPIOA, &GPIO_InitStructure);//初始化GPIOA.3 //Usart2 NVIC 配置 NVIC_InitStructure.NVIC_IRQChannel = USART2_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority=2 ;//抢占优先级3 NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; //子优先级3 NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; //IRQ通道使能 NVIC_Init(&NVIC_InitStructure); //根据指定的参数初始化VIC寄存器 //USART 初始化设置 USART_InitStructure.USART_BaudRate = bound;//串口波特率 USART_InitStructure.USART_WordLength = USART_WordLength_8b;//字长为8位数据格式 USART_InitStructure.USART_StopBits = USART_StopBits_1;//一个停止位 USART_InitStructure.USART_Parity = USART_Parity_No;//无奇偶校验位 USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;//无硬件数据流控制 USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx; //收发模式 USART_Init(USART2, &USART_InitStructure); //初始化串口2 USART_ITConfig(USART2,USART_IT_RXNE,ENABLE); //开启串口接收中断 USART_Cmd(USART2, ENABLE); //使能串口2 } //串口3初始化 void USART3_Configuration(u32 bound) { GPIO_InitTypeDef GPIO_InitStructure; NVIC_InitTypeDef NVIC_InitStructure; USART_InitTypeDef USART_InitStructure;; RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART3,ENABLE); RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB,ENABLE);//开启GPIOA和USART1时钟 //USART3_TX GPIOB.10 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10; //PB.10 GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; //复用推挽输出 GPIO_Init(GPIOB, &GPIO_InitStructure);//初始化GPIOA.10 //USART3_RX GPIOB.3初始化 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11;//PB11 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;//浮空输入 GPIO_Init(GPIOB, &GPIO_InitStructure);//初始化GPIOB.11 //Usart3 NVIC 配置 NVIC_InitStructure.NVIC_IRQChannel = USART3_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority=2 ;//抢占优先级3 NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; //子优先级3 NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; //IRQ通道使能 NVIC_Init(&NVIC_InitStructure); //根据指定的参数初始化VIC寄存器 //USART 初始化设置 USART_InitStructure.USART_BaudRate = bound;//串口波特率 USART_InitStructure.USART_WordLength = USART_WordLength_8b;//字长为8位数据格式 USART_InitStructure.USART_StopBits = USART_StopBits_1;//一个停止位 USART_InitStructure.USART_Parity = USART_Parity_No;//无奇偶校验位 USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;//无硬件数据流控制 USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx; //收发模式 USART_Init(USART3, &USART_InitStructure); //初始化串口3 USART_ITConfig(USART3,USART_IT_RXNE,ENABLE); //开启串口接收中断 USART_Cmd(USART3, ENABLE); //使能串口3 } //串口1发送一帧数据 void USART1_SendOneData(uint8_t SendOneData) { USART_SendData(USART1, SendOneData); while (USART_GetFlagStatus(USART1, USART_FLAG_TC) == RESET) {} } //串口2发送一帧数据 void USART2_SendOneData(uint8_t SendOneData) { USART_SendData(USART2, SendOneData); while (USART_GetFlagStatus(USART2, USART_FLAG_TC) == RESET) {} } //串口3发送一帧数据 void USART3_SendOneData(uint8_t SendOneData) { USART_SendData(USART3, SendOneData); while (USART_GetFlagStatus(USART3, USART_FLAG_TC) == RESET) {} } //串口1发送一列数据 void USART1_SendUnfixedData(uint8_t *Buffer, uint8_t Length) { uint8_t i; for(i=0;i<Length;i++) { USART1_SendOneData(*Buffer++); } } //串口2发送一列数据 void USART2_SendUnfixedData(uint8_t *Buffer, uint8_t Length) { uint8_t i; for(i=0;i<Length;i++) { USART2_SendOneData(*Buffer++); } } //串口3发送一列数据 void USART3_SendUnfixedData(uint8_t *Buffer, uint8_t Length) { uint8_t i; LED_ON; for(i=0;i<Length;i++) { USART3_SendOneData(*Buffer++); } LED_OFF; } //串口1中断服务函数 void USART1_IRQHandler(void) { u8 Res;//数据暂存 if(USART_GetITStatus(USART1, USART_IT_RXNE) != RESET) //接收中断 { Res =USART_ReceiveData(USART1); //读取接收到的数据 switch(UART1ReceIn)//读取接收到的数据有几位 每一位对应的数据协议校验 { case 0: if(Res==‘T‘) UART1ReceBuff[UART1ReceIn++] = Res; else UART1ReceIn = 0; break; case 1: if(Res==‘M‘) UART1ReceBuff[UART1ReceIn++] = Res; else UART1ReceIn = 0; break; case 2: if(Res==0x0f) UART1ReceBuff[UART1ReceIn++] = Res; else UART1ReceIn = 0; break; case 3: if(Res==0x01) UART1ReceBuff[UART1ReceIn++] = Res; else UART1ReceIn = 0; break; case 4: if(Res==0x31) UART1ReceBuff[UART1ReceIn++] = Res; else UART1ReceIn = 0; break; default: UART1ReceBuff[UART1ReceIn++] = Res; break; } if(UART1ReceIn >= 57) { UART1ReceFullFlag = 1; //数据完整接受完 } USART_ClearITPendingBit(USART1, USART_IT_RXNE);//清除相对应的中断位 清除中断预处理位USART_ClearITPendingBit左移八位是USART_ClearFlag } else if(USART_GetITStatus(USART1, USART_IT_TXE) != RESET) // 发送中断 USART_GetITStatus { USART_ClearITPendingBit(USART1, USART_IT_TXE); // clear interrupt 清除中断预处理位 } } //串口2中断服务函数 void USART2_IRQHandler(void) { u8 Res; #if SYSTEM_SUPPORT_OS //如果SYSTEM_SUPPORT_OS为真,则需要支持OS. OSIntEnter(); #endif if(USART_GetITStatus(USART2, USART_IT_RXNE) != RESET) //接收中断(接收到的数据必须是0x0d 0x0a结尾) { Res =USART_ReceiveData(USART2); //读取接收到的数据USART_ReceiveData if((USART_RX_STA&0x8000)==0)//接收未完成 { if(USART_RX_STA&0x4000)//接收到了0x0d { if(Res!=0x0a)USART_RX_STA=0;//接收错误,重新开始 else USART_RX_STA|=0x8000; //接收完成了 } else //还没收到0X0D { if(Res==0x0d)USART_RX_STA|=0x4000; else { UART2ReceBuff[USART_RX_STA&0X3FFF]=Res ; USART_RX_STA++; if(USART_RX_STA>(USART_REC_LEN-1))USART_RX_STA=0;//接收数据错误,重新开始接收 } } } } #if SYSTEM_SUPPORT_OS //如果SYSTEM_SUPPORT_OS为真,则需要支持OS. OSIntExit(); #endif } //串口3中断服务函数 void USART3_IRQHandler(void) { u8 Res;//数据暂存 if(USART_GetITStatus(USART3, USART_IT_RXNE) != RESET) //接收中断 { Res =USART_ReceiveData(USART3); //读取接收到的数据 USART_ReceiveData switch(UART3ReceIn)//读取接收到的数据有几位 每一位对应的数据协议校验 { case 0: if(Res==‘T‘) UART3ReceBuff[UART3ReceIn++] = Res; else UART3ReceIn = 0; break; case 1: if(Res==‘M‘) UART3ReceBuff[UART3ReceIn++] = Res; else UART3ReceIn = 0; break; case 2: if(Res==0x0f) UART3ReceBuff[UART3ReceIn++] = Res; else UART3ReceIn = 0; break; case 3: if(Res==0x01) UART3ReceBuff[UART3ReceIn++] = Res; else UART3ReceIn = 0; break; case 4: if(Res==0x31) UART3ReceBuff[UART3ReceIn++] = Res; else UART3ReceIn = 0; break; default: UART3ReceBuff[UART3ReceIn++] = Res; break; } if(UART3ReceIn >= 57) { UART3ReceFullFlag = 1; //数据完整接受完 } USART_ClearITPendingBit(USART3, USART_IT_RXNE);//清除相对应的中断位 清除中断预处理位USART_ClearITPendingBit左移八位是USART_ClearFlag } else if(USART_GetITStatus(USART3, USART_IT_TXE) != RESET) // 发送中断 USART_GetITStatus { USART_ClearITPendingBit(USART3, USART_IT_TXE); // clear interrupt 清除中断预处理位 } } //发送开关量输入数据 void SendInputData(void) { // 组包,第一帧 UART1SendBuff[0] = 0XAA; UART1SendBuff[1] = 0XBB; UART1SendBuff[2] = ReadInData.ByteData[0]; UART1SendBuff[3] = ReadInData.ByteData[1]; UART1SendBuff[4] = ReadInData.ByteData[2]; UART1SendBuff[5] = ReadInData.ByteData[3]; //165检测结构 UART1SendBuff[6] = 0XCC; UART1SendBuff[7] = 0XDD; // 发送第一帧数据 USART3_SendUnfixedData(UART1SendBuff,8); Delay_m(350); // 延时,和计算机软件时间匹配 } void SendAnalogData(void) // 通过串口发送模拟量数据 { // 组包,第一帧 UART1SendBuff[0] = 0XAA; UART1SendBuff[1] = 0XBB; UART1SendBuff[2] = 0X01; UART1SendBuff[6] = 0XCC; UART1SendBuff[7] = 0XDD; UART1SendBuff[3] = 0x10; UART1SendBuff[4] = (AnalogChannel[0].AveVal >> 8); UART1SendBuff[5] = (u8)AnalogChannel[0].AveVal; // 发送第一帧数据 USART3_SendUnfixedData(UART1SendBuff, 8); Delay_m(300); // 延时,和计算机软件时间匹配 //--------------------------------------------------------- // 组包,第二帧 UART1SendBuff[3] = 0x20; UART1SendBuff[4] = (AnalogChannel[1].AveVal >> 8); UART1SendBuff[5] = (u8)AnalogChannel[1].AveVal; // 发送第二帧数据 USART3_SendUnfixedData(UART1SendBuff, 8); Delay_m(300); // 延时,和计算机软件时间匹配 /* //--------------------------------------------------------- // 组包,第三帧 UART1SendBuff[3] = 0x30; UART1SendBuff[4] = (AnalogChannel[2].AveVal >> 8); UART1SendBuff[5] = (u8)AnalogChannel[2].AveVal; // 发送第三帧数据 USART3_SendUnfixedData(UART1SendBuff, 8); Delay_m(300); // 延时,和计算机软件时间匹配 //--------------------------------------------------------- // 组包,第四帧 UART1SendBuff[1] = 0x40; UART1SendBuff[2] = (AnalogChannel[3].AveVal >> 8); UART1SendBuff[3] = (u8)AnalogChannel[3].AveVal; // 发送第四帧数据 USART_SendUnfixedData(UART1SendBuff, 8); Delay_m(300); // 延时,和计算机软件时间匹配 //--------------------------------------------------------- // 组包,第五帧 UART1SendBuff[1] = 0x50; UART1SendBuff[2] = (AnalogChannel[4].AveVal >> 8); UART1SendBuff[3] = (u8)AnalogChannel[4].AveVal; // 发送第五帧数据 USART_SendUnfixedData(UART1SendBuff, 8); Delay_m(300); // 延时,和计算机软件时间匹配 //--------------------------------------------------------- // 组包,第六帧 UART1SendBuff[1] = 0x60; UART1SendBuff[2] = (AnalogChannel[5].AveVal >> 8); UART1SendBuff[3] = (u8)AnalogChannel[5].AveVal; // 发送第六帧数据 USART_SendUnfixedData(UART1SendBuff, 8); Delay_m(300); // 延时,和计算机软件时间匹配 //--------------------------------------------------------- // 组包,第七帧 UART1SendBuff[1] = 0x70; UART1SendBuff[2] = (AnalogChannel[6].AveVal >> 8); UART1SendBuff[3] = (u8)AnalogChannel[6].AveVal; // 发送第七帧数据 USART_SendUnfixedData(UART1SendBuff, 8); Delay_m(300); // 延时,和计算机软件时间匹配 //--------------------------------------------------------- // 组包,第八帧 UART1SendBuff[1] = 0x80; UART1SendBuff[2] = (AnalogChannel[7].AveVal >> 8); UART1SendBuff[3] = (u8)AnalogChannel[7].AveVal; // 发送第八帧数据 USART_SendUnfixedData(UART1SendBuff, 8); Delay_m(300); // 延时,和计算机软件时间匹配 */ }
.h
#ifndef __USER_USART_H #define __USER_USART_H #include "stm32f10x.h" #define UART1BuffSize 64 //接收数据的位 #define UART2BuffSize 64 //接收缓存数据的字节 #define UART3BuffSize 64 //接收缓存数据的字节 extern u8 UART1SendBuff[UART1BuffSize]; //发送数据 extern u8 UART1ReceBuff[UART1BuffSize]; //接收缓存数据 extern u16 UART1ReceIn;//接收状态标记数据位数 extern u8 UART1ReceFullFlag; //接收数据状态 extern u8 UART2SendBuff[UART2BuffSize]; extern u8 UART2ReceBuff[UART2BuffSize]; extern u16 UART2ReceIn; extern u8 UART2ReceFullFlag; extern u8 UART3SendBuff[UART3BuffSize]; extern u8 UART3ReceBuff[UART3BuffSize]; extern u16 UART3ReceIn; extern u8 UART3ReceFullFlag; void USART1_Configuration(u32 bound);//穿口初始化 void USART2_Configuration(u32 bound); void USART3_Configuration(u32 bound); void USART1_SendOneData(uint8_t SendOneData); //串口1发送一帧数据 void USART2_SendOneData(uint8_t SendOneData); void USART3_SendOneData(uint8_t SendOneData); void USART1_SendUnfixedData(uint8_t *Buffer, uint8_t Length); void USART2_SendUnfixedData(uint8_t *Buffer, uint8_t Length); void USART3_SendUnfixedData(uint8_t *Buffer, uint8_t Length); void SendInputData(void); void SendAnalogData(void); // 通过串口发送模拟量数据 #define USART_REC_LEN 200 //定义最大接收字节数 200 #define EN_USART1_RX 1 //使能(1)/禁止(0)串口1接收 extern u8 USART_RX_BUF[USART_REC_LEN]; //接收缓冲,最大USART_REC_LEN个字节.末字节为换行符 extern u16 USART_RX_STA; //接收状态标记 //如果想串口中断接收,请不要注释以下宏定义 #endif
main
#include "user_usart.h"
#include "user_gpio.h"
#include "user_74_165.h"
#include "user_74_595.h"
#include "user_timer.h"
#include "user_adc.h"
#include "user_iwdg.h"
#include "user_crc.h"
#include <string.h>
#include "delay.h"
#include "JQ8900.h"
#include "LED.h"
#include "user_gpio.h"
#include "user_74_595.h"
#include "wdg.h"
#include "stdio.h"
uint8_t FLAG_INA7 = 0; //撑开按钮按下标志
uint8_t FLAG_INA6 = 0; //缩回按钮按下标志
uint8_t FLAG_INA7_EN = 1; //撑开按钮按过标志
uint8_t FLAG_INA6_EN = 0; //缩回按钮按过标志
uint8_t crc16_data1[] = { 0x01,0x00,0x00,0x00,0x04,0x05,0x06,0x07,0x08,0x09,0xAA};
uint8_t crc16_data2[] = { 0x02,0x00,0x00,0x00,0x04,0x05,0x06,0x07,0x08,0x09,0xBB};
uint8_t crc16_data3[] = { 0x03,0x00,0x00,0x00,0x04,0x05,0x06,0x07,0x08,0x09,0xCC};
uint8_t crc16_data4[] = { 0xFE, 0x01,0x02,0x03,0x00,0x00,0x02,0x04,0x00,0x00,0x00,0x00 };
uint8_t table4[]={
0x01,0x02,0x02,0x02,0x02,0x02,
0x02,0x02,0x02,0x02,0x02,0x02,
0x02,0x02,0x03,0x02,0x02,0x02,
0x02,0x02,0x02,0x04,0x02,0x02,
0x02,0x02,0x02,0x02,0x05,0x02,
0x02,0x02,0x02,0x02,0x02,0x06,
0x02,0x02,0x02,0x02,0x05,0x02,
0x02,0x02,0x02,0x04,0x02,0x02,
0x02,0x02,0x03,0x02,0x02,0x02,
0x02,0x02,0x02,0x02,0x02,0x02,
0x01,0x02,0x02,0x02,0x02,0x02,
0x02,0x02,0x02,0x02,0x02,0x02,
0x02,0x02,0x03,0x02,0x02,0x02,
0x02,0x02,0x02,0x04,0x02,0x02,
0x02,0x02,0x02,0x02,0x05,0x02,
0x02,0x02,0x02,0x02,0x02,0x06};
uint8_t table5[]={0x02,0x02,0x02,0x02,0x02,0x02};
uint8_t table6[]={‘u‘,‘s‘,‘a‘,‘r‘,‘t‘,‘2‘};
uint16_t rec = 0;
uint16_t rec1 = 0;
void Crc_Data_Change(void);
static unsigned char music[10] = {0x00,0x01, 0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09 };
//语音循环发送 发送歌曲位置
static unsigned char music_speek()
{
uint8_t i;
for(i=0;i<8;i++)
{
SendData(0x0a);//数据头
SendData(music[i]);//第几首
SendData(0x0b);//数据尾u
delay_ms(6000);
}
delay_ms(3000);
}
//选择下一首
unsigned char music_down()
{
SendData(0x15);//数据尾u
}
int main(void)
{
delay_init();
JQ8900_Init();
LED_Init();
TESTLED=1;
delay_ms(3000);
//设置NVIC中断分组2:2位抢占优先级,2位响应优先级
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);
//配置串口1
USART1_Configuration(9600);
USART2_Configuration(9600);
USART3_Configuration(9600);
TIM3_Int_Init(2000,7199); //10Khz 的计数频率,计数到 1000 为 100ms
// IWDG_Init(4,625); //与分频数为64,重载值为625,溢出时间为1s
while(1)
{
/************语音模块的时序函数******************/
// uint8_t addr=0x15;
// uint8_t i;
// JQ8900_SDA = 1;/*开始拉高*/
// delay_us ( 1000 );
// JQ8900_SDA = 0;/*开始引导码*/
// delay_us ( 2200 );/*此处延时最少要大于2ms,此参数延时为310ms */
// for ( i = 0; i < 8; i++ ) /*总共8位数据 */
// {
// JQ8900_SDA = 1;
// if ( addr & 0x01 ) /*3:1表示数据位1,每个位用两个脉冲表示 */
// {
// delay_us ( 500 );
// JQ8900_SDA = 0;
// delay_us ( 210 );
// }
// else /*1:3表示数据位0 ,每个位用两个脉冲表示 */
// {
// delay_us ( 210 );
// JQ8900_SDA = 0;
// delay_us ( 500 );
// }
// addr >>= 1;
// }
// JQ8900_SDA = 1;
// SendData(0x15); SendData(0x15);
// music_speek();
//
// music_down();
// delay_ms(8000);
// SendData(0x15);
// TESTLED=!TESTLED;
/**************
串口部分程序
**********/
//USART1_SendOneData(4);
//USART1_SendUnfixedData(crc16_data3,11);
//delay_ms(3000);
//uint8_t count;
//for(count=0;count<100;count++)
//{
//USART1_SendUnfixedData(crc16_data3,11);
//delay_ms(100);
//}
//for(count=0;count<100;count++)
//{
//USART1_SendUnfixedData(crc16_data4,11);
//delay_ms(100);
//}
// USART1_SendUnfixedData(table4,4);
USART1_SendUnfixedData(crc16_data1,11);
delay_ms(500);
USART2_SendUnfixedData(crc16_data2,11);
delay_ms(500);
USART3_SendUnfixedData(crc16_data3,11);
//delay_ms(100);
//printf("串口123发送程序");
//USART1_SendUnfixedData(crc16_data1,11);
// TESTLED=!TESTLED;
// USART1_SendUnfixedDaata(crc16_data2,11);
//
// delay_ms(10);
// TESTLED=!TESTLED;
// USART2_SendUnfixedData(crc16_data1,11);
//
// delay_ms(10);
// USART3_SendUnfixedData(crc16_data2,11);
//
// delay_ms(10);
// TESTLED=!TESTLED;
// USART1_SendUnfixedData(table6,6);
/**************
语音模块发送指令
**********/
//int i,j;
//for(i=0;i<10;i++)
// for(j=0;j<10;j++)
// { SendData(0x0a);//数据头
// SendData(music[i]);//第几首
// SendData(music[j]);//第几首
// SendData(0x0b);//数据尾u
// delay_ms(5000);
// }
// SendData(0x0a);//数据头
// SendData(music[1]);//第几首
// SendData(music[0]);//第几首
// SendData(music[0]);//第几首
// SendData(0x0b);//数据尾u
// delay_ms(5000);
// SendData(0x0a);//数据头
// SendData(music[5]);//第5首
// SendData(music[5]);//第5首
// SendData(0x0b);//数据尾u
// delay_ms(5000);
//test();
//IWDG_ReloadCounter();//喂狗
}
}
原文http://www#51hei.com/bbs/forum.php?mod=viewthread&tid=166144
标签:default 软件时间 使用 串口 模块 efi i++ 控制 频率
原文地址:https://www.cnblogs.com/iCloudelectron/p/13201969.html