-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathpwmg_2.h
117 lines (99 loc) · 5.31 KB
/
pwmg_2.h
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
/*
pwmg_2.h: Definitions for the PWMG2 related registers used by Padauk microcontrollers.
Copyright (C) 2020 serisman <[email protected]>
Copyright (C) 2019-2020 freepdk https://free-pdk.github.io
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2, or (at your option) any later version.
This library 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 this library. If not, see <http://www.gnu.org/licenses/>.
As a special exception, if you link this library with other files,
some of which are compiled with SDCC, to produce an executable,
this library does not by itself cause the resulting executable to
be covered by the GNU General Public License. This exception does
not however invalidate any other reasons why the executable file
might be covered by the GNU General Public License.
*/
#ifndef __PDK_DEVICE_PERIPH_PWMG_2_H__
#define __PDK_DEVICE_PERIPH_PWMG_2_H__
#if !defined(__PDK_DEVICE_H__)
#error "You must #include "pdk/device.h" instead of "pdk/device/periph/pwmg_2.h" by itself."
#endif
// __sfr definitions
__sfr __at(PWMG2C_ADDR) _pwmg2c;
__sfr __at(PWMG2S_ADDR) _pwmg2s;
__sfr __at(PWMG2DTH_ADDR) _pwmg2dth;
__sfr __at(PWMG2DTL_ADDR) _pwmg2dtl;
__sfr __at(PWMG2CUBH_ADDR) _pwmg2cubh;
__sfr __at(PWMG2CUBL_ADDR) _pwmg2cubl;
#define PWMG2C _pwmg2c
#define PWMG2S _pwmg2s
#define PWMG2DTH _pwmg2dth
#define PWMG2DTL _pwmg2dtl
#define PWMG2CUBH _pwmg2cubh
#define PWMG2CUBL _pwmg2cubl
// PWMG2C (PWMG2 Control) register definitions
#define PWMG2C_CLK_SRC_BIT 0
#define PWMG2C_OUT_PIN_SEL_BIT0 1
#define PWMG2C_CTR_RST_BIT 4
#define PWMG2C_INVERT_OUT_BIT 5
#define PWMG2C_STATUS_OUT_BIT 6
#define PWMG2C_ENABLE_BIT 7
#define PWMG2C_CLK_SYSCLK 0x00
#define PWMG2C_CLK_IHRC (1 << PWMG2C_CLK_SRC_BIT)
#define PWMG2C_OUT_NONE 0x00
#define PWMG2C_OUT_PB3 (1 << PWMG2C_OUT_PIN_SEL_BIT0)
#define PWMG2C_OUT_PA3 (3 << PWMG2C_OUT_PIN_SEL_BIT0)
#define PWMG2C_OUT_PB2 (4 << PWMG2C_OUT_PIN_SEL_BIT0)
#define PWMG2C_OUT_PA5 (5 << PWMG2C_OUT_PIN_SEL_BIT0)
#define PWMG2C_RESET_COUNTER (1 << PWMG2C_CTR_RST_BIT)
#define PWMG2C_INVERT_OUT (1 << PWMG2C_INVERT_OUT_BIT)
#define PWMG2C_STATUS_OUT (1 << PWMG2C_STATUS_OUT_BIT)
#define PWMG2C_ENABLE (1 << PWMG2C_ENABLE_BIT)
// PWMG2S (PWMG2 Scalar) register definitions
#define PWMG2S_SCALE_BIT0 0
#define PWMG2S_PRESCALE_BIT0 5
#define PWMG2S_INT_MODE_BIT 7
#define PWMG2S_SCALE_NONE 0x00
#define PWMG2S_SCALE_DIV2 (1 << PWMG2S_SCALE_BIT0)
#define PWMG2S_SCALE_DIV3 (2 << PWMG2S_SCALE_BIT0)
#define PWMG2S_SCALE_DIV4 (3 << PWMG2S_SCALE_BIT0)
#define PWMG2S_SCALE_DIV5 (4 << PWMG2S_SCALE_BIT0)
#define PWMG2S_SCALE_DIV6 (5 << PWMG2S_SCALE_BIT0)
#define PWMG2S_SCALE_DIV7 (6 << PWMG2S_SCALE_BIT0)
#define PWMG2S_SCALE_DIV8 (7 << PWMG2S_SCALE_BIT0)
#define PWMG2S_SCALE_DIV9 (8 << PWMG2S_SCALE_BIT0)
#define PWMG2S_SCALE_DIV10 (9 << PWMG2S_SCALE_BIT0)
#define PWMG2S_SCALE_DIV11 (10 << PWMG2S_SCALE_BIT0)
#define PWMG2S_SCALE_DIV12 (11 << PWMG2S_SCALE_BIT0)
#define PWMG2S_SCALE_DIV13 (12 << PWMG2S_SCALE_BIT0)
#define PWMG2S_SCALE_DIV14 (13 << PWMG2S_SCALE_BIT0)
#define PWMG2S_SCALE_DIV15 (14 << PWMG2S_SCALE_BIT0)
#define PWMG2S_SCALE_DIV16 (15 << PWMG2S_SCALE_BIT0)
#define PWMG2S_SCALE_DIV17 (16 << PWMG2S_SCALE_BIT0)
#define PWMG2S_SCALE_DIV18 (17 << PWMG2S_SCALE_BIT0)
#define PWMG2S_SCALE_DIV19 (18 << PWMG2S_SCALE_BIT0)
#define PWMG2S_SCALE_DIV20 (19 << PWMG2S_SCALE_BIT0)
#define PWMG2S_SCALE_DIV21 (20 << PWMG2S_SCALE_BIT0)
#define PWMG2S_SCALE_DIV22 (21 << PWMG2S_SCALE_BIT0)
#define PWMG2S_SCALE_DIV23 (22 << PWMG2S_SCALE_BIT0)
#define PWMG2S_SCALE_DIV24 (23 << PWMG2S_SCALE_BIT0)
#define PWMG2S_SCALE_DIV25 (24 << PWMG2S_SCALE_BIT0)
#define PWMG2S_SCALE_DIV26 (25 << PWMG2S_SCALE_BIT0)
#define PWMG2S_SCALE_DIV27 (26 << PWMG2S_SCALE_BIT0)
#define PWMG2S_SCALE_DIV28 (27 << PWMG2S_SCALE_BIT0)
#define PWMG2S_SCALE_DIV29 (28 << PWMG2S_SCALE_BIT0)
#define PWMG2S_SCALE_DIV30 (29 << PWMG2S_SCALE_BIT0)
#define PWMG2S_SCALE_DIV31 (30 << PWMG2S_SCALE_BIT0)
#define PWMG2S_SCALE_DIV32 (31 << PWMG2S_SCALE_BIT0)
#define PWMG2S_PRESCALE_NONE 0x00
#define PWMG2S_PRESCALE_DIV4 (1 << PWMG2S_PRESCALE_BIT0)
#define PWMG2S_PRESCALE_DIV16 (2 << PWMG2S_PRESCALE_BIT0)
#define PWMG2S_PRESCALE_DIV64 (3 << PWMG2S_PRESCALE_BIT0)
#define PWMG2_INT_AT_DUTY 0x00
#define PWMG2_INT_AT_0 (1 << PWMG2S_INT_MODE_BIT)
#endif //__PDK_DEVICE_PERIPH_PWMG_2_H__