もっと今更、SC-88ProにS/PDIFを付けよう

Dependencies:   mbed

もっと今更、SC-88ProにS/PDIFを付けよう

STM32F103C8T6 ARM STM32 (blue pill)

  • モデル:STM32F103C8T6
  • コア:ARM 32 Cortex-M3 CPU
  • 72MHz頻度を作動させる
  • 64Kフラッシュメモリ、20K SRAM
  • 2.0-3.6Vパワー、I/O

というやつ。

/media/uploads/peu605/frontview.jpg

詳細はwikiの説明に

https://developer.mbed.org/users/peu605/code/DIT88proSTM32F1/wiki/説明

しまったなぁ、wikiのタイトル、漢字にしてしまったよ…

STM32F103C8T6, Roland, SC-88pro, S/PDIF, SPIDF, デジタル出力

Committer:
peu605
Date:
Tue Sep 12 07:41:48 2017 +0000
Revision:
11:79658b6d3f39
Parent:
10:bbf0ab5cc56f
remove CRC form channel status

Who changed what in which revision?

UserRevisionLine numberNew contents of line
peu605 0:b3d998305b9d 1 #include "stm32f1xx_ll_bus.h"
peu605 0:b3d998305b9d 2 #include "stm32f1xx_ll_gpio.h"
peu605 0:b3d998305b9d 3 #include "stm32f1xx_ll_dma.h"
peu605 0:b3d998305b9d 4 #include "stm32f1xx_ll_spi.h"
peu605 0:b3d998305b9d 5 #include "stm32f1xx_ll_cortex.h"
peu605 0:b3d998305b9d 6
peu605 10:bbf0ab5cc56f 7 //#include "stm32f1xx_ll_rcc.h"
peu605 10:bbf0ab5cc56f 8 //#include "stm32f1xx_ll_system.h"
peu605 10:bbf0ab5cc56f 9 //#include "stm32f1xx_ll_utils.h"
peu605 2:62c8aa0c38c7 10
peu605 3:bdac1803f0fd 11
peu605 0:b3d998305b9d 12 /**
peu605 0:b3d998305b9d 13 * STM32F103C8T6 Blue Pill
peu605 0:b3d998305b9d 14 *
peu605 0:b3d998305b9d 15 * Software Digital audio Transmitter
peu605 0:b3d998305b9d 16 * for Roland SC-88pro (32kHz, 18bit, Right justified, 256fs)
peu605 0:b3d998305b9d 17 *
peu605 0:b3d998305b9d 18 * @author masuda, Masuda Naika
peu605 0:b3d998305b9d 19 */
peu605 0:b3d998305b9d 20
peu605 0:b3d998305b9d 21 // channel status consumer
peu605 0:b3d998305b9d 22 // byte0
peu605 0:b3d998305b9d 23 #define C_PRO 0
peu605 0:b3d998305b9d 24 #define C_AUDIO 1
peu605 0:b3d998305b9d 25 #define C_COPY 2
peu605 0:b3d998305b9d 26 #define C_EMPH0 3
peu605 0:b3d998305b9d 27 #define C_EMPH1 4
peu605 0:b3d998305b9d 28 #define C_EMPH2 5
peu605 0:b3d998305b9d 29 #define C_MODE0 6
peu605 0:b3d998305b9d 30 #define C_MODE1 7
peu605 0:b3d998305b9d 31
peu605 0:b3d998305b9d 32 // byte3
peu605 0:b3d998305b9d 33 #define C_FS0 0
peu605 0:b3d998305b9d 34 #define C_FS1 1
peu605 0:b3d998305b9d 35 #define C_FS2 2
peu605 0:b3d998305b9d 36 #define C_FS3 3
peu605 0:b3d998305b9d 37 #define C_CLKACC0 4
peu605 0:b3d998305b9d 38 #define C_CLKACC1 5
peu605 0:b3d998305b9d 39
peu605 0:b3d998305b9d 40 #define _BV(bit) (1 << (bit))
peu605 0:b3d998305b9d 41
peu605 0:b3d998305b9d 42 // SPDIF preambles, last cell zero, stretched double to 16bit
peu605 0:b3d998305b9d 43 #define PREAMBLE_Z 0b1111110011000000 //0b11101000
peu605 0:b3d998305b9d 44 #define PREAMBLE_X 0b1111110000001100 //0b11100010
peu605 0:b3d998305b9d 45 #define PREAMBLE_Y 0b1111110000110000 //0b11100100
peu605 0:b3d998305b9d 46
peu605 0:b3d998305b9d 47 // Biphase Mark Code table
peu605 0:b3d998305b9d 48 volatile const uint16_t bmcTable[16] = {
peu605 0:b3d998305b9d 49 0b1111000011110000,
peu605 0:b3d998305b9d 50 0b1100111100001111,
peu605 0:b3d998305b9d 51 0b1111001100001111,
peu605 0:b3d998305b9d 52 0b1100110011110000,
peu605 0:b3d998305b9d 53 0b1111000011001111,
peu605 0:b3d998305b9d 54 0b1100111100110000,
peu605 0:b3d998305b9d 55 0b1111001100110000,
peu605 0:b3d998305b9d 56 0b1100110011001111,
peu605 0:b3d998305b9d 57 0b1111000011110011,
peu605 0:b3d998305b9d 58 0b1100111100001100,
peu605 0:b3d998305b9d 59 0b1111001100001100,
peu605 0:b3d998305b9d 60 0b1100110011110011,
peu605 0:b3d998305b9d 61 0b1111000011001100,
peu605 0:b3d998305b9d 62 0b1100111100110011,
peu605 0:b3d998305b9d 63 0b1111001100110011,
peu605 0:b3d998305b9d 64 0b1100110011001100,
peu605 0:b3d998305b9d 65 };
peu605 0:b3d998305b9d 66
peu605 0:b3d998305b9d 67 // SPIRx-DMA circular buffer
peu605 0:b3d998305b9d 68 typedef struct {
peu605 0:b3d998305b9d 69 uint16_t ltCh[8];
peu605 0:b3d998305b9d 70 uint16_t rtCh[8];
peu605 0:b3d998305b9d 71 } SpiRxBuff;
peu605 0:b3d998305b9d 72
peu605 0:b3d998305b9d 73 // SPITx-DMA circular buffer
peu605 0:b3d998305b9d 74 typedef struct {
peu605 0:b3d998305b9d 75 uint16_t aCh[8];
peu605 0:b3d998305b9d 76 uint16_t bCh[8];
peu605 0:b3d998305b9d 77 } SpiTxBuff;
peu605 0:b3d998305b9d 78
peu605 0:b3d998305b9d 79 // channel status
peu605 0:b3d998305b9d 80 typedef struct {
peu605 0:b3d998305b9d 81 uint8_t ltCh;
peu605 0:b3d998305b9d 82 uint8_t rtCh;
peu605 0:b3d998305b9d 83 } ChannelStatus;
peu605 0:b3d998305b9d 84
peu605 0:b3d998305b9d 85 // Private function prototypes
peu605 0:b3d998305b9d 86 uint8_t calcCRC(uint8_t *chStatusPtr);
peu605 0:b3d998305b9d 87 uint32_t oddParity(uint32_t val);
peu605 0:b3d998305b9d 88 void setChannelStatus();
peu605 0:b3d998305b9d 89 void setupPeripherals();
peu605 0:b3d998305b9d 90 void transferFrames();
peu605 0:b3d998305b9d 91 void transferFrame();
peu605 2:62c8aa0c38c7 92 void transferSubFrame(uint32_t frameIndex, bool aCh, uint16_t *rxBuffPtr, uint16_t *txBuffPtr);
peu605 2:62c8aa0c38c7 93 void toBinary(uint16_t *val_ptr, char *str);
peu605 2:62c8aa0c38c7 94 void debugOut();
peu605 7:f3536af611e6 95 void SystemClock_Config();
peu605 7:f3536af611e6 96
peu605 7:f3536af611e6 97 // for 72MHz
peu605 10:bbf0ab5cc56f 98 //extern "C" uint8_t SetSysClock_PLL_HSE(uint8_t bypass); // in "system_clock.c"