1

Тема: NJW1153

GENERAL DESCRIPTION
NJW1153 is a 6-channel electronic volume IC. It includes Input selector, tone control, volume, mute, input selector gain control, volume output gain control and 3 REC outputs. Each mode and conditions are set by the 3-wired serial control data.

http://forum.rcl-radio.ru/uploads/image … 91fb07.pdf


NJW1153.h

//  NJW1153 MITSUBISHI SOUND PROCESSOR ICs
//  Alexander Liman
//  liman324@yandex.ru
//  rcl-radio.ru

#ifndef  NJW1153_H
#define  NJW1153_H

#define VOL_1   0B00000101
#define VOL_2   0B00010101
#define VOL_3   0B00100101
#define VOL_4   0B00110101
#define VOL_5   0B01000101
#define VOL_6   0B01010101
#define SETUP1  0B01100101
#define SETUP2  0B01110101
#define SETUP3  0B10000101
#define SETUP4  0B10010101

#include <Arduino.h>


class  NJW1153
  {
    public:
 NJW1153(uint8_t,uint8_t,uint8_t); 
 void init();  
 void volume1(byte vol1);
 void volume2(byte vol2);
 void volume3(byte vol3);
 void volume4(byte vol4);
 void volume5(byte vol5);
 void volume6(byte vol6);
 void setup1(byte in_gain, byte out_gain, bool bsw, bool ssw);
 void setup2(int treb, bool tsw);
 void setup3(int bass);
 void setup4(byte input, byte multi_sel, bool rec2, bool rec1, bool rec0);
    private:

  uint8_t REQ_PIN;
  uint8_t SCK_PIN;
  uint8_t DATA_PIN;
  void Write(byte reg, byte dout);
  };
#endif

NJW1153.cpp

#include <NJW1153.h>

NJW1153::NJW1153(uint8_t req, uint8_t sck, uint8_t data){
          REQ_PIN = req;
          SCK_PIN = sck;
          DATA_PIN = data;
      pinMode(REQ_PIN,OUTPUT);
      pinMode(SCK_PIN,OUTPUT);
      pinMode(DATA_PIN,OUTPUT);
      digitalWrite(REQ_PIN,HIGH);
      digitalWrite(SCK_PIN,HIGH);
      digitalWrite(DATA_PIN,HIGH);
      delay(100);
}
void NJW1153::init(){// INITIAL CONDITION
   Write(255,VOL_1);
   Write(255,VOL_2);
   Write(255,VOL_3);
   Write(255,VOL_4);
   Write(255,VOL_5);
   Write(255,VOL_6);
   Write(0,SETUP1);
   Write(0,SETUP2);
   Write(0,SETUP3);
   Write(0,SETUP4);
}
/*
     INITIAL CONDITION
D15 ......................... D0
1 1 1 1 1 1 1 1 0 0 0 0 0 1 0 1
1 1 1 1 1 1 1 1 0 0 0 1 0 1 0 1
1 1 1 1 1 1 1 1 0 0 1 0 0 1 0 1
1 1 1 1 1 1 1 1 0 0 1 1 0 1 0 1
1 1 1 1 1 1 1 1 0 1 0 0 0 1 0 1
1 1 1 1 1 1 1 1 0 1 0 1 0 1 0 1
0 0 0 0 0 0 0 0 0 1 1 0 0 1 0 1
0 0 0 0 0 0 0 0 0 1 1 1 0 1 0 1
0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 1
0 0 0 0 0 0 0 0 1 0 0 1 0 1 0 1
*/

void NJW1153::volume1(byte vol1){Write(vol1<<1,VOL_1);}
void NJW1153::volume2(byte vol2){Write(vol2<<1,VOL_2);}
void NJW1153::volume3(byte vol3){Write(vol3<<1,VOL_3);}
void NJW1153::volume4(byte vol4){Write(vol4<<1,VOL_4);}
void NJW1153::volume5(byte vol5){Write(vol5<<1,VOL_5);}
void NJW1153::volume6(byte vol6){Write(vol6<<1,VOL_6);}

void NJW1153::setup1(byte in_gain, byte out_gain, bool bsw, bool ssw){
 byte set1 = in_gain << 5 | out_gain << 2 | bsw << 1 | ssw;
 Write(set1,SETUP1);
}
 
void NJW1153::setup2(int treb, bool tsw){
   bool cb_treb;
   if(treb>0){cb_treb=1;}else{cb_treb=0;}
   byte set2 = cb_treb << 7 | abs(treb) << 3 | tsw << 2;
   Write(set2,SETUP2);
}
void NJW1153::setup3(int bass){
   bool cb_bass;
   if(bass > 0){cb_bass=1;}else{cb_bass=0;}
   byte set3 = cb_bass << 7 | abs(bass) << 3;
   Write(set3,SETUP3);
}
 
void NJW1153::setup4(byte input, byte multi_sel, bool rec2, bool rec1, bool rec0){
   byte set4 = input << 5 | multi_sel << 3 | rec2 << 2 | rec1 << 1 | rec0;
   Write(set4,SETUP4);
}

void NJW1153::Write(byte reg, byte dout){  // WRITE_REG 
   digitalWrite(SCK_PIN,HIGH);
   digitalWrite(REQ_PIN,LOW);
     for(int i = 7; i >= 0; i--){
        digitalWrite(DATA_PIN, (dout >> i) & 0x01);
        digitalWrite(SCK_PIN,LOW);digitalWrite(SCK_PIN,HIGH);
        }
     for(int i = 7; i >= 0; i--){
        digitalWrite(DATA_PIN, (reg >> i) & 0x01);
        digitalWrite(SCK_PIN,LOW); digitalWrite(SCK_PIN,HIGH);
        } 
   digitalWrite(REQ_PIN,HIGH); 
   delay(1);       
 }  

test.ino

#define REQ    2
#define SCK    3
#define DATA   4

#include <NJW1153.h>

NJW1153 njw(REQ,SCK,DATA);


void setup(){
  delay(100);
  //init();
  audio();
  }

void loop(){
  
  }

void audio(){
  njw.volume1(0);//  0...-100dB === byte 0...100 | mute = byte 127
  njw.volume2(0);//  0...-100dB === byte 0...100 | mute = byte 127
  njw.volume3(0);//  0...-100dB === byte 0...100 | mute = byte 127
  njw.volume4(0);//  0...-100dB === byte 0...100 | mute = byte 127
  njw.volume5(0);//  0...-100dB === byte 0...100 | mute = byte 127
  njw.volume6(0);//  0...-100dB === byte 0...100 | mute = byte 127
  njw.setup1(0, 0, 1, 0);
  // in_gain 0|-3|-6|-9|-12dB === byte 0...4
  // out_gain 0|+3|+6|+9|+12|+15|+18 === byte 0...6
  // bsw (SWch Output add to L/Rch Output) off|add === bool 0...1
  // ssw (SW Output ON/OFF) sw output on|sw output off === bool 0...1
  njw.setup2(0, 1);
  // treb +-10dB === int -10...+10
  // tsw (Tone Control) off|on === bool 0...1
  njw.setup3(0);
  // bass +-10dB === int -10...+10
  njw.setup4(0, 0,  0,0,0);
  // input 1...8 === byte 0...7
  // multi_sel (Multi Channel Selector):
  //       Input Selector Output Signal === byte 0
  //       Multi channel Input Signal A === byte 1   
  //       Multi channel Input Signal B === byte 2
  // rec2 on|off === bool 0...1
  // rec1 on|off === bool 0...1
  // rec0 on|off === bool 0...1
  }