Numworks Epsilon
1.4.1
Graphing Calculator Operating System
tim.h
Go to the documentation of this file.
1
#ifndef REGS_TIM_H
2
#define REGS_TIM_H
3
4
#include "
register.h
"
5
6
class
TIM
{
7
public
:
8
class
CR1
:
Register16
{
9
public
:
10
REGS_BOOL_FIELD
(CEN, 0);
11
REGS_BOOL_FIELD
(ARPE, 7);
12
};
13
14
class
CCMR
:
Register64
{
15
/* We're declaring CCMR as a 64 bits register. CCMR doesn't exsist per se,
16
* it is in fact the consolidation of CCMR1 and CCMR2. Both are 16 bits
17
* registers, so one could expect the consolidation to be 32 bits. However,
18
* both CCMR1 and CCMR2 live on 32-bits boundaries, so the consolidation has
19
* to be 64 bits wide, even though we'll only use 32 bits out of 64. */
20
public
:
21
enum class
CC1S
:
uint8_t
{
22
OUTPUT
= 0,
23
INPUT_TI2
= 1,
24
INPUT_TI1
= 2,
25
INPUT_TRC
= 3
26
};
27
enum class
OCM
:
uint8_t
{
28
Frozen
= 0,
29
ActiveOnMatch
= 1,
30
InactiveOnMatch
= 2,
31
Toggle
= 3,
32
ForceInactive
= 4,
33
ForceActive
= 5,
34
PWM1
= 6,
35
PWM2
= 7
36
};
37
typedef
OCM
OC1M
;
38
typedef
OCM
OC2M
;
39
typedef
OCM
OC3M
;
40
typedef
OCM
OC4M
;
41
REGS_BOOL_FIELD
(OC1PE, 3);
42
REGS_TYPE_FIELD
(
OC1M
, 6, 4);
43
REGS_BOOL_FIELD
(OC2PE, 11);
44
REGS_TYPE_FIELD
(
OC2M
, 14, 12);
45
REGS_BOOL_FIELD
(OC3PE, 35);
46
REGS_TYPE_FIELD
(
OC3M
, 38, 36);
47
REGS_BOOL_FIELD
(OC4PE, 43);
48
REGS_TYPE_FIELD
(
OC4M
, 46, 44);
49
};
50
51
class
CCER
:
Register16
{
52
public
:
53
REGS_BOOL_FIELD
(CC1E, 0);
54
REGS_BOOL_FIELD
(CC2E, 4);
55
REGS_BOOL_FIELD
(CC3E, 8);
56
REGS_BOOL_FIELD
(CC4E, 12);
57
};
58
59
class
BDTR
:
Register16
{
60
public
:
61
REGS_BOOL_FIELD
(MOE, 15);
62
};
63
64
class
PSC
:
public
Register16
{};
65
class
ARR
:
public
Register16
{};
66
class
CCR1
:
public
Register16
{};
67
class
CCR2
:
public
Register16
{};
68
class
CCR3
:
public
Register16
{};
69
class
CCR4
:
public
Register16
{};
70
71
constexpr
TIM
(
int
i) : m_index(i) {}
72
REGS_REGISTER_AT
(CR1, 0
x0
);
73
REGS_REGISTER_AT
(CCMR, 0x18);
74
REGS_REGISTER_AT
(CCER, 0x20);
75
REGS_REGISTER_AT
(PSC, 0x28);
76
REGS_REGISTER_AT
(ARR, 0x2C);
77
REGS_REGISTER_AT
(CCR1, 0x34);
78
REGS_REGISTER_AT
(CCR2, 0x38);
79
REGS_REGISTER_AT
(CCR3, 0x3C);
80
REGS_REGISTER_AT
(CCR4, 0x40);
81
REGS_REGISTER_AT
(BDTR, 0x44);
82
private
:
83
constexpr
uint32_t
Base()
const
{
84
return
(m_index == 1 ? 0x40010000 : 0x40000000 + 0x400*(m_index-2));
85
};
86
int
m_index;
87
};
88
89
constexpr
TIM
TIM1
(1);
90
constexpr
TIM
TIM3
(3);
91
92
#endif
TIM::CCMR::OC4M
OCM OC4M
Definition:
tim.h:40
TIM::CCMR::OCM::ForceInactive
TIM
Definition:
tim.h:6
TIM::BDTR
Definition:
tim.h:59
TIM::CCMR::CC1S::INPUT_TI1
register.h
TIM::CCR1
Definition:
tim.h:66
TIM::CCMR::OCM::PWM2
TIM::CCR4
Definition:
tim.h:69
x0
#define x0
Definition:
b_tgamma.c:86
TIM::CCMR::OCM::InactiveOnMatch
TIM::CCMR::OC2M
OCM OC2M
Definition:
tim.h:38
TIM::TIM
constexpr TIM(int i)
Definition:
tim.h:71
TIM3
constexpr TIM TIM3(3)
TIM::CCR2
Definition:
tim.h:67
uint8_t
unsigned char uint8_t
Definition:
stdint.h:4
TIM::CCMR::CC1S::INPUT_TI2
TIM::CCMR::REGS_TYPE_FIELD
REGS_TYPE_FIELD(OC1M, 6, 4)
TIM::PSC
Definition:
tim.h:64
Register
Definition:
register.h:8
TIM::CR1
Definition:
tim.h:8
TIM::BDTR::REGS_BOOL_FIELD
REGS_BOOL_FIELD(MOE, 15)
TIM::CCMR::OCM::Frozen
TIM::CCMR::OCM::PWM1
TIM::CR1::REGS_BOOL_FIELD
REGS_BOOL_FIELD(CEN, 0)
uint32_t
unsigned int uint32_t
Definition:
stdint.h:6
TIM::CCMR::CC1S
CC1S
Definition:
tim.h:21
TIM::CCMR::OCM::ActiveOnMatch
TIM::CCER
Definition:
tim.h:51
TIM::CCMR
Definition:
tim.h:14
TIM::CCER::REGS_BOOL_FIELD
REGS_BOOL_FIELD(CC1E, 0)
TIM::REGS_REGISTER_AT
REGS_REGISTER_AT(CR1, 0x0)
TIM::CCMR::CC1S::INPUT_TRC
TIM1
constexpr TIM TIM1(1)
TIM::CCMR::OCM::Toggle
TIM::CCMR::OCM::ForceActive
TIM::ARR
Definition:
tim.h:65
TIM::CCMR::REGS_BOOL_FIELD
REGS_BOOL_FIELD(OC1PE, 3)
TIM::CCMR::CC1S::OUTPUT
TIM::CCMR::OC3M
OCM OC3M
Definition:
tim.h:39
TIM::CCR3
Definition:
tim.h:68
TIM::CCMR::OC1M
OCM OC1M
Definition:
tim.h:37
TIM::CCMR::OCM
OCM
Definition:
tim.h:27
epsilon
ion
src
device
regs
tim.h
Generated by
1.8.14