标题: 基于STM32F103两轮平衡小车设计(开源) [打印本页]

作者: 51hei大小    时间: 2016-6-17 14:25
标题: 基于STM32F103两轮平衡小车设计(开源)
给大家分享个两轮平衡小车设计,不多说了,直接上图



附件资料



  1. /**---------------------------------------------------------------
  2.         项目:两轮自平衡小车(Two-Wheels Auto-Balancing Vechile)
  3.         版本:v1.0.0
  4.         文件:AHRS_Rcv.c
  5.         功能:AHRS姿态数据接收
  6.         作者:[email]flotox@yeah.net[/email]
  7.         日期:2014.9.7
  8.         更新:2014.9.7
  9. ----------------------------------------------------------------*/

  10. #include "stm32f10x.h"
  11. #include "AHRS_Rcv.h"

  12. /**
  13.         *        @brief                AHRS姿态数据接收外设初始化
  14.         *        @param                none
  15.         *        @retval                none
  16.         */
  17. void        AHRS_Rcv_Init(void){
  18.         
  19.         GPIO_InitTypeDef        GPIO_InitStructure;
  20.         USART_InitTypeDef        USART_InitStructure;
  21.         NVIC_InitTypeDef        NVIC_InitStructure;
  22.         
  23.         /*开启GPIOC外设时钟*/
  24.         RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);
  25.         
  26.         /*开启USART2外设时钟*/
  27.         RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2, ENABLE);
  28.         
  29.         /*USART2的GPIO配置*/
  30.         /*配置USART2 Tx(PA.02)为AF_PP模式*/
  31.         GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2;
  32.         GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
  33.         GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  34.         GPIO_Init(GPIOA, &GPIO_InitStructure);
  35.         
  36.         /*配置USART2 Rx(PA.03)为IN_FLOATING*/
  37.         GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3;
  38.         GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
  39.         GPIO_Init(GPIOA, &GPIO_InitStructure);
  40.         
  41.         /*USART2 NVIC配置*/
  42.         NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);                                                                                                        //2 bits for pre-emption priority 2 bits for subpriority
  43.         
  44.         NVIC_InitStructure.NVIC_IRQChannel = USART2_IRQn;
  45.         NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;                                                                //指定抢占式优先级别,可取0~3
  46.         NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;                                                                                        //指定响应式优先级别,可取0~3
  47.         NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
  48.         NVIC_Init(&NVIC_InitStructure);
  49.         
  50.         /*USART2模式配置*/
  51.         USART_InitStructure.USART_BaudRate = 115200;
  52.         USART_InitStructure.USART_WordLength = USART_WordLength_8b;
  53.         USART_InitStructure.USART_StopBits = USART_StopBits_1;
  54.         USART_InitStructure.USART_Parity = USART_Parity_No;
  55.         USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
  56.         USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;
  57.         USART_Init(USART2, &USART_InitStructure);
  58.         
  59.         USART_Cmd(USART2, ENABLE);
  60.         
  61.         /*接收中断使能*/
  62.         USART_ITConfig(USART2, USART_IT_RXNE, ENABLE);
  63. }
复制代码

二轮自平衡小车.rar (15.64 MB, 下载次数: 77)


作者: tjlt    时间: 2016-7-28 19:18
回复送黑比吗
作者: 很吊的    时间: 2017-6-27 10:44
路过,板子太大了
作者: wxd_cs    时间: 2017-7-7 21:40
谢谢楼主
作者: yewang87    时间: 2017-7-10 22:26
谢谢楼主分享!
作者: ylzhuai    时间: 2017-7-29 08:51
好想要,就是没有HB




欢迎光临 (http://www.51hei.com/bbs/) Powered by Discuz! X3.1