File tree Expand file tree Collapse file tree 2 files changed +18
-14
lines changed Expand file tree Collapse file tree 2 files changed +18
-14
lines changed Original file line number Diff line number Diff line change 6
6
//!
7
7
//! # Hardware required
8
8
//!
9
- //! * STM32F411E-DISCO evaluation board
9
+ //! * STM32F407G-DISC1 or STM32F411E-DISCO evaluation board
10
10
//! * Headphones or speakers with a headphone plug
11
11
//!
12
12
//! # Procedure
@@ -64,6 +64,11 @@ use stm32f4xx_hal::stm32::{DMA1, SPI3};
64
64
65
65
use cs43l22:: { Cs43L22 , Register } ;
66
66
67
+ /// Volume in decibels
68
+ ///
69
+ /// Depending on your speakers, you may need to adjust this value.
70
+ const VOLUME : i8 = -100 ;
71
+
67
72
const SINE_SAMPLES : usize = 64 ;
68
73
69
74
/// A sine wave spanning 64 samples
@@ -164,12 +169,9 @@ fn main() -> ! {
164
169
// Word length 16 bits
165
170
dac. write ( Register :: InterfaceCtl1 , 0b0_0_0_0_01_11 ) . unwrap ( ) ;
166
171
167
- // Reduce the headphone volume to make the demo less annoying
168
- let headphone_volume = -30i8 as u8 ;
169
- dac. write ( Register :: HeadphoneAVol , headphone_volume)
170
- . unwrap ( ) ;
171
- dac. write ( Register :: HeadphoneBVol , headphone_volume)
172
- . unwrap ( ) ;
172
+ // Reduce the headphone volume something more comfortable
173
+ dac. write ( Register :: HeadphoneAVol , VOLUME as u8 ) . unwrap ( ) ;
174
+ dac. write ( Register :: HeadphoneBVol , VOLUME as u8 ) . unwrap ( ) ;
173
175
174
176
// Power up DAC
175
177
dac. write ( Register :: PowerCtl1 , 0b1001_1110 ) . unwrap ( ) ;
Original file line number Diff line number Diff line change 5
5
//!
6
6
//! # Hardware required
7
7
//!
8
- //! * STM32F411E-DISCO evaluation board
8
+ //! * STM32F407G-DISC1 or STM32F411E-DISCO evaluation board
9
9
//! * Headphones or speakers with a headphone plug
10
10
//!
11
11
//! # Procedure
@@ -54,6 +54,11 @@ use stm32f4xx_hal::prelude::*;
54
54
55
55
use cs43l22:: { Cs43L22 , Register } ;
56
56
57
+ /// Volume in decibels
58
+ ///
59
+ /// Depending on your speakers, you may need to adjust this value.
60
+ const VOLUME : i8 = -100 ;
61
+
57
62
/// A sine wave spanning 64 samples
58
63
///
59
64
/// With a sample rate of 48 kHz, this produces a 750 Hz tone.
@@ -161,12 +166,9 @@ fn main() -> ! {
161
166
// Word length 16 bits
162
167
dac. write ( Register :: InterfaceCtl1 , 0b0_0_0_0_01_11 ) . unwrap ( ) ;
163
168
164
- // Reduce the headphone volume to make the demo less annoying
165
- let headphone_volume = -30i8 as u8 ;
166
- dac. write ( Register :: HeadphoneAVol , headphone_volume)
167
- . unwrap ( ) ;
168
- dac. write ( Register :: HeadphoneBVol , headphone_volume)
169
- . unwrap ( ) ;
169
+ // Reduce the headphone volume something more comfortable
170
+ dac. write ( Register :: HeadphoneAVol , VOLUME as u8 ) . unwrap ( ) ;
171
+ dac. write ( Register :: HeadphoneBVol , VOLUME as u8 ) . unwrap ( ) ;
170
172
171
173
// Power up DAC
172
174
dac. write ( Register :: PowerCtl1 , 0b1001_1110 ) . unwrap ( ) ;
You can’t perform that action at this time.
0 commit comments