#ifndef _MAIN_H_
#define _MAIN_H_

// IO definitions
#define PIN_LED_ONBOARD     PIN5_bm // PORT B
#define PIN_BUTTON          PIN0_bm // PORT C
#define PIN_LED_BUTTON      PIN1_bm // PORT C
#define PIN_BUZZER          PIN2_bm // PORT C
#define PIN_SPARE           PIN3_bm // PORT C

// RTC definitions
#define RTC_PERIOD  1024    // 32768 Hz / prescaler (32) / 1024 = 1 second

// Serial definitions
#define PIN_TX  PIN2_bm
#define PIN_RX  PIN3_bm
#define PIN_DIR PIN4_bm
#define SERIAL_BAUDRATE 1389    // 9600 baud

volatile unsigned char serialRXbuffer;                      // the buffer to hold the response byte
volatile unsigned char serialTXbuffer[PROTOCOL_FRAME_SIZE]; // the buffer to hold the received bytes
volatile unsigned char serialTXbufferIndex;                 // the pointer to the current locatin in the buffer

#define ALIASserialGetRS485Mode          (PORTB.IN &= PIN_DIR)      // check the RS485 mode
#define ALIASserialSetRS485ModeSend      (PORTB.OUT |= PIN_DIR)     // set the RS485 mode to send
#define ALIASserialSetRS485ModeReceive   (PORTB.OUT &= ~PIN_DIR)    // set the RS485 mode to receive

// game definitions
#define GAMESTATE_INIT  0
#define GAMESTATE_RUNNING  1
#define GAMESTATE_FINISHED  3

volatile unsigned char gameState;   // record the current state of the game
volatile unsigned char gameLevel;   // record the difficulty

#endif