2020-02-15 22:09:55 +01:00
|
|
|
/* Reflow Oven Controller
|
|
|
|
*
|
|
|
|
* Copyright (C) 2020 Mario Hüttel <mario.huettel@gmx.net>
|
|
|
|
*
|
|
|
|
* This file is part of the Reflow Oven Controller Project.
|
|
|
|
*
|
|
|
|
* The reflow oven controller is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* GDSII-Converter is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with the reflow oven controller project.
|
|
|
|
* If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2020-02-16 17:35:35 +01:00
|
|
|
/**
|
|
|
|
* @file systick.h
|
|
|
|
*/
|
|
|
|
|
2020-02-02 00:01:08 +01:00
|
|
|
#ifndef __SYSTICK_H__
|
|
|
|
#define __SYSTICK_H__
|
|
|
|
|
|
|
|
#include <stdint.h>
|
2020-05-02 19:06:42 +02:00
|
|
|
#include <stdbool.h>
|
2020-02-02 00:01:08 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Reload value for the systick timer.
|
|
|
|
*
|
|
|
|
* This value has to be configured to set the systick to a one milliscond tick interval
|
2020-06-14 13:25:47 +02:00
|
|
|
* The default value is 16800, which results in a 100us tick for 168 MHz CPU speed
|
2020-02-02 00:01:08 +01:00
|
|
|
*/
|
2020-06-14 13:25:47 +02:00
|
|
|
#define SYSTICK_RELOAD (16800UL)
|
2020-02-02 00:01:08 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Variable used by the systick_wait_ms function
|
|
|
|
*/
|
|
|
|
extern volatile uint32_t wait_tick_ms;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Systemclock in milliseconds.
|
|
|
|
*
|
|
|
|
* This value must not be reset during the whole runtime.
|
2020-06-01 20:45:27 +02:00
|
|
|
* @warning In order to use this, you must assure that the read access is atomic.
|
2020-02-02 00:01:08 +01:00
|
|
|
*/
|
|
|
|
extern volatile uint64_t global_tick_ms;
|
|
|
|
|
2020-06-13 22:47:45 +02:00
|
|
|
/**
|
|
|
|
* @brief Wait counter for the display. This must not be used anywhere else
|
|
|
|
*/
|
2020-06-14 13:25:47 +02:00
|
|
|
extern volatile uint32_t lcd_tick_100us;
|
2020-06-13 22:47:45 +02:00
|
|
|
|
2020-02-02 00:01:08 +01:00
|
|
|
/**
|
|
|
|
* @brief Setup the Systick timer to generate a 1 ms tick
|
|
|
|
*/
|
|
|
|
void systick_setup(void);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Wait for x milliseconds
|
|
|
|
*
|
|
|
|
* This function is not reentrant and must not be called from an interrupt
|
|
|
|
*
|
|
|
|
* @warning Do not use in interrupt context
|
|
|
|
* @param ms wait time in ms
|
|
|
|
*/
|
|
|
|
void systick_wait_ms(uint32_t ms);
|
|
|
|
|
2020-02-25 19:34:23 +01:00
|
|
|
uint64_t systick_get_global_tick();
|
2020-02-02 00:01:08 +01:00
|
|
|
|
2020-06-14 13:35:47 +02:00
|
|
|
void systick_get_uptime_from_tick(uint32_t *days, uint32_t *hours, uint32_t *minutes, uint32_t *seconds);
|
|
|
|
|
2020-05-02 19:06:42 +02:00
|
|
|
bool systick_ticks_have_passed(uint64_t start_timestamp, uint64_t ticks);
|
|
|
|
|
2020-02-02 00:01:08 +01:00
|
|
|
#endif /* __SYSTICK_H__ */
|