Subversion Repositories HomeAutomation

Rev

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

  1. /**
  2.  * @defgroup pcint PCINT Library
  3.  * @code #include <drivers/mcu/pcint.h> @endcode
  4.  *
  5.  * @brief Functions for pcint usage.
  6.  *
  7.  * ...
  8.  *
  9.  * @author  Linus Lundin
  10.  * @date    2009-03-01
  11.  */
  12.  
  13. /**@{*/
  14.  
  15. #ifndef PCINT_H_
  16. #define PCINT_H_
  17. #include <config.h>
  18. #ifndef PCINT_NUM_PCINTS
  19. #   error PCINT_NUM_PCINTS is not defined! Edit config.inc.
  20. #endif
  21.  
  22. /*-----------------------------------------------------------------------------
  23.  * Includes
  24.  *---------------------------------------------------------------------------*/
  25. #include <inttypes.h>
  26. #include <stdio.h>
  27.  
  28. /*-----------------------------------------------------------------------------
  29.  * Defines
  30.  *---------------------------------------------------------------------------*/
  31.  
  32. /**
  33.  * @brief Definition for ...
  34.  *
  35.  * When passed as the type argument to ...
  36.  */
  37.  
  38. /*-----------------------------------------------------------------------------
  39.  * Public Types
  40.  *---------------------------------------------------------------------------*/
  41.  
  42. /**
  43.  * @brief Type of the callback function pointer
  44.  */
  45. typedef void (*pcintCallback_t)(uint8_t);
  46.  
  47. /*-----------------------------------------------------------------------------
  48.  * Public Function Prototypes
  49.  *---------------------------------------------------------------------------*/
  50.  
  51. /**
  52.  * @brief Initializes a pin-change interupt and activate callbacks.
  53.  *
  54.  * @param pcint_id
  55.  *      The PCINT id (0<=pcint_id<PCINT_NUM_PCINTS).
  56.  * @param pcintBit
  57.  *      ...
  58.  * @param callback
  59.  *      Pointer to optional callback function on the form
  60.  *      void callback(uint8_t pcint_id). The callback function is called with the
  61.  *      pcint number as the argument whenever the pcint is thrown. It is called
  62.  *      from the interrupt handler and must be very short. Null if not used.
  63.  */
  64. void Pcint_SetCallback(uint8_t pcint_id, uint8_t pcintBit, pcintCallback_t callback);
  65.  
  66.  
  67. /**
  68.  * @brief Initializes a pin-change interupt and activate callbacks.
  69.  *
  70.  * @param pcint_id
  71.  *      The PCINT id (0<=pcint_id<PCINT_NUM_PCINTS).
  72.  * @param allInTheMiddle
  73.  *      Use the standard pin definitions in GPIO
  74.  * @param callback
  75.  *      Pointer to optional callback function on the form
  76.  *      void callback(uint8_t pcint_id). The callback function is called with the
  77.  *      pcint number as the argument whenever the pcint is thrown. It is called
  78.  *      from the interrupt handler and must be very short. Null if not used.
  79.  */
  80. static inline __attribute__ ((always_inline)) void Pcint_SetCallbackPin(uint8_t pcint_id, volatile uint8_t* port, volatile uint8_t* pin, volatile uint8_t* ddr,uint8_t nr, uint8_t pcint, pcintCallback_t callback) {Pcint_SetCallback(pcint_id, pcint, *callback);}
  81.  
  82. /**@}*/
  83. #endif /*PCINT_H_*/
  84.