Subversion Repositories HomeAutomation

Rev

Rev 157 | 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.  
  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_OSC/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.  
  49. /*-----------------------------------------------------------------------------
  50.  * Public Function Prototypes
  51.  *---------------------------------------------------------------------------*/
  52. void initTimer(void);
  53. int isTimerOvfl(void);
  54. uint16_t getTimerVal(void);
  55. void setTimerVal(uint16_t value);
  56. int receiveRC5(uint8_t *address, uint8_t *command);
  57. int checkIr(uint8_t *proto, uint8_t *address, uint8_t *command);
  58.  
  59.  
  60.  
  61. #endif /*MCU_H_*/
  62.