標(biāo)題: 基于STM32F103兩輪平衡小車設(shè)計(jì)(開源) [打印本頁(yè)]

作者: 51hei大小    時(shí)間: 2016-6-17 14:25
標(biāo)題: 基于STM32F103兩輪平衡小車設(shè)計(jì)(開源)
給大家分享個(gè)兩輪平衡小車設(shè)計(jì),不多說(shuō)了,直接上圖



附件資料



  1. /**---------------------------------------------------------------
  2.         項(xiàng)目:兩輪自平衡小車(Two-Wheels Auto-Balancing Vechile)
  3.         版本:v1.0.0
  4.         文件:AHRS_Rcv.c
  5.         功能:AHRS姿態(tài)數(shù)據(jù)接收
  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姿態(tài)數(shù)據(jù)接收外設(shè)初始化
  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外設(shè)時(shí)鐘*/
  24.         RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);
  25.         
  26.         /*開啟USART2外設(shè)時(shí)鐘*/
  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;                                                                //指定搶占式優(yōu)先級(jí)別,可取0~3
  46.         NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;                                                                                        //指定響應(yīng)式優(yōu)先級(jí)別,可取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. }
復(fù)制代碼

二輪自平衡小車.rar (15.64 MB, 下載次數(shù): 77)


作者: tjlt    時(shí)間: 2016-7-28 19:18
回復(fù)送黑比嗎
作者: 很吊的    時(shí)間: 2017-6-27 10:44
路過(guò),板子太大了
作者: wxd_cs    時(shí)間: 2017-7-7 21:40
謝謝樓主
作者: yewang87    時(shí)間: 2017-7-10 22:26
謝謝樓主分享!
作者: ylzhuai    時(shí)間: 2017-7-29 08:51
好想要,就是沒(méi)有HB




歡迎光臨 (http://www.torrancerestoration.com/bbs/) Powered by Discuz! X3.1