-
Notifications
You must be signed in to change notification settings - Fork 1
/
muses_72323.h
149 lines (126 loc) · 4.41 KB
/
muses_72323.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
#ifndef MUSES_72323_H
#define MUSES_72323_H
#include <stdint.h>
#include <stdbool.h>
/** \define Lower attenuation boundary */
#define MUSES_72323_MAX_ATTENUATION 0x1BF
/** \define Upper clock-divider boundary */
#define MUSES_72323_MAX_CHANNEL_GAIN 7
/** \define Upper chip-address boundary */
#define MUSES_72323_MAX_CHIP_ADDR 3
/** \define Upper clock-divider boundary */
#define MUSES_72323_MAX_CLOCK_DIVIDER 7
/** \define Upper zero-window boundary */
#define MUSES_72323_MAX_ZERO_WINDOW 3
#ifdef __cplusplus
extern "C"
{
#endif
/** Possible errors */
typedef enum
{
MUSES_72323_ERROR_NONE = 0,
MUSES_72323_ERROR_CHIP_ADDRESS_GREATER_THAN_MAX,
MUSES_72323_ERROR_ATTENUTION_GREATER_THAN_MAX,
MUSES_72323_ERROR_CHANNEL_GAIN_GREATER_THAN_MAX,
MUSES_72323_ERROR_CLOCK_DIVIDER_GREATER_THAN_MAX,
MUSES_72323_ERROR_ZERO_WINDOW_GREATER_THAN_MAX,
} muses_72323_error_t;
typedef enum
{
MUSES_72323_SOFT_STEP_CLOCK_EXTERNAL = 0x00,
MUSES_72323_SOFT_STEP_CLOCK_INTERNAL = 0x01,
} muses_72323_soft_step_clock_source_t;
/** \typedef A command to be sent via SPI */
typedef uint16_t muses_72323_command_t;
/** \typedef Address one of the [0..3] chips on same SPI line */
typedef uint8_t muses_72323_chip_address_t;
/** \typedef [0..7] times 3dB gain per channel */
typedef uint8_t muses_72323_channel_gain_t;
/** \typedef The zero-window */
typedef uint8_t muses_72323_zero_window_t;
/** \typedef The clock-divider */
typedef uint8_t muses_72323_soft_step_clock_divider_t;
/** \typedef volume-attenuation in 0.25dB steps [0..447] */
typedef uint16_t muses_72323_attenuation_t;
/**
* \enum Select channel for commands
*/
typedef enum
{
MUSES_72323_CHANNEL_LEFT = 0x00, MUSES_72323_CHANNEL_RIGHT = 0x01,
} muses_72323_channel_t;
/**
* \func Configure the MUSES 72323.
*
* \param command The memory-address to write generated command to
* \param chip_address The chip-address to send command to
* \param zero_window
* \param clock_divider
* \param soft_step_clock
*
* \return 16-bit command to be sent to MUSES 72323.
*/
muses_72323_error_t
muses_72323_configure (
muses_72323_command_t *command,
const muses_72323_chip_address_t chip_address,
const muses_72323_zero_window_t zero_window,
const muses_72323_soft_step_clock_divider_t clock_divider,
const muses_72323_soft_step_clock_source_t soft_step_clock);
/**
* \func Set channel-gain.
*
* When \param l_r_control is true the value for right channel is ignored.
*
* \param command The memory-address to write generated command to
* \param chip_address The chip-address to send command to
* \param left The left channel gain
* \param right The right channel gain
* \param link_channels Link L/R channels
* \param zero_cross Use zero-cross
*
* \return 16-bit command to be sent to MUSES 72323.
*/
muses_72323_error_t
muses_72323_set_gain (muses_72323_command_t *command,
const muses_72323_chip_address_t chip_address,
const muses_72323_channel_gain_t left,
const muses_72323_channel_gain_t right,
const bool link_channels, const bool use_zero_cross);
/**
* Set volume per channel.
*
* \param command The memory-address to write generated command to
* \param chip_address The chip-address to send command to
* \param channel The channel-number [0..1] to set volume for
* \param attenuation The volume-attenuation in -0.25db steps in range [0...447].
* \param use_soft_step Use soft-step
*
* \return zero or error-code on error
*/
muses_72323_error_t
muses_72323_set_volume (muses_72323_command_t *command,
const muses_72323_chip_address_t chip_address,
const muses_72323_channel_t channel,
const muses_72323_attenuation_t attenuation,
const bool use_soft_step);
/**
* Mute a channel. Un-mute it by setting a volume.
*
* \param command The memory-address to write generated command to
* \param chip_address The chip-address to send command to
* \param channel The channel-number [0..1] to set volume for
* \param use_soft_step Use soft-step
*
* \return 16-bit command to be sent to MUSES 72323.
*/
muses_72323_error_t
muses_72323_mute (muses_72323_command_t *command,
const muses_72323_chip_address_t chip_address,
const muses_72323_channel_t channel,
const bool use_soft_step);
#ifdef __cplusplus
}
#endif
#endif /* MUSES_72323_H */