#ifndef SYSTEM_H_
#define SYSTEM_H_

#include <inttypes.h>
#include "config.h"
#include <avr/io.h>
#include <avr/pgmspace.h>
#include <avr/wdt.h>
#include <avr/interrupt.h>

#ifdef _LONG_ADDR_SPACE_
	#define flash_read_byte(x,y) pgm_read_byte_far(pgm_get_far_address(x)+y)
	#define flash_read_word(x,y) pgm_read_word_far(pgm_get_far_address(x)+y)
	#define flash_read_dword(x,y) pgm_read_dword_far(pgm_get_far_address(x)+y)
#else
	#define flash_read_byte(x,y) pgm_read_byte((uint16_t)(&x)+y)
	#define flash_read_word(x,y) pgm_read_word((uint16_t)(&x)+y)
	#define flash_read_dword(x,y) pgm_read_dword((uint16_t)(&x)+y)
#endif

//#define NULL 0

void _memcopy(volatile uint8_t *src,volatile uint8_t *dest, uint16_t size);
void System_SWReboot();


#endif /* SYSTEM_H_ */