pcm.h
Go to the documentation of this file.
1 /*
2  * pcm.h
3  *
4  * Copyright (c) 2014 Jeremy Garff <jer @ jers.net>
5  * PCM version Copyright (c) Ton van Overbeek <tvoverbeek @ gmail.com>
6  *
7  * All rights reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without modification, are permitted
10  * provided that the following conditions are met:
11  *
12  * 1. Redistributions of source code must retain the above copyright notice, this list of
13  * conditions and the following disclaimer.
14  * 2. Redistributions in binary form must reproduce the above copyright notice, this list
15  * of conditions and the following disclaimer in the documentation and/or other materials
16  * provided with the distribution.
17  * 3. Neither the name of the owner nor the names of its contributors may be used to endorse
18  * or promote products derived from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
21  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
22  * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
23  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
25  * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
27  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28  *
29  */
30 
31 #ifndef __PCM_H__
32 #define __PCM_H__
33 
34 #include <stdint.h>
35 
36 /*
37  *
38  * Pin mapping of alternate pin configuration for PCM
39  *
40  * GPIO ALT PCM_CLK ALT PCM-FS ALT PCM_DIN ALT PCM_DOUT
41  *
42  * 18 0
43  * 19 0
44  * 20 0
45  * 21 0
46  * 28 2
47  * 29 2
48  * 30 2
49  * 31 2
50  *
51  */
52 
53 
54 typedef struct
55 {
56  uint32_t cs;
57 #define RPI_PCM_CS_STBY (1 << 25)
58 #define RPI_PCM_CS_SYNC (1 << 24)
59 #define RPI_PCM_CS_RXSEX (1 << 23)
60 #define RPI_PCM_CS_RXF (1 << 22)
61 #define RPI_PCM_CS_TXE (1 << 21)
62 #define RPI_PCM_CS_RXD (1 << 20)
63 #define RPI_PCM_CS_TXD (1 << 19)
64 #define RPI_PCM_CS_RXR (1 << 18)
65 #define RPI_PCM_CS_TXW (1 << 17)
66 #define RPI_PCM_CS_RXERR (1 << 16)
67 #define RPI_PCM_CS_TXERR (1 << 15)
68 #define RPI_PCM_CS_RXSYNC (1 << 14)
69 #define RPI_PCM_CS_TXSYNC (1 << 13)
70 #define RPI_PCM_CS_DMAEN (1 << 9)
71 #define RPI_PCM_CS_RXTHR(val) ((val & 0x03) << 7)
72 #define RPI_PCM_CS_TXTHR(val) ((val & 0x03) << 5)
73 #define RPI_PCM_CS_RXCLR (1 << 4)
74 #define RPI_PCM_CS_TXCLR (1 << 3)
75 #define RPI_PCM_CS_TXON (1 << 2)
76 #define RPI_PCM_CS_RXON (1 << 1)
77 #define RPI_PCM_CS_EN (1 << 0)
78  uint32_t fifo;
79  uint32_t mode;
80 #define RPI_PCM_MODE_CLK_DIS (1 << 28)
81 #define RPI_PCM_MODE_PDMN (1 << 27)
82 #define RPI_PCM_MODE_PDME (1 << 26)
83 #define RPI_PCM_MODE_FRXP (1 << 25)
84 #define RPI_PCM_MODE_FTXP (1 << 24)
85 #define RPI_PCM_MODE_CLKM (1 << 23)
86 #define RPI_PCM_MODE_CLKI (1 << 22)
87 #define RPI_PCM_MODE_FSM (1 << 21)
88 #define RPI_PCM_MODE_FSI (1 << 20)
89 #define RPI_PCM_MODE_FLEN(val) ((val & 0x3ff) << 10)
90 #define RPI_PCM_MODE_FSLEN(val) ((val & 0x3ff) << 0)
91  uint32_t rxc;
92 #define RPI_PCM_RXC_CH1WEX (1 << 31)
93 #define RPI_PCM_RXC_CH1EN (1 << 30)
94 #define RPI_PCM_RXC_CH1POS(val) ((val & 0x3ff) << 20)
95 #define RPI_PCM_RXC_CH1WID(val) ((val & 0x0f) << 16)
96 #define RPI_PCM_RXC_CH2WEX (1 << 15)
97 #define RPI_PCM_RXC_CH2EN (1 << 14)
98 #define RPI_PCM_RXC_CH2POS(val) ((val & 0x3ff) << 4)
99 #define RPI_PCM_RXC_CH2WID(val) ((val & 0x0f) << 0)
100  uint32_t txc;
101 #define RPI_PCM_TXC_CH1WEX (1 << 31)
102 #define RPI_PCM_TXC_CH1EN (1 << 30)
103 #define RPI_PCM_TXC_CH1POS(val) ((val & 0x3ff) << 20)
104 #define RPI_PCM_TXC_CH1WID(val) ((val & 0x0f) << 16)
105 #define RPI_PCM_TXC_CH2WEX (1 << 15)
106 #define RPI_PCM_TXC_CH2EN (1 << 14)
107 #define RPI_PCM_TXC_CH2POS(val) ((val & 0x3ff) << 4)
108 #define RPI_PCM_TXC_CH2WID(val) ((val & 0x0f) << 0)
109  uint32_t dreq;
110 #define RPI_PCM_DREQ_TX_PANIC(val) ((val & 0x7f) << 24)
111 #define RPI_PCM_DREQ_RX_PANIC(val) ((val & 0x7f) << 16)
112 #define RPI_PCM_DREQ_TX(val) ((val & 0x7f) << 8)
113 #define RPI_PCM_DREQ_RX(val) ((val & 0x7f) << 0)
114  uint32_t inten;
115 #define RPI_PCM_INTEN_RXERR (1 << 3)
116 #define RPI_PCM_INTEN_TXERR (1 << 2)
117 #define RPI_PCM_INTEN_RXR (1 << 1)
118 #define RPI_PCM_INTEN_TXW (1 << 0)
119  uint32_t intstc;
120 #define RPI_PCM_INTSTC_RXERR (1 << 3)
121 #define RPI_PCM_INTSTC_TXERR (1 << 2)
122 #define RPI_PCM_INTSTC_RXR (1 << 1)
123 #define RPI_PCM_INTSTC_TXW (1 << 0)
124  uint32_t gray;
125 #define RPI_PCM_GRAY_RXFIFOLEVEL(val) ((val & 0x3f) << 16)
126 #define RPI_PCM_GRAY_FLUSHED(val) ((val & 0x3f) << 10
127 #define RPI_PCM_GRAY_RXLEVEL(val) ((val & 0x3f) << 4)
128 #define RPI_PCM_GRAY_FLUSH (1 << 2)
129 #define RPI_PCM_GRAY_CLR (1 << 1)
130 #define RPI_PCM_GRAY_EN (1 << 0)
131 } __attribute__((packed, aligned(4))) pcm_t;
132 
133 
134 #define PCM_OFFSET (0x00203000)
135 #define PCM_PERIPH_PHYS (0x7e203000)
136 
137 #define NUM_PCMFUNS 4
138 #define PCMFUN_CLK 0
139 #define PCMFUN_FS 1
140 #define PCMFUN_DIN 2
141 #define PCMFUN_DOUT 3
142 
143 typedef struct
144 {
145  int pinnum;
146  int altnum;
148 
149 typedef struct
150 {
151  const int count;
154 
155 
156 int pcm_pin_alt(int pcmfun, int pinnum);
157 
158 
159 #endif /* __PCM_H__ */
int altnum
Definition: pcm.h:146
uint32_t fifo
Definition: pcm.h:78
uint32_t mode
Definition: pcm.h:79
uint32_t gray
Definition: pcm.h:124
uint32_t inten
Definition: pcm.h:114
uint32_t dreq
Definition: pcm.h:109
int pinnum
Definition: pcm.h:145
int pcm_pin_alt(int pcmfun, int pinnum)
Definition: pcm.c:109
const int count
Definition: pcm.h:151
uint32_t txc
Definition: pcm.h:100
const pcm_pin_table_t * pins
Definition: pcm.h:152
struct __attribute__ aligned
uint32_t rxc
Definition: pcm.h:91
uint32_t intstc
Definition: pcm.h:119


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