#ifndef REMOTE_H
#define REMOTE_H


/** DMA channel to use */
#define  RC_DMACHANNEL   1


/** Timer ticks per microsecond. */
#define  TICKS_PER_uS    5


/** Queue length for received keycodes */
#define  RC_QUEUE_SIZE   16


/**
 * The treshold value is used to cleanup the timer samples. If two
 * samples have a distance less than RC_TRESHOLD microseconds, they
 * get discarded. Note that this length must be shorter, than the
 * shortest signal length you want to measure.
 *
 * \sa TimerHandler()
 */
#define  RC_TRESHOLD   10


/*
 * Keycode constants
 *
 * All received keycodes are decoded into 32bit long integers,
 * consisting of one key-repeat bit, 4 bits for the detected
 * protocol type and 27 bits for the keycode itself.
 *
 * Bit    31:  key repeat bit
 * Bit 30-27:  IR protocol
 * Bit  26-0:  key code
 */
#define  RCKEY_REPEAT    0x80000000
#define  RCKEY_PROTO     0x78000000
#define  RCKEY_CODE      0x07FFFFFF

#define  RCKEY_NONE      0x00000000
#define  RCKEY_RC5       0x08000000
#define  RCKEY_NEC       0x10000000
#define  RCKEY_SONY      0x18000000
#define  RCKEY_RECS80    0x20000000
#define  RCKEY_DENON     0x28000000
#define  RCKEY_MOTOROLA  0x30000000
#define  RCKEY_JAPAN     0x38000000
#define  RCKEY_SAMSUNG   0x40000000
#define  RCKEY_DAEWOO    0x48000000


// RC5 decoder settings
//
#define  RC5_SHORT       889
#define  RC5_LONG        (RC5_SHORT * 2)
#define  RC5_MARGIN      (RC5_SHORT / 2)

// NEC decoder settings
//
#define  NEC_PULSE       560
#define  NEC_START1      (NEC_PULSE * 16)
#define  NEC_START2      (NEC_PULSE * 8)
#define  NEC_REPEAT      (NEC_PULSE * 4)
#define  NEC_PAUSE0      (NEC_PULSE * 1)
#define  NEC_PAUSE1      (NEC_PULSE * 3)
#define  NEC_MARGIN      (NEC_PULSE / 2)

// SAMSUNG decoder settings
//
#define  SAM_PULSE       560
#define  SAM_START1      (SAM_PULSE * 8)
#define  SAM_START2      (SAM_PULSE * 8)
#define  SAM_PAUSE0      (SAM_PULSE * 1)
#define  SAM_PAUSE1      (SAM_PULSE * 3)
#define  SAM_MARGIN      (SAM_PULSE / 2)
#define  SAM_REPEATMS    120

extern  int            RC_KeyAvail();
extern  unsigned long  RC_GetKey();

extern  void           RC_Init();
extern  void           RC_Done();

#endif