2012年4月30日月曜日

Arduino UNOにEasyMP3を繋げてみた。

数年前に購入してすっかり放置しっぱなしだったEasyMP3を動かすべく、Arduinoに繋いでみた。
作成したコードは以下の通り。

 #include 

//EasyMP3
//
//参考:VS1001Kの使い方
//     http://www.cek.ne.jp/~kunio.h/vs1001.html
//http://www.yuki-lab.jp/hw/mp3player.html
//

int vol_up_val = 0;
int old_vol_up_val = 0;
int vol_down_val = 0;
int old_vol_down_val = 0;
int volume =0x4F;
unsigned long startTime = 0;
int incomingByte = 0; // 受信データ用
unsigned char beep_start[]={
  0x53, 0xEF, 0x6E, 0x31, 0, 0, 0, 0 };
unsigned char beep_stop[]={
  0x45, 0x78, 0x69, 0x74, 0, 0, 0, 0 };
unsigned char mp3_data[]={
  0xFF,0xF2,0x40,0xC0,0x19,0xB7,0x00,0x14,0x02,0xE6,0x5C, 
  0x01,0x92,0x68,0x01,0xF1,0x5E,0x03,0x08,0xF0,0x24,0x80, 
  0x05,0x9E,0x20,0xC6,0xFC,0x12,0x32,0x5C,0xBF,0xF9,0xB9, 
  0x20,0x4A,0x7F,0x85,0xEC,0x4C,0xCD,0xC7,0x27,0xFE,0x5C, 
  0x34,0x25,0xCB,0xE6,0xFF,0xFF,0x8E,0x42,0xE1,0xA0,0x5E, 
  0xCA,0x6E,0x30,0x9F,0xFF,0xF8,0xC2,0x12,0x84,0xB9,0x7C, 
  0xDC,0x61,0x09,0x4A,0x7F,0xFF,0xFF,0xF9,0x7D,0x32,0x51, 
  0x09,0x7C,0xE1,0xA5,0x6E,0xB4,0xFF,0xFF,0xFF,0xFF,0xD3, 
  0x34,0x41,0x91,0xF0,0x11,0x8F,0x00,0x0F,0x81,0x9C,0x10, 
  0xEE,0x59,0xCE,0x56,0x67,0xFF,0xF2,0x42,0xC0,0xEC,0x53, 
  0x09,0x15,0xF9,0xAA,0xA8,0x0D,0xD9,0x40,0x00,0xCA,0x34, 
  0x53,0xD9,0x18,0xAB,0x7D,0xF7,0x89,0x3F,0x11,0x38,0x94, 
  0x82,0x59,0x93,0x20,0x6A,0x0C,0xEE,0x8E,0x58,0xFA,0x38, 
  0x82,0xCA,0xF0,0x58,0xBB,0xDA,0x0C,0x50,0x56,0x1F,0xBB, 
  0x18,0x5D,0x8B,0x9F,0xDA,0x71,0x4F,0xFF,0xBD,0xFE,0xEF, 
  0x69,0x36,0x86,0x3C,0x50,0xBB,0x0A,0x07,0x89,0x54,0xF0, 
  0x88,0x9F,0x90,0x95,0x30,0x94,0x2E,0x7E,0xF0,0x64,0x96, 
  0x79,0x08,0x3E,0x20,0x97,0x28,0x34,0x9C,0x09,0x7F,0xD2, 
  0xC0,0x01,0x75,0xF8,0x05,0x6B,0x5F,0x41,0x17,0x0B,0xE7, 
  0xFF,0xF2,0x40,0xC0,0x61,0xE5,0x0B,0x16,0x09,0xC6,0xC5, 
  0x74,0x7B,0xCC,0x94,0x7A,0xF7,0x80,0x76,0xB2,0xD2,0xF8, 
  0x39,0x06,0x38,0xFD,0x71,0xC5,0xDE,0x3A,0x38,0xBF,0xD5, 
  0xF7,0x12,0x37,0xCB,0xF5,0x63,0x0C,0x9B,0xCE,0x77,0x25, 
  0xED,0xFB,0x3D,0x6B,0x35,0xF9,0x6D,0xD7,0xF9,0x2C,0xD1, 
  0x97,0x15,0x87,0x93,0xA4,0x49,0x4A,0x18,0x16,0x07,0xA1, 
  0x60,0xF7,0x52,0x94,0xDB,0x02,0x16,0x70,0xB2,0xD8,0x80, 
  0x30,0xC2,0x94,0x40,0x81,0x74,0x5A,0x19,0x7A,0x80,0x60, 
  0x41,0x21,0x46,0x95,0xD5,0xC4,0x40,0xD2,0x01,0xC0,0x01, 
  0xDA,0xD9,0xA0,0xB1,0x01,0xFF,0xF2,0x42,0xC0,0x82,0x10, 
  0x0B,0x12,0xF9,0x9E,0xC9,0x7E,0x7A,0xC6,0x95,0x55,0x09, 
  0x8B,0x19,0x5E,0x8B,0x26,0xCA,0xEB,0x68,0x8A,0x05,0x8F, 
  0x36,0xA5,0xA5,0x03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0x43,0x87,0x5F,0x4F,0x27,0x9C,0x2C, 
  0xD0,0x91,0xF3,0x87,0x9B,0x54,0xED,0xD1,0xB4,0xF3,0x39, 
  0x87,0x22,0x06,0x86,0x0D,0x71,0xE4,0x6F,0x2A,0x08,0x04, 
  0xC0,0x03,0x2A,0xB1,0xE2,0x05,0x4D,0x64,0xA1,0x9C,0xA6, 
  0x0D,0x41,0xA6,0xF2,0x7A,0xC1,0x30,0xC3,0x38,0x26,0x09, 
  0x50,0x08,0xC4,0xF6,0x30,0x0C,0xA6,0xA9,0x17,0x00,0x13, 
  0x0C,0xDC,0xC4,0x2F,0x28,0xEB,0x3F,0xCD,0x7A,0x3D,0x2F, 
  0xFF,0xF2,0x40,0xC0,0x18,0x6F,0x2E,0x13,0xA1,0xF2,0xBC, 
  0x36,0xCB,0x4E,0x99,0x6E,0xFC,0xEE,0xC5,0xF0,0xA0,0xB7, 
  0x92,0xD4,0xEE,0x79,0x7C,0x50,0x5D,0xE5,0x04,0x94,0xA9, 
  0x76,0xCF,0x6C,0x70,0xDD,0x0D,0xD4,0xEE,0xED,0x98,0xE8, 
  0xC8,0x35,0x36,0x7A,0x0C,0x05,0x80,0x03,0xBC,0xBE,0x91, 
  0x00,0x7C,0xAE,0x65,0xB8,0x91,0xA3,0x33,0xBA,0x68,0x60, 
  0xD4,0x1A,0x66,0xF8,0x43,0xA0,0x20,0x89,0xE7,0x80,0xD8, 
  0x1E,0x4F,0xA0,0x04,0x60,0x06,0x0A,0xA4,0x91,0x24,0xFA, 
  0x9F,0x57,0x53,0xF4,0x7A,0xDB,0x5F,0x56,0xE3,0x6E,0x0B, 
  0x8B,0x3A,0x1C,0xF9,0x5E,0xFF,0xF2,0x42,0xC0,0xB1,0x00, 
  0x38,0x14,0x09,0xEE,0xB4,0x36,0xD3,0x4E,0x99,0xA4,0x78, 
  0x94,0x73,0xC4,0x66,0x30,0xF5,0xEA,0xDB,0xBA,0x67,0x67, 
  0x95,0x6B,0xAB,0x68,0x5D,0x08,0xA1,0x39,0x56,0xAB,0x1E, 
  0xD5,0x03,0xE8,0x01,0x70,0x00,0xB3,0x93,0x33,0x19,0x8C, 
  0x61,0x8F,0xBB,0x5D,0x24,0x12,0x63,0xD3,0x4B,0x5D,0x91, 
  0x08,0x43,0x22,0x56,0x1A,0xC5,0x10,0x21,0x84,0xA8,0xEA, 
  0x80,0xBF,0x16,0x8E,0x3D,0x46,0x18,0x9C,0x6E,0x9A,0x91, 
  0xE6,0xC9,0x6F,0xD2,0x7D,0x27,0xD7,0xE9,0x6B,0xFF,0x0A, 
  0x03,0x43,0x89,0xD5,0xBF,0x52,0x97,0x0A,0x25,0x95,0x0D, 
  0xFF,0xF2,0x40,0xC0,0xF5,0xC3,0x41,0x13,0x81,0xEE,0xA8, 
  0x5E,0xD3,0x44,0x98,0xFC,0xCF,0x97,0xF9,0x58,0xB5,0x33, 
  0xB1,0x85,0x47,0x86,0xD7,0x98,0x01,0x3B,0xA3,0x4F,0x7E, 
  0x04,0xA6,0xC3,0x39,0x21,0x70,0x27,0x62,0xB5,0x18,0x10, 
  0x09,0x99,0x00,0x8B,0x7E,0xF2,0xBF,0x52,0x18,0x26,0x30, 
  0x1C,0xB0,0x01,0x49,0x30,0xE0,0xC3,0x11,0x46,0x05,0xCC, 
  0x49,0x14,0x28,0xB2,0xED,0x4B,0x57,0x5A,0x2F,0xB7,0x46, 
  0x63,0x34,0xD2,0xDA,0x9F,0x56,0x32,0xB7,0xA2,0x25,0xFF, 
  0x94,0x28,0x33,0x7F,0x3B,0xC4,0x50,0xEC,0xB1,0xE2,0x26, 
  0xA1,0xB7,0x07,0x7F,0xFB,0xFF,0xF2,0x42,0xC0,0x67,0x6A, 
  0x4C,0x13,0xF9,0x6A,0x90,0x7E,0xDB,0x44,0x94,0x3F,0xFF, 
  0x14,0xD6,0x2A,0xFF,0xFF,0xC1,0x34,0x8C,0x48,0x22,0x00, 
  0x06,0x8F,0x21,0xFD,0x64,0x60,0x04,0x92,0x42,0xEA,0x74, 
  0x32,0x37,0xAA,0x5A,0x9F,0x67,0x01,0x8B,0x3F,0x37,0x31, 
  0xDD,0x06,0x3C,0x01,0x34,0x30,0xE0,0x5C,0x78,0x78,0xCB, 
  0xD6,0xF1,0x31,0x8A,0x69,0x61,0x93,0x92,0x42,0xCE,0x4B, 
  0xC5,0x02,0x4E,0x73,0xC6,0x24,0x30,0xCD,0x08,0x66,0xC6, 
  0x35,0xAB,0xA2,0x3D,0x2F,0xB3,0xBD,0x34,0x87,0x13,0xEE, 
  0x71,0x45,0x68,0xFA,0xEA,0x05,0x84,0x41,0x36,0x4C,0x9A, 
  0xFF,0xF2,0x40,0xC0,0xC9,0x92,0x56,0x13,0xD0,0x6E,0x70, 
  0x54,0xD3,0xCC,0x28,0x06,0xD7,0x0E,0xA4,0x1D,0x9C,0x9D, 
  0xD9,0xA9,0x88,0x7B,0xB5,0xA3,0x56,0xB7,0x4B,0x4B,0x5A, 
  0x9B,0x2C,0xA9,0xAD,0x6F,0x99,0x6C,0xC0,0x4C,0x14,0x14, 
  0xEF,0xB4,0x20,0x91,0x5F,0xBC,0x81,0x41,0x41,0x5D,0xD4, 
  0x20,0xBD,0x05,0x1A,0x6F,0xE2,0x68,0x56,0x41,0x41,0x57, 
  0xF9,0xBF,0x89,0x82,0x8E,0xC7,0x8F,0x0A,0x0A,0x09,0x37, 
  0xF1,0x05,0x0A,0x0A,0x0A,0x0A,0x09,0x05,0x37,0xFF,0x10, 
  0x50,0x50,0x53,0x65,0xFF,0xFF,0xFD,0x75,0xDF,0xFF,0xFF, 
  0x68,0x4F,0xFF,0x84,0x70,0xFF,0xF2,0x42,0xC0,0x27,0x50, 
  0x5F,0x17,0xE8,0x82,0x3C,0x11,0x58,0x18,0x01,0x55,0x48, 
  0xBC,0x52,0xFC,0x4A,0x4C,0x3C,0xD5,0xF6,0x11,0x2D,0xBF, 
  0xEA,0x03,0x5C,0x57,0x29,0xBF,0xC3,0x75,0x1C,0xE6,0xDD, 
  0xBF,0xED,0xEF,0xD0,0x98,0x77,0x71,0x95,0x73,0xFF,0xED, 
  0x54,0xBE,0xD5,0xEE,0xAE,0xC2,0xD5,0x0B,0xFF,0xF1,0x97, 
  0x8A,0xE4,0x42,0x09,0x99,0xB1,0xEA,0x94,0xDC,0x78,0xB5, 
  0x34,0x0F,0xF1,0x8F,0xFC,0x15,0xF6,0xFA,0xB1,0x47,0xA9, 
  0x6C,0x67,0x43,0x8B,0xF2,0x76,0x22,0xED,0xDA,0x85,0xBA, 
  0x2F,0xC7,0xF9,0xCF,0xFC,0xDB,0x46,0x2E,0x50,0x0A,0x84, 
  0xFF,0xF2,0x40,0xC0,0xC6,0x4A,0x59,0x28,0x2B,0x19,0xE0, 
  0x01,0x89,0x78,0x00,0x52,0x85,0x3C,0x8E,0x54,0x9A,0x48, 
  0x5A,0x72,0x32,0x94,0xBF,0x43,0x4F,0x24,0x53,0x4B,0xEC, 
  0x4B,0x99,0x0E,0x66,0x1F,0xFF,0xCE,0x7F,0xFF,0x3F,0x10, 
  0xAE,0x82,0x62,0x71,0x34,0x18,0x59,0x9B,0x51,0xC7,0x59, 
  0xCE,0xEE,0xA5,0xFE,0x02,0xBB,0x30,0x91,0x49,0xD5,0x4B, 
  0xF3,0xDC,0x9A,0xA9,0x57,0x8E,0x72,0x10,0xC0,0x5D,0x60, 
  0x67,0xFC,0x7D,0xD6,0xBA,0xDD,0xB3,0x8B,0x5A,0x0A,0x4C, 
  0x41,0x4D,0x45,0x33,0x2E,0x39,0x33,0xAA,0xAA,0xAA,0xAA, 
  0xAA,0xAA,0xAA,0xAA,0xAA,0x54,0x41,0x47,0x48,0x65,0x6C, 
  0x6C,0x6F,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, 
  0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, 
  0x20,0x20,0x20,0x20,0x20,0x50,0x61,0x6E,0x75,0x2D,0x4B, 
  0x72,0x69,0x73,0x74,0x69,0x61,0x6E,0x20,0x50,0x6F,0x69, 
  0x6B,0x73,0x61,0x6C,0x6F,0x20,0x20,0x20,0x20,0x20,0x20, 
  0x20,0x20,0x56,0x53,0x44,0x53,0x50,0x20,0x54,0x65,0x73, 
  0x74,0x69,0x6E,0x67,0x20,0x20,0x20,0x20,0x20,0x20,0x20, 
  0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, 
  0x20,0x20,0x20,0x4D,0x50,0x33,0x20,0x48,0x65,0x6C,0x6C, 
  0x6F,0x2C,0x20,0x57,0x6F,0x72,0x6C,0x64,0x21,0x20,0x20, 
  0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, 
  0x00, /* . */};

void setup(){
  //ピン定義
  //#define SO 0
#define SI 2
#define SCLK 3
#define CS 4
#define RESET 5
#define BSYNC 6
#define DCLK 7
#define DREQ 8
#define VOLUP 9
#define VOLDOWN 10
  //pinMode(SO,INPUT);
  pinMode(SI,OUTPUT);
  pinMode(SCLK,OUTPUT);
  pinMode(CS,OUTPUT);
  pinMode(RESET,OUTPUT);
  pinMode(BSYNC,INPUT);
  pinMode(DCLK,OUTPUT);
  pinMode(DREQ,INPUT);
  pinMode(VOLUP,INPUT);
  pinMode(VOLDOWN,INPUT);
  //プルアップ
  digitalWrite(VOLUP,HIGH);
  digitalWrite(VOLDOWN,HIGH);

  //debug
  Serial.begin(57600);



  //初期化処理
  //ハードウエアリセット解除
  digitalWrite(RESET,HIGH);
  //1msec以上待つ
  delay(1);
  //EasyMP3初期化
  MP3_init();
  incomingByte=48;

}
//MP3データByte送信
void MP3_data_write(unsigned char data){
  char i;
  //DREQがHighに成るまで待つ
  while(digitalRead(DREQ) == LOW);
  //BSYNCをHIGH
  digitalWrite(BSYNC,HIGH);
  //1Byte送信
  //shiftOut(SI,DCLK,MSBFIRST,data);
  //shiftOutの中身は、以下のコードと等価
  for (i=0; i<8; i++){
    //指定したビットだけ立てる
    // 2 And 0x80
    // 00000010 And 10000000 = 00000000
    //
    if (data & 0x80){
      //SIをHighにする
      digitalWrite(SI,HIGH);
    }
    else {
      //SIをLowにする
      digitalWrite(SI,LOW);
    }
    //クロックをHighにする
    digitalWrite(DCLK,HIGH);
    //dataを1bit左シフトする
    // 00000010 -> 00000100
    data <<= 1;
    //クロックをLowにする
    digitalWrite(DCLK,LOW);
    //BSYNCをLow *怪しい箇所
    digitalWrite(BSYNC,LOW);

  }
  //BSYNCをLow *怪しい箇所
  //digitalWrite(BSYNC,LOW);

}
//****************************************
// EasyMP3 初期化
//****************************************
void MP3_init(void){
  //DREQがHighに成るまで待つ
  while(digitalRead(DREQ) == LOW);
  //ソフトウエアリセット
  MP3_command(0, 0x0004);
  //5usec以上まつ
  delayMicroseconds(5);
  //解除
  MP3_command(0, 0x0000);
  //DREQがHighに成るまで待つ
  while(digitalRead(DREQ) == LOW);
  //クロック指定(14.318Mhz)
  MP3_command(3, 0x8000 + (unsigned int)((14318180)/2000));
  //ボリューム指定
  Set_Vol(0x4F);

}
//****************************************
// ボリュームセット(左右同時)
//****************************************
void Set_Vol(unsigned int data){
  //ボリューム指定 上位8bit=左 下位8bit=右
  MP3_command(11, (data << 8)|(data)); // 音量設定
}
//****************************************
// EasyMP3コマンド送信
//****************************************
void MP3_command(unsigned char addr,unsigned int arg){
  //CSをLowにする
  digitalWrite(CS,LOW);
  MP3_command_write(2);//書き込みモード
  MP3_command_write(addr);//アドレス指定
  MP3_command_write(arg >> 8);//上位8bit
  MP3_command_write(arg);//下位8bit
  //CSをHighにする
  digitalWrite(CS,HIGH);
}
//****************************************
// EasyMP3 コマンド 1byte出力
//****************************************
void MP3_command_write(unsigned char data){
  shiftOut(SI,SCLK,MSBFIRST,data);
}
void loop(){


  //Beepを成らしてみる
   unsigned char i;
   for (i=0;i<8;++i){
   MP3_data_write(beep_start[i]);
   }
   delay(500);
   for (i=0;i<8;++i){
   MP3_data_write(beep_stop[i]);
   }
   delay(500);
   //Serial.println("STOP");
  

  unsigned char *p;

  for(int x = 0 ; x < 4 ; x++) {

    p = &mp3_data[0]; // Point "p" to the beginning of array
    while(p <= &mp3_data[sizeof(mp3_data) - 1]) {
      MP3_data_write(*p++);
      //delay(1);
    }

    //End of file - send 2048 zeros before next file
    //digitalWrite(MP3_XDCS, LOW); //Select Data
    for (int i = 0 ; i < 2048 ; i++) {
      //while(!digitalRead(DREQ)); //If we ever see DREQ low, then we wait here
      //SPI.transfer(0);
      MP3_data_write(0);
    }

  }


}
動作テスト用のBeep音は鳴るのだが、配列に入れたMP3データの再生が上手くいかない。 MP3_data_write関数が悪いのかなぁ。BSYNCの扱いがイマイチ良く分からないんだよね。 先頭1ビットだけHなのか、1-7ビットまでがHなのか。

0 件のコメント:

コメントを投稿