/*
 * \file stm32f10x_systick.h
 * \brief   Provides systick timer functionality.
 *
 * Copyright (C) 2013 Houtouridis Christos <houtouridis.ch@gmail.com>
 * All Rights Reserved.
 *
 * NOTICE:  All information contained herein is, and remains
 * the property of Houtouridis Christos. The intellectual
 * and technical concepts contained herein are proprietary to
 * Houtouridis Christos and are protected by copyright law.
 * Dissemination of this information or reproduction of this material
 * is strictly forbidden unless prior written permission is obtained
 * from Houtouridis Christos.
 *
 * Author:     Houtouridis Christos <houtouridis.ch@gmail.com>
 * Date:       11/2013
 * Version:    0.2
 */

#ifndef __stm32f10x_systick_h__
#define __stm32f10x_systick_h__

#ifdef __cplusplus
extern "C" {
#endif

#include <stm32f10x.h>
#include <stm32f10x_clock.h>
#include <sys/types.h>

#define ST_MAX_CRONTAB_ENTRIES      (10)

#ifndef __weak
#define __weak __attribute__ ((weak))
#endif

/*
 * Also defined in types.h
 */
#ifndef  _CLOCK_T_
#define  _CLOCK_T_   unsigned long     /* clock() */
typedef _CLOCK_T_ clock_t;             /*!< CPU time type */
#endif
#ifndef _TIME_T_
#define  _TIME_T_ long                 /* time() */
typedef _TIME_T_ time_t;               /*!< date/time in unix secs past 1-Jan-70 type for 68 years*/
#endif


typedef void (*cronfun_t) (void);      /*!< Pointer to void function (void) to use with cron */

/*!
 * Cron Table data type
 */
typedef struct
{
   cronfun_t   fun;
   clock_t     tic;
}CronTab_t;


/* ======== Core Functionalities ============ */
extern void SysTick_Callback (void);

void SysTick_DeInit (void);
void SysTick_Init (clock_t sf);


/* ======== OS like Functionalities ============ */

clock_t get_freq (void);
int set_freq (clock_t f);


#ifdef __cplusplus
}
#endif

#endif   //#ifndef __stm32f10x_systick_h__
