aboutsummaryrefslogtreecommitdiff
path: root/ports/nrf/drivers/ticker.h
blob: 6ac87cd503623e6da957624823780739d04380a1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#ifndef __MICROPY_INCLUDED_LIB_TICKER_H__
#define __MICROPY_INCLUDED_LIB_TICKER_H__

/*************************************
 * 62.5kHz (16µs cycle time) ticker.
 ************************************/

#include "nrf.h"

typedef void (*callback_ptr)(void);
typedef int32_t (*ticker_callback_ptr)(void);

void ticker_init(callback_ptr slow_ticker_callback);
void ticker_start(void);
void ticker_stop(void);

int clear_ticker_callback(uint32_t index);
int set_ticker_callback(uint32_t index, ticker_callback_ptr func, int32_t initial_delay_us);

int set_low_priority_callback(callback_ptr callback, int id);

#define CYCLES_PER_MICROSECONDS 16

#define MICROSECONDS_PER_TICK 16
#define CYCLES_PER_TICK (CYCLES_PER_MICROSECONDS*MICROSECONDS_PER_TICK)
// This must be an integer multiple of MICROSECONDS_PER_TICK
#define MICROSECONDS_PER_MACRO_TICK 6000
#define MILLISECONDS_PER_MACRO_TICK 6

#endif // __MICROPY_INCLUDED_LIB_TICKER_H__