Robobo
component_pwm.h
1 /* ----------------------------------------------------------------------------
2  * SAM Software Package License
3  * ----------------------------------------------------------------------------
4  * Copyright (c) 2012, Atmel Corporation
5  *
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following condition is met:
10  *
11  * - Redistributions of source code must retain the above copyright notice,
12  * this list of conditions and the disclaimer below.
13  *
14  * Atmel's name may not be used to endorse or promote products derived from
15  * this software without specific prior written permission.
16  *
17  * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
18  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
20  * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
21  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
23  * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
24  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
25  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
26  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  * ----------------------------------------------------------------------------
28  */
29 
30 #ifndef _SAM3N_PWM_COMPONENT_
31 #define _SAM3N_PWM_COMPONENT_
32 
33 /* ============================================================================= */
35 /* ============================================================================= */
38 
39 #if !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__))
40 
41 typedef struct {
47  RoReg Reserved1[3];
48 } PwmCh_num;
50 #define PWMCH_NUM_NUMBER 4
51 typedef struct {
60  RoReg Reserved1[120];
62 } Pwm;
63 #endif /* !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */
64 /* -------- PWM_MR : (PWM Offset: 0x00) PWM Mode Register -------- */
65 #define PWM_MR_DIVA_Pos 0
66 #define PWM_MR_DIVA_Msk (0xffu << PWM_MR_DIVA_Pos)
67 #define PWM_MR_DIVA_CLK_OFF (0x0u << 0)
68 #define PWM_MR_DIVA_CLK_DIV1 (0x1u << 0)
69 #define PWM_MR_PREA_Pos 8
70 #define PWM_MR_PREA_Msk (0xfu << PWM_MR_PREA_Pos)
71 #define PWM_MR_PREA_MCK (0x0u << 8)
72 #define PWM_MR_PREA_MCKDIV2 (0x1u << 8)
73 #define PWM_MR_PREA_MCKDIV4 (0x2u << 8)
74 #define PWM_MR_PREA_MCKDIV8 (0x3u << 8)
75 #define PWM_MR_PREA_MCKDIV16 (0x4u << 8)
76 #define PWM_MR_PREA_MCKDIV32 (0x5u << 8)
77 #define PWM_MR_PREA_MCKDIV64 (0x6u << 8)
78 #define PWM_MR_PREA_MCKDIV128 (0x7u << 8)
79 #define PWM_MR_PREA_MCKDIV256 (0x8u << 8)
80 #define PWM_MR_PREA_MCKDIV512 (0x9u << 8)
81 #define PWM_MR_PREA_MCKDIV1024 (0xAu << 8)
82 #define PWM_MR_DIVB_Pos 16
83 #define PWM_MR_DIVB_Msk (0xffu << PWM_MR_DIVB_Pos)
84 #define PWM_MR_DIVB_CLK_OFF (0x0u << 16)
85 #define PWM_MR_DIVB_CLK_DIV1 (0x1u << 16)
86 #define PWM_MR_PREB_Pos 24
87 #define PWM_MR_PREB_Msk (0xfu << PWM_MR_PREB_Pos)
88 #define PWM_MR_PREB_MCK (0x0u << 24)
89 #define PWM_MR_PREB_MCKDIV2 (0x1u << 24)
90 #define PWM_MR_PREB_MCKDIV4 (0x2u << 24)
91 #define PWM_MR_PREB_MCKDIV8 (0x3u << 24)
92 #define PWM_MR_PREB_MCKDIV16 (0x4u << 24)
93 #define PWM_MR_PREB_MCKDIV32 (0x5u << 24)
94 #define PWM_MR_PREB_MCKDIV64 (0x6u << 24)
95 #define PWM_MR_PREB_MCKDIV128 (0x7u << 24)
96 #define PWM_MR_PREB_MCKDIV256 (0x8u << 24)
97 #define PWM_MR_PREB_MCKDIV512 (0x9u << 24)
98 #define PWM_MR_PREB_MCKDIV1024 (0xAu << 24)
99 /* -------- PWM_ENA : (PWM Offset: 0x04) PWM Enable Register -------- */
100 #define PWM_ENA_CHID0 (0x1u << 0)
101 #define PWM_ENA_CHID1 (0x1u << 1)
102 #define PWM_ENA_CHID2 (0x1u << 2)
103 #define PWM_ENA_CHID3 (0x1u << 3)
104 /* -------- PWM_DIS : (PWM Offset: 0x08) PWM Disable Register -------- */
105 #define PWM_DIS_CHID0 (0x1u << 0)
106 #define PWM_DIS_CHID1 (0x1u << 1)
107 #define PWM_DIS_CHID2 (0x1u << 2)
108 #define PWM_DIS_CHID3 (0x1u << 3)
109 /* -------- PWM_SR : (PWM Offset: 0x0C) PWM Status Register -------- */
110 #define PWM_SR_CHID0 (0x1u << 0)
111 #define PWM_SR_CHID1 (0x1u << 1)
112 #define PWM_SR_CHID2 (0x1u << 2)
113 #define PWM_SR_CHID3 (0x1u << 3)
114 /* -------- PWM_IER : (PWM Offset: 0x10) PWM Interrupt Enable Register -------- */
115 #define PWM_IER_CHID0 (0x1u << 0)
116 #define PWM_IER_CHID1 (0x1u << 1)
117 #define PWM_IER_CHID2 (0x1u << 2)
118 #define PWM_IER_CHID3 (0x1u << 3)
119 /* -------- PWM_IDR : (PWM Offset: 0x14) PWM Interrupt Disable Register -------- */
120 #define PWM_IDR_CHID0 (0x1u << 0)
121 #define PWM_IDR_CHID1 (0x1u << 1)
122 #define PWM_IDR_CHID2 (0x1u << 2)
123 #define PWM_IDR_CHID3 (0x1u << 3)
124 /* -------- PWM_IMR : (PWM Offset: 0x18) PWM Interrupt Mask Register -------- */
125 #define PWM_IMR_CHID0 (0x1u << 0)
126 #define PWM_IMR_CHID1 (0x1u << 1)
127 #define PWM_IMR_CHID2 (0x1u << 2)
128 #define PWM_IMR_CHID3 (0x1u << 3)
129 /* -------- PWM_ISR : (PWM Offset: 0x1C) PWM Interrupt Status Register -------- */
130 #define PWM_ISR_CHID0 (0x1u << 0)
131 #define PWM_ISR_CHID1 (0x1u << 1)
132 #define PWM_ISR_CHID2 (0x1u << 2)
133 #define PWM_ISR_CHID3 (0x1u << 3)
134 /* -------- PWM_CMR : (PWM Offset: N/A) PWM Channel Mode Register -------- */
135 #define PWM_CMR_CPRE_Pos 0
136 #define PWM_CMR_CPRE_Msk (0xfu << PWM_CMR_CPRE_Pos)
137 #define PWM_CMR_CPRE_MCK (0x0u << 0)
138 #define PWM_CMR_CPRE_MCKDIV2 (0x1u << 0)
139 #define PWM_CMR_CPRE_MCKDIV4 (0x2u << 0)
140 #define PWM_CMR_CPRE_MCKDIV8 (0x3u << 0)
141 #define PWM_CMR_CPRE_MCKDIV16 (0x4u << 0)
142 #define PWM_CMR_CPRE_MCKDIV32 (0x5u << 0)
143 #define PWM_CMR_CPRE_MCKDIV64 (0x6u << 0)
144 #define PWM_CMR_CPRE_MCKDIV128 (0x7u << 0)
145 #define PWM_CMR_CPRE_MCKDIV256 (0x8u << 0)
146 #define PWM_CMR_CPRE_MCKDIV512 (0x9u << 0)
147 #define PWM_CMR_CPRE_MCKDIV1024 (0xAu << 0)
148 #define PWM_CMR_CPRE_CLKA (0xBu << 0)
149 #define PWM_CMR_CPRE_CLKB (0xCu << 0)
150 #define PWM_CMR_CALG (0x1u << 8)
151 #define PWM_CMR_CPOL (0x1u << 9)
152 #define PWM_CMR_CPD (0x1u << 10)
153 /* -------- PWM_CDTY : (PWM Offset: N/A) PWM Channel Duty Cycle Register -------- */
154 #define PWM_CDTY_CDTY_Pos 0
155 #define PWM_CDTY_CDTY_Msk (0xffffffffu << PWM_CDTY_CDTY_Pos)
156 #define PWM_CDTY_CDTY(value) ((PWM_CDTY_CDTY_Msk & ((value) << PWM_CDTY_CDTY_Pos)))
157 /* -------- PWM_CPRD : (PWM Offset: N/A) PWM Channel Period Register -------- */
158 #define PWM_CPRD_CPRD_Pos 0
159 #define PWM_CPRD_CPRD_Msk (0xffffffffu << PWM_CPRD_CPRD_Pos)
160 #define PWM_CPRD_CPRD(value) ((PWM_CPRD_CPRD_Msk & ((value) << PWM_CPRD_CPRD_Pos)))
161 /* -------- PWM_CCNT : (PWM Offset: N/A) PWM Channel Counter Register -------- */
162 #define PWM_CCNT_CNT_Pos 0
163 #define PWM_CCNT_CNT_Msk (0xffffffffu << PWM_CCNT_CNT_Pos)
164 /* -------- PWM_CUPD : (PWM Offset: N/A) PWM Channel Update Register -------- */
165 #define PWM_CUPD_CUPD_Pos 0
166 #define PWM_CUPD_CUPD_Msk (0xffffffffu << PWM_CUPD_CUPD_Pos)
167 #define PWM_CUPD_CUPD(value) ((PWM_CUPD_CUPD_Msk & ((value) << PWM_CUPD_CUPD_Pos)))
168 
172 #endif /* _SAM3N_PWM_COMPONENT_ */
WoReg PWM_ENA
(Pwm Offset: 0x04) PWM Enable Register
Definition: component_pwm.h:53
volatile uint32_t RwReg
Definition: sam3n00a.h:54
PwmCh_num hardware registers.
Definition: component_pwm.h:41
WoReg PWM_IDR
(Pwm Offset: 0x14) PWM Interrupt Disable Register
Definition: component_pwm.h:57
#define PWMCH_NUM_NUMBER
Pwm hardware registers.
Definition: component_pwm.h:50
RwReg PWM_CDTY
(PwmCh_num Offset: 0x4) PWM Channel Duty Cycle Register
Definition: component_pwm.h:43
volatile uint32_t WoReg
Definition: sam3n00a.h:53
RwReg PWM_CMR
(PwmCh_num Offset: 0x0) PWM Channel Mode Register
Definition: component_pwm.h:42
RwReg PWM_CPRD
(PwmCh_num Offset: 0x8) PWM Channel Period Register
Definition: component_pwm.h:44
WoReg PWM_DIS
(Pwm Offset: 0x08) PWM Disable Register
Definition: component_pwm.h:54
Definition: component_pwm.h:51
RoReg PWM_IMR
(Pwm Offset: 0x18) PWM Interrupt Mask Register
Definition: component_pwm.h:58
volatile const uint32_t RoReg
Definition: sam3n00a.h:49
RwReg PWM_MR
(Pwm Offset: 0x00) PWM Mode Register
Definition: component_pwm.h:52
RoReg PWM_ISR
(Pwm Offset: 0x1C) PWM Interrupt Status Register
Definition: component_pwm.h:59
WoReg PWM_IER
(Pwm Offset: 0x10) PWM Interrupt Enable Register
Definition: component_pwm.h:56
RoReg PWM_SR
(Pwm Offset: 0x0C) PWM Status Register
Definition: component_pwm.h:55
RwReg PWM_CUPD
(PwmCh_num Offset: 0x10) PWM Channel Update Register
Definition: component_pwm.h:46
RwReg PWM_CCNT
(PwmCh_num Offset: 0xC) PWM Channel Counter Register
Definition: component_pwm.h:45