#if !defined(__DEFS_H__)
#define __DEFS_H__

/* 最大8つのMCP23017を接続可能 */ 
#define MAX_IO_MODULE             8

/* 1つのMCP23017あたりの接続ポイント数 */ 
#define N_TURNOUTS_PER_IO_MODULE  8

/* 接続可能なポイントの総数 */
#define MAX_N_TURNOUTS   (MAX_IO_MODULE * N_TURNOUTS_PER_IO_MODULE)

/* 7セグメントLED表示用エラーコード */
#define ERR_NO_MEMORY   "E1" /* EEPROM接続無し */
#define ERR_NO_MCP20317 "E2" /* MCP23017接続無し */
#define ERR_R_ILLCMD    "E3" /* 経路データ:コマンドエラー */
#define ERR_R_SYNTAX    "E4" /* 経路データ:書式エラー */
#define ERR_R_ORDERING  "E5" /* 経路データ:順序エラー */
#define ERR_R_MISSING   "E6" /* 経路データ:欠落エラー */
#define ERR_R_NONTERM   "E7" /* 経路データ:行終端エラー */
#define ERR_R_TURNOUT   "E8" /* 経路データ:ポイント番号範囲外 */

/* 動作種別 */
enum action_e {
  ACTION_VALIDATE = 0,
  ACTION_DISPLAY,
  ACTION_OPERATION,
};

/* 開通方向 */
enum turnout_dir_e {
  TURNOUT_DIR_NORMAL = 0, /* 定位 */
  TURNOUT_DIR_REVERSE     /* 反位 */
};

extern uint8_t        io_module_table[];
extern uint16_t       n_routes;

extern void display_number(uint16_t n);
extern void display_turnout_and_dir(uint16_t p,
                                    enum turnout_dir_e tdir);

#endif /*__DEFS_H__*/
