亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? asuro 013, remote controlled by rc5.c

?? Asuro 小車示例代碼Remote controlled
?? C
?? 第 1 頁 / 共 3 頁
字號:
/*

  ================================================================================

	Program		: Asuro controlled by IR remote control
	Release date	: 2004-09-16
	Author		: Henk van Winkoop

	Build	: 037, 2004-09-16, V2.1
	Build	: 038, 2005-02-01, V2.2, comments enlarged/added


  ================================================================================

  Asuro is remotly controlled by infrared signals according the RC5 standard.
  Use keys: Vol-, Vol+, Prg-, Prg+ and Standby for driving left/right/forward/reverse/stop.

  Remember:
    If Asuro is driving, both engines will draw relatively much current from the batteries.
    The battery voltage will drop significantly.
    The Asuro IR-receiver chip is very sensitive to low voltage.
    So with not fully charged batteries, Asuro may not respond to remote control signals when driving!

  An RC5 signal is 14 bits width.
  2 startbits, a toggle bit, 5 address bits, 6 command bits
  +----+----+----+----+----+----+----+----+----+----+----+----+----+----+
  | S1 | S2 | TG | A4 | A3 | A2 | A1 | A0 | C5 | C4 | C3 | C2 | C1 | C0 |
  +----+----+----+----+----+----+----+----+----+----+----+----+----+----+

  A low  bit starts with a high level, going low  halfway bittime.
  |       |
  +---+   |
  |   |   |
  |   +---+
  |       |

  A high bit starts with a low  level, going high halfway bittime.
  |       |
  |   +---+
  |   |   |
  +---+   |
  |       |

  Each RC5-bit duration is 1778us.


  Asuro contains a 3-pin IR(Infra Red)-signal receive chip. 
  This chip demodulates any received 36KHz infrared signal and outputs a clean digital code.
  If Asuro is beamed with an RC5 remote control, this chip will output a clean RC5 digital code.
  The Asuro IR-chip output is directly connected to the ATMEGA8 (microcontroller) RXD pin.

  Normally, the first bit of a RC5 signal received by the ATMEGA8 RXD pin should generate an interrupt.
  This interrupt then would start a internal ATMEGA8 timer for analysing the next received RC5 bits. 

  The ATMEGA8 RXD pin however can not simply generate an interrupt.
  It only generates an interrupt if a valid serial CHARACTER (complete valid character, not signal)
  is received on the RXD-pin.

  Probably the Asuro was not intended to be used for IR-control.
  So we need to use a little trick.

  The UART generates an interrupt when a valid complete character is received.
  The UART detects a valid character if a low-going startbit is detected and if after a certain time
  (depending on the baudrate) a valid high-level (stopbit) is detected.

  Now we use the low-going edge in the first RC5-startbit (S1) as the UART startbit detection.
  If we set the UART to 4800baud and if we set the expected/received character to have 5 bits,
  then the UART will expect a high-level stopbit in the middle of the high part of our second 
  RC5-startbit (S2)


  |-------------------RC5-code-as-is-generated-by-Asuro-IR-receive-chip-------------------|

  |---startbit1---|---startbit2---|---togglebit---|---address4----|--//---|---command0----|

  |----low-bit----|----low-bit----|-low/high-bit--|-low/high-bit--|--//---|-low/high-bit--|

  |-----1778us----|-----1778us----|-----1778us----|-----1778us----|--//---|-----1778us----|

  |--------------------------------14*1778=24892us----------------------------------------|

  +-------+       +-------+       +-------+-------+-------+-------+--//---+-------+-------+
     S1(h)|  S1(l)|  S2(h)|  S2(l)|  TG   |  TG   |  A4   |  A4   |       |  C0   |  C0   |
          +-------+       +-------+-------+-------+-------+-------+--//---+-------+-------+
 

          |-------------|   expected character-length by UART when UART is set to 4800baud/5bits per character

        ->| |<-             startbit

                    ->| |<- expected stopbit

             0 0 0 1 1   <- received 5-bits data, not important/not used

  --------+ +-+-+-+-+-+-+-------------
          |S|1|2|3|4|5|S
          +-+-+-+-+-+-+|
                       |
                       |<-  halfway stopbit an interrupt is generated by the UART (detecting valid received character)
                       |
  +-------+       +----|--+       +-------+-------+-------+-------+--//---+-------+-------+
     S1(h)|  S1(l)|  S2(h)|  S2(l)|  TG   |  TG   |  A4   |  A4   |       |  C0   |  C0   |
          +-------+       +-------+-------+-------+-------+-------+--//---+-------+-------+

  So it is NOT possible to generate an interrupt in the first RC5-startbit S1 as was first 
  intended but it IS possible to generate an interrupt in the SECOND RC5-startbit S2.
  Because each RC5 code always contains 2 startbits, this is no problem.

  In stead of using 4800baud/5bit we could also have used 9600baud/8bit to let the stopbit occur in the
  high part of the RC5-S2 signal.

  Now we can start the internal ATMEGA8 timer0 to detect the level of the remaining RC5 bits.


                       |<-  here an interrupt is generated by the UART
                       |
  +-------+       +----|--+       +-------+-------+-------+-------+--//---+-------+-------+
     S1(h)|  S1(l)|  S2(h)|  S2(l)|  TG   |  TG   |  A4   |  A4   |       |  C0   |  C0   |
          +-------+       +-------+-------+-------+-------+-------+--//---+-------+-------+



  After the first interrupt, timer/counter0 is used to measure the delay to the next bits.
  As the first timer/counter0 interval (A1-B2) differs from the remaining timer/counter0 intervals (B2-B14), a 
  different timer/counter0 timervalue is used.

  |---startbit1---|---startbit2---|---togglebit---|---address4----|--//---|---command0----|

  |----low-bit----|----low-bit----|-low/high-bit--|-low/high-bit--|--//---|-low/high-bit--|

                  |-----1778us----|
									
          |---------2223us--------|

                       |<-  here an interrupt is generated by the UART
                       |
  +-------+       +----|--+       +-------+-------+-------+-------+--//---+-------+-------+
     S1(h)|  S1(l)|  S2(h)|  S2(l)|  TG   |  TG   |  A4   |  A4   |       |  C0   |  C0   |
          +-------+       +-------+-------+-------+-------+-------+--//---+-------+-------+

                            --|---------------|---------------|-----------------------|----  needed timer0 interrupts
                    ---1---                                                                  timer0 interrupts counter (dummy, predefined)
                           ---2---------------3---------------4----------------------14----  timer0 interrupts counter (updated)
					
  --------+ +-+-+-+-+-+-+-------------
          |S|1|2|3|4|5|S
          +-+-+-+-+-+-+

          |-----1778us----|           (length of one single RC5 bit)

          |---1352us---|              (208us (=1/4800baud) * 6,5 (1 startbit + 5 databits + 0,5 stopbit))

                       |--| 426us     ((A) distance between 4800baud-stopbit/interrupt and RC5-S2 going low)
											 
                          |---| 445us ((B) = 1778/4 = length of a quarter of one RC5-bit)

                       |------| 871us (= (A) + (B) = 426 + 445 = distance between interrupt and half of low half of RC5-S2

  So each time a UART interrupt is generated, timer0 is used to delay the running program for 871us so it will be
  exactly in the middle of the low part of RC5-startbit S2.
  Then for each remaining RC5 bit, timer0 will be used to find the middle of each second-half of each bit .

  Timer0 prescaler output /256 is selected. So timer0 clock frequency is 8MHz / 256 = 31250Hz = 32us period.
  Timer0 is 8-bits wide, so timer0 continuously counts up from 0 to 255 and then resets to 0 again.
  Timer0 generates an interrupt (if enabled) on each 255 to 0 transition.

  To make timer0 delay (first time) 871us, divide it by timer0 clockcycle duration of 32us makes 871/32 = 27 clockcycles.
  To make timer0 delay 27 (0x1B) clockcycles, set it's initial value to 0xFF minus 0x1B = 0xE4. 
  So it will take 27*32 = 864us (closest to 871us) after a UART interrupt when the first timer0 interrupt will occur.

                       |------| 871us (= (A) + (B) = 426 + 445 (871/32=27=0x1B => 0xFF-0x1B=0xE4)


  The USART takes 3 samples in the middle of each bit. Also in the expected stopbit.
  If valid, an interrupt will be generated immediately after detecting a valid stopbit,
  so almost halfway the stopbit, which is approximately halfway the RC5-S2 bit.
	
  The RXD interrupt handler will then disable itself and init timer/counter0 and enable timer/counter0 interrupt.
  When timer/counter0 interrupt handler has detected 1 dummy (RC5-S2) plus 12 real bits, it will disable it's own interrupt.

  Remember: each bit value is checked in the second half part of each bit, because the second half part represents the
  real bit value. But, because a '1' bit in real world is represented by a low voltage level, (due to IR-chip characteristics)
  the bit-value detected must be inverted to represent the real received infrared value.(???)

  Some IR signal info:
	
  Infrared signal carrier frequency     = 36KHz
  Infrared signal carrier bit duration  = 1/36000 = 27,78us

  Each data bit takes 64 carrier bits. so...

   - data bit frequency = 36000/64   = 562,5Hz 
   - data bit size      = 64*27,78us = 1778us 


  ##########  NO NEED TO READ, JUST FOR MY OWN THOUGHTS ##########


  TTTTTTTTTT
  1234567890
	
    +-+ +-+ +-+
    | | | | | |
  +-+ +-+ +-+ +-//
    +-+ +-+-+ +-//
    | | |   | |
  +-+ +-+   +-+

  +---+---+---+---
   S1  S2  TG

  To detect first startbit, be sure that a stopbit is detected at positin 6.
  Set baudrate to 9600, one bit is 104us, 

  Low level from 1st startbit is at t=890us.
  stopbit (bit 8 from 0-7) is from 832us to 936us

  4800baud and 5 bits

  bit    time
  1 =    0 -  207 ns
  2 =  208 -  415 ns
  3 =  416 -  623 ns
  4 =  624 -  831 ns
  5 =  832 - 1039 ns
  S = 1040 - 1247 stopbit is well inside low part T6 (T6=890ns-1780ns) 

  Using baudrate 4800 with 5-bits dataframe will find valid stopbit inside T6.

  If a valid frame is detected then a '1' bit is assumed to be received.
  If a frame error is detected then a '1' bit followed by a '0' bit is assumed to be received.

  This will make the expected 4800baud stopbit detection occur in the high part of the second startbit S2.
  A startbit is detected when S1 is going low. The expected stopbit must be in the high part of S2.
  If the bitrate is set, for instance, to 9600baud (104us) then using 8-bits with 1 startbit and 1 stopbit,
    will expect a stopbit at (1+8+0.5) * 104 = 9.5 * 104 = 988us after S1 going low, is in high part of S2.
    So this bitrate will also work fine.
  The bitrate must be choosen that way, so that the expected stopbit will occur in the high part of S2.

  ##########  END OF NO NEED TO READ, JUST FOR MY OWN THOUGHTS ##########




*/

#include "asuro.h"
#include "hvwdefines.h"

//remote control key codes
#define REMOTE_KEY_STD_BY 12
#define REMOTE_KEY_VOL_UP 16
#define REMOTE_KEY_VOL_DW 17
#define REMOTE_KEY_PRG_UP 32
#define REMOTE_KEY_PRG_DW 33
#define REMOTE_KEY_0       0

#define ASURO_FORWARD      REMOTE_KEY_PRG_UP
#define ASURO_REVERSE      REMOTE_KEY_PRG_DW
#define ASURO_TURN_LEFT    REMOTE_KEY_VOL_UP
#define ASURO_TURN_RIGHT   REMOTE_KEY_VOL_DW
#define ASURO_STOP         REMOTE_KEY_0

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美乱妇23p| 欧美无乱码久久久免费午夜一区| 亚洲一区二区偷拍精品| 亚洲免费观看视频| 亚洲欧美在线观看| 成人欧美一区二区三区小说| 国产精品萝li| 亚洲视频一区二区免费在线观看 | 欧美日韩精品电影| 91国产福利在线| 欧美色图第一页| 欧美日韩国产综合一区二区三区 | 国产另类ts人妖一区二区| 久久精品国产一区二区三| 久久精品国产亚洲一区二区三区| 国产一区二区三区四| 丁香天五香天堂综合| 成人a级免费电影| 91成人在线精品| 欧美一区午夜精品| 久久久国产精品麻豆| 国产精品九色蝌蚪自拍| 亚洲国产精品久久久男人的天堂| 五月婷婷综合激情| 激情文学综合丁香| 色综合久久六月婷婷中文字幕| 欧美在线观看禁18| 久久久久久久久伊人| 综合电影一区二区三区 | 亚洲激情一二三区| 美女一区二区视频| 色综合一个色综合| 欧美日韩亚洲综合一区 | www.性欧美| 337p亚洲精品色噜噜噜| 国产欧美一区二区三区在线看蜜臀| 17c精品麻豆一区二区免费| 一区二区三区不卡视频在线观看| 久久国产精品区| 一本到三区不卡视频| 精品国产一区二区三区不卡| 一区二区三区久久久| 韩国av一区二区三区四区| 一本久道久久综合中文字幕| 久久综合色一综合色88| 亚洲综合在线观看视频| 岛国精品在线观看| 欧美一区二区三区免费大片| 亚洲人快播电影网| 国产一区二区福利视频| 精品视频一区 二区 三区| 中文一区二区在线观看| 激情综合色综合久久综合| 色呦呦一区二区三区| 国产欧美综合在线| 精油按摩中文字幕久久| 欧美一区二区三区婷婷月色| 亚洲综合色婷婷| 94色蜜桃网一区二区三区| 精品国产91洋老外米糕| 视频一区视频二区中文字幕| 色一情一伦一子一伦一区| 国产欧美日韩精品一区| 国产在线乱码一区二区三区| 日韩精品一区二区三区中文不卡| 亚洲国产另类av| 91久久精品日日躁夜夜躁欧美| 国产日产精品1区| 国产美女一区二区| 欧美精品一区二区久久婷婷| 日本亚洲视频在线| 91 com成人网| 蜜桃久久精品一区二区| 欧美一级免费观看| 视频一区二区欧美| 欧美久久久久久蜜桃| 亚州成人在线电影| 欧美人成免费网站| 香蕉av福利精品导航| 4438x亚洲最大成人网| 日韩av网站在线观看| 91精品国产综合久久久蜜臀粉嫩| 日本免费新一区视频| 日韩一区二区三区电影| 久久66热re国产| 久久免费精品国产久精品久久久久 | 国产精品久久看| 99国产精品视频免费观看| 亚洲精品国产高清久久伦理二区| 91黄视频在线观看| 免费观看久久久4p| 久久天堂av综合合色蜜桃网| 国产超碰在线一区| 亚洲福利电影网| 欧美欧美午夜aⅴ在线观看| 免费在线观看日韩欧美| 久久久久久久久久久久电影| 成人性色生活片| 亚洲欧美一区二区不卡| 欧美日本视频在线| 国产九九视频一区二区三区| 中文字幕中文字幕一区二区 | 捆绑变态av一区二区三区| 国产夜色精品一区二区av| 成人av在线资源网站| 亚洲国产精品一区二区www在线| 日韩女优av电影| 92精品国产成人观看免费| 午夜视频在线观看一区二区三区| 久久色中文字幕| 欧美日韩精品一区二区天天拍小说| 精品在线观看免费| 夜夜精品视频一区二区| 久久久99精品久久| 欧美无人高清视频在线观看| 国产在线不卡一卡二卡三卡四卡| 日韩美女久久久| 精品国产乱码91久久久久久网站| 色综合色综合色综合| 国产一区中文字幕| 亚洲综合图片区| 国产精品国产馆在线真实露脸| 欧美福利一区二区| 色哟哟日韩精品| 成人免费va视频| 男男视频亚洲欧美| 亚洲国产精品久久久男人的天堂| 中文字幕第一区第二区| 日韩精品专区在线影院重磅| 欧美性受xxxx黑人xyx性爽| 国产精品香蕉一区二区三区| 美国欧美日韩国产在线播放| 一区二区三区加勒比av| 一区免费观看视频| 国产目拍亚洲精品99久久精品| 91 com成人网| 欧美精品xxxxbbbb| 91福利视频网站| 色激情天天射综合网| 91在线精品一区二区三区| 国产精品888| 国产精品一品视频| 国产在线一区观看| 麻豆精品一二三| 日韩精品色哟哟| 亚洲成人免费观看| 午夜一区二区三区视频| 一区二区不卡在线播放 | 欧美国产禁国产网站cc| 精品国产凹凸成av人导航| 日韩欧美三级在线| 欧美成人女星排名| 精品国产伦一区二区三区观看方式| 91.麻豆视频| 精品国产乱码久久久久久闺蜜| 日韩精品一区二区三区四区视频 | 亚洲成人综合网站| 日本大胆欧美人术艺术动态 | 成人晚上爱看视频| 成人免费视频一区| 99热在这里有精品免费| 99精品国产视频| 在线欧美小视频| 欧美成人精品高清在线播放| 91精品国产综合久久国产大片| 7777精品伊人久久久大香线蕉的| 欧美日韩高清不卡| 欧美一区二区精美| 久久久99精品久久| 亚洲日本护士毛茸茸| 午夜欧美电影在线观看| 免费观看成人鲁鲁鲁鲁鲁视频| 久久99精品国产91久久来源| 成人影视亚洲图片在线| 色视频欧美一区二区三区| 欧美日韩成人在线| 久久久久久免费毛片精品| 中文字幕在线不卡一区二区三区| 亚洲综合男人的天堂| 麻豆精品一区二区| 成人h精品动漫一区二区三区| 欧美日韩一区 二区 三区 久久精品 | 亚洲黄色av一区| 麻豆精品视频在线观看免费| 成人综合激情网| 欧美日韩一区成人| 国产精品午夜电影| 午夜精品久久久久久久99水蜜桃| 国产在线精品一区二区三区不卡 | 7777精品伊人久久久大香线蕉完整版| 精品国产乱码久久久久久浪潮| 亚洲色图在线视频| 乱一区二区av| 在线亚洲人成电影网站色www| 欧美mv日韩mv亚洲| 亚洲图片欧美综合| heyzo一本久久综合| 日韩欧美一区二区久久婷婷| 亚洲欧美日韩一区二区三区在线观看 | 亚洲一区免费视频|