asuro.h介绍

来源:互联网 发布:python自动化股票交易 编辑:程序博客网 时间:2024/05/20 04:48
asuro本身带了些函数库,初次实用asuro可以从这些现成的函数入手。
这些基本函数的声明都在asuro.h中,如下:

  1. /* Init function Processor will be initalized to work correctly */
  2. /*这个函数会使处理器复位到设定的初始状态,必须在程序的开头处调用。如果不调用这个函数,处理器甚至不会与PC终端进行通讯。*/
  3. void Init(void);
  4.  
  5. /* Set Status LED (OFF,GREEN,RED,YELLOW)*/
  6. /* example code set Status LED GREEN */
  7. /* StatusLED(GREEN); */
  8. /*可以通过此函数实现状态LED(D12)的开或关,可用参数OFF,GREEN,RED,YELLOW*/
  9. inline void StatusLED(unsigned char color);
  10. /* function for front LED */
  11. /* example code front LED On */
  12. /* FrontLED(ON); */
  13. /*控制前置LED(D11),参数:ON与OFF*/
  14. inline void FrontLED(unsigned char status);
  15.  
  16. /* function for Back LEDs */
  17. /* example code right LED On left LED Off */
  18. /* BackLED(OFF,ON); */
  19. /*后置LED(D15、D16),参数:ON、OFF。参数1表示左,参数2表示右*/
  20. void BackLED(unsigned char left, unsigned char right);
  21.  
  22. /* Set motor direction (FWD,RWD,BREAK,FREE)*/
  23. /* example code set Direction for right motor to rewind */
  24. /* MotorDir(BREAK,RWD); */
  25. /*控制两个马达的方向,需要在对马达进行速度控制之前调用它。参数:FWD(前)、RWD(后退)、BREAK(减速或突然停止)、FREE(放开控制)*/
  26. inline void MotorDir(unsigned char left_dir, unsigned char right_dir);
  27.  
  28. /* range for motor speed 0..255 */
  29. /* example code set speed for left motor to 150 */
  30. /* MotorSpeed(150,0); */
  31. /*供给马达的电能,表示速度,0-255,达到60开始运转*/
  32. inline void MotorSpeed(unsigned char left_speed, unsigned char right_speed);
  33.  
  34. /* function for serial communication */
  35. void SerWrite(unsigned char *data,unsigned char length);
  36. /* timeout = 0 => bloking mode !!! */
  37. void SerRead(unsigned char *data, unsigned char length, unsigned int timeout);
  38.  
  39. /* function to read out line follow phototransistors (left,rigth) */
  40. /*将底部光感器(T9、T10)的强度读到参数中(通常参数是长2的整形数组),强度范围0-1023*/
  41. void LineData(unsigned int *data);
  42.  
  43. /* function to read out odometrie phototransistors (left,rigth) */
  44. /*点亮LED(D13、D14),将T11、T12的值存到data数组中*/
  45. void OdometrieData(unsigned int *data);
  46.  
  47. /* function to read out switches */
  48. /*扫描触碰开关的状态,返回1个字节。K6-K1分别对应第0位到第5位*/
  49. unsigned char PollSwitch (void);
  50. /* for working with Interrupt */
  51. void StartSwitch(void);
  52. void StopSwitch(void);
  53.  
  54. /* Sleep function using 36kHz counter */
  55. /*处理器等待.单位为72khz,即1/72000秒*/
  56. void Sleep(unsigned char timer36kHz);
  57. /* ----------- END ------------ */ 
这些函数的实现全部在asuro.c中。