Rev 1125 | Details | Compare with Previous | Last modification | View Log | SVN | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 1125 | linlun | 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_ |
||
| 1136 | arune | 16 | #define PCINT_H_ |
| 17 | |||
| 1125 | linlun | 18 | #include <config.h> |
| 19 | #ifndef PCINT_NUM_PCINTS |
||
| 20 | # error PCINT_NUM_PCINTS is not defined! Edit config.inc. |
||
| 21 | #endif |
||
| 1136 | arune | 22 | |
| 23 | #if PCINT_NUM_PCINTS > 0 |
||
| 1125 | linlun | 24 | |
| 25 | /*----------------------------------------------------------------------------- |
||
| 26 | * Includes |
||
| 27 | *---------------------------------------------------------------------------*/ |
||
| 28 | #include <inttypes.h> |
||
| 29 | #include <stdio.h> |
||
| 30 | |||
| 31 | /*----------------------------------------------------------------------------- |
||
| 32 | * Defines |
||
| 33 | *---------------------------------------------------------------------------*/ |
||
| 34 | |||
| 35 | /** |
||
| 36 | * @brief Definition for ... |
||
| 37 | * |
||
| 38 | * When passed as the type argument to ... |
||
| 39 | */ |
||
| 40 | |||
| 41 | /*----------------------------------------------------------------------------- |
||
| 42 | * Public Types |
||
| 43 | *---------------------------------------------------------------------------*/ |
||
| 44 | |||
| 45 | /** |
||
| 46 | * @brief Type of the callback function pointer |
||
| 47 | */ |
||
| 1136 | arune | 48 | typedef void (*pcintCallback_t)(uint8_t, uint8_t); |
| 1125 | linlun | 49 | |
| 50 | /*----------------------------------------------------------------------------- |
||
| 51 | * Public Function Prototypes |
||
| 52 | *---------------------------------------------------------------------------*/ |
||
| 53 | |||
| 54 | /** |
||
| 55 | * @brief Initializes a pin-change interupt and activate callbacks. |
||
| 56 | * |
||
| 57 | * @param pcint_id |
||
| 58 | * The PCINT id (0<=pcint_id<PCINT_NUM_PCINTS). |
||
| 59 | * @param pcintBit |
||
| 60 | * ... |
||
| 61 | * @param callback |
||
| 62 | * Pointer to optional callback function on the form |
||
| 63 | * void callback(uint8_t pcint_id). The callback function is called with the |
||
| 64 | * pcint number as the argument whenever the pcint is thrown. It is called |
||
| 65 | * from the interrupt handler and must be very short. Null if not used. |
||
| 66 | */ |
||
| 67 | void Pcint_SetCallback(uint8_t pcint_id, uint8_t pcintBit, pcintCallback_t callback); |
||
| 68 | |||
| 69 | |||
| 70 | /** |
||
| 71 | * @brief Initializes a pin-change interupt and activate callbacks. |
||
| 72 | * |
||
| 73 | * @param pcint_id |
||
| 74 | * The PCINT id (0<=pcint_id<PCINT_NUM_PCINTS). |
||
| 75 | * @param allInTheMiddle |
||
| 76 | * Use the standard pin definitions in GPIO |
||
| 77 | * @param callback |
||
| 78 | * Pointer to optional callback function on the form |
||
| 79 | * void callback(uint8_t pcint_id). The callback function is called with the |
||
| 80 | * pcint number as the argument whenever the pcint is thrown. It is called |
||
| 81 | * from the interrupt handler and must be very short. Null if not used. |
||
| 82 | */ |
||
| 83 | 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);} |
||
| 1136 | arune | 84 | |
| 85 | #endif /*PCINT_NUM_PCINTS > 0*/ |
||
| 1125 | linlun | 86 | /**@}*/ |
| 87 | #endif /*PCINT_H_*/ |