/* --------------------------------------------------------------------------- * dio.h - v0.1 (c) 2007 Micro-key bv * --------------------------------------------------------------------------- * Micro-key bv * Industrieweg 28, 9804 TG Noordhorn * Postbus 92, 9800 AB Zuidhorn * The Netherlands * Tel: +31 594 503020 * Fax: +31 594 505825 * Email: support@microkey.nl * Web: www.microkey.nl * --------------------------------------------------------------------------- * Description: Digital inputs/outputs interface. * --------------------------------------------------------------------------- * Version(s): 0.1, 10-09-2007, Marcel Mulder. * Creation. * --------------------------------------------------------------------------- */ #ifndef __DIO_H__ #define __DIO_H__ /** \file dio.h \brief Digital inputs/outputs interface. */ /* --------------------------------------------------------------------------- * System include files. * --------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------- * Application include files. * --------------------------------------------------------------------------- */ #include "lpc23xx.h" #include "types.h" /* --------------------------------------------------------------------------- * Constant and macro definitions. * --------------------------------------------------------------------------- */ /** Maximum number of digital inputs*/ //const UINT8 maxDI_Channels = 11; #define maxDI_Channels (11) /** Maximum number of digital outputs*/ //const UINT8 maxDO_Channels = 8; #define maxDO_Channels (8) /* --------------------------------------------------------------------------- * Type definitions. * --------------------------------------------------------------------------- */ typedef void (*t_dio_callbackfunc)(void); typedef enum { RISING_EDGE, /**< Generates interrupt on rising edge*/ FALLING_EDGE, /**< Generates interrupt on falling edge*/ BOTH_EDGES /**< Generates interrupt on both edges*/ } t_di_mode; typedef struct t_OUTPUT { UINT32 portBaseAddr; UINT32 pinMask; } t_output; typedef struct t_CALLBACKLISTITEM { t_dio_callbackfunc pCallback; t_di_mode mode; struct t_CALLBACKLISTITEM *next; } t_callbackListItem; typedef struct t_INPUT { UINT32 portBaseAddr; UINT32 pinMask; t_callbackListItem *pCallbackList; } t_input; /* --------------------------------------------------------------------------- * Variable declarations. * --------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------- * Function declarations. * --------------------------------------------------------------------------- */ /** \brief Initialize DIO.*/ void dioInit (void); void dio_inMuxEn (BOOLEAN mode); void dio_outMuxEn (BOOLEAN mode); BOOLEAN dio_inMuxRB (void); BOOLEAN dio_outMuxRB (void); /** \brief Register callback function digital input events defined in mode (rising, falling edge or both) */ RESULT dioRegisterCallback( t_dio_callbackfunc pFunc, /**< Function pointer to callback function */ UINT8 channel, /**< 0..10 = valid, 11..255 = future use */ t_di_mode mode ); /** \brief Remove register callback function for digital input*/ RESULT dioRemoveCallback( t_dio_callbackfunc pFunc, UINT8 channel ); /** \brief Read digital input.*/ BOOLEAN dioRead ( UINT8 device, /**< 0 = Self, 1..32 = Remote device */ UINT8 channel /**< 0..10 = valid, 11..255 = future use */ ); /** \brief Readback digital outputs.*/ BOOLEAN dioReadBack ( UINT8 device, /**< 0 = Self, 1..32 = Remote device */ UINT8 channel /**< 0..7 = valid, 8..255 = future use */ ); /** \brief Write digital outputs.*/ void dioWrite ( UINT8 device, /**< 0 = Self, 1..32 = Remote device */ UINT8 channel, /**< 0..7 = valid, 8..255 = future use */ BOOLEAN data ); void dioSetDechatterTime( UINT8 channel, UINT32 time ); #endif /* __DIO_H__ */