nRF Connect SDK API 0.1.0
Loading...
Searching...
No Matches
cs47l63_reg_conf.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2018 Nordic Semiconductor ASA
3 *
4 * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5 */
6
7#ifndef _CS47L63_REG_CONF_H_
8#define _CS47L63_REG_CONF_H_
9
10#include "cs47l63_spec.h"
11
12/* Magic value to signal a sleep instead of register address.
13 * This can be used e.g. after resets where time is needed before
14 * a device is ready.
15 * Note that this is a busy wait, and should only be used sparingly where fast
16 * execution is not critical.
17 *
18 * 0001 is used as the reg addr. In case of a fault, this reg is read only.
19 */
20#define SPI_BUSY_WAIT 0x0001
21#define SPI_BUSY_WAIT_US_1000 1000
22#define SPI_BUSY_WAIT_US_3000 3000
23
24#define MAX_VOLUME_REG_VAL 0x80
25#define MAX_VOLUME_DB 64
26#define OUT_VOLUME_DEFAULT 0x62
27#define VOLUME_UPDATE_BIT (1 << 9)
28
29#define CS47L63_SOFT_RESET_VAL 0x5A000000
30
31/* clang-format off */
32/* Set up clocks */
33const uint32_t clock_configuration[][2] = {
34 { CS47L63_SAMPLE_RATE3, 0x0012 },
35 { CS47L63_SAMPLE_RATE2, 0x0002 },
36 { CS47L63_SAMPLE_RATE1, 0x0003 },
37 { CS47L63_SYSTEM_CLOCK1, 0x034C },
38 { CS47L63_ASYNC_CLOCK1, 0x034C },
39 { CS47L63_FLL1_CONTROL2, 0x88200008 },
40 { CS47L63_FLL1_CONTROL3, 0x10000 },
41 { CS47L63_FLL1_GPIO_CLOCK, 0x0005 },
42 { CS47L63_FLL1_CONTROL1, 0x0001 },
43};
44/* clang-format on */
45
46/* Set up GPIOs */
47const uint32_t GPIO_configuration[][2] = {
48 { CS47L63_GPIO6_CTRL1, 0x61000001 },
49 { CS47L63_GPIO7_CTRL1, 0x61000001 },
50 { CS47L63_GPIO8_CTRL1, 0x61000001 },
51
52 /* Enable CODEC LED */
53 { CS47L63_GPIO10_CTRL1, 0x41008001 },
54};
55
56const uint32_t pdm_mic_enable_configure[][2] = {
57 /* Set MICBIASes */
58 { CS47L63_LDO2_CTRL1, 0x0005 },
59 { CS47L63_MICBIAS_CTRL1, 0x00EC },
60 { CS47L63_MICBIAS_CTRL5, 0x0272 },
61
62 /* Enable IN1L */
63 { CS47L63_INPUT_CONTROL, 0x000F },
64
65 /* Enable PDM mic as digital input */
66 { CS47L63_INPUT1_CONTROL1, 0x50021 },
67
68 /* Un-mute and set gain to 0dB */
69 { CS47L63_IN1L_CONTROL2, 0x800080 },
70 { CS47L63_IN1R_CONTROL2, 0x800080 },
71
72 /* Volume Update */
73 { CS47L63_INPUT_CONTROL3, 0x20000000 },
74
75 /* Send PDM MIC to I2S Tx */
76 { CS47L63_ASP1TX1_INPUT1, 0x800010 },
77 { CS47L63_ASP1TX2_INPUT1, 0x800011 },
78};
79
80/* Set up input */
81const uint32_t line_in_enable[][2] = {
82 /* Select LINE-IN as analog input */
83 { CS47L63_INPUT2_CONTROL1, 0x50020 },
84
85 /* Set IN2L and IN2R to single-ended */
86 { CS47L63_IN2L_CONTROL1, 0x10000000 },
87 { CS47L63_IN2R_CONTROL1, 0x10000000 },
88
89 /* Un-mute and set gain to 0dB */
90 { CS47L63_IN2L_CONTROL2, 0x800080 },
91 { CS47L63_IN2R_CONTROL2, 0x800080 },
92
93 /* Enable IN2L and IN2R */
94 { CS47L63_INPUT_CONTROL, 0x000F },
95
96 /* Volume Update */
97 { CS47L63_INPUT_CONTROL3, 0x20000000 },
98
99 /* Route IN2L and IN2R to I2S */
100 { CS47L63_ASP1TX1_INPUT1, 0x800012 },
101 { CS47L63_ASP1TX2_INPUT1, 0x800013 },
102};
103
104/* Set up output */
105const uint32_t output_enable[][2] = {
106 { CS47L63_OUTPUT_ENABLE_1, 0x0002 },
107 { CS47L63_OUT1L_INPUT1, 0x800020 },
108 { CS47L63_OUT1L_INPUT2, 0x800021 },
109};
110
111const uint32_t output_disable[][2] = {
112 { CS47L63_OUTPUT_ENABLE_1, 0x00 },
113};
114
115/* Set up ASP1 (I2S) */
116const uint32_t asp1_enable[][2] = {
117 /* Enable ASP1 GPIOs */
118 { CS47L63_GPIO1_CTRL1, 0x61000000 },
119 { CS47L63_GPIO2_CTRL1, 0xE1000000 },
120 { CS47L63_GPIO3_CTRL1, 0xE1000000 },
121 { CS47L63_GPIO4_CTRL1, 0xE1000000 },
122 { CS47L63_GPIO5_CTRL1, 0x61000001 },
123
124/* Set correct sample rate */
125#if CONFIG_AUDIO_SAMPLE_RATE_16000_HZ
126 { CS47L63_SAMPLE_RATE1, 0x000000012 },
127#elif CONFIG_AUDIO_SAMPLE_RATE_24000_HZ
128 { CS47L63_SAMPLE_RATE1, 0x000000002 },
129#elif CONFIG_AUDIO_SAMPLE_RATE_48000_HZ
130 { CS47L63_SAMPLE_RATE1, 0x000000003 },
131#endif
132 /* Disable unused sample rates */
133 { CS47L63_SAMPLE_RATE2, 0 },
134 { CS47L63_SAMPLE_RATE3, 0 },
135 { CS47L63_SAMPLE_RATE4, 0 },
136
137 /* Set ASP1 in slave mode and 16 bit per channel */
138 { CS47L63_ASP1_CONTROL2, 0x10100200 },
139 { CS47L63_ASP1_CONTROL3, 0x0000 },
140 { CS47L63_ASP1_DATA_CONTROL1, 0x0020 },
141 { CS47L63_ASP1_DATA_CONTROL5, 0x0020 },
142 { CS47L63_ASP1_ENABLES1, 0x30003 },
143};
144
145const uint32_t FLL_toggle[][2] = {
146 { CS47L63_FLL1_CONTROL1, 0x0000 },
148 { CS47L63_FLL1_CONTROL1, 0x0001 },
149};
150
151const uint32_t soft_reset[][2] = {
152 { CS47L63_SFT_RESET, CS47L63_SOFT_RESET_VAL },
154};
155
156#endif /* _CS47L63_REG_CONF_H_ */
const uint32_t GPIO_configuration[][2]
Definition: cs47l63_reg_conf.h:47
#define SPI_BUSY_WAIT
Definition: cs47l63_reg_conf.h:20
const uint32_t asp1_enable[][2]
Definition: cs47l63_reg_conf.h:116
const uint32_t line_in_enable[][2]
Definition: cs47l63_reg_conf.h:81
const uint32_t pdm_mic_enable_configure[][2]
Definition: cs47l63_reg_conf.h:56
#define SPI_BUSY_WAIT_US_1000
Definition: cs47l63_reg_conf.h:21
const uint32_t clock_configuration[][2]
Definition: cs47l63_reg_conf.h:33
const uint32_t FLL_toggle[][2]
Definition: cs47l63_reg_conf.h:145
#define SPI_BUSY_WAIT_US_3000
Definition: cs47l63_reg_conf.h:22
const uint32_t output_disable[][2]
Definition: cs47l63_reg_conf.h:111
const uint32_t soft_reset[][2]
Definition: cs47l63_reg_conf.h:151
#define CS47L63_SOFT_RESET_VAL
Definition: cs47l63_reg_conf.h:29
const uint32_t output_enable[][2]
Definition: cs47l63_reg_conf.h:105