Subversion Repositories HomeAutomation

Rev

Rev 1462 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | SVN | RSS feed

  1. /**
  2.  * @defgroup pca95xx PCA95xx Library
  3.  * @code #include <drivers/io/pca95xx.h> @endcode
  4.  *
  5.  * @brief Functions for using a pca95xx I2C IO-expander.
  6.  *
  7.  * ...
  8.  *
  9.  * @author  Anders Runeson
  10.  * @date    2010-04-01
  11.  */
  12.  
  13. /**@{*/
  14.  
  15. #ifndef PCA9XX_H_
  16. #define PCA9XX_H_
  17.  
  18. #include <config.h>
  19. #ifndef PCA9XX_NUM_CALLBACKS
  20. #define PCA9XX_NUM_CALLBACKS 1
  21. #endif
  22.  
  23. /*-----------------------------------------------------------------------------
  24.  * Includes
  25.  *---------------------------------------------------------------------------*/
  26. #include <inttypes.h>
  27. #include <stdio.h>
  28.  
  29. /*-----------------------------------------------------------------------------
  30.  * Defines
  31.  *---------------------------------------------------------------------------*/
  32.  
  33.  
  34. /*-----------------------------------------------------------------------------
  35.  * Public Types
  36.  *---------------------------------------------------------------------------*/
  37.  
  38. /**
  39.  * @brief Type of the callback function pointer
  40.  */
  41. typedef void (*pca9xxCallback_t)(uint8_t, uint8_t);
  42.  
  43. /*-----------------------------------------------------------------------------
  44.  * Public Function Prototypes
  45.  *---------------------------------------------------------------------------*/
  46.  
  47. /**
  48.  * @brief Stores a callback for an io interrupt.
  49.  *
  50.  * @param callback
  51.  *      Pointer to optional callback function on the form
  52.  *      void callback(uint16_t inputs). The callback function is called with the
  53.  *      port status as the argument whenever the interrupt is thrown. It is called
  54.  *      from the interrupt handler and must be very short.
  55.  */
  56. void Pca95xx_SetCallback(pca9xxCallback_t callback);
  57.  
  58. /**
  59.  * @brief Poll the PCA95xx for the input status.
  60.  *
  61.  * Reads the input status of the PCA95xx and returns the data.
  62.  *
  63.  * @retval
  64.  *      The input registers.
  65.  */
  66. uint16_t Pca95xx_GetInputs(void);
  67.  
  68. /**
  69.  * @brief Sets the PCA95xx outputs.
  70.  *
  71.  * @param Outputs
  72.  *      The data to be set as outputs.
  73.  * @param Mask
  74.  *      Passing a mask makes it possible to set one or more output without
  75.  *      affecting the other ports. Set bit to 1 to set the corresponding
  76.  *      port bit to the value of the Output parameter bit.
  77.  */
  78. void Pca95xx_SetOutputs(uint16_t Outputs, uint16_t Mask);
  79.  
  80. /**
  81.  * @brief Sets the PCA95xx port direction.
  82.  *
  83.  * @param Direction
  84.  *      The data to be used for setting port direction.
  85.  * @param Mask
  86.  *      Passing a mask makes it possible to set direction for one or more
  87.  *      ports without affecting the others. Set bit to 1 to set the
  88.  *      corresponding direction bit to the value of the Direction parameter
  89.  *      bit.
  90.  */
  91. void Pca95xx_SetDirection(uint16_t Direction, uint16_t Mask);
  92.  
  93.  
  94. /**@}*/
  95. #endif /*PCA9XX_H_*/
  96.