/** @file stk_regs.h
 * Module defining systick (STK) registers.
 *
 * Mainly made to be used by the stk module. It is recommanded to go through
 * the functions provided by that module instead of directly using the registers
 * defined here.
 */

#ifndef _STK_REGS_H_
#define _STK_REGS_H_

//--includes--------------------------------------------------------------------

#include <stdint.h>


//--type definitions------------------------------------------------------------

#define STK_BASE_ADDRESS 0xE000E010

union STK_CTRL {
	struct {
		uint32_t ENABLE:1;
		uint32_t TICKINT:1;
		uint32_t CLKSOURCE:1;
		uint32_t reserved1:13;
		uint32_t COUNTFLAG:1;
		uint32_t reserved2:15;
	};
	uint32_t word;
};

union STK_LOAD {
	struct {
		uint32_t RELOAD:24;
		uint32_t reserved1:8;
	};
	uint32_t word;
};

union STK_VAL {
	struct {
		uint32_t CURRENT:24;
		uint32_t reserved1:8;
	};
	uint32_t word;
};

union STK_CALIB {
	struct {
		uint32_t TENMS:24;
		uint32_t reserved1:6;
		uint32_t SKEW:1;
		uint32_t NOREF:1;
	};
	uint32_t word;
};

struct STK {
	union STK_CTRL CTRL;
	union STK_LOAD LOAD;
	union STK_VAL VAL;
	union STK_CALIB CALIB;
};


//--functions-------------------------------------------------------------------

#endif //_STK_REGS_H_

