Open FFBoard
Open source force feedback firmware
cppmain.h
Go to the documentation of this file.
1/*
2 * cppmain.h
3 *
4 * Created on: Jan 4, 2020
5 * Author: Yannick
6 */
7
8#ifndef CPPMAIN_H_
9#define CPPMAIN_H_
10
11#include "constants.h"
12
13#ifndef DEFAULTMAIN
14#define DEFAULTMAIN 0
15#endif
16
17#pragma once
18#ifdef __cplusplus
19
20#include "FFBoardMain.h"
21#include "ledEffects.h"
22#include "ClassChooser.h"
23
24
25
26extern "C" {
27#endif
28
29#include "eeprom_addresses.h"
30#include "main.h"
31#include "cmsis_compiler.h"
32
33
34void cppmain();
35void usb_init();
36void tudThread(void *argument);
37
38#ifdef __cplusplus
39}
40
41static inline bool inIsr(){
42 return (__get_PRIMASK() != 0U) || (__get_IPSR() != 0U);
43}
44
45template<class T,class C>
46int8_t cliptest(T v, C l, C h)
47{
48 if(v > h){
49 return 1;
50 }else if(v < l){
51 return -1;
52 }else{
53 return 0;
54 }
55}
56
57template<class T,class C>
58T clip(T v, C l, C h)
59{
60 return { v > h ? h : v < l ? l : v };
61}
62
63uint32_t micros(); // Returns microsecond scaled time
64unsigned long getRunTimeCounterValue(void); // RTOS
65
66void refreshWatchdog(); // Refreshes the watchdog
67
68#endif
69
70
71#endif /* CPPMAIN_H_ */
C
T clip(T v, C l, C h)
Definition: cppmain.h:58
void cppmain()
Definition: cppmain.cpp:30
uint32_t micros()
Definition: cppmain.cpp:116
void refreshWatchdog()
Definition: cppmain.cpp:103
unsigned long getRunTimeCounterValue(void)
Definition: cppmain.cpp:144
void usb_init()
int8_t cliptest(T v, C l, C h)
Definition: cppmain.h:46
static bool inIsr()
Definition: cppmain.h:41
void tudThread(void *argument)