#ifndef _APP_SERV_H_
#define _APP_SERV_H_

#include "app_cfg.h"

extern CPU_INT32U incas_bill_nom_counter[24];
extern CPU_INT32U incas_common_bill_counter;

#define   KBRD_TASK_STK_SIZE        256
#define   USER_TASK_STK_SIZE        384
#define   MENU_TASK_STK_SIZE        512
#define   COIN_TASK_STK_SIZE        384
#define   VALIDATOR_TASK_STK_SIZE   384
#define   FISCAL_TASK_STK_SIZE      384
#define   MODEM_TASK_STK_SIZE       768


#define   VALIDATOR_TASK_PRIO   USER_HIGHEST_PRIO
#define   USER_TASK_PRIO        (USER_HIGHEST_PRIO+1)
#define   COIN_TASK_PRIO        (USER_HIGHEST_PRIO+2)
#define   KBRD_TASK_PRIO        (USER_HIGHEST_PRIO+3)
#define   FISCAL_TASK_PRIO      (USER_HIGHEST_PRIO+4)
#define   MENU_TASK_PRIO        (USER_HIGHEST_PRIO+5)
#define   MODEM_TASK_PRIO       USER_LOWEST_PRIO

enum{
  EVENT_SEC = 1,
  EVENT_STARTUP,
  
  EVENT_COIN_INSERTED,
  EVENT_BILL_ESCROW,
  EVENT_BILL_STACKED,
  
  EVENT_MODE_CHANGE,
  
  EVENT_KEY_EMPTY,
  EVENT_KEY_F1,
  EVENT_KEY_F2,
  EVENT_KEY_F3,
  EVENT_KEY_LEFT,
  EVENT_KEY_UP,
  EVENT_KEY_RIGHT,
  EVENT_KEY_STOP,
  EVENT_KEY_DOWN,
  EVENT_KEY_START,
  EVENT_KEY_USER_START,
  EVENT_KEY_DEFERRED_CH1,
  EVENT_KEY_DEFERRED_CH2,
  EVENT_KEY_DEFERRED_CH3,
  EVENT_KEY_DEFERRED_CH4,
  EVENT_KEY_DEFERRED_CH5,
  EVENT_KEY_DEFERRED_CH6,
  EVENT_KEY_DEFERRED_CH7,
  EVENT_KEY_DEFERRED_CH8,
  EVENT_KEY_DEFERRED_CH9,
  EVENT_KEY_DEFERRED_CH10,

  EVENT_INCASSATION,
  EVENT_INCASSATION_FINISH
};

#define LED_on()   {FIO1SET_bit.P1_21= 1;}
#define LED_off()  {FIO1CLR_bit.P1_21= 1;}

extern void UserStartupFunc(void);
extern void PostUserEvent(int event);

extern void InitUserMenu(void);
extern int GetRecentChannelPrice(CPU_INT08U ch, CPU_INT32U* price, CPU_INT32U* time);

#endif //#ifndef _APP_SERV_H_
