16bit resolution PWM wave player with SD card, super lite version.

Dependencies:   mbed DirectSPI FastPWM

Supported boards (confirmed):
Nucleo-F030R8
Nucleo-L152RE
Nucleo-F401RE
Nucleo-F411RE

Only compilation is OK (unchecked, but may work):
Nucleo-L073RZ
Nucleo-F334R8
Nucleo-F303RE
Nucleo-F429ZI
Nucleo-F446RE
Nucleo-F446ZE
Nucleo-L476RG

Supported SD card:
SDSC/SDHC card,
FAT16 and FAT32.
(1) At first, format SD card using SD Card Formatter
https://www.sdcard.org/downloads/formatter_4/index.html
(2) Copy PCM wav files to the SD card.
Supported file:
PCM wave file that have file extension ".wav" on root directory.
16bit/8bit, fs(sampling rate)=32kHz,44.1kHz,48kHz.
Stereo/Mono.

Hardware setting:
Refer to the file port_setting.txt
PWM output port:
Left upper(Hi) PWM 8bit out: PB_5 (TM3_CH2)
Right upper(Hi) PWM 8bit out: PB4 (TM3_CH1)
Left lower(Low) PWM 8bit out: PC_9 (TM3_CH4)
Right lower(Low) PWM 8bit out: PC_8 (TM3_CH3)
http://mpu.up.seesaa.net/image/16bit-wave-player-output-schema.png
USER_BUTTON: PC_13(default button)
Next song: One click in Play mode.
Pause : Push long time .
Play : One click from Pause.

Committer:
mimi3
Date:
Fri Oct 09 07:47:36 2020 +0900
Revision:
21:dc161a192ba7
Parent:
12:4c13a0b4fb59
trivial change

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mimi3 0:9a5c2fb0d96f 1 #include "sys.h"
mimi3 0:9a5c2fb0d96f 2 #include "sd_card.h"
mimi3 0:9a5c2fb0d96f 3 #include "fat_lib.h"
mimi3 0:9a5c2fb0d96f 4 #include "pwm_lib.h"
mimi3 0:9a5c2fb0d96f 5 #include "wave_player_main.h"
mimi3 0:9a5c2fb0d96f 6
mimi3 0:9a5c2fb0d96f 7 /* SD card pin
mimi3 0:9a5c2fb0d96f 8 Pin side
mimi3 0:9a5c2fb0d96f 9 --------------\
mimi3 0:9a5c2fb0d96f 10 9 = \ DAT2/NC
mimi3 0:9a5c2fb0d96f 11 1 ===| CS/DAT3 [CS]
mimi3 0:9a5c2fb0d96f 12 2 ===| CMD/DI [DI]
mimi3 0:9a5c2fb0d96f 13 3 ===| VSS1
mimi3 0:9a5c2fb0d96f 14 Bottom 4 ===| VDD
mimi3 0:9a5c2fb0d96f 15 View 5 ===| CLK [CLK]
mimi3 0:9a5c2fb0d96f 16 6 ===| VSS2
mimi3 0:9a5c2fb0d96f 17 7 ===| DO/DAT0 [DO]
mimi3 0:9a5c2fb0d96f 18 8 =| DAT1/IRQ
mimi3 0:9a5c2fb0d96f 19 -----------------
mimi3 0:9a5c2fb0d96f 20
mimi3 0:9a5c2fb0d96f 21 Arduino NUCLEO-F411 NUCLEO-F030R8
mimi3 0:9a5c2fb0d96f 22 Logo side
mimi3 0:9a5c2fb0d96f 23 -----------------
mimi3 0:9a5c2fb0d96f 24 8 =| DAT1/IRQ
mimi3 0:9a5c2fb0d96f 25 7 ===| DO/DAT0 [DO] D12 D12/PA_6 D12/PA_6
mimi3 0:9a5c2fb0d96f 26 6 ===| VSS2
mimi3 0:9a5c2fb0d96f 27 Top 5 ===| CLK [CLK] D13 D13/PA_5 D13/PA_5
mimi3 0:9a5c2fb0d96f 28 View 4 ===| VDD
mimi3 0:9a5c2fb0d96f 29 3 ===| VSS1
mimi3 0:9a5c2fb0d96f 30 2 ===| CMD/DI [DI] D11 D11/PA_7 D11/PA_7
mimi3 0:9a5c2fb0d96f 31 1 ===| CS/DAT3 [CS] D8 D10/PB_6 D10/PB_6
mimi3 0:9a5c2fb0d96f 32 9 = / DAT2/NC
mimi3 0:9a5c2fb0d96f 33 --------------/
mimi3 0:9a5c2fb0d96f 34 */
mimi3 0:9a5c2fb0d96f 35
mimi3 10:1108261dabe8 36 #if UART_INFO && DEVICE_SERIAL
mimi3 12:4c13a0b4fb59 37 RawSerial pc(USBTX,USBRX);
mimi3 0:9a5c2fb0d96f 38 #endif
mimi3 0:9a5c2fb0d96f 39
mimi3 0:9a5c2fb0d96f 40 int main() {
mimi3 10:1108261dabe8 41 #if UART_INFO && DEVICE_SERIAL
mimi3 0:9a5c2fb0d96f 42 setbuf(stdout,0);
mimi3 0:9a5c2fb0d96f 43 pc.baud(115200);
mimi3 0:9a5c2fb0d96f 44 #endif
mimi3 0:9a5c2fb0d96f 45 wait_us(100*1000); /* wait 100msec */
mimi3 0:9a5c2fb0d96f 46 pwm_init();
mimi3 0:9a5c2fb0d96f 47 sd_init();
mimi3 0:9a5c2fb0d96f 48 FAT_init();
mimi3 0:9a5c2fb0d96f 49 wave_player_main();
mimi3 0:9a5c2fb0d96f 50 }
mimi3 0:9a5c2fb0d96f 51
mimi3 0:9a5c2fb0d96f 52
mimi3 10:1108261dabe8 53 void error(const char* format, ...) { }