vendor
rpi_ws281x
pcm.c
Go to the documentation of this file.
1
/*
2
* pcm.c
3
*
4
* Copyright (c) 2014 Jeremy Garff <jer @ jers.net>
5
* PCM version Copyright (c) 2016 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
32
#include <stdint.h>
33
#include "
pcm.h
"
34
35
36
// Mapping of Pin to alternate function for PCM_CLK
37
const
pcm_pin_table_t
pcm_pin_clk
[] =
38
{
39
{
40
.
pinnum
= 18,
41
.altnum = 0,
42
},
43
{
44
.pinnum = 28,
45
.altnum = 2,
46
},
47
};
48
49
// Mapping of Pin to alternate function for PCM_FS
50
const
pcm_pin_table_t
pcm_pin_fs
[] =
51
{
52
{
53
.
pinnum
= 19,
54
.altnum = 0,
55
},
56
{
57
.pinnum = 29,
58
.altnum = 2,
59
},
60
};
61
62
// Mapping of Pin to alternate function for PCM_DIN
63
const
pcm_pin_table_t
pcm_pin_din
[] =
64
{
65
{
66
.
pinnum
= 20,
67
.altnum = 0,
68
},
69
{
70
.pinnum = 30,
71
.altnum = 2,
72
},
73
};
74
75
// Mapping of Pin to alternate function for PCM_DOUT
76
const
pcm_pin_table_t
pcm_pin_dout
[] =
77
{
78
{
79
.
pinnum
= 21,
80
.altnum = 0,
81
},
82
{
83
.pinnum = 31,
84
.altnum = 2,
85
},
86
};
87
88
const
pcm_pin_tables_t
pcm_pin_tables
[
NUM_PCMFUNS
] =
89
{
90
{
91
.
pins
=
pcm_pin_clk
,
92
.count =
sizeof
(
pcm_pin_clk
) /
sizeof
(
pcm_pin_clk
[0]),
93
},
94
{
95
.pins =
pcm_pin_fs
,
96
.count =
sizeof
(
pcm_pin_fs
) /
sizeof
(
pcm_pin_fs
[0]),
97
},
98
{
99
.pins =
pcm_pin_din
,
100
.count =
sizeof
(
pcm_pin_din
) /
sizeof
(
pcm_pin_din
[0]),
101
},
102
{
103
.pins =
pcm_pin_dout
,
104
.count =
sizeof
(
pcm_pin_dout
) /
sizeof
(
pcm_pin_dout
[0]),
105
},
106
};
107
108
109
int
pcm_pin_alt
(
int
pcmfun,
int
pinnum)
110
{
111
if
(pcmfun < 0 || pcmfun > 3) {
112
return
-1;
113
}
114
const
pcm_pin_tables_t
*pintable = &
pcm_pin_tables
[pcmfun];
115
int
i;
116
117
for
(i = 0; i < pintable->
count
; i++)
118
{
119
if
(pintable->
pins
[i].
pinnum
== pinnum)
120
{
121
return
pintable->
pins
[i].
altnum
;
122
}
123
}
124
125
return
-1;
126
}
127
NUM_PCMFUNS
#define NUM_PCMFUNS
Definition:
pcm.h:137
pcm.h
pcm_pin_dout
const pcm_pin_table_t pcm_pin_dout[]
Definition:
pcm.c:76
pcm_pin_table_t::pinnum
int pinnum
Definition:
pcm.h:145
pcm_pin_tables_t
Definition:
pcm.h:149
pcm_pin_table_t
Definition:
pcm.h:143
pcm_pin_table_t::altnum
int altnum
Definition:
pcm.h:146
pcm_pin_tables_t::count
const int count
Definition:
pcm.h:151
pcm_pin_tables
const pcm_pin_tables_t pcm_pin_tables[NUM_PCMFUNS]
Definition:
pcm.c:88
pcm_pin_alt
int pcm_pin_alt(int pcmfun, int pinnum)
Definition:
pcm.c:109
pcm_pin_din
const pcm_pin_table_t pcm_pin_din[]
Definition:
pcm.c:63
pcm_pin_clk
const pcm_pin_table_t pcm_pin_clk[]
Definition:
pcm.c:37
pcm_pin_tables_t::pins
const pcm_pin_table_t * pins
Definition:
pcm.h:152
pcm_pin_fs
const pcm_pin_table_t pcm_pin_fs[]
Definition:
pcm.c:50
ws281x
Author(s): Alexey Rogachevskiy
, Oleg Kalachev
autogenerated on Wed Jun 15 2022 02:21:36