pwm.h
Go to the documentation of this file.
1 /*
2  * pwm.h
3  *
4  * Copyright (c) 2014 Jeremy Garff <jer @ jers.net>
5  *
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without modification, are permitted
9  * provided that the following conditions are met:
10  *
11  * 1. Redistributions of source code must retain the above copyright notice, this list of
12  * conditions and the following disclaimer.
13  * 2. Redistributions in binary form must reproduce the above copyright notice, this list
14  * of conditions and the following disclaimer in the documentation and/or other materials
15  * provided with the distribution.
16  * 3. Neither the name of the owner nor the names of its contributors may be used to endorse
17  * or promote products derived from this software without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
20  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
21  * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
22  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
24  * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
26  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  *
28  */
29 
30 #ifndef __PWM_H__
31 #define __PWM_H__
32 
33 #include <stdint.h>
34 
35 /*
36  *
37  * Pin mappint of alternate pin configuration for PWM
38  *
39  * GPIO ALT PWM0 ALT PWM1
40  *
41  * 12 0
42  * 13 0
43  * 18 5
44  * 19 5
45  * 40 0
46  * 41 0
47  * 45 0
48  * 52 1
49  * 53 1
50  *
51  */
52 
53 
54 #define RPI_PWM_CHANNELS 2
55 
56 
57 typedef struct
58 {
59  uint32_t ctl;
60 #define RPI_PWM_CTL_MSEN2 (1 << 15)
61 #define RPI_PWM_CTL_USEF2 (1 << 13)
62 #define RPI_PWM_CTL_POLA2 (1 << 12)
63 #define RPI_PWM_CTL_SBIT2 (1 << 11)
64 #define RPI_PWM_CTL_RPTL2 (1 << 10)
65 #define RPI_PWM_CTL_MODE2 (1 << 9)
66 #define RPI_PWM_CTL_PWEN2 (1 << 8)
67 #define RPI_PWM_CTL_MSEN1 (1 << 7)
68 #define RPI_PWM_CTL_CLRF1 (1 << 6)
69 #define RPI_PWM_CTL_USEF1 (1 << 5)
70 #define RPI_PWM_CTL_POLA1 (1 << 4)
71 #define RPI_PWM_CTL_SBIT1 (1 << 3)
72 #define RPI_PWM_CTL_RPTL1 (1 << 2)
73 #define RPI_PWM_CTL_MODE1 (1 << 1)
74 #define RPI_PWM_CTL_PWEN1 (1 << 0)
75  uint32_t sta;
76 #define RPI_PWM_STA_STA4 (1 << 12)
77 #define RPI_PWM_STA_STA3 (1 << 11)
78 #define RPI_PWM_STA_STA2 (1 << 10)
79 #define RPI_PWM_STA_STA1 (1 << 9)
80 #define RPI_PWM_STA_BERR (1 << 8)
81 #define RPI_PWM_STA_GAP04 (1 << 7)
82 #define RPI_PWM_STA_GAP03 (1 << 6)
83 #define RPI_PWM_STA_GAP02 (1 << 5)
84 #define RPI_PWM_STA_GAP01 (1 << 4)
85 #define RPI_PWM_STA_RERR1 (1 << 3)
86 #define RPI_PWM_STA_WERR1 (1 << 2)
87 #define RPI_PWM_STA_EMPT1 (1 << 1)
88 #define RPI_PWM_STA_FULL1 (1 << 0)
89  uint32_t dmac;
90 #define RPI_PWM_DMAC_ENAB (1 << 31)
91 #define RPI_PWM_DMAC_PANIC(val) ((val & 0xff) << 8)
92 #define RPI_PWM_DMAC_DREQ(val) ((val & 0xff) << 0)
93  uint32_t resvd_0x0c;
94  uint32_t rng1;
95  uint32_t dat1;
96  uint32_t fif1;
97  uint32_t resvd_0x1c;
98  uint32_t rng2;
99  uint32_t dat2;
100 } __attribute__((packed, aligned(4))) pwm_t;
101 
102 
103 #define PWM_OFFSET (0x0020c000)
104 #define PWM_PERIPH_PHYS (0x7e20c000)
105 
106 
107 typedef struct
108 {
109  int pinnum;
110  int altnum;
112 
113 typedef struct
114 {
115  const int count;
118 
119 
120 int pwm_pin_alt(int chan, int pinnum);
121 
122 
123 #endif /* __PWM_H__ */
int pwm_pin_alt(int chan, int pinnum)
Definition: pwm.c:89
uint32_t sta
Definition: pwm.h:75
uint32_t fif1
Definition: pwm.h:96
uint32_t dat2
Definition: pwm.h:99
uint32_t dmac
Definition: pwm.h:89
uint32_t rng1
Definition: pwm.h:94
uint32_t rng2
Definition: pwm.h:98
uint32_t resvd_0x0c
Definition: pwm.h:93
uint32_t dat1
Definition: pwm.h:95
const pwm_pin_table_t * pins
Definition: pwm.h:116
const int count
Definition: pwm.h:115
uint32_t resvd_0x1c
Definition: pwm.h:97
struct __attribute__ aligned
int altnum
Definition: pwm.h:110
int pinnum
Definition: pwm.h:109


ws281x
Author(s): Alexey Rogachevskiy , Oleg Kalachev
autogenerated on Wed Jun 15 2022 02:46:00