Subversion Repositories HomeAutomation

Rev

Rev 1543 | Blame | Compare with Previous | Last modification | View Log | SVN | RSS feed

  1. #ifndef SNS_INPUTANALOG
  2. #define SNS_INPUTANALOG
  3.  
  4. /*-----------------------------------------------------------------------------
  5.  * Includes
  6.  *---------------------------------------------------------------------------*/
  7. /* system files */
  8. #include <avr/io.h>
  9. #include <avr/interrupt.h>
  10. #include <stdio.h>
  11. /* lib files */
  12. #include <config.h>
  13. #include <bios.h>
  14. #include <drivers/can/stdcan.h>
  15. #include <drivers/timer/timer.h>
  16. #include <drivers/mcu/gpio.h>
  17. #include <drivers/adc/adc.h>
  18. #include <drivers/io/PCA95xx.h>
  19.  
  20. //to use PCINT lib. uncomment the line below
  21. //#include <drivers/mcu/pcint.h>
  22.  
  23. void sns_inputAnalog_Init(void);
  24. void sns_inputAnalog_Process(void);
  25. void sns_inputAnalog_HandleMessage(StdCan_Msg_t *rxMsg);
  26. void sns_inputAnalog_List(uint8_t ModuleSequenceNumber);
  27.  
  28. struct sns_inputAnalog_Config{
  29.     uint16_t            LowTh;          //Config, low level threshold voltage
  30.     uint16_t            HighTh;         //Config, high level threshold voltage
  31.     uint16_t            Periodicity;    //Config, periodicity
  32.     uint8_t             Type;           //Config, if sensor is of type periodic or digital input
  33.     uint8_t             PullupEnable;   //Config, if the pullup should be enabled
  34.     uint8_t             RefEnable;      //Config, if the reference to GND should be enabled
  35. } sns_inputAnalog_Config[sns_inputAnalog_NUM_SUPPORTED];
  36.  
  37. #ifndef sns_inputAnalog_USEEEPROM
  38. #define sns_inputAnalog_USEEEPROM 0
  39. #endif
  40.  
  41. #if sns_inputAnalog_USEEEPROM==1
  42.     struct sns_inputAnalog_Data{
  43.         struct sns_inputAnalog_Config Config0;
  44. #if sns_inputAnalog_NUM_SUPPORTED>=2
  45.         struct sns_inputAnalog_Config Config1;
  46. #endif
  47. #if sns_inputAnalog_NUM_SUPPORTED>=3
  48.         struct sns_inputAnalog_Config Config2;
  49. #endif
  50. #if sns_inputAnalog_NUM_SUPPORTED>=4
  51.         struct sns_inputAnalog_Config Config3;
  52. #endif
  53.     }; 
  54. #endif
  55.  
  56. #define TRUE 1
  57. #define FALSE 0
  58.  
  59. #define MAX(a,b) ((a)>(b) ? (a) : (b))
  60. #define MIN(a,b) ((a)<(b) ? (a) : (b))
  61.  
  62. #if sns_inputAnalog0PullupPCA95xx==1 | sns_inputAnalog1PullupPCA95xx==1 | sns_inputAnalog2PullupPCA95xx==1 | sns_inputAnalog3PullupPCA95xx==1 | sns_inputAnalog0RefPCA95xx==1 | sns_inputAnalog1RefPCA95xx==1 | sns_inputAnalog2RefPCA95xx==1 | sns_inputAnalog3RefPCA95xx==1
  63. #define sns_inputAnalog_ENABLE_PCA95xx 1
  64. #else
  65. #define sns_inputAnalog_ENABLE_PCA95xx 0
  66. #endif
  67.  
  68.  
  69. #endif // SNS_INPUTANALOG
  70.