• 大小: 7.32MB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2023-08-21
  • 语言: 其他
  • 标签: STM32L0  HAL库  

资源简介

简介:STM32与上位机之间用通信协议(自己定义)进行串口通信。怎么判断上位机发过来的指令是正确的,而不是一串乱码?怎么从正确的指令中提取出想要的命令代号,从而实现想要的功能? 方法:读取上位机发来的命令,逐位判断命令的包头和包尾,如果能对应上,则这串指令是正确的,然后从指令中提取想要的数据和命令等。举个栗子:通信协议是自己定义的,不是modbus协议等。。如F0 5A 15 15 25 16 09 02 12 14 FF A5 F0(都是16进制),F0 5A是包头,A5 F0是包尾,黑色15是命令代号,中间蓝色是我想发的数据,橙色FF是校验位。只要包头包尾校验正确,基本这串指令不会有问题。

资源截图

代码片段和文件信息

/**
  ******************************************************************************
  * @file    system_stm32l0xx.c
  * @author  MCD Application Team
  * @version V1.7.1
  * @date    25-November-2016
  * @brief   CMSIS Cortex-M0+ Device Peripheral Access layer System Source File.
  *
  *   This file provides two functions and one global variable to be called from 
  *   user application:
  *      - SystemInit(): This function is called at startup just after reset and 
  *                      before branch to main program. This call is made inside
  *                      the “startup_stm32l0xx.s“ file.
  *
  *      - SystemCoreClock variable: Contains the core clock (HCLK) it can be used
  *                                  by the user application to setup the SysTick 
  *                                  timer or configure other parameters.
  *                                     
  *      - SystemCoreClockUpdate(): Updates the variable SystemCoreClock and must
  *                                 be called whenever the core clock is changed
  *                                 during program execution.
  *
  *
  ******************************************************************************
  * @attention
  *
  * 

© COPYRIGHT(c) 2016 STMicroelectronics


  *
  * Redistribution and use in source and binary forms with or without modification
  * are permitted provided that the following conditions are met:
  *   1. Redistributions of source code must retain the above copyright notice
  *      this list of conditions and the following disclaimer.
  *   2. Redistributions in binary form must reproduce the above copyright notice
  *      this list of conditions and the following disclaimer in the documentation
  *      and/or other materials provided with the distribution.
  *   3. Neither the name of STMicroelectronics nor the names of its contributors
  *      may be used to endorse or promote products derived from this software
  *      without specific prior written permission.
  *
  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS“
  * AND ANY EXPRESS OR IMPLIED WARRANTIES INCLUDING BUT NOT LIMITED TO THE
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  * FOR ANY DIRECT INDIRECT INCIDENTAL SPECIAL EXEMPLARY OR CONSEQUENTIAL
  * DAMAGES (INCLUDING BUT NOT LIMITED TO PROCUREMENT OF SUBSTITUTE GOODS OR
  * SERVICES; LOSS OF USE DATA OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  * CAUSED AND ON ANY THEORY OF LIABILITY WHETHER IN CONTRACT STRICT LIABILITY
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  * OF THIS SOFTWARE EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
  ******************************************************************************
  */

/** @addto

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

     文件       4640  2018-06-15 21:20  Receive_it\.mxproject

     文件     490933  2017-08-05 09:48  Receive_it\Drivers\CMSIS\Device\ST\STM32L0xx\Include\stm32l011xx.h

     文件     502148  2017-08-05 09:48  Receive_it\Drivers\CMSIS\Device\ST\STM32L0xx\Include\stm32l021xx.h

     文件     503392  2017-08-05 09:48  Receive_it\Drivers\CMSIS\Device\ST\STM32L0xx\Include\stm32l031xx.h

     文件     514607  2017-08-05 09:48  Receive_it\Drivers\CMSIS\Device\ST\STM32L0xx\Include\stm32l041xx.h

     文件     518739  2017-08-05 09:48  Receive_it\Drivers\CMSIS\Device\ST\STM32L0xx\Include\stm32l051xx.h

     文件     616127  2017-08-05 09:48  Receive_it\Drivers\CMSIS\Device\ST\STM32L0xx\Include\stm32l052xx.h

     文件     629289  2017-08-05 09:48  Receive_it\Drivers\CMSIS\Device\ST\STM32L0xx\Include\stm32l053xx.h

     文件     529954  2017-08-05 09:48  Receive_it\Drivers\CMSIS\Device\ST\STM32L0xx\Include\stm32l061xx.h

     文件     627342  2017-08-05 09:48  Receive_it\Drivers\CMSIS\Device\ST\STM32L0xx\Include\stm32l062xx.h

     文件     640504  2017-08-05 09:48  Receive_it\Drivers\CMSIS\Device\ST\STM32L0xx\Include\stm32l063xx.h

     文件     539799  2017-08-05 09:48  Receive_it\Drivers\CMSIS\Device\ST\STM32L0xx\Include\stm32l071xx.h

     文件     646331  2017-08-05 09:48  Receive_it\Drivers\CMSIS\Device\ST\STM32L0xx\Include\stm32l072xx.h

     文件     659701  2017-08-05 09:48  Receive_it\Drivers\CMSIS\Device\ST\STM32L0xx\Include\stm32l073xx.h

     文件     551014  2017-08-05 09:48  Receive_it\Drivers\CMSIS\Device\ST\STM32L0xx\Include\stm32l081xx.h

     文件     657546  2017-08-05 09:48  Receive_it\Drivers\CMSIS\Device\ST\STM32L0xx\Include\stm32l082xx.h

     文件     670916  2017-08-05 09:48  Receive_it\Drivers\CMSIS\Device\ST\STM32L0xx\Include\stm32l083xx.h

     文件       8393  2017-08-05 09:48  Receive_it\Drivers\CMSIS\Device\ST\STM32L0xx\Include\stm32l0xx.h

     文件       3922  2017-08-05 09:48  Receive_it\Drivers\CMSIS\Device\ST\STM32L0xx\Include\system_stm32l0xx.h

     文件      10891  2017-08-05 09:48  Receive_it\Drivers\CMSIS\Device\ST\STM32L0xx\Source\Templates\arm\startup_stm32l011xx.s

     文件      11166  2017-08-05 09:48  Receive_it\Drivers\CMSIS\Device\ST\STM32L0xx\Source\Templates\arm\startup_stm32l021xx.s

     文件      10431  2017-08-05 09:48  Receive_it\Drivers\CMSIS\Device\ST\STM32L0xx\Source\Templates\arm\startup_stm32l031xx.s

     文件      10681  2017-08-05 09:48  Receive_it\Drivers\CMSIS\Device\ST\STM32L0xx\Source\Templates\arm\startup_stm32l041xx.s

     文件      11017  2017-08-05 09:48  Receive_it\Drivers\CMSIS\Device\ST\STM32L0xx\Source\Templates\arm\startup_stm32l051xx.s

     文件      11204  2017-08-05 09:48  Receive_it\Drivers\CMSIS\Device\ST\STM32L0xx\Source\Templates\arm\startup_stm32l052xx.s

     文件      11278  2017-08-05 09:48  Receive_it\Drivers\CMSIS\Device\ST\STM32L0xx\Source\Templates\arm\startup_stm32l053xx.s

     文件      11029  2017-08-05 09:48  Receive_it\Drivers\CMSIS\Device\ST\STM32L0xx\Source\Templates\arm\startup_stm32l061xx.s

     文件      11215  2017-08-05 09:48  Receive_it\Drivers\CMSIS\Device\ST\STM32L0xx\Source\Templates\arm\startup_stm32l062xx.s

     文件      11273  2017-08-05 09:48  Receive_it\Drivers\CMSIS\Device\ST\STM32L0xx\Source\Templates\arm\startup_stm32l063xx.s

     文件      11325  2017-08-05 09:48  Receive_it\Drivers\CMSIS\Device\ST\STM32L0xx\Source\Templates\arm\startup_stm32l071xx.s

............此处省略626个文件信息

评论

共有 条评论