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)
USER_BUTTON: PC_13(default button)
Next song: One click in Play mode.
Pause : Push long time .
Play : One click from Pause.
sys.h@16:1bb81504b23b, 2019-02-17 (annotated)
- Committer:
- mimi3
- Date:
- Sun Feb 17 11:59:16 2019 +0900
- Revision:
- 16:1bb81504b23b
- Parent:
- 11:8dc9fa1e1bdc
mod: comment only
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mimi3 | 0:9a5c2fb0d96f | 1 | #ifndef __SYS_H__ |
mimi3 | 0:9a5c2fb0d96f | 2 | #define __SYS_H__ |
mimi3 | 0:9a5c2fb0d96f | 3 | |
mimi3 | 0:9a5c2fb0d96f | 4 | #include <stdint.h> |
mimi3 | 0:9a5c2fb0d96f | 5 | #include <stdbool.h> |
mimi3 | 0:9a5c2fb0d96f | 6 | #include "mbed.h" |
mimi3 | 0:9a5c2fb0d96f | 7 | |
mimi3 | 0:9a5c2fb0d96f | 8 | /* Selectable options depended on each situation. |
mimi3 | 0:9a5c2fb0d96f | 9 | * If a functionality is needed, the value should be set to 1. |
mimi3 | 0:9a5c2fb0d96f | 10 | * */ |
mimi3 | 0:9a5c2fb0d96f | 11 | |
mimi3 | 0:9a5c2fb0d96f | 12 | /*---------------------- |
mimi3 | 0:9a5c2fb0d96f | 13 | -- Selectable Options |
mimi3 | 0:9a5c2fb0d96f | 14 | ----------------------*/ |
mimi3 | 0:9a5c2fb0d96f | 15 | #define PWM16BIT 1 |
mimi3 | 0:9a5c2fb0d96f | 16 | #define DATA_8BIT_SUPPORT 1 |
mimi3 | 16:1bb81504b23b | 17 | #define HAVE_BUTTON_SW 1 // for 'Play','Pause','Power off' |
mimi3 | 0:9a5c2fb0d96f | 18 | /* Enable either the type of blink or dimmer */ |
mimi3 | 16:1bb81504b23b | 19 | #define HAVE_LED_IND_PWM 1 // blink LED during playing (750msec interval) |
mimi3 | 16:1bb81504b23b | 20 | #define HAVE_LED_IND_BLINK 0 // dimmer LED during playing |
mimi3 | 0:9a5c2fb0d96f | 21 | /**********************/ |
mimi3 | 16:1bb81504b23b | 22 | #define HAVE_LED_PAUSE_INDICATOR 1 // blink or dimmer during pausing |
mimi3 | 16:1bb81504b23b | 23 | #define HAVE_POWER_OFF_MODE 0 // under construction |
mimi3 | 0:9a5c2fb0d96f | 24 | //-- Select FAT32/FAT16 or FAT16 only |
mimi3 | 16:1bb81504b23b | 25 | #define HAVE_FAT32 1 // 0: FAT16 only, 1: FAT16 and FAT32 support |
mimi3 | 0:9a5c2fb0d96f | 26 | //--- end option setting |
mimi3 | 0:9a5c2fb0d96f | 27 | |
mimi3 | 0:9a5c2fb0d96f | 28 | // TEST PORT |
mimi3 | 0:9a5c2fb0d96f | 29 | #define TEST_PORT PA_8 // D7 |
mimi3 | 0:9a5c2fb0d96f | 30 | // LED indicator |
mimi3 | 0:9a5c2fb0d96f | 31 | #define IND_LED PB_10 |
mimi3 | 0:9a5c2fb0d96f | 32 | |
mimi3 | 0:9a5c2fb0d96f | 33 | //-- debug purpose |
mimi3 | 0:9a5c2fb0d96f | 34 | #define UART_INFO 1 |
mimi3 | 0:9a5c2fb0d96f | 35 | #define DEBUG_WAV_PLAYER 0 |
mimi3 | 0:9a5c2fb0d96f | 36 | #define DEBUG_FAT_LIB 0 |
mimi3 | 0:9a5c2fb0d96f | 37 | #define DEBUG_SD_CARD 0 |
mimi3 | 0:9a5c2fb0d96f | 38 | #define TEST_PORT_ENABLE 1 |
mimi3 | 0:9a5c2fb0d96f | 39 | // |
mimi3 | 0:9a5c2fb0d96f | 40 | #define HAVE_DIRECT_SPI 1 |
mimi3 | 0:9a5c2fb0d96f | 41 | |
mimi3 | 0:9a5c2fb0d96f | 42 | typedef uint16_t word; |
mimi3 | 0:9a5c2fb0d96f | 43 | typedef uint32_t dword; |
mimi3 | 0:9a5c2fb0d96f | 44 | typedef uint8_t byte; |
mimi3 | 0:9a5c2fb0d96f | 45 | typedef int8_t sbyte; |
mimi3 | 0:9a5c2fb0d96f | 46 | typedef bool sbit; |
mimi3 | 0:9a5c2fb0d96f | 47 | |
mimi3 | 7:0ea766ea5ee9 | 48 | #ifdef __CC_ARM |
mimi3 | 7:0ea766ea5ee9 | 49 | # define OPT_SPEED /* N/A */ |
mimi3 | 7:0ea766ea5ee9 | 50 | #else |
mimi3 | 6:d9ea630e1ba5 | 51 | # define OPT_SPEED __attribute__((optimize("O3"))) |
mimi3 | 6:d9ea630e1ba5 | 52 | #endif |
mimi3 | 6:d9ea630e1ba5 | 53 | |
mimi3 | 0:9a5c2fb0d96f | 54 | #endif /* __SYS_H__ */ |
mimi3 | 0:9a5c2fb0d96f | 55 | |
mimi3 | 0:9a5c2fb0d96f | 56 |