Тема: R2S15900SP
Description
The R2S15900SP is an optimum audio signal processor IC for TV. It has a 5ch input selector, surround/pseudo stereo tone control(2band), output gain control and 2ch master volume. It can control all of these functions with I2 C bus.
Features
• Volume 0 to –84dB, –∞/ 1dB step | Each channel is independence control.
• 5 input selector + MUTE
• 2 Rec output
• Tone control Bass: –15dB to +15dB/ 1dB step | Treble: –15dB to +15dB/ 1dB step
• Surround <Low/ High> / Pseudo Stereo
• Mode selector Bypass/ Tone / Tone & Pseudo Stereo or Surround
• Output gain control 0dB/ +4.5dB
• I2C-BUS control
• Package 28pin SOP
Даташит - Данный контент доступен только зарегистрированным пользователям.
Библиотека - Данный контент доступен только зарегистрированным пользователям.
R2S15900SP.h
// Алксандр Лиман
// liman324@yandex.ru
#ifndef R2S15900SP_H
#define R2S15900SP_H
#define R2S15900SP_address 0b1000001
#define R2S15900SP_VOL_L 0x00
#define R2S15900SP_VOL_R 0x01
#define R2S15900SP_INPUT 0x02
#define R2S15900SP_BASS 0x03
#define R2S15900SP_TREB 0x04
#include <Arduino.h>
class R2S15900SP
{
public:
R2S15900SP();
void setVol_l(int vol_l); // volume left >> int 84...0 === -84...0 dB
void setVol_r(int vol_r); // volume_right >> int 84...0 === -84...0 dB
void setIn(int in, int gain, int mute);
// input >> int 0 === all off | int 1...5 === input 1...5
// gain >> int 0...1 === 0 dB...+4.5 dB
// mute >> int 0...1 === mute on...mute off
void set_Bass(int surr, int mode, int bass);
// surround mode >> int 0...1 === low level...high level
// mode selector >> int 0...3 === bypass tone tone&Pseudo_stereo tone&Surround
// tone control bass >> int -15...15 === -15dB...+15dB
void set_Treb(int treb); // tone control treble >> int -15...15 === -15dB...+15dB
private:
void writeWire(char a, char b);
};
#endif //R2S15900SP_H
R2S15900SP.cpp
#include <Arduino.h>
#include <Wire.h>
#include "R2S15900SP.h"
R2S15900SP::R2S15900SP(){
Wire.begin();
}
void R2S15900SP::setVol_l(int vol_l){
byte vol_l10 = vol_l/10;
byte vol_l1 = vol_l%10;
writeWire(R2S15900SP_VOL_L, (vol_l10 << 4) + vol_l1);
}
void R2S15900SP::setVol_r(int vol_r){
byte vol_r10 = vol_r/10;
byte vol_r1 = vol_r%10;
writeWire(R2S15900SP_VOL_R, (vol_r10 << 4) + vol_r1);
}
void R2S15900SP::setIn(int in, int gain, int mute){
switch(in){
case 0: in = 0b00011;break;
case 1: in = 0b00111;break;
case 2: in = 0b01011;break;
case 3: in = 0b01111;break;
case 4: in = 0b10011;break;
case 5: in = 0b10111;break;
}
writeWire(R2S15900SP_INPUT, (in << 3) + (gain << 2) + (mute << 1) + mute);
}
void R2S15900SP::set_Bass(int surr, int mode, int bass){
if(bass >= 0){bass = bass + 0b10000;}
if(bass < 0){bass = abs(bass);}
writeWire(R2S15900SP_BASS, (bass << 3) + (surr << 2) + mode);
}
void R2S15900SP::set_Treb(int treb){
if(treb >= 0){treb = treb + 0b10000;}
if(treb < 0){treb = abs(treb);}
writeWire(R2S15900SP_TREB, (treb << 3));
}
void R2S15900SP::writeWire(char a, char b){
Wire.beginTransmission(R2S15900SP_address);
Wire.write(a);
Wire.write(b);
Wire.endTransmission();
}
test.ino
#include <Wire.h>
#include <R2S15900SP.h>
R2S15900SP r2s;
void setup() {
audio();
}
void loop() {
}
void audio(){
r2s.setVol_l(0); // volume left >> int 84...0 === -84...0 dB
r2s.setVol_r(0); // volume_right >> int 84...0 === -84...0 dB
r2s.setInput(1, 0, 0);
// input >> int 0 === all off | int 1...5 === input 1...5
// gain >> int 0...1 === 0 dB...+4.5 dB
// mute >> int 0...1 === mute off...mute on
r2s.set_Bass(0, 0, 0);
// surround mode >> int 0...1 === low level...high level
// mode selector >> int 0...3 === bypass tone tone&Pseudo_stereo tone&Surround
// tone control bass >> int -15...15 === -15dB...+15dB
r2s.set_Treb(0); // tone control treble >> int -15...15 === -15dB...+15dB
}
Скетч использует 2054 байт (6%) памяти устройства. Всего доступно 32256 байт.
Глобальные переменные используют 219 байт (10%) динамической памяти, оставляя 1829 байт для локальных переменных. Максимум: 2048 байт.
Библиотека zip - Данный контент доступен только зарегистрированным пользователям.