找回密码
 立即注册

QQ登录

只需一步,快速开始

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

TOF10120 stm32串口一直输r6# 求帮助

[复制链接]
ID:538333 发表于 2019-7-22 23:19 | 显示全部楼层 |阅读模式
/**
  ******************************************************************************
  * @file    main.c
  * @author  kevin_guo
  * @version V1.0.0
  * @date    12-15-2017
  * @brief   This file provides functions to main
  ******************************************************************************
  * @attention   
  ******************************************************************************
  */
  
/* Includes ------------------------------------------------------------------*/
#include "stm32f10x.h"   
#include <stm32f10x_conf.h>

#include "delay.h"
#include "usart.h"   

/* extern variables ----------------------------------------------------------*/
extern unsigned short int length_val;
extern unsigned char rxbuf[16],rxempty, rxcnt,rxflag,waitflag;
extern unsigned int timeout;
/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
/* Private macro -------------------------------------------------------------*/
/* Private function prototypes -----------------------------------------------*/
/* Private function ----------------------------------------------------------*/
//void BuzzerInit(voi
/
//  GPIO_InitTypeDef  GPIO_InitStructur
//
//  
//  
//  
//    RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE);
//    GPIO_PinRemapConfig(GPIO_Remap_SWJ_JTAGDisable,ENABLE
////    GPIO_PinRemapConfig(GPIO_Remap_SWJ_Disable,ENAB
//    GPIO_PinRemapConfig(GPIO_Remap_PD01,ENABLE
//    DBGMCU_Config(DBGMCU_CR_TRACE_IOEN,DISABLE
//
//  /* Enable the GPIO Clock */
//  RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE

//    /* Configure the GPIO pin */
//  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_
//  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_P
//  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MH
//  GPIO_Init(GPIOB, &GPIO_InitStructure);
//
//    GPIO_ResetBits(GPIOB, GPIO_Pin_4
////    GPIO_SetBits(GPIOB, GPIO_Pin
/
/*******************************************************************************
* Function Name  : main
* Description    : main program body
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
int main(void)
{            
    unsigned char i;
   
//    BuzzerInit(
    Delay_Init();                 
   
    Uart_Init(9600);            
        
    Send_Data_To_UART1('s');
    Send_Data_To_UART1('5');
    Send_Data_To_UART1('-');
    Send_Data_To_UART1('1');
    Send_Data_To_UART1('#');
    Delay_mS(10);
    waitflag=1;
    while(waitflag==1);
    waitflag=0;
    Delay_mS(1000);
    rxcnt=0;
    while(1)
    {
        
        Send_Data_To_UART1('r');
        Send_Data_To_UART1('6');
        Send_Data_To_UART1('#');
        timeout=10000;
        while((rxflag==0)&&(timeout--));
        
        if(rxflag)
        {
            for(i=0; i<rxcnt; i++)
            {
                if(rxbuf=='m')                {                    if(rxbuf[i+1]=='m')   
/************************END OF FILE*************************/

回复

使用道具 举报

ID:421308 发表于 2019-7-23 08:47 | 显示全部楼层
你下面的代码就是输出r6#啊
回复

使用道具 举报

ID:538333 发表于 2019-7-23 09:44 | 显示全部楼层
986212146 发表于 2019-7-23 08:47
你下面的代码就是输出r6#啊

如何改让他输出距离值
回复

使用道具 举报

ID:421308 发表于 2019-7-23 16:04 | 显示全部楼层
代码不完整啊
回复

使用道具 举报

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

本版积分规则

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

Powered by 单片机教程网

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