blob: 7d74c6e06244af1832d5bffd447faf42cf9233b6 [file] [log] [blame]
lowRISC Contributors802543a2019-08-31 12:12:56 +01001#ifndef _F_LIB_RV_TIMER_H__
2#define _F_LIB_RV_TIMER_H__
3
4#include <stdbool.h>
5#include <stddef.h>
6#include <stdint.h>
7
8/**
9 * Set hart timer prescaler
10 *
11 * Program hart timer prescaler to produce 1us ticks
12 *
13 * @param hart hart selection
14 */
15void rv_timer_set_us_tick(uint32_t hart);
16
17/**
18 * Set hart timer compare value
19 *
20 * Program hart timer compare value. When this value is met, an interrupt will
21 * be triggered.
22 *
23 * @param hart hart selection
24 */
25void rv_timer_set_cmp(uint32_t hart, uint64_t cmp);
26
27/**
28 * Enable hart timer to begin counting
29 *
30 * @param hart hart selection
31 * @param en 1 enables timer, 0 disables timer
32 */
33void rv_timer_ctrl(uint32_t hart, bool en);
34
35/**
36 * Set hart timer interrupt enable
37 *
38 * @param hart hart selection
39 * @param en 1 enables interrupt, 0 disables interrupt
40 */
41void rv_timer_intr_enable(uint32_t hart, bool en);
42
43/**
44 * Clear all active interrupts
45 * Interrupt state clearing is W1C (write-one-clear)
46 */
47void rv_timer_clr_all_intrs(void);
48
49#endif // _F_LIB_RV_TIMER_H__