もっと今更、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:
Fri Sep 01 13:20:19 2017 +0000
Revision:
0:b3d998305b9d
Child:
2:62c8aa0c38c7
first release

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