#ifndef __CONFIG_H__
#define __CONFIG_H__

#define MONITOR_KEYWORD __monitor // for IAR

#ifdef __BORLANDC__
#undef MONITOR_KEYWORD
#define MONITOR_KEYWORD
#endif

#ifdef __ARCHELON__
#undef MONITOR_KEYWORD
#define MONITOR_KEYWORD _MONITOR
#endif

// define this for tools without dynamic allocation (i.e. Quadravox)
#ifdef __ARCHELON__
#define CONFIG_NO_MALLOC
#endif

// no inlining
#define INLINE 

//
// Platform definition (SideARM, or RFIO, or...)
//

// define this for testing with Borland C
#ifdef __BORLANDC__
#define CONFIG_PLATFORM_SIM
#endif


#define CONFIG_PLATFORM_SIDEARM
#undef CONFIG_PLATFORM_RFIO

#  if !defined(CONFIG_PLATFORM_SIDEARM) && !defined(CONFIG_PLATFORM_RFIO)
#    error "*** platform not defined! ***"
#  endif

#  if defined(CONFIG_PLATFORM_SIDEARM) && defined(CONFIG_PLATFORM_RFIO)
#    error "*** Platform duplicate definition! ***"
#  endif

//
// SideARM specific defines
//

#ifdef CONFIG_PLATFORM_SIDEARM
// defines SideARM hardware rev
#  undef  CONFIG_SIDEARM_HW_REV3
#  define CONFIG_SIDEARM_HW_REV4

#  if !defined(CONFIG_SIDEARM_HW_REV3) && !defined(CONFIG_SIDEARM_HW_REV4)
#    error "SideARM hardware rev not defined"
#  endif

#  if defined(CONFIG_SIDEARM_HW_REV3) && defined(CONFIG_SIDEARM_HW_REV4)
#    error "SideARM hardware rev duplicate definition"
#  endif

#endif

//
// SideARM environmental MSP430 default feature set
//

#ifdef CONFIG_PLATFORM_SIDEARM
#define CONFIG_INIT_SENSORS
#define CONFIG_EVENTQ_LED
#define CONFIG_INCLUDE_GFI
#undef CONFIG_INCLUDE_GFIPOLL
#undef CONFIG_INCLUDE_RTC
#define CONFIG_GFI_SCAN
#define CONFIG_INCLUDE_KVH
#endif

//
// RFIO board default feature set
//

#ifdef CONFIG_PLATFORM_RFIO
#undef CONFIG_INIT_SENSORS
#undef CONFIG_EVENTQ_LED
#undef CONFIG_INCLUDE_GFI
#undef CONFIG_INCLUDE_RTC
#define CONFIG_INCLUDE_GFIPOLL
#undef CONFIG_GFI_SCAN
#undef CONFIG_INCLUDE_KVH
#endif

#ifndef CONFIG_GFI_SCAN
#warning "*** Ground fault scanning not enabled! ***"
#endif

/*
 * undef either of the two following defines to use the ADC value directly, 
 * commenting either define utilizes a linear curve fit calculated through
 * testing 
 */

#define CONFIG_GFI_USE_LOWSIDE_LINEAR
#undef  CONFIG_GFI_USE_HIGHSIDE_LINEAR

/* undef one or the other */

#define CONFIG_GFI_ED_PERSPECTIVE
#undef  CONFIG_GFI_WAYNE_PERSPECTIVE

#  if !defined(CONFIG_GFI_ED_PERSPECTIVE) && !defined(CONFIG_GFI_WAYNE_PERSPECTIVE)
#    error "Please define a GFI measurement perspective"
#  endif

#  if defined(CONFIG_GFI_ED_PERSPECTIVE) && defined(CONFIG_GFI_WAYNE_PERSPECTIVE)
#    error "GFI measurement perspective duplicate definition"
#  endif


//
// timerb defines
//

#undef CONFIG_TIMERB_4HZ
#define CONFIG_TIMERB_8HZ

//
// adc12 module defines
//

#ifdef CONFIG_TIMERB_4HZ
#define CONFIG_ADC12_KVH_SAMPLES (16)
#define CONFIG_ADC12_KVH_NOTIFY_THRESHOLD (4)
#endif

#ifdef CONFIG_TIMERB_8HZ
#define CONFIG_ADC12_KVH_SAMPLES (24)
#define CONFIG_ADC12_KVH_NOTIFY_THRESHOLD (8)
#endif

#ifndef CONFIG_ADC12_KVH_NOTIFY_THRESHOLD
#define CONFIG_ADC12_KVH_NOTIFY_THRESHOLD (CONFIG_ADC12_KVH_SAMPLES >> 1)
#endif

//
// kvh module defines
//

#define CONFIG_KVH_HIGH_TURN_THRESHOLD_LEVEL (315.0)
#define CONFIG_KVH_LOW_TURN_THRESHOLD_LEVEL  (45.0)

#define CONFIG_KVH_LOW_TURN_THRESHOLD_COUNT (4)
#define CONFIG_KVH_HIGH_TURN_THRESHOLD_COUNT (4)

//
// "wrap": add 360.0 to negative headings, subtract 360.0 to headings > 360.0
// "clip": floor(heading, 0.0) and ceiling(heading, 360.0)
//

#undef  CONFIG_KVH_ZERO_WRAP
#define CONFIG_KVH_ZERO_CLIP

#if defined(CONFIG_KVH_ZERO_CLIP) && defined(CONFIG_KVH_ZERO_WRAP)
#error "choose one zero error handling method"
#endif

#if !defined(CONFIG_KVH_ZERO_CLIP) && !defined(CONFIG_KVH_ZERO_WRAP)
#error "choose one zero error handling method"
#endif

#define CONFIG_KVH_ADC_COUNTS_FLOOR (124)
#define CONFIG_KVH_ADC_COUNTS_CEILING (2358)

//
// cmdproc input buffer size
//
#define CONFIG_INPUT_BUFFER_SIZE (192)

//
// usart0 queue sizes
//
#define CONFIG_USART0_TX_QUEUE_SIZE (32)
#define CONFIG_USART0_RX_QUEUE_SIZE (32)

//
// usart1 queue sizes
//
#define CONFIG_USART1_TX_QUEUE_SIZE (16)
#define CONFIG_USART1_RX_QUEUE_SIZE (16)


// define the total number of commands in cmdparse.c if no malloc
#define CONFIG_CMDPARSE_NUMCMDS (64)

// generic stack used for parsing command strings
#define CONFIG_INCLUDE_GENERIC_STACK

#undef CONFIG_INCLUDE_CORECMDS

#define CONFIG_TIMER_TICKS_PER_SECOND (1)

#endif /* __CONFIG_H__ */
