{"id":178597,"date":"2013-05-02T13:13:03","date_gmt":"2013-05-02T09:13:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=178597"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=178597","title":{"rendered":"<span class=\"post_title\">\u0421\u0443\u0434\u043d\u043e \u043d\u0430 \u0432\u043e\u0437\u0434\u0443\u0448\u043d\u043e\u0439 \u043f\u043e\u0434\u0443\u0448\u043a\u0435 \u00ab\u041b\u0443\u043d\u044c\u00bb \u0447\u0430\u0441\u0442\u044c 2<\/span>"},"content":{"rendered":"<div class=\"content html_format\">   \t\u0414\u043e\u0431\u0440\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0441\u0443\u0442\u043e\u043a!<\/p>\n<p>  \u041a\u0430\u043a \u0438 \u043e\u0431\u0435\u0449\u0430\u043b \u044f \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0443 \u0441\u0432\u043e\u0439 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0439 <a href=\"http:\/\/habrahabr.ru\/post\/175017\/\">\u043f\u043e\u0441\u0442<\/a> \u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u044b\u043c \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435\u043c \u044d\u043b\u0435\u043a\u0442\u0440\u043e\u043d\u043d\u043e\u0439 \u043d\u0430\u0447\u0438\u043d\u043a\u0438 \u0438 \u041f\u041e.<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/35e\/3a6\/76d\/35e3a676dc63f78243127b368cbfed05.jpg\"\/><\/p>\n<p>  <a name=\"habracut\"><\/a><\/p>\n<h1>\u041b\u0443\u043d\u044c 1.0<\/h1>\n<p>  \u041f\u0435\u0440\u0432\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 \u0431\u044b\u043b \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0441\u0442: stm32vl-discovery, \u043f\u0443\u043b\u044c\u0442 \u043e\u0442 \u0434\u0440\u0435\u0432\u043d\u0435\u0439 \u0440\u0430\u0434\u0438\u043e\u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c\u043e\u0439 \u043c\u0430\u0448\u0438\u043d\u043a\u0438 \u0438 2 \u0438\u043d\u0432\u0435\u0440\u0442\u043e\u0440\u0430 \u0434\u043b\u044f \u0434\u0432\u0438\u0433\u0430\u0442\u0435\u043b\u0435\u0439. \u0415\u0441\u043b\u0438 \u0441\u0445\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0442\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u043b\u043e \u044d\u0442\u043e \u043a\u0430\u043a-\u0442\u043e \u0442\u0430\u043a:<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/828\/37d\/b7c\/82837db7c32113d6dfa833236df85c3e.jpg\"\/><\/p>\n<p>  \u0412 \u043f\u0440\u043e\u0448\u0438\u0432\u043a\u0435 \u043a\u0430\u043a \u0438 \u0432 \u043a\u043e\u043c\u043f\u043e\u043d\u043e\u0432\u043a\u0435 \u0442\u043e\u0436\u0435 \u043d\u0438\u0447\u0435\u0433\u043e \u0441\u043b\u043e\u0436\u043d\u043e\u0433\u043e \u043d\u0435 \u0431\u044b\u043b\u043e. \u0423\u043f\u0440\u0430\u0432\u043b\u044f\u043b\u043e\u0441\u044c \u0432\u0441\u0451 stm32vl-discovery, \u0430 \u043a\u043e\u0434 \u0431\u044b\u043b \u043d\u0430\u043f\u0438\u0441\u0430\u043d \u0437\u0430 \u043f\u0430\u0440\u0443 \u0447\u0430\u0441\u043e\u0432 \u0432 CoIDE. \u041e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u0432\u044b\u0440\u0430\u0437\u0438\u0442\u044c \u043d\u0438\u0437\u043a\u0438\u0439 \u043f\u043e\u043a\u043b\u043e\u043d \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430\u043c \u044d\u0442\u043e\u0439 \u0441\u0440\u0435\u0434\u044b \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u0435\u0441\u043b\u0438 \u0431 \u043d\u0435 \u0435\u0435 \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u043e \u0442\u043e, \u043a\u0442\u043e \u0437\u043d\u0430\u0435\u0442, \u043c\u043e\u0436\u0435\u0442 \u044f \u0442\u0430\u043a \u0438 \u043d\u0435 \u043f\u0435\u0440\u0435\u043b\u0435\u0437 \u0431\u044b \u0441 AVR.<\/p>\n<p>  \u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0431\u044b\u043b\u0430 \u043f\u0440\u043e\u0441\u0442\u0430\u044f \u043d\u043e \u0430\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u043e \u043d\u0435\u0443\u0434\u043e\u0431\u043d\u0430\u044f. \u0412 \u0421\u0412\u041f \u043d\u0443\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0442\u0440\u0435\u043c\u044f \u0434\u0432\u0438\u0433\u0430\u0442\u0435\u043b\u044f\u043c\u0438, \u0430 \u043f\u0443\u043b\u044c\u0442 \u0434\u0430\u0432\u0430\u043b \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u0432\u0443\u043c\u044f. \u041f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u043a\u0430\u043a-\u0442\u043e \u0432\u044b\u043a\u0440\u0443\u0447\u0438\u0432\u0430\u0442\u044c\u0441\u044f, \u043a\u043d\u043e\u043f\u043a\u0430 \u201c\u0432\u043f\u0435\u0440\u0435\u0434\u201d \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u043b\u0430 \u0442\u044f\u0433\u043e\u0432\u044b\u043c \u0432\u0438\u043d\u0442\u043e\u043c, \u043a\u043d\u043e\u043f\u043a\u0430 \u201c\u043d\u0430\u0437\u0430\u0434\u201d \u043e\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u043b\u0430 \u0441\u0443\u0434\u043d\u043e, \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u043b\u043e\u0441\u044c \u0436\u0435 \u0441\u0443\u0434\u043d\u043e \u043d\u0430\u0436\u0430\u0442\u0438\u0435\u043c \u043a\u043d\u043e\u043f\u043a\u0438 \u043d\u0430 \u0441\u0430\u043c\u043e\u0439 \u043e\u0442\u043b\u0430\u0434\u043e\u0447\u043d\u043e\u0439 \u043f\u043b\u0430\u0442\u0435.<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041f\u0435\u0440\u0432\u043e\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u0430\u044f \u043f\u0440\u043e\u0448\u0438\u0432\u043a\u0430<\/b><\/p>\n<div class=\"spoiler_text\">#include &lt;stm32f10x.h&gt;<br \/>  #include &lt;stm32f10x_gpio.h&gt;<br \/>  #include &lt;stm32f10x_rcc.h&gt;<br \/>  #include &lt;stm32f10x_tim.h&gt;<br \/>  #include &lt;misc.h&gt;<\/p>\n<p>  void init_leds();<br \/>  void init_motors();<br \/>  void init_timer();<br \/>  void init_button();<br \/>  void Delay_sig();<\/p>\n<p>  int sec=0;<br \/>  int sm1=1000;<br \/>  int m1=750;<br \/>  int m2=750;<br \/>  int i,l;<\/p>\n<p>  uint8_t r1=0,r2=0,r3=0,r4=0;<\/p>\n<p>  #define first_motor GPIO_Pin_10<br \/>  #define second_motor GPIO_Pin_12<br \/>  #define servo_motor GPIO_Pin_11<br \/>  #define blue_led GPIO_Pin_8<br \/>  #define green_led GPIO_Pin_9<\/p>\n<p>  #define radio4 GPIO_Pin_8<br \/>  #define radio3 GPIO_Pin_9<br \/>  #define radio2 GPIO_Pin_10<br \/>  #define radio1 GPIO_Pin_11<\/p>\n<p>  #define BUTTON GPIO_Pin_0 <\/p>\n<p>  int main()<\/p>\n<p>  {<br \/>  init_leds();<br \/>  init_button();<br \/>  init_motors();<br \/>  init_timer();<\/p>\n<p>  SysTick_Config(SystemCoreClock \/300);<\/p>\n<p>  do<br \/>   {<\/p>\n<p>  r1 = GPIO_ReadInputDataBit(GPIOA,radio1);<br \/>   r2 = GPIO_ReadInputDataBit(GPIOA,radio2);<br \/>   r3 = GPIO_ReadInputDataBit(GPIOA,radio3);<br \/>   r4 = GPIO_ReadInputDataBit(GPIOA,radio4);<\/p>\n<p>  }while (1);<br \/>  }<\/p>\n<p>  void SysTick_Handler()<br \/>  {<br \/>  static uint8_t btn_old_state = 0;<br \/>  uint8_t btn_state = GPIO_ReadInputDataBit(GPIOA, BUTTON);<\/p>\n<p>  if (btn_old_state == 0 &#038;&#038; btn_state == 1)<br \/>  {<br \/>  if(m1&lt;1000)m1=m1+50;<br \/>  }<\/p>\n<p>  if(r1==1)<br \/>  {<br \/>   if(sm1&lt;1600) sm1=sm1+10;<br \/>  }<\/p>\n<p>  else<br \/>  {<br \/>   if(sm1&gt;1000) sm1=sm1-10;<br \/>  }<\/p>\n<p>  if(r3==1)<br \/>  {<br \/>   m2=900;<br \/>  }<\/p>\n<p>  else<br \/>  {<br \/>   m2=750;<br \/>  }<\/p>\n<p>  if(r2==1)<br \/>   {<br \/>   if(sm1&gt;400) sm1=sm1-10;<br \/>   }<\/p>\n<p>  else<br \/>  {<br \/>   if(sm1&lt;1000) sm1=sm1+10;<br \/>  }<\/p>\n<p>  if(r4==1)<br \/>  {<br \/>   m1=750;<br \/>  }<\/p>\n<p>  btn_old_state = btn_state;<br \/>  }<\/p>\n<p>  void init_leds()<br \/>  {<br \/>  RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE);<br \/>  GPIO_InitTypeDef gpio;<br \/>  GPIO_StructInit(&#038;gpio);<br \/>  gpio.GPIO_Mode = GPIO_Mode_Out_PP;<br \/>  gpio.GPIO_Pin = blue_led|green_led;<br \/>  GPIO_Init(GPIOC, &#038;gpio);<br \/>  GPIO_ResetBits(GPIOC, blue_led);<br \/>  GPIO_ResetBits(GPIOC, green_led);<br \/>  }<\/p>\n<p>  void init_motors()<br \/>  {<br \/>  RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE);<br \/>  GPIO_InitTypeDef gpio;<br \/>  GPIO_StructInit(&#038;gpio);<br \/>  gpio.GPIO_Mode = GPIO_Mode_Out_PP;<br \/>  gpio.GPIO_Pin = first_motor|second_motor|servo_motor;<br \/>  GPIO_Init(GPIOC, &#038;gpio);<br \/>  GPIO_ResetBits(GPIOC, first_motor);<br \/>  GPIO_ResetBits(GPIOC, second_motor);<br \/>  GPIO_ResetBits(GPIOC, servo_motor);<br \/>  }<\/p>\n<p>  void init_button()<br \/>  {<br \/>  RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);<br \/>  GPIO_InitTypeDef gpio;<br \/>  GPIO_StructInit(&#038;gpio);<br \/>  gpio.GPIO_Mode = GPIO_Mode_IPD;<br \/>  gpio.GPIO_Pin = BUTTON|radio1|radio2|radio3|radio4|BT_en;<br \/>  gpio.GPIO_Speed = GPIO_Speed_2MHz;<br \/>  GPIO_Init(GPIOA, &#038;gpio);<br \/>  }<\/p>\n<p>  void init_timer()<br \/>  {<br \/>  RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM6, ENABLE);<br \/>  TIM_TimeBaseInitTypeDef base_timer;<br \/>  TIM_TimeBaseStructInit(&#038;base_timer);<br \/>  base_timer.TIM_Prescaler = 12000 \u2014 1;<br \/>  base_timer.TIM_Period = 20;<br \/>  TIM_TimeBaseInit(TIM6, &#038;base_timer);<br \/>  TIM_ITConfig(TIM6, TIM_IT_Update, ENABLE);<\/p>\n<p>  TIM_Cmd(TIM6, ENABLE);<br \/>  NVIC_EnableIRQ(TIM6_DAC_IRQn);<br \/>  }<\/p>\n<p>  void Delay_sig()<br \/>  {<br \/>  int us=0;<br \/>  for(us=0; us&lt;5000; us++)<br \/>  {<br \/>  if(us==sm1){GPIO_ResetBits(GPIOC, servo_motor);}<br \/>  if(us==m1) {GPIO_ResetBits(GPIOC, first_motor);}<br \/>  if(us==m2){GPIO_ResetBits(GPIOC, second_motor);}<br \/>  }<br \/>  }<\/p>\n<p>  void TIM6_DAC_IRQHandler()<br \/>  {<br \/>  if (TIM_GetITStatus(TIM6, TIM_IT_Update) != RESET)<br \/>  {<br \/>  TIM_ClearITPendingBit(TIM6, TIM_IT_Update);<br \/>  GPIO_SetBits(GPIOC, first_motor);<br \/>  GPIO_SetBits(GPIOC, second_motor);<br \/>  GPIO_SetBits(GPIOC, servo_motor);<br \/>  Delay_sig();<br \/>  }<br \/>  }  <\/div>\n<\/div>\n<h1>\u041b\u0443\u043d\u044c 2.0<\/h1>\n<p>  \u041d\u0430\u0441\u0442\u0430\u0432\u0438\u0432 \u0433\u043e\u0440\u0443 \u043a\u043e\u0441\u0442\u044b\u043b\u0435\u0439 \u043a\u0430\u043a \u0432 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0435 \u0442\u0430\u043a \u0438 \u0432 \u043c\u0435\u0445\u0430\u043d\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u043d\u0430\u0448\u0435\u0433\u043e \u0440\u043e\u0431\u043e\u0442\u0430 \u043c\u044b \u0440\u0435\u0448\u0438\u043b\u0438, \u0447\u0442\u043e \u043d\u0430\u0434\u043e \u043e\u0441\u043d\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0432\u0441\u0451 \u043f\u0435\u0440\u0435\u0434\u0435\u043b\u044b\u0432\u0430\u0442\u044c. <br \/>  \u041f\u0435\u0440\u0432\u044b\u043c \u0434\u0435\u043b\u043e\u043c \u0440\u0435\u0448\u0438\u043b\u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0438 \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u044b \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0431\u044b\u043b \u043a\u0443\u043f\u043b\u0435\u043d \u0434\u0430\u0442\u0447\u0438\u043a MPU-6050 \u0438 \u043c\u043e\u0434\u0443\u043b\u044c bluetooth HC-04. <br \/>  C \u0431\u043b\u044e\u0442\u0443\u0437\u043e\u043c \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u043d\u0435 \u0432\u043e\u0437\u043d\u0438\u043a\u043b\u043e, \u0430 \u0432\u043e\u0442 \u0430\u043a\u0441\u0435\u043b\u0435\u0440\u043e\u043c\u0435\u0442\u0440 \u043f\u043e\u0447\u0435\u043c\u0443-\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u043b \u043d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e. \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0447\u0435\u0440\u0435\u0437 10 \u0441\u0435\u043a\u0443\u043d\u0434 \u0440\u0430\u0431\u043e\u0442\u044b \u043e\u043d \u043e\u0442\u043a\u043b\u044e\u0447\u0430\u043b\u0441\u044f, \u0430 \u043f\u043e\u0442\u043e\u043c \u0438 \u0432\u043e\u0432\u0441\u0435 \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u043b \u043e\u0442\u0432\u0435\u0447\u0430\u0442\u044c. <br \/>  \u041e\u0431\u0434\u0443\u043c\u0430\u0432 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0435 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u044b \u0431\u044b\u043b\u043e \u0440\u0435\u0448\u0435\u043d\u043e \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u043e\u0442\u043b\u0430\u0434\u043e\u0447\u043d\u0443\u044e \u043f\u043b\u0430\u0442\u0443, \u0430 \u0441 \u043d\u0435\u0439 \u0438 \u0432\u0441\u044e \u0441\u0445\u0435\u043c\u0443 \u043a\u043e\u043c\u043f\u043e\u043d\u043e\u0432\u043a\u0438.<\/p>\n<p>  \u041f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c \u0432\u043e\u0442 \u0447\u0442\u043e:<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/045\/628\/747\/045628747f39c65f02e74ecfa225d2ea.jpg\"\/><\/p>\n<p>  \u0413\u043b\u0430\u0432\u043d\u044b\u043c \u043e\u0433\u043e\u0440\u0447\u0435\u043d\u0438\u0435\u043c \u0431\u044b\u043b\u043e \u0443\u0437\u043d\u0430\u0442\u044c, \u0447\u0442\u043e CoIDE \u043d\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043c\u0438\u043a\u0440\u043e\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u043e\u0432 STM32F303. \u041d\u0435 \u0434\u043e\u043b\u0433\u043e \u0434\u0443\u043c\u0430\u044f \u0431\u044b\u043b\u0430 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0430 \u043a\u043e\u043c\u043c\u0435\u0440\u0447\u0435\u0441\u043a\u0430\u044f \u0441\u0431\u043e\u0440\u043a\u0430 \u0432\u0441\u0435 \u0442\u043e\u0433\u043e \u0436\u0435 eclipse \u2014 Atollic TrueSTUDIO. Lite \u0432\u0435\u0440\u0441\u0438\u044f \u0431\u044b\u043b\u0430 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0430 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c \u043e\u0442\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0439 \u043f\u0440\u043e\u0448\u0438\u0432\u043a\u0438 (\u043d\u0435 \u0431\u043e\u043b\u0435\u0435 32\u041a\u0411) \u043d\u0430\u0441 \u044d\u0442\u043e \u0443\u0441\u0442\u0440\u043e\u0438\u043b\u043e \u0438 \u043f\u0440\u043e\u0435\u043a\u0442 \u043f\u0435\u0440\u0435\u0435\u0445\u0430\u043b \u0432 \u0434\u0440\u0443\u0433\u0443\u044e \u0441\u0440\u0435\u0434\u0443. <br \/>  \u041d\u0430 \u0441\u0430\u0439\u0442\u0435 ST \u043c\u043e\u0436\u043d\u043e \u0441\u043a\u0430\u0447\u0430\u0442\u044c \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0438 \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432 \u0434\u043b\u044f \u044d\u0442\u043e\u0439 IDE, \u0447\u0442\u043e \u0442\u043e\u0436\u0435 \u043d\u0435 \u043c\u0430\u043b\u043e \u043d\u0430\u0441 \u043e\u0431\u0440\u0430\u0434\u043e\u0432\u0430\u043b\u043e. \u041f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u043f\u043e\u044f\u0432\u0438\u043b\u0438\u0441\u044c \u043a\u043e\u0433\u0434\u0430 \u043d\u0430\u0447\u0430\u043b\u0438 \u0443\u0433\u043b\u0443\u0431\u043b\u0435\u043d\u043d\u043e \u0438\u0437\u0443\u0447\u0430\u0442\u044c \u043a\u043e\u0434. \u0414\u0435\u043b\u043e \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u0434 \u0438\u0437 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u043f\u0440\u043e\u0448\u0438\u0432\u043a\u0438 \u043d\u0435\u043b\u044c\u0437\u044f, \u0432 STM32f3 \u0432 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0438 STM32f100 \u043f\u043e\u043c\u0435\u043d\u044f\u043b\u0438\u0441\u044c \u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043c\u043d\u043e\u0433\u0438\u0445 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u043e\u0432. \u0414\u0430 \u0438 \u043d\u0430 \u0442\u043e\u0442 \u043c\u043e\u043c\u0435\u043d\u0442 \u043c\u044b \u043d\u0430\u0448\u043b\u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u043e\u0442 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044f, \u0431\u044b\u043b\u043e \u0442\u0430\u043a\u043e\u0435 \u0447\u0443\u0432\u0441\u0442\u0432\u043e, \u0447\u0442\u043e \u043d\u0438\u043a\u0442\u043e \u0432\u043e\u043e\u0431\u0449\u0435 \u043d\u0435 \u0437\u0430\u043d\u0438\u043c\u0430\u043b\u0441\u044f \u044d\u0442\u043e\u0439 \u043e\u0442\u043b\u0430\u0434\u043e\u0447\u043d\u043e\u0439 \u043f\u043b\u0430\u0442\u043e\u0439 \u0445\u043e\u0442\u044f \u043e\u043d\u0430 \u0431\u044b\u043b\u0430 \u0443\u0436\u0435 \u0433\u043e\u0434 \u043a\u0430\u043a \u0432 \u043f\u0440\u043e\u0434\u0430\u0436\u0435. \u041f\u0440\u043e\u0431\u043b\u0435\u043c \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u043e\u0441\u044c \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u0440\u0435\u0448\u0438\u043b\u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0434\u0430\u0442\u0447\u0438\u043a \u0432\u043b\u0430\u0436\u043d\u043e\u0441\u0442\u0438. \u041a\u043e\u0434 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0434\u0430\u0442\u0447\u0438\u043a\u043e\u043c \u044f \u0447\u0435\u0441\u0442\u043d\u043e \u043f\u043e\u0437\u0430\u0438\u043c\u0441\u0442\u0432\u043e\u0432\u0430\u043b \u0438\u0437 \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/160017\/\">\u201dSTM32 + DHT11\u201d<\/a>, \u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u0430\u044f \u0434\u043e \u044d\u0442\u043e\u0433\u043e \u043c\u043e\u043c\u0435\u043d\u0442\u0430 \u043f\u0440\u043e\u0448\u0438\u0432\u043a\u0430 \u043d\u0430\u043f\u0440\u043e\u0447\u044c \u043e\u0442\u043a\u0430\u0437\u044b\u0432\u0430\u043b\u0430\u0441\u044c \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u043d\u043e\u0432\u044b\u043c \u043a\u043e\u0434\u043e\u043c, \u043e\u043d \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u043b\u0441\u044f. \u041d\u0438\u043a\u0430\u043a\u0438\u0445 \u043e\u0448\u0438\u0431\u043e\u043a \u0438\u043b\u0438 \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0439 \u043f\u0440\u0438 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 \u043d\u0435 \u0431\u044b\u043b\u043e \u043d\u043e \u043a\u043e\u0434 \u0443\u043f\u043e\u0440\u043d\u043e \u043d\u0435 \u0445\u043e\u0442\u0435\u043b \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c\u0441\u044f \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e, \u0443\u0431\u0438\u0432 \u0434\u0432\u0430 \u0434\u043d\u044f \u0438 \u043e\u0447\u0435\u043d\u044c \u043c\u043d\u043e\u0433\u043e \u043d\u0435\u0440\u0432\u043d\u044b\u0445 \u043a\u043b\u0435\u0442\u043e\u043a \u0432\u044b\u044f\u0441\u043d\u0438\u043b\u043e\u0441\u044c, \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u043e\u0442\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044e \u0432 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430\u0445 \u0442\u043e \u0432\u0441\u0435 \u0437\u0430\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442. \u041d\u043e \u0442\u0443\u0442 \u0432\u043e\u0437\u043d\u0438\u043a\u043b\u0430 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u044f \u0441\u043e\u0432\u0441\u0435\u043c \u043d\u0435 \u043e\u0436\u0438\u0434\u0430\u043b, \u043f\u043e\u0441\u043b\u0435 \u043e\u0442\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u0440\u0430\u0437\u043c\u0435\u0440 \u043f\u0440\u043e\u0448\u0438\u0432\u043a\u0438 \u0441\u0442\u0430\u043b \u043f\u0440\u0435\u0432\u044b\u0448\u0430\u0442\u044c 32\u041a\u0411, \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u0438\u0441\u043a\u0430\u0442\u044c \u043d\u043e\u0432\u0443\u044e \u0441\u0440\u0435\u0434\u0443 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438. \u041f\u043e\u0441\u043b\u0435 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043f\u043e\u0438\u0441\u043a\u043e\u0432 \u043d\u0430\u0442\u043a\u043d\u0443\u043b\u0441\u044f \u043d\u0430 <a href=\"http:\/\/robocraft.ru\/blog\/ARM\/653.html\">\u0441\u0442\u0430\u0442\u044c\u044e<\/a> \u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0435 IDE \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 Eclipse. \u041e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u0440\u043e\u0435\u043a\u0442 \u0438 \u043e\u043f\u044f\u0442\u044c \u043f\u0435\u0440\u0435\u0435\u0437\u0436\u0430\u0442\u044c. <br \/>  \u041e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u0441 \u043f\u043e\u043a\u0443\u043f\u043a\u043e\u0439 \u0431\u043b\u044e\u0442\u0443\u0437 \u043c\u043e\u0434\u0443\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430\u0441\u044c \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u0430\u043d\u0434\u0440\u043e\u0438\u0434. \u0414\u043e \u044d\u0442\u043e\u0433\u043e \u044f \u043d\u0438 \u0440\u0430\u0437\u0443 \u043d\u0435 \u043f\u0438\u0441\u0430\u043b \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u043c\u043e\u0431\u0438\u043b\u044c\u043d\u044b\u0445 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432 \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0430\u0447\u0430\u0442\u044c \u0431\u044b\u043b\u043e \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0442\u0430\u043a\u0438 \u0441\u043b\u043e\u0436\u043d\u043e. \u041e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u043c\u0435\u043d\u044f \u0432\u044b\u0432\u043e\u0434\u0438\u043b\u043e \u0438\u0437 \u0441\u0435\u0431\u044f \u043d\u0435\u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043a\u0430\u043a \u043f\u0435\u0440\u0435\u0434\u0432\u0438\u043d\u0443\u0442\u0430\u044f \u0432 \u0433\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u043e\u043c \u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440\u0435 \u043a\u043d\u043e\u043f\u043a\u0430 \u0432\u044b\u0437\u044b\u0432\u0430\u043b\u0430 \u043e\u0448\u0438\u0431\u043a\u0443 \u0438 \u0437\u0430\u043a\u0440\u044b\u0442\u0438\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.<br \/>  \u041a\u0440\u043e\u043c\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043d\u044b\u0445 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 \u043c\u043d\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0431\u044b\u043b\u043e \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u043e \u043d\u0430 \u043f\u0435\u0440\u0435\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u043a\u043e\u043c\u043f\u043e\u043d\u043e\u0432\u043a\u0438. <\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/ff7\/5f1\/6f1\/ff75f16f1eb4f612d7f0407856ead101.jpg\"\/><\/p>\n<p>  \u0424\u044e\u0437\u0435\u043b\u044f\u0436, \u044e\u0431\u043a\u0443 \u0438 \u043c\u0430\u0447\u0442\u0443 \u0441 \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u044f\u044e\u0449\u0438\u043c \u0434\u0432\u0438\u0433\u0430\u0442\u0435\u043b\u0435\u043c \u043e\u0441\u0442\u0430\u0432\u0438\u043b\u0438 \u0438\u0437 \u043f\u0435\u0440\u0432\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438. \u0414\u0432\u0438\u0433\u0430\u0442\u0435\u043b\u044c \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043b\u0438 \u0432 \u0432\u0435\u0440\u0442\u0438\u043a\u0430\u043b\u044c\u043d\u043e\u0435 \u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u0430 \u044d\u043b\u0435\u043a\u0442\u0440\u043e\u043d\u0438\u043a\u0443 \u0441\u043c\u0435\u0441\u0442\u0438\u043b\u0438 \u0432 \u043e\u0434\u043d\u043e \u043c\u0435\u0441\u0442\u043e. \u0422\u0430\u043a\u0436\u0435 \u0434\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043f\u0435\u0440\u0435\u0444\u0435\u0440\u0438\u0438 \u0440\u0430\u0437\u0432\u0435\u043b\u0438 \u043a\u043e\u043c\u043c\u0443\u0442\u0430\u0446\u0438\u043e\u043d\u043d\u0443\u044e \u043f\u043b\u0430\u0442\u0443:<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/b55\/662\/1d5\/b556621d54bd48c2d04d9948acc3818d.jpg\"\/><\/p>\n<p>  \u041f\u0440\u0438\u0432\u043e\u0434\u0438\u0442\u044c \u0432\u0435\u0441\u044c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043d\u044b\u0439 \u043a\u043e\u0434 \u0432 \u0441\u0442\u0430\u0442\u044c\u0435 \u043d\u0435 \u0432\u0438\u0436\u0443 \u0441\u043c\u044b\u0441\u043b\u0430 \u0442\u0430\u043a \u0438 \u0434\u0443\u043c\u0430\u044e \u0431\u0443\u0434\u0435\u0442 \u043b\u0443\u0447\u0448\u0435 \u0435\u0441\u043b\u0438 \u044f \u0443\u0434\u0435\u043b\u044e \u0431\u043e\u043b\u044c\u0448\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u044f \u043c\u043e\u043c\u0435\u043d\u0442\u0430\u043c \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u044b\u0437\u0432\u0430\u043b\u0438 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b.<\/p>\n<p>  \u041a\u0430\u043a\u0438\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u0441\u0442\u0430\u0432\u0438\u043b\u0438\u0441\u044c \u043f\u0435\u0440\u0435\u0434 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043e\u0439:<\/p>\n<p>  0. \u0423\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0441\u0435\u0440\u0432\u043e\u043f\u0440\u0438\u0432\u043e\u0434\u0430\u043c\u0438 \u0438 \u0438\u043d\u0432\u0435\u0440\u0442\u043e\u0440\u0430\u043c\u0438;<br \/>  1. \u0421\u0447\u0438\u0442\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0439 \u0432 \u043e\u0442\u043b\u0430\u0434\u043e\u0447\u043d\u0443\u044e \u043f\u043b\u0430\u0442\u0443 \u0434\u0430\u0442\u0447\u0438\u043a\u043e\u0432;<br \/>  2. \u0421\u043e\u0433\u043b\u0430\u0441\u043d\u043e \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u0438\u044f\u043c \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u0443\u0440\u0441;<br \/>  3. \u041f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c \u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u043d\u0430 \u0442\u0435\u043b\u0435\u0444\u043e\u043d;<br \/>  4. \u041e\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u0438\u043b\u0438 \u043e\u0431\u044a\u0435\u0437\u0436\u0430\u0442\u044c \u043f\u0440\u0435\u043f\u044f\u0442\u0441\u0442\u0432\u0438\u044f \u043d\u0430 \u043f\u0443\u0442\u0438;<br \/>  5. \u0418\u0441\u043a\u0430\u0442\u044c \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0438\u0439 \u043c\u0430\u0440\u0448\u0440\u0443\u0442 \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u044f;<br \/>  6. \u0421\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 \u043f\u0435\u0440\u0438\u0444\u0435\u0440\u0438\u0439\u043d\u044b\u0445 \u0434\u0430\u0442\u0447\u0438\u043a\u043e\u0432;<br \/>  7. \u041d\u0435 \u0434\u043e\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e \u0440\u0430\u0437\u0440\u044f\u0434\u0430 \u0431\u0430\u0442\u0430\u0440\u0435\u0438.<\/p>\n<p>  \u041f\u0443\u043d\u043a\u0442 \u043d\u043e\u043b\u044c \u0431\u044b\u043b \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u043e\u0432\u0430\u043d \u043d\u0430 \u0428\u0418\u041c \u0441 \u0442\u0440\u0435\u043c\u044f \u043a\u0430\u043d\u0430\u043b\u0430\u043c\u0438. \u0412 \u0438\u0442\u043e\u0433\u0435 \u043f\u043e\u0441\u043b\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043a\u043e\u0434\u0430 \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u043b\u0430 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c\u0441\u044f \u0432\u043e\u0442 \u0442\u0430\u043a\u0430\u044f \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0430:<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/47f\/8cb\/f02\/47f8cbf02c0ba1b07e91b9cd4efa8bce.jpg\"\/><br \/>  , \u0433\u0434\u0435 \u043f\u043e \u0432\u0435\u0440\u0442\u0438\u043a\u0430\u043b\u0438 \u043e\u0434\u043d\u0430 \u043a\u043b\u0435\u0442\u043a\u0430 \u2014 0.4 \u0432\u043e\u043b\u044c\u0442\u0430, \u0430 \u043f\u043e \u0433\u043e\u0440\u0438\u0437\u043e\u043d\u0442\u0430\u043b\u0438 \u043e\u0434\u043d\u0430 \u043a\u043b\u0435\u0442\u043a\u0430 \u2014 2.5 \u043c\u0441.<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0418\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0428\u0418\u041c<\/b><\/p>\n<div class=\"spoiler_text\">\n<p>  void TIM_Init()<\/p>\n<p>  {<\/p>\n<p>  uint16_t Channel1Pulse = 139, Channel2Pulse = 104, Channel3Pulse = 104;<\/p>\n<p>  TIM_Config();<\/p>\n<p>  \/* TIM1 clock enable *\/<\/p>\n<p>  RCC_APB2PeriphClockCmd(RCC_APB2Periph_TIM1, ENABLE);<\/p>\n<p>  \/* Time Base configuration *\/<\/p>\n<p>  TIM_TimeBaseStructure.TIM_Prescaler = (uint16_t) ((SystemCoreClock \/ 100000));<\/p>\n<p>  TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;<\/p>\n<p>  TIM_TimeBaseStructure.TIM_Period = (1000);<\/p>\n<p>  TIM_TimeBaseStructure.TIM_ClockDivision = 0;<\/p>\n<p>  TIM_TimeBaseStructure.TIM_RepetitionCounter = 0;<\/p>\n<p>  TIM_TimeBaseInit(TIM1, &#038;TIM_TimeBaseStructure);<\/p>\n<p>  \/* Channel 1, 2,3 Configuration in PWM mode *\/<\/p>\n<p>  TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM1;<\/p>\n<p>  TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable;<\/p>\n<p>  TIM_OCInitStructure.TIM_OutputNState = TIM_OutputNState_Disable;<\/p>\n<p>  TIM_OCInitStructure.TIM_Pulse = Channel1Pulse;<\/p>\n<p>  TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_High;<\/p>\n<p>  TIM_OCInitStructure.TIM_OCNPolarity = TIM_OCNPolarity_High;<\/p>\n<p>  TIM_OCInitStructure.TIM_OCIdleState = TIM_OCIdleState_Set;<\/p>\n<p>  TIM_OCInitStructure.TIM_OCNIdleState = TIM_OCIdleState_Reset;<\/p>\n<p>  TIM_OC1Init(TIM1, &#038;TIM_OCInitStructure);<\/p>\n<p>  TIM_OCInitStructure.TIM_Pulse = Channel2Pulse;<\/p>\n<p>  TIM_OC2Init(TIM1, &#038;TIM_OCInitStructure);<\/p>\n<p>  TIM_OCInitStructure.TIM_Pulse = Channel3Pulse;<\/p>\n<p>  TIM_OC3Init(TIM1, &#038;TIM_OCInitStructure);<\/p>\n<p>  \/* TIM1 counter enable *\/<\/p>\n<p>  TIM_Cmd(TIM1, ENABLE);<\/p>\n<p>  \/* TIM1 Main Output Enable *\/<\/p>\n<p>  TIM_CtrlPWMOutputs(TIM1, ENABLE);<\/p>\n<p>  }<\/p><\/div>\n<\/div>\n<p>  \u0414\u043b\u044f \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438 \u043d\u0430\u0434\u043e \u0431\u044b\u043b\u043e \u043b\u0438\u0448\u044c \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c:<\/p>\n<blockquote><p>TIM_OCInitStructure.TIM_Pulse = n;<br \/>  TIM_OC1Init(TIM1, &#038;TIM_OCInitStructure);  <\/p><\/blockquote>\n<p>  \u041f\u0435\u0440\u0432\u044b\u0439 \u043f\u0443\u043d\u043a\u0442 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0440\u0435\u0448\u0438\u043b\u0438 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u043e\u0442 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044f. \u0414\u0430 \u044f \u043c\u043e\u0433 \u0441\u043d\u044f\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435, \u043d\u043e \u0431\u0435\u0437 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0441 \u043d\u0438\u043c\u0438 \u0441\u043b\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0447\u0442\u043e-\u0442\u043e \u0434\u0435\u043b\u0430\u0442\u044c. <\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/f50\/8c5\/7c2\/f508c57c2ba63ac998ed169c5965e4b2.jpg\"\/><\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/575\/778\/d38\/575778d386198c12d08b518c027ff14f.jpg\"\/><\/p>\n<p>  \u0413\u0440\u0430\u0444\u0438\u043a\u0438 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u044e\u0442 \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u0438\u044f \u0430\u043a\u0441\u0435\u043b\u0435\u0440\u043e\u043c\u0435\u0442\u0440\u0430 \u0431\u0435\u0437 \u0444\u0438\u043b\u044c\u0442\u0440\u043e\u0432. \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0438\u0434\u0435\u0442 \u043a\u0440\u0435\u043d, \u043f\u043e\u0442\u043e\u043c \u0442\u0430\u043d\u0433\u0430\u0436, \u0434\u0430\u043b\u044c\u0448\u0435 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u0438 \u043a\u0440\u0435\u043d, \u0438 \u0442\u0430\u043d\u0433\u0430\u0436. <\/p>\n<p>  \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0441\u043e \u0432\u0442\u043e\u0440\u044b\u043c \u0443\u0436\u0435 \u0431\u044b\u043b\u043e \u0441\u043b\u043e\u0436\u043d\u0435\u0435, \u0435\u0441\u043b\u0438 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0435 \u043a\u043e\u0434\u044b \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u043a\u0438 \u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u043e\u0434\u043d\u043e\u0433\u043e \u0434\u0430\u0442\u0447\u0438\u043a\u0430 \u0432 \u0441\u0435\u0442\u0438 \u0435\u0449\u0435 \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u043b\u0438, \u0442\u043e \u0447\u0442\u043e\u0431 \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u043a\u0430 \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u043b\u0430 \u0432\u0441\u0435 \u0442\u0440\u0438 \u0434\u0430\u0442\u0447\u0438\u043a\u0430 \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u043f\u043e\u0438\u0441\u043a\u0430\u0442\u044c. \u041f\u043e\u0441\u043b\u0435 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0434\u043d\u0435\u0439 \u0447\u0442\u0435\u043d\u0438\u044f \u0432\u0438\u043a\u0438\u043f\u0435\u0434\u0438\u0438 (<a href=\"http:\/\/en.wikipedia.org\/wiki\/Attitude_and_heading_reference_system\">AHRS<\/a>, <a href=\"http:\/\/en.wikipedia.org\/wiki\/Inertial_measurement_unit\">IMU<\/a>, <a href=\"http:\/\/ru.wikipedia.org\/wiki\/\u041a\u0432\u0430\u0442\u0435\u0440\u043d\u0438\u043e\u043d\">\u041a\u0432\u0430\u0442\u0435\u0440\u043d\u0438\u043e\u043d<\/a>, <a href=\"http:\/\/ru.wikipedia.org\/wiki\/\u0423\u0433\u043b\u044b_\u042d\u0439\u043b\u0435\u0440\u0430\">\u0423\u0433\u043b\u044b \u042d\u0439\u043b\u0435\u0440\u0430<\/a>, <a href=\"http:\/\/ru.wikipedia.org\/wiki\/\u0424\u0438\u043b\u044c\u0442\u0440_\u041a\u0430\u043b\u043c\u0430\u043d\u0430\">\u0424\u0438\u043b\u044c\u0442\u0440 \u041a\u0430\u043b\u043c\u0430\u043d\u0430<\/a>), \u0433\u0443\u0433\u043b\u0435\u043d\u0438\u044f \u0438 \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u0430 \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u043e\u0432, \u0447\u0442\u0435\u043d\u0438\u044f \u0441\u0442\u0430\u0442\u0435\u0439 \u0438 \u0444\u043e\u0440\u0443\u043c\u043e\u0432, \u043c\u043d\u0435 \u0432\u043e \u0441\u043d\u0435 \u044f\u0432\u0438\u043b\u0441\u044f \u0441\u0430\u043c \u0420\u0443\u0434\u043e\u043b\u044c\u0444 \u042d\u043c\u0438\u043b\u044c \u041a\u0430\u043b\u043c\u0430\u043d \u0438 \u043f\u0440\u043e\u0434\u0438\u043a\u0442\u043e\u0432\u0430\u043b \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 <a href=\"http:\/\/www.x-io.co.uk\/\">\u0411\u0440\u0438\u0442\u0430\u043d\u0441\u043a\u0443\u044e \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u044e<\/a> \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0437\u0430\u043d\u0438\u043c\u0430\u043b\u0430\u0441\u044c \u0432 \u043e\u0431\u0449\u0435\u043c-\u0442\u043e \u0442\u0435\u043c \u0436\u0435, \u0447\u0442\u043e \u0438 \u044f. \u0418\u043c\u0435\u043d\u043d\u043e \u0443 \u043d\u0438\u0445 \u044f \u0438 \u043f\u043e\u0434\u0433\u043b\u044f\u0434\u0435\u043b \u043e\u0442\u043a\u0440\u044b\u0442\u0443\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0441 \u0434\u0430\u0442\u0447\u0438\u043a\u043e\u0432. \u0422\u0430\u043c \u0436\u0435 \u0443 \u043d\u0438\u0445 \u043b\u0435\u0436\u0438\u0442 \u0438 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0438 \u0441\u043f\u043e\u0441\u043e\u0431 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f. \u0418\u0437 \u043d\u0435\u0433\u043e \u044f \u0432\u0437\u044f\u043b \u0444\u043e\u0440\u043c\u0443\u043b\u044b \u0434\u043b\u044f \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0438\u0437 \u043a\u0432\u0430\u0442\u0435\u0440\u043d\u0438\u043e\u043d\u043e\u0432 \u043a\u0440\u0435\u043d\u0430, \u0442\u0430\u043d\u0433\u0430\u0436\u0430 \u0438 \u0440\u044b\u0441\u043a\u0430\u043d\u044c\u044f.<\/p>\n<blockquote><p>float getPitch()<br \/>  {<br \/>  return atan2(2*(q2*q3 + q0*q1), q0*q0 \u2014 q1*q1 \u2014 q2*q2 + q3*q3);<br \/>  }<\/p>\n<p>  float getYaw()<br \/>  {<br \/>  return asin(-2*(q1*q3 \u2014 q0*q2));<br \/>  }<\/p>\n<p>  float getRoll()<br \/>  {<br \/>  return atan2(2*(q1*q2 + q0*q3), q0*q0 + q1*q1 \u2014 q2*q2 \u2014 q3*q3);<br \/>  }  <\/p><\/blockquote>\n<p>  \u041a\u043e\u0433\u0434\u0430 \u0421\u0412\u041f \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u0442 \u0432 \u0440\u0435\u0436\u0438\u043c \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u043a\u0438 \u043a\u0443\u0440\u0441\u0430 \u0442\u0435\u043a\u0443\u0449\u0435\u0435 \u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442\u0441\u044f \u0437\u0430 \u0442\u043e\u0447\u043a\u0443 \u043e\u0442\u0441\u0447\u0435\u0442\u0430:<\/p>\n<blockquote><p>nullkorr=getRoll()*DegToRadIMU;<\/p><\/blockquote>\n<p>  \u0414\u0430\u043b\u0435\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u0430\u043a\u0438\u043c \u0436\u0435 \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c \u0442\u0435\u043a\u0443\u0449\u0435\u0435 \u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0438 \u0432\u044b\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0443\u0433\u043e\u043b \u043c\u0435\u0436\u0434\u0443 \u0442\u043e\u0447\u043a\u043e\u0439 \u043e\u0442\u0441\u0447\u0435\u0442\u0430 \u0438 \u0442\u0435\u043a\u0443\u0449\u0438\u043c \u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0435\u043c.<\/p>\n<blockquote><p>float retangle(float a,float b)<br \/>  {<br \/>   a+=180;<br \/>   b+=180;<br \/>   int r1=0;<br \/>  r1 = a-b;<br \/>  r1=r1%360;<br \/>  if(r1 &lt; 0) r1 += 360;<br \/>  if(r1 &gt; 180) return -(360 \u2014 r1);<br \/>  else return r1;<br \/>  }  <\/p><\/blockquote>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0443\u0433\u043b\u0430 \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u044e\u0442\u0441\u044f \u043d\u0430 \u0441\u0435\u0440\u0432\u043e\u043f\u0440\u0438\u0432\u043e\u0434 \u0433\u0434\u0435 \u043e\u0442 \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u0443\u0433\u043b\u0430 \u043f\u043e\u0432\u043e\u0440\u043e\u0442\u0430 \u043e\u0442\u043d\u0438\u043c\u0430\u0435\u0442\u0441\u044f \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u0438\u0440\u0443\u044e\u0449\u0438\u0439 \u0443\u0433\u043e\u043b.<\/p>\n<p>  \u0421 \u0442\u0440\u0435\u0442\u044c\u0438\u043c \u043f\u0443\u043d\u043a\u0442\u043e\u043c \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u043d\u0435 \u0431\u044b\u043b\u043e, \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u0440\u0430\u0431\u043e\u0442\u044b \u0441 UART \u0438\u043b\u0438 \u0441 HC-04 \u043d\u0435 \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0442\u0440\u0443\u0434\u0430.<br \/>  \u0421 \u0447\u0435\u0442\u0432\u0435\u0440\u0442\u044b\u043c \u043f\u0443\u043d\u043a\u0442\u043e\u043c \u0431\u044b\u043b\u0438 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435\u043f\u0440\u0438\u044f\u0442\u043d\u043e\u0441\u0442\u0438, \u0443\u043b\u044c\u0442\u0440\u0430\u0437\u0432\u0443\u043a\u043e\u0432\u043e\u0439 \u0434\u0430\u0442\u0447\u0438\u043a \u043f\u0440\u0438\u0435\u0445\u0430\u043b \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u0441 \u0434\u0430\u0442\u0447\u0438\u043a\u043e\u043c \u0432\u043b\u0430\u0436\u043d\u043e\u0441\u0442\u0438 \u0438 \u044f \u043c\u0430\u044f\u043b\u0441\u044f \u043f\u043e\u0438\u0441\u043a\u043e\u043c \u043d\u043e\u0432\u043e\u0439 \u0441\u0440\u0435\u0434\u044b \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438. \u0414\u0430 \u0438 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0434\u0430\u0442\u0447\u0438\u043a\u0430 \u0440\u0430\u0437\u0440\u0443\u0448\u0438\u043b\u043e \u043c\u043e\u0438 \u0440\u043e\u0437\u043e\u0432\u044b\u0435 \u043c\u0435\u0447\u0442\u044b \u043e \u0442\u043e\u043c \u0447\u0442\u043e \u043e\u043d \u0431\u044c\u0435\u0442 \u043f\u043e \u043f\u0440\u044f\u043c\u043e\u0439 \u0443\u0437\u043a\u0438\u043c \u043b\u0443\u0447\u043e\u043c \u0438 \u043e\u0442\u0440\u0430\u0436\u0430\u0435\u0442\u0441\u044f \u043e\u0431\u0440\u0430\u0442\u043d\u043e \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e \u043e\u0442 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u0430 \u0438 \u0443\u0433\u043b\u0430 \u043f\u043e\u0432\u043e\u0440\u043e\u0442\u0430 \u043f\u043e\u0432\u0435\u0440\u0445\u043d\u043e\u0441\u0442\u0438. \u0427\u0442\u043e\u0431 \u043d\u0435 \u0433\u0440\u0443\u0437\u0438\u0442\u044c \u041c\u041a \u043b\u0438\u0448\u043d\u0438\u043c\u0438 \u0437\u0430\u0434\u0430\u0447\u0430\u043c\u0438 \u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0441 \u0434\u0430\u0442\u0447\u0438\u043a\u043e\u043c \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u043e\u0432\u0430\u043d\u043e \u043d\u0430 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f\u0445. \u041f\u0440\u0438\u043c\u0435\u0440 \u0432\u0437\u044f\u0442 \u0443 \u044d\u0442\u043e\u0433\u043e \u0445\u043e\u0440\u043e\u0448\u0435\u0433\u043e <a href=\"https:\/\/github.com\/andythekid\">\u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430<\/a> \u0432 \u044d\u0442\u043e\u043c <a href=\"https:\/\/github.com\/andythekid\/HC-SR04Stm32Min\/blob\/master\/main.c\">\u043c\u0435\u0441\u0442\u0435<\/a>. \u041a\u043e\u0434 \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u0435\u0440\u0435\u0434\u0435\u043b\u0430\u0442\u044c \u0442\u0430\u043a \u043a\u0430\u043a \u0432 STM32f3 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u0435\u0440\u0435\u0438\u043d\u0430\u0447\u0438\u043b\u0438 \u0442\u0430\u0439\u043c\u0435\u0440\u044b.<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0418\u0437\u043c\u0435\u043d\u0435\u043d\u043d\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442<\/b><\/p>\n<div class=\"spoiler_text\">\n<p>  \/**<\/p>\n<p>  **===========================================================================<\/p>\n<p>  **<\/p>\n<p>  ** Abstract: Ultrasonic sensor interrupt handler<\/p>\n<p>  **<\/p>\n<p>  **===========================================================================<\/p>\n<p>  *\/<\/p>\n<p>  void EXTI3_IRQHandler(void)<\/p>\n<p>  {<\/p>\n<p>  \/\/ \u0415\u0441\u043b\u0438 \u043f\u043e\u0439\u043c\u0430\u043b\u0438 \u043d\u0430\u0440\u0430\u0441\u0442\u0430\u044e\u0449\u0438\u0439 \u0444\u0440\u043e\u043d\u0442<\/p>\n<p>  if (!catcher_status)<\/p>\n<p>  {<\/p>\n<p>  \/\/ \u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u043e\u0442\u0441\u0447\u0451\u0442 \u0434\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0438\u043c\u043f\u0443\u043b\u044c\u0441\u0430<\/p>\n<p>  TIM6-&gt;CR1 |= TIM_CR1_CEN;<\/p>\n<p>  \/\/ \u041f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0430\u0435\u043c\u0441\u044f \u043d\u0430 \u043e\u0442\u043b\u043e\u0432 \u0441\u043f\u0430\u0434\u0430\u044e\u0449\u0435\u0433\u043e \u0444\u0440\u043e\u043d\u0442\u0430<\/p>\n<p>  catcher_status = 1;<\/p>\n<p>  EXTI-&gt;RTSR &#038;= ~EXTI_RTSR_TR3;<\/p>\n<p>  EXTI-&gt;FTSR |= EXTI_FTSR_TR3;<\/p>\n<p>  }<\/p>\n<p>  \/\/ \u0415\u0441\u043b\u0438 \u043f\u043e\u0439\u043c\u0430\u043b\u0438 \u0441\u043f\u0430\u0434\u0430\u044e\u0449\u0438\u0439 \u0444\u0440\u043e\u043d\u0442<\/p>\n<p>  else<\/p>\n<p>  {<\/p>\n<p>  TIM6-&gt;CR1 &#038;= ~TIM_CR1_CEN; \/\/ \u041e\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0442\u0430\u0439\u043c\u0435\u0440<\/p>\n<p>  if(TIM6-&gt;CNT&gt;58)<\/p>\n<p>  {<\/p>\n<p>  duration = TIM6-&gt;CNT; \/\/ \u0421\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0434\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0432 \u043c\u043a\u0441<\/p>\n<p>  if(duration&lt;5800 &#038;&#038; korr&lt;25 &#038;&#038; korr&gt;-25 &#038;&#038; stepmode==5)<\/p>\n<p>  {<\/p>\n<p>  m1=0;<\/p>\n<p>  upper_ctrl(m1); \/\/motor off<\/p>\n<p>  bbf=0;<\/p>\n<p>  stepmode=1;<\/p>\n<p>  }<\/p>\n<p>  smas[scnum]=TIM6-&gt;CNT;<\/p>\n<p>  }<\/p>\n<p>  TIM6-&gt;CNT = 0; \/\/ \u041e\u0431\u043d\u0443\u043b\u044f\u0435\u043c \u0440\u0435\u0433\u0438\u0441\u0442\u0440-\u0441\u0447\u0451\u0442\u0447\u0438\u043a<\/p>\n<p>  \/\/ \u041f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0430\u0435\u043c\u0441\u044f \u043d\u0430 \u043e\u0442\u043b\u043e\u0432 \u043d\u0430\u0440\u0430\u0441\u0442\u0430\u044e\u0449\u0435\u0433\u043e \u0444\u0440\u043e\u043d\u0442\u0430<\/p>\n<p>  catcher_status = 0;<\/p>\n<p>  EXTI-&gt;FTSR &#038;= ~EXTI_FTSR_TR3;<\/p>\n<p>  EXTI-&gt;RTSR |= EXTI_RTSR_TR3;<\/p>\n<p>  \/\/ \u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0442\u0430\u0439\u043c\u0435\u0440 6 \u043d\u0430 \u043e\u0442\u0441\u0447\u0451\u0442 50 \u043c\u0441<\/p>\n<p>  TIM6-&gt;DIER |= TIM_DIER_UIE; \/\/ \u0420\u0430\u0437\u0440\u0435\u0448\u0430\u0435\u043c \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u0435 \u043e\u0442 \u0442\u0430\u0439\u043c\u0435\u0440\u0430<\/p>\n<p>  TIM6-&gt;CR1 |= TIM_CR1_CEN; \/\/ \u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0442\u0430\u0439\u043c\u0435\u0440<\/p>\n<p>  }<\/p>\n<p>  EXTI-&gt;PR |= 0x01; \/\/\u041e\u0447\u0438\u0449\u0430\u0435\u043c \u0444\u043b\u0430\u0433<\/p>\n<p>  }<\/p>\n<p>  \/**<\/p>\n<p>  **===========================================================================<\/p>\n<p>  **<\/p>\n<p>  ** Abstract: Ultrasonic sensor interrupt handler<\/p>\n<p>  ** \u041e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f TIM7<\/p>\n<p>  ** \u0412\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u0442\u0430\u0439\u043c\u0435\u0440 7 \u043e\u0442\u0441\u0447\u0438\u0442\u0430\u043b 10 \u043c\u043a\u0441 \u0434\u043b\u044f \u0441\u0438\u0433\u043d\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0438\u043c\u043f\u0443\u043b\u044c\u0441\u0430<\/p>\n<p>  **===========================================================================<\/p>\n<p>  *\/<\/p>\n<p>  void TIM7_IRQHandler(void)<\/p>\n<p>  {<\/p>\n<p>  TIM7-&gt;SR &#038;= ~TIM_SR_UIF; \/\/ \u0421\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0435\u043c \u0444\u043b\u0430\u0433 UIF<\/p>\n<p>  GPIOD-&gt;ODR &#038;= ~GPIO_Pin_2; \/\/ \u041e\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0441\u0438\u0433\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u0438\u043c\u043f\u0443\u043b\u044c\u0441<\/p>\n<p>  TIM7-&gt;DIER &#038;= ~TIM_DIER_UIE; \/\/ \u0417\u0430\u043f\u0440\u0435\u0449\u0430\u0435\u043c \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u0435 \u043e\u0442 \u0442\u0430\u0439\u043c\u0435\u0440\u0430 7<\/p>\n<p>  }<\/p>\n<p>  \/**<\/p>\n<p>  **===========================================================================<\/p>\n<p>  **<\/p>\n<p>  ** Abstract: Ultrasonic sensor interrupt handler<\/p>\n<p>  ** \u041e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f TIM6_DAC<\/p>\n<p>  ** \u0412\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u0442\u0430\u0439\u043c\u0435\u0440 6 \u043e\u0442\u0441\u0447\u0438\u0442\u0430\u043b 50 \u043c\u043a\u0441 \u0434\u043b\u044f \u043f\u0435\u0440\u0438\u043e\u0434\u0430 \u0446\u0438\u043a\u043b\u0430<\/p>\n<p>  **===========================================================================<\/p>\n<p>  *\/<\/p>\n<p>  void TIM6_DAC_IRQHandler(void)<\/p>\n<p>  {<\/p>\n<p>  TIM6-&gt;SR &#038;= ~TIM_SR_UIF; \/\/ \u0421\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0435\u043c \u0444\u043b\u0430\u0433 UIF<\/p>\n<p>  if(scaning==2)<\/p>\n<p>  {<\/p>\n<p>  if(smas[scnum]&gt;800)<\/p>\n<p>  {<\/p>\n<p>  scnum++;<\/p>\n<p>  US_servo_ctrl(scnum);<\/p>\n<p>  if(scnum&gt;=160)<\/p>\n<p>  {<\/p>\n<p>  scnum=0;<\/p>\n<p>  scaning=3;<\/p>\n<p>  US_servo_ctrl(80);<\/p>\n<p>  }<\/p>\n<p>  }<\/p>\n<p>  else<\/p>\n<p>  {<\/p>\n<p>  scd++;<\/p>\n<p>  if(scd&gt;3)<\/p>\n<p>  {<\/p>\n<p>  scd=0;<\/p>\n<p>  smas[scnum]=23200;<\/p>\n<p>  scnum++;<\/p>\n<p>  US_servo_ctrl(scnum);<\/p>\n<p>  }<\/p>\n<p>  }<\/p>\n<p>  }<\/p>\n<p>  GPIOD-&gt;ODR |= GPIO_Pin_2; \/\/ \u0412\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u0441\u0438\u0433\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u0438\u043c\u043f\u0443\u043b\u044c\u0441<\/p>\n<p>  \/\/ \u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0442\u0430\u0439\u043c\u0435\u0440 7 \u043d\u0430 \u043e\u0442\u0441\u0447\u0451\u0442 10 \u043c\u0441<\/p>\n<p>  TIM7-&gt;DIER |= TIM_DIER_UIE; \/\/ \u0420\u0430\u0437\u0440\u0435\u0448\u0430\u0435\u043c \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u0435 \u043e\u0442 \u0442\u0430\u0439\u043c\u0435\u0440\u0430 7<\/p>\n<p>  TIM7-&gt;CR1 |= TIM_CR1_CEN; \/\/ \u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0442\u0430\u0439\u043c\u0435\u0440<\/p>\n<p>  }<\/p>\n<p>  void USsensor_init()<\/p>\n<p>  {<\/p>\n<p>  \/\/========================================================================<\/p>\n<p>  \/\/ \u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u0442\u0430\u0439\u043c\u0435\u0440\u0430 6<\/p>\n<p>  \/\/ \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f 2-\u0445 \u0446\u0435\u043b\u0435\u0439:<\/p>\n<p>  \/\/ 1) \u041f\u043e\u0434\u0441\u0447\u0451\u0442 \u0434\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 Echo \u0438\u043c\u043f\u0443\u043b\u044c\u0441\u0430 (150 \u043c\u043a\u0441 \u2014 25 \u043c\u0441)<\/p>\n<p>  \/\/ 2) \u041f\u043e\u0434\u0441\u0447\u0451\u0442 \u0441 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u0435\u043c \u0434\u043b\u044f \u043e\u0442\u0447\u0451\u0442\u0430 \u043f\u0435\u0440\u0438\u043e\u0434\u0430 \u0446\u0438\u043a\u043b\u0430 \u2014 \u0432\u0440\u0435\u043c\u0435\u043d\u0438,<\/p>\n<p>  \/\/ \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0433\u043e \u0434\u043b\u044f \u0437\u0430\u0442\u0443\u0445\u0430\u043d\u0438\u044f \u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u044b\u0445 \u043a\u043e\u043b\u0435\u0431\u0430\u043d\u0438\u0439 \u0432 \u043b\u0438\u043d\u0438\u0438 Echo<\/p>\n<p>  \/\/========================================================================<\/p>\n<p>  \/\/ \u0412\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u0442\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0442\u0430\u0439\u043c\u0435\u0440\u0430<\/p>\n<p>  RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM6, ENABLE);<\/p>\n<p>  \/\/ \u0412\u044b\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u043f\u0440\u0435\u0434\u0434\u0435\u043b\u0438\u0442\u0435\u043b\u044c \u043d\u0430 \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u043d\u0438\u0435 \u0440\u0430\u0437 \u0432 \u043c\u043a\u0441<\/p>\n<p>  TIM6-&gt;PSC = 72 \u2014 1;<\/p>\n<p>  \/\/ \u0413\u0440\u0430\u043d\u0438\u0446\u0430 \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u043d\u0438\u044f \u2014 50 \u043c\u0441 = 50 000 \u043c\u043a\u0441<\/p>\n<p>  TIM6-&gt;ARR = 50000;<\/p>\n<p>  \/\/\u0420\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u0435 TIM6_IRQn \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f \u2014 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0434\u043b\u044f \u043e\u0442\u0441\u0447\u0451\u0442\u0430 \u043f\u0435\u0440\u0438\u043e\u0434\u0430 \u0446\u0438\u043a\u043b\u0430<\/p>\n<p>  NVIC_SetPriority(TIM6_DAC_IRQn, 3);<\/p>\n<p>  NVIC_EnableIRQ(TIM6_DAC_IRQn);<\/p>\n<p>  \/\/========================================================================<\/p>\n<p>  \/\/ \u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u0442\u0430\u0439\u043c\u0435\u0440\u0430 7<\/p>\n<p>  \/\/========================================================================<\/p>\n<p>  \/\/ \u0412\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u0442\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0442\u0430\u0439\u043c\u0435\u0440\u0430<\/p>\n<p>  RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM7, ENABLE);<\/p>\n<p>  \/\/ \u0412\u044b\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u043f\u0440\u0435\u0434\u0434\u0435\u043b\u0438\u0442\u0435\u043b\u044c \u043d\u0430 \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u043d\u0438\u0435 \u0440\u0430\u0437 \u0432 \u043c\u043a\u0441<\/p>\n<p>  TIM7-&gt;PSC = 72 \u2014 1;<\/p>\n<p>  \/\/ \u0413\u0440\u0430\u043d\u0438\u0446\u0430 \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u043d\u0438\u044f \u2014 10 \u043c\u043a\u0441<\/p>\n<p>  TIM7-&gt;ARR = 10;<\/p>\n<p>  \/\/\u0420\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u0435 TIM7_IRQn \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f \u2014 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0434\u043b\u044f \u043e\u0442\u0441\u0447\u0451\u0442\u0430 \u0441\u0438\u0433\u043d\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0438\u043c\u043f\u0443\u043b\u044c\u0441\u0430<\/p>\n<p>  NVIC_SetPriority(TIM7_IRQn, 2);<\/p>\n<p>  NVIC_EnableIRQ(TIM7_IRQn);<\/p>\n<p>  \/\/========================================================================<\/p>\n<p>  EXTI_InitTypeDef EXTI_InitStructure;<\/p>\n<p>  GPIO_InitTypeDef GPIO_InitStructure;<\/p>\n<p>  NVIC_InitTypeDef NVIC_InitStructure;<\/p>\n<p>  RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);<\/p>\n<p>  RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOD, ENABLE);<\/p>\n<p>  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;<\/p>\n<p>  GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;<\/p>\n<p>  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_DOWN;<\/p>\n<p>  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;<\/p>\n<p>  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2;<\/p>\n<p>  GPIO_Init(GPIOD, &#038;GPIO_InitStructure);<\/p>\n<p>  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;<\/p>\n<p>  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;<\/p>\n<p>  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;<\/p>\n<p>  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3;<\/p>\n<p>  GPIO_Init(GPIOD, &#038;GPIO_InitStructure);<\/p>\n<p>  SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOD, EXTI_PinSource3);<\/p>\n<p>  \/* Configure EXTI3 line *\/<\/p>\n<p>  EXTI_InitStructure.EXTI_Line = EXTI_Line3;<\/p>\n<p>  EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;<\/p>\n<p>  EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising;<\/p>\n<p>  EXTI_InitStructure.EXTI_LineCmd = ENABLE;<\/p>\n<p>  EXTI_Init(&#038;EXTI_InitStructure);<\/p>\n<p>  NVIC_InitStructure.NVIC_IRQChannel = EXTI3_IRQn;<\/p>\n<p>  NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0x0F;<\/p>\n<p>  NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0x0F;<\/p>\n<p>  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;<\/p>\n<p>  NVIC_Init(&#038;NVIC_InitStructure);<\/p>\n<p>  }<\/p><\/div>\n<\/div>\n<p>  \u0412 \u044d\u0442\u043e\u043c \u043a\u043e\u0434\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u0435 \u043d\u0430 PORTD.3, \u0442\u043e\u0447\u043d\u0435\u0435 \u043e\u043d\u043e \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u043d\u0430 PORTD, \u044f \u0442\u0430\u043a \u0438 \u043d\u0435 \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u043b\u0441\u044f \u043f\u043e\u0447\u0435\u043c\u0443 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u0435 \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u043d\u0430 \u0432\u0441\u0435\u0445 \u043f\u043e\u0440\u0442\u0430\u0445 \u043d\u0430 \u0442\u0440\u0435\u0442\u044c\u0435\u043c \u043f\u0438\u043d\u0435. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f \u0432\u0437\u044f\u0442\u043e \u0438\u0437 \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u043e\u0442 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044f, \u0431\u044b\u043b\u0430 \u043f\u0440\u0435\u0434\u043f\u0440\u0438\u043d\u044f\u0442\u0430 \u043f\u043e\u043f\u044b\u0442\u043a\u0430 \u043f\u0438\u0441\u0430\u0442\u044c \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u0432 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u044b \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u0439, \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u201c0\u201d \u043b\u0438\u0431\u043e \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f \u043d\u0435\u0442, \u043b\u0438\u0431\u043e \u043e\u043d\u043e \u0435\u0441\u0442\u044c \u043d\u0430 \u0432\u0441\u0435\u0445 \u043f\u043e\u0440\u0442\u0430\u0445. <br \/>  \u0415\u0441\u043b\u0438 \u043a\u0442\u043e-\u0442\u043e \u043e\u0431\u044a\u044f\u0441\u043d\u0438\u0442 \u0433\u0434\u0435 \u043e\u0448\u0438\u0431\u043a\u0430 \u0431\u0443\u0434\u0443 \u043e\u0447\u0435\u043d\u044c \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u0435\u043d.<\/p>\n<p>  \u041f\u044f\u0442\u044b\u0439 \u043f\u0443\u043d\u043a\u0442 \u0431\u044b\u043b \u0431\u044b\u0441\u0442\u0440\u043e \u043f\u0440\u043e\u0439\u0434\u0435\u043d, \u0430 \u0432\u043e\u0442 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u0410\u0426\u041f \u0432 \u0448\u0435\u0441\u0442\u043e\u043c \u043f\u0440\u0438\u0447\u0438\u043d\u0438\u043b\u0430 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0433\u043e\u043b\u043e\u0432\u043d\u0443\u044e \u0431\u043e\u043b\u044c. <br \/>  \u041e\u043f\u044f\u0442\u044c \u0436\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b, \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u043d\u0430\u0440\u0435\u043a\u0430\u043d\u0438\u0439 \u043d\u0435\u0442, \u043f\u0440\u0438\u043c\u0435\u0440 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043e\u0442\u043b\u0438\u0447\u043d\u043e. \u0422\u043e\u043b\u044c\u043a\u043e \u0432 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043e\u043d\u0438 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u043b\u0438 \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u043d\u0438\u0435 \u0438\u0437 \u043e\u0434\u043d\u043e\u0433\u043e \u043a\u0430\u043d\u0430\u043b\u0430 \u0410\u0426\u041f, \u0430 \u0443 \u043c\u0435\u043d\u044f \u0438\u0445 \u0447\u0435\u0442\u044b\u0440\u0435. \u0412 \u0434\u0430\u0442\u0430\u0448\u0438\u0442\u0435 \u0440\u0430\u0441\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043e \u043a\u0430\u043d\u0430\u043b\u0430\u0445, \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u044b\u0445 \u0433\u0440\u0443\u043f\u043f\u0430\u0445, \u0432\u0432\u0435\u0434\u0435\u043d\u043d\u044b\u0445 \u0433\u0440\u0443\u043f\u043f\u0430\u0445. \u0418\u0437-\u0437\u0430 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u043d\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0431\u044b\u043b \u0432\u044b\u0431\u0440\u0430\u043d \u0441\u0442\u0430\u0440\u044b\u0439 \u201c\u0434\u0435\u0434\u043e\u0432\u0441\u043a\u0438\u0439\u201d \u043c\u0435\u0442\u043e\u0434: <br \/>  -\u0412\u044b\u0431\u043e\u0440 \u043a\u0430\u043d\u0430\u043b\u0430;<br \/>  -\u0417\u0430\u043f\u0443\u0441\u043a \u043e\u0434\u043d\u043e\u0440\u0430\u0437\u043e\u0432\u043e\u0433\u043e \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u043d\u0438\u044f;<br \/>  -\u041e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430;<br \/>  -\u041f\u043e\u0432\u0442\u043e\u0440.<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u0447\u0438\u0442\u044b\u0432\u0430\u043d\u0438\u0435 \u0410\u0426\u041f<\/b><\/p>\n<div class=\"spoiler_text\">  void ADC1_2_IRQHandler(void)<\/p>\n<p>  {<\/p>\n<p>  ADC_ClearITPendingBit(ADC1, ADC_IT_EOC);<\/p>\n<p>  ADC1ConvertedValue =ADC_GetConversionValue(ADC1);<\/p>\n<p>  \/* Compute the voltage *\/<\/p>\n<p>  ADC1ConvertedVoltage = (ADC1ConvertedValue *3300)\/0xFFF;<\/p>\n<p>  adcp[iadc]= ADC1ConvertedVoltage;<\/p>\n<p>  iadc++;<\/p>\n<p>  ADCready=1;<\/p>\n<p>  }<\/p>\n<p>  void SetADCchannel()<\/p>\n<p>  {<\/p>\n<p>  \/*Configure ADC channel *\/<\/p>\n<p>  numadc[0]=7; \/\/BT<\/p>\n<p>  numadc[1]=16; \/\/Termometer<\/p>\n<p>  numadc[2]=6; \/\/ Battery voltage<\/p>\n<p>  numadc[3]=3; \/\/ Gas sensor<\/p>\n<p>  kadc=4; \/\/ amount channels<\/p>\n<p>  }<\/p>\n<p>  void getADC(uint8_t channel)<\/p>\n<p>  {<\/p>\n<p>  if(ADCready==1)<\/p>\n<p>  {<\/p>\n<p>  ADCready=0;<\/p>\n<p>  ADC_RegularChannelConfig(ADC1, channel, 1, ADC_SampleTime);<\/p>\n<p>  ADC_StartConversion(ADC1);<\/p>\n<p>  }<\/p>\n<p>  }<\/p>\n<p>  uint8_t ADC_init()<\/p>\n<p>  {<\/p>\n<p>  uint16_t calibration_value = 0;<\/p>\n<p>  ADC_InitTypeDef ADC_InitStructure;<\/p>\n<p>  ADC_CommonInitTypeDef ADC_CommonInitStructure;<\/p>\n<p>  GPIO_InitTypeDef GPIO_InitStructure;<\/p>\n<p>  \/* Configure the ADC clock *\/<\/p>\n<p>  RCC_ADCCLKConfig(RCC_ADC12PLLCLK_Div2);<\/p>\n<p>  \/* Enable ADC1 clock *\/<\/p>\n<p>  RCC_AHBPeriphClockCmd(RCC_AHBPeriph_ADC12, ENABLE);<\/p>\n<p>  \/* ADC Channel configuration *\/<\/p>\n<p>  \/* GPIOC Periph clock enable *\/<\/p>\n<p>  RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOC, ENABLE);<\/p>\n<p>  RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA, ENABLE);<\/p>\n<p>  \/* Configure ADC Channel7 as analog input *\/<\/p>\n<p>  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0|GPIO_Pin_1|GPIO_Pin_2|GPIO_Pin_3;<\/p>\n<p>  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AN;<\/p>\n<p>  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;<\/p>\n<p>  GPIO_Init(GPIOC, &#038;GPIO_InitStructure);<\/p>\n<p>  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0|GPIO_Pin_1|GPIO_Pin_2;<\/p>\n<p>  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AN;<\/p>\n<p>  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;<\/p>\n<p>  GPIO_Init(GPIOA, &#038;GPIO_InitStructure);<\/p>\n<p>  ADC_StructInit(&#038;ADC_InitStructure);<\/p>\n<p>  \/* Calibration procedure *\/<\/p>\n<p>  ADC_VoltageRegulatorCmd(ADC1, ENABLE);<\/p>\n<p>  \/* Insert delay equal to *\/<\/p>\n<p>  Delay(15);<\/p>\n<p>  ADC_SelectCalibrationMode(ADC1, ADC_CalibrationMode_Single);<\/p>\n<p>  ADC_StartCalibration(ADC1);<\/p>\n<p>  while(ADC_GetCalibrationStatus(ADC1) != RESET );<\/p>\n<p>  calibration_value = ADC_GetCalibrationValue(ADC1);<\/p>\n<p>  ADC_CommonInitStructure.ADC_Mode = ADC_Mode_Independent;<\/p>\n<p>  ADC_CommonInitStructure.ADC_Clock = ADC_Clock_AsynClkMode;<\/p>\n<p>  ADC_CommonInitStructure.ADC_DMAAccessMode = ADC_DMAAccessMode_Disabled;<\/p>\n<p>  ADC_CommonInitStructure.ADC_DMAMode = ADC_DMAMode_OneShot;<\/p>\n<p>  ADC_CommonInitStructure.ADC_TwoSamplingDelay = 1000;<\/p>\n<p>  ADC_CommonInit(ADC1, &#038;ADC_CommonInitStructure);<\/p>\n<p>  ADC_InitStructure.ADC_ContinuousConvMode = ADC_ContinuousConvMode_Disable;<\/p>\n<p>  ADC_InitStructure.ADC_Resolution = ADC_Resolution_12b;<\/p>\n<p>  ADC_InitStructure.ADC_ExternalTrigConvEvent = ADC_ExternalTrigConvEvent_0;<\/p>\n<p>  ADC_InitStructure.ADC_ExternalTrigEventEdge = ADC_ExternalTrigEventEdge_None;<\/p>\n<p>  ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right;<\/p>\n<p>  ADC_InitStructure.ADC_OverrunMode = ADC_OverrunMode_Disable;<\/p>\n<p>  ADC_InitStructure.ADC_AutoInjMode = ADC_AutoInjec_Disable;<\/p>\n<p>  ADC_InitStructure.ADC_NbrOfRegChannel = 1;<\/p>\n<p>  ADC_Init(ADC1, &#038;ADC_InitStructure);<\/p>\n<p>  ADC_RegularChannelSequencerLengthConfig(ADC1,1);<\/p>\n<p>  \/* ADC1 regular channel7 configuration *\/<\/p>\n<p>  ADC_RegularChannelConfig(ADC1, ADC_Channel_7, 1, ADC_SampleTime);<\/p>\n<p>  ADC_TempSensorCmd(ADC1,ENABLE);<\/p>\n<p>  \/* Enable ADC1 *\/<\/p>\n<p>  ADC_Cmd(ADC1, ENABLE);<\/p>\n<p>  \/* wait for ADRDY *\/<\/p>\n<p>  while(!ADC_GetFlagStatus(ADC1, ADC_FLAG_RDY));<\/p>\n<p>  NVIC_InitTypeDef NVIC_InitStructure;<\/p>\n<p>  NVIC_InitStructure.NVIC_IRQChannel = ADC1_2_IRQn;<\/p>\n<p>  NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;<\/p>\n<p>  NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1;<\/p>\n<p>  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;<\/p>\n<p>  NVIC_Init(&#038;NVIC_InitStructure);<\/p>\n<p>  ADC_ITConfig(ADC1, ADC_IT_EOC, ENABLE);<\/p>\n<p>  return 1;<\/p>\n<p>  }<\/p>\n<p>  \/* \u0438 \u0433\u0434\u0435-\u0442\u043e \u0432 main \u0440\u0430\u0437\u043c\u0435\u0441\u0442\u0438\u0442\u044c<\/p>\n<p>  if(iadc&lt;kadc)<\/p>\n<p>  {<\/p>\n<p>  getADC(numadc[iadc]);<\/p>\n<p>  }<\/p>\n<p>  else<\/p>\n<p>  {<\/p>\n<p>  iadc=0;<\/p>\n<p>  }<\/p>\n<p>  *\/<\/p><\/div>\n<\/div>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e \u043a\u0430\u043a \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u043b\u0441\u044f \u0441 \u0410\u0426\u041f \u0441\u0435\u0434\u044c\u043c\u043e\u0439 \u043f\u0443\u043d\u043a\u0442 \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u043d\u0435 \u0432\u044b\u0437\u0432\u0430\u043b.<\/p>\n<p>  \u041f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u0430\u043d\u0434\u0440\u043e\u0438\u0434\u0430 \u043e\u0441\u043e\u0431\u044b\u0445 \u0442\u0440\u0443\u0434\u043d\u043e\u0441\u0442\u0435\u0439 \u0438 \u043f\u043e\u0442\u0435\u0440\u044c \u0441\u043e \u0441\u0442\u043e\u0440\u043e\u043d\u044b \u043d\u0435\u0440\u0432\u043d\u044b\u0445 \u043d\u0435 \u0432\u044b\u0437\u0432\u0430\u043b\u043e (\u043d\u0435 \u0441\u0447\u0438\u0442\u0430\u044f \u0432\u044b\u043b\u0435\u0442\u043e\u0432 \u043e\u0442 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043c\u0435\u0441\u0442\u043e\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043a\u043d\u043e\u043f\u043a\u0438) \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0431\u043b\u044e\u0442\u0443\u0437 \u0432 \u0441\u0435\u0442\u0438 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e, \u0430 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u0438\u0437 \u044d\u0442\u043e\u0439 <a href=\"http:\/\/habrahabr.ru\/post\/111405\/\">\u0441\u0442\u0430\u0442\u044c\u0438<\/a> \u0434\u043e\u0431\u0430\u0432\u0438\u043b \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c\u044e \u0438 \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435\u043c \u0441\u0443\u0434\u043d\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043f\u0435\u0440\u0435\u0434\u0432\u0438\u0436\u0435\u043d\u0438\u044f \u043f\u0430\u043b\u044c\u0446\u0430 \u0432\u0432\u0435\u0440\u0445\/\u0432\u043d\u0438\u0437 \u0438 \u0432\u043b\u0435\u0432\u043e\/\u0432\u043f\u0440\u0430\u0432\u043e \u043f\u043e \u044d\u043a\u0440\u0430\u043d\u0443.<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041a\u043b\u0430\u0441\u0441 SomeView<\/b><\/p>\n<div class=\"spoiler_text\">\n<p>  public class SomeView extends View {<\/p>\n<p>  Paint paint;<\/p>\n<p>  int[] X;<\/p>\n<p>  int[] Y;<\/p>\n<p>  final static int Radius=50;<\/p>\n<p>  int PointerCount;<\/p>\n<p>  public SomeView(Context context, AttributeSet attrs)<\/p>\n<p>  {<\/p>\n<p>  super(context, attrs);<\/p>\n<p>  paint = new Paint();<\/p>\n<p>  paint.setColor(Color.RED);<\/p>\n<p>  paint.setStyle(Style.STROKE);<\/p>\n<p>  paint.setStrokeWidth(3);<\/p>\n<p>  PointerCount=0;<\/p>\n<p>  X=new int[10];\/\/\u042d\u0442\u043e \u0431\u0443\u0434\u0443\u0442 \u043c\u0430\u0441\u0441\u0438\u0432\u044b \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442(\u0431\u0443\u0434\u0435\u043c \u0432\u043e\u0441\u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c \u0434\u043e 10 \u043f\u0430\u043b\u044c\u0446\u0435\u0432)<\/p>\n<p>  Y=new int[10];<\/p>\n<p>  }<\/p>\n<p>  <a href=\"http:\/\/habrahabr.ru\/users\/override\/\" class=\"user_link\">Override<\/a><\/p>\n<p>  public boolean onTouchEvent(MotionEvent event)<\/p>\n<p>  {<\/p>\n<p>  StringBuilder result=new StringBuilder(300);<\/p>\n<p>  PointerCount=event.getPointerCount();<\/p>\n<p>  for(int i=0;i&lt;PointerCount;i++)<\/p>\n<p>  {<\/p>\n<p>  int ptrId=event.getPointerId(i);<\/p>\n<p>  X[i]=(int) event.getX(i);\/\/ \u0417\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u0435\u043c \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b<\/p>\n<p>  Y[i]=(int) event.getY(i);<\/p>\n<p>  MainActivity.flag=1;<\/p>\n<p>  MainActivity.setX(X[i], Y[i],ptrId);<\/p>\n<p>  }<\/p>\n<p>  return true;<\/p>\n<p>  }<\/p>\n<p>  protected void onDraw(Canvas canvas)<\/p>\n<p>  {<\/p>\n<p>  for(int i=0;i&lt;PointerCount;i++)<\/p>\n<p>  {<\/p>\n<p>  if(Y[i]&lt;(MainActivity.height\/4))Y[i]=MainActivity.height\/4;<\/p>\n<p>  if(Y[i]&gt;(MainActivity.height*0.75)-75)Y[i]=(int) (MainActivity.height*0.75)-75;<\/p>\n<p>  canvas.drawCircle(X[i], Y[i], Radius, paint);<\/p>\n<p>  canvas.drawLine(MainActivity.width\/2, (int) (MainActivity.height*0.75)-25, X[i], Y[i], paint);<\/p>\n<p>  canvas.drawLine(0, (int) (MainActivity.height\/4)-50, MainActivity.width, (int) (MainActivity.height\/4)-50, paint);<\/p>\n<p>  canvas.drawLine(0, (int) (MainActivity.height*0.75)-25, MainActivity.width, (int) (MainActivity.height*0.75)-25, paint);<\/p>\n<p>  }<\/p>\n<p>  invalidate();<\/p>\n<p>  }<\/p>\n<p>  }<\/p><\/div>\n<\/div>\n<p>  \u0410 \u0434\u043b\u044f \u0432\u044b\u0432\u043e\u0434\u0430 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e \u0434\u0430\u0442\u0447\u0438\u043a\u0430\u0445 \u0431\u044b\u043b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d DialogFragment:<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041a\u043b\u0430\u0441\u0441 dialog<\/b><\/p>\n<div class=\"spoiler_text\">\n<p>  public class dialog extends DialogFragment implements OnClickListener {<\/p>\n<p>  final String LOG_TAG = \u00abmyLogs\u00bb;<\/p>\n<p>  android.widget.TextView datch;<\/p>\n<p>  public View onCreateView(LayoutInflater inflater, ViewGroup container,<\/p>\n<p>  Bundle savedInstanceState) {<\/p>\n<p>  getDialog().setTitle(\u00ab\u041f\u043e\u043a\u0430\u0437\u0430\u043d\u0438\u044f \u0434\u0430\u0442\u0447\u0438\u043a\u043e\u0432\u00bb);<\/p>\n<p>  View v = inflater.inflate(R.layout.dialog, null);<\/p>\n<p>  v.findViewById(R.id.btnYes).setOnClickListener(this);<\/p>\n<p>  datch = (android.widget.TextView)v.findViewById(R.id.textView1);<\/p>\n<p>  datch.setText(MainActivity.mesdat);<\/p>\n<p>  return v;<\/p>\n<p>  }<\/p>\n<p>  public void onClick(View v) {<\/p>\n<p>  Log.d(LOG_TAG, \u00abDialog: \u00bb + ((Button) v).getText());<\/p>\n<p>  dismiss();<\/p>\n<p>  }<\/p>\n<p>  public void onDismiss(DialogInterface dialog) {<\/p>\n<p>  super.onDismiss(dialog);<\/p>\n<p>  Log.d(LOG_TAG, \u00abDialog: onDismiss\u00bb);<\/p>\n<p>  }<\/p>\n<p>  public void onCancel(DialogInterface dialog) {<\/p>\n<p>  super.onCancel(dialog);<\/p>\n<p>  Log.d(LOG_TAG, \u00abDialog: onCancel\u00bb);<\/p>\n<p>  }<\/p>\n<p>  }<\/p><\/div>\n<\/div>\n<h1>\u041f\u043e\u0441\u043b\u0435\u0441\u043b\u043e\u0432\u0438\u0435<\/h1>\n<p>  \u042f \u0437\u043d\u0430\u044e, \u0447\u0442\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043e\u0445\u0432\u0430\u0442\u0438\u043b \u043b\u0438\u0448\u044c \u0432 \u043e\u0431\u0449\u0438\u0445 \u0447\u0435\u0440\u0442\u0430\u0445 \u043d\u043e \u0435\u0441\u043b\u0438 \u0431\u0443\u0434\u0443\u0442 \u0432\u043e\u043f\u0440\u043e\u0441\u044b \u044f \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u043e\u0441\u0442\u0430\u0440\u0430\u044e\u0441\u044c \u043d\u0430 \u043d\u0438\u0445 \u043e\u0442\u0432\u0435\u0442\u0438\u0442\u044c. \u041f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0434\u0430\u043b\u0435\u043a\u0430 \u043e\u0442 \u0438\u0434\u0435\u0430\u043b\u0430, \u0435\u0449\u0435 \u043d\u0430\u0434\u043e \u043c\u043d\u043e\u0433\u043e \u0447\u0435\u0433\u043e \u0443\u0447\u0435\u0441\u0442\u044c. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u0440\u0438 \u0440\u0435\u0437\u043a\u043e\u043c \u043f\u043e\u0432\u043e\u0440\u043e\u0442\u0435 \u0438\u043d\u0435\u0440\u0446\u0438\u044f \u0441\u0443\u0434\u043d\u0430 \u0437\u0430\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0435\u0433\u043e \u00ab\u0432\u0438\u043b\u044f\u0442\u044c \u0445\u0432\u043e\u0441\u0442\u043e\u043c\u00bb \u0435\u0449\u0435 \u043c\u0435\u0442\u0440\u043e\u0432 \u0441\u0435\u043c\u044c. \u041d\u043e \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0442\u044c \u0438 \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u0448\u0443 \u0440\u0430\u0431\u043e\u0442\u0443.    \t \t\t   \t<\/p>\n<div class=\"clear\"><\/div>\n<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/178597\/\"> http:\/\/habrahabr.ru\/post\/178597\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\">   \t\u0414\u043e\u0431\u0440\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0441\u0443\u0442\u043e\u043a!<\/p>\n<p>  \u041a\u0430\u043a \u0438 \u043e\u0431\u0435\u0449\u0430\u043b \u044f \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0443 \u0441\u0432\u043e\u0439 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0439 <a href=\"http:\/\/habrahabr.ru\/post\/175017\/\">\u043f\u043e\u0441\u0442<\/a> \u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u044b\u043c \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435\u043c \u044d\u043b\u0435\u043a\u0442\u0440\u043e\u043d\u043d\u043e\u0439 \u043d\u0430\u0447\u0438\u043d\u043a\u0438 \u0438 \u041f\u041e.<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/35e\/3a6\/76d\/35e3a676dc63f78243127b368cbfed05.jpg\"\/><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-178597","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/178597","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=178597"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/178597\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=178597"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=178597"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=178597"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}