Skip to content
This repository was archived by the owner on Jun 8, 2025. It is now read-only.

Commit d693fb6

Browse files
committed
CMS@pwm
1 parent 3b87ec4 commit d693fb6

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ target_compile_definitions(${PROJECT_NAME} PRIVATE
231231
#I2S_SOUND
232232
# PWM mode for i2s driver
233233
#AUDIO_PWM_PIN=26
234-
#CMS
234+
CMS
235235
#SOUND_BLASTER
236236
#ADLIB
237237
TANDY3V

src/main.cpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -148,22 +148,26 @@ void __scratch_y("second_core") second_core() {
148148
samples[active_buffer][sample_index * 2] = sample;
149149
samples[active_buffer][sample_index * 2 + 1] = sample;
150150

151-
#ifdef CMS
152-
cms_samples(&samples[active_buffer][sample_index * 2]);
153-
#endif
151+
154152

155153
if (sample_index++ >= i2s_config.dma_trans_count) {
156154
sample_index = 0;
157155
i2s_dma_write(&i2s_config, samples[active_buffer]);
158156
active_buffer ^= 1;
159157
}
160158
#else
159+
int16_t samples[2] = { sample, sample };
160+
#ifdef CMS
161+
162+
cms_samples(samples);
163+
#endif
161164
// register uint8_t r_divider = snd_divider + 4; // TODO: tume up divider per channel
162-
uint16_t corrected_sample = (uint16_t)((int32_t)sample + 0x8000L) >> 4;
165+
uint16_t corrected_sample_l = (uint16_t)((int32_t)samples[0] + 0x8000L) >> 4;
166+
uint16_t corrected_sample_r = (uint16_t)((int32_t)samples[1] + 0x8000L) >> 4;
163167
// register uint8_t l_divider = snd_divider + 4;
164168
//register uint16_t l_v = (uint16_t)((int32_t)sample + 0x8000L) >> 4;
165-
pwm_set_gpio_level(PWM_PIN0, corrected_sample);
166-
pwm_set_gpio_level(PWM_PIN1, corrected_sample);
169+
pwm_set_gpio_level(PWM_PIN0, corrected_sample_l);
170+
pwm_set_gpio_level(PWM_PIN1, corrected_sample_r);
167171
#endif
168172
last_sound_tick = tick;
169173
}

0 commit comments

Comments
 (0)