#ifndef SCMT_CONFIG_H_
#define SCMT_CONFIG_H_

/* Activate measurement functions. Provide dummy functions otherwise */
#ifndef MEASURE_TIME
#define MEASURE_TIME (0)
#endif

/* Replace printing by dummy function. This will keep timer init, but removes impact of printing on system performance */
#ifndef MEASURE_TIME_NOPRINT
#define MEASURE_TIME_NOPRINT (0)
#endif

/* Only first IPL should init the timer.
   In case of bus access issues, you can check addresses and register values with SCMT_DEBUG.
   (Dont forget to add a call to scmt_module_start then and set debug level to NOTICE(2). ) */
#define SCMT_INIT   (1)
#define SCMT_DEBUG  (0)

/* SCMT base address */
/* V4H:0xE6040000 */
/* V4H-ICUMX:  0xFC000000 + (13*0x00200000) + 0x00040000 = 0xFDA40000 */
#define SCMT_BASE   (0xFDA40000)

/* For boot time measurement, you can signal the start of SCMT by GPIO pin toggle */
/* See code for adaption of toggled pin */
#define SCMT_TOGGLE_GPIO (1)

/* SCMT is counting with OSCCLK = 131.57 kHz */
/* Tick = 7.6 µs*/
/* Full 32-bit wrap around therefore: 32643 seconds == 9.07 hours */
/* NOTE: WRAPAROUND HANDLING NOT IMPLEMENTED! */
#define SCMT_MS2TICKS(ms) ((ms)*131.579)

/* If the startup time until start of SCMT is known, we can set it as start value of the timer to see absolute time right away */
//#define SCMT_START_VALUE (0)    /* No offset, add offset using your spreadsheet program */
//#define SCMT_START_VALUE (2750) /* 20.9ms with MODEMR[1:0]: 0x0 0x801105a4 > ICUMX Boot from HyperFlash 160MHz, Unsecure Boot */
//#define SCMT_START_VALUE (2842) /* 21.6ms with MODEMR[1:0]: 0x0 0x801105a4 > ICUMX Boot from HyperFlash 80MHz, Unsecure Boot */
//#define SCMT_START_VALUE (2974) /* 22.6ms with MODEMR[1:0]: 0x0 0x801105a8 > ICUMX Boot from SerialFlash 133MHz QuadIO, Unsecure Boot */
//#define SCMT_START_VALUE (3237) /* 24.6ms with MODEMR[1:0]: 0x0 0x801105a8 > ICUMX Boot from SerialFlash 80MHz QuadIO, Unsecure Boot */
#define SCMT_START_VALUE (7184) /* 54.6ms with MODEMR[1:0]: 0x0 0x801105a8 > ICUMX Boot from SerialFlash 40MHz, Unsecure Boot */

/* Start a little self-test routine to check Timer-Frequency against baudrate */
/* #define TIMER_TEST_VS_BAUD (921600) */
#define TIMER_TEST_VS_BAUD (0)

/* SCMT frequency slightly depends on MD-Pin settings!! See V4H UM Table 8.1.4e Note 5 */
#define TIMER_FREQ (131578.9)

/* Module name show in log output */
#define MODULE "ICUMX:"

/* Arry size for time checkpoints */
#define TIME_CHECKPOINTS_MAX (20)

/* Print additional infos about compiler or MODEMR register */
#define PRINT_INFO (1)

/* Calculates milliseconds from timer ticks. May be disabled if compiler is currently not prepared to handle floats */
#define PRINT_FLOAT (1)

/* PRINTING
   You need to configure a way to hook into the systems print functionality
*/

/* Uses the ERROR macro defined by log.h - Works for ICUMX and CR Core */
#include <log.h>          /* Access to ERROR() print function */
#define PRINTFN(args...) ERROR(args)

/* Uses facilities provided by Dummy_CA76 application */
//#define USE_LOG_PRINTF (1)
//void log_printf(const char *fmt, ...); /* Provided by scmt_checkpoint_log.c */
//int32_t PutChar(char outChar);         /* Provided by devdrv.c */
//#define PRINTFN(args...) {log_printf(args);}
//#define PUTFN(outChar) PutChar(outChar)




#endif
