Subversion Repositories HomeAutomation

Rev

Rev 201 | Blame | Last modification | View Log | SVN | RSS feed

  1. #ifndef IR_H_
  2. #define IR_H_
  3.  
  4.  
  5. /*-----------------------------------------------------------------------------
  6.  * Includes
  7.  *---------------------------------------------------------------------------*/
  8. #include <stdio.h>
  9. #include <bios.h>
  10.  
  11. /*-----------------------------------------------------------------------------
  12.  * Defines
  13.  *---------------------------------------------------------------------------*/
  14. #define IRPORT  PORTD
  15. #define IRPIN   PIND
  16. #define IRDDR   DDRD
  17. #define IRBIT   PD2
  18.  
  19. #define IR_OK               1
  20. #define IR_FAILED           -1  //?
  21. #define IR_NO_PROTOCOL      2
  22. #define IR_TIME_OVFL        3
  23. #define IR_NO_DATA          4
  24.  
  25. #define CYCLES_PER_US       (F_CPU/1000000)
  26.  
  27. #define IR_PROTO_RC5        0
  28. #define IR_RC5_ST_BIT       864*CYCLES_PER_US       //us
  29. #define IR_RC5_BIT          864*2*CYCLES_PER_US
  30. #define IR_RC5_TIMEOUT      105     //ms
  31.  
  32. #define IR_PROTO_RC6        1
  33. #define IR_RC6_ST_BIT       1*CYCLES_PER_US     //us
  34. #define IR_RC6_TIMEOUT      1       //ms
  35.  
  36. #define IR_PROTO_RCMM       2
  37. #define IR_RCMM_ST_BIT      256*CYCLES_PER_US       //us //Wont work together with SHARP
  38. #define IR_RCMM_TIMEOUT     158     //ms
  39.  
  40. #define IR_PROTO_SIRC       3
  41. #define IR_SIRC_ST_BIT      2400*CYCLES_PER_US  //us
  42. #define IR_SIRC_TIMEOUT     40      //ms
  43.  
  44. #define IR_PROTO_SHARP      4
  45. #define IR_SHARP_ST_BIT     275*CYCLES_PER_US       //us //Wont work together with RCMM
  46. #define IR_SHARP_TIMEOUT    55      //ms
  47.  
  48. #define IR_MIN_REPEATE_PULSE_WIDTH  200
  49. #define IR_MAX_REPEATE_PULSE_WIDTH  40000
  50.  
  51.  
  52. /*-----------------------------------------------------------------------------
  53.  * Public Function Prototypes
  54.  *---------------------------------------------------------------------------*/
  55. void initTimer(void);
  56. int isTimerOvfl(void);
  57. uint16_t getTimerVal(void);
  58. void setTimerVal(uint16_t value);
  59. int receiveRC5(uint8_t *address, uint8_t *command);
  60. int checkIr(uint8_t *proto, uint8_t *address, uint8_t *command);
  61. int checkIrIdle(void);
  62. uint16_t getLastProtoTimeout(void);
  63.  
  64.  
  65. #endif /*MCU_H_*/
  66.