CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug Reports on this forum. Send them to support@ccsinfo.com

PT2257 audio controller I2C protocol

 
Post new topic   Reply to topic    CCS Forum Index -> Code Library
View previous topic :: View next topic  
Author Message
wangine



Joined: 07 Jul 2009
Posts: 96
Location: Curtea de Arges, Romania

View user's profile Send private message Send e-mail Yahoo Messenger

PT2257 audio controller I2C protocol
PostPosted: Mon Aug 02, 2010 12:45 pm     Reply with quote

Greeting
Below we have a driver written by me for an IC (volume control)
the SDA / SCL volume control that lets the 79 decades
It is written for two channels simultaneously but can write and balance

Code:
////////////////////////////////////////////////////////////////
// Driver sda/ Scl volum PT2257                               //
// Version 0.1                                                // 
// Writer Tanase Bogdan                                       //
// Chip information                                           //
// Pin 1 == Left In                                           //
// Pin 2 == Left Out                                           // 
// Pin 3 == VSS                                                //
// Pin 4 == SDA                                                //
// Pin 5 == SCL                                                //
// Pin 6 == VDD (3 to 9V)                                 //
// Pin 7 == Right Out                                        //
// Pin 8 == Right In                                          //                 
////////////////////////////////////////////////////////////////
// Require pullup rezistor an SDA/SCL 10k

#define zeci_max 0b11100000
#define zeci_min 0b11100111
#define unit_max 0b11010000
#define unit_min 0b11011001

volatile unsigned int zeci, unit, ref, level;

void vol_send_data(void);


//////////////////////////////////////////////////////////////////
//   functie ce desparte valoarea volumului in zeci si unitati
//    value function that divides the volume into tens and units
void decode_niv (unsigned int vol)
{
   if(vol >= 79)
      {
         vol = 79;
      }
//**********************************
   zeci = vol/10; // cifra zecilor
   unit = vol%10; // cifra unitatilor
      vol_send_data();
}
//
//////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////
//    function that allows data transmission chip
void vol_send_data()
{
   i2c_start();
   i2c_write(0x88);  // Adress chip
   i2c_write(0b11100000 + zeci); //Write tens value
   i2c_write(0b11010000 + unit); //Write units value
   i2c_stop();
}
//
/////////////////////////////////////////////////////////////////

/////////////////////////////////////////////////////////////////
// The first function called in the program
void volume ()
{   

   if(0x14 == ref)      // ref is reference value for comparation tast
      {   
         if(level <= 79)   // Maxim level is -79dB
         level++;
      }
//****************************
   if(0x13 == ref)
      {   if(level >= 1)
         level--;
      }

   decode_niv(level);
}
//
/////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////
// mute functions
void muting ()
{
   if(0x15 == ref)
      {
         i2c_start();
   i2c_write(0x88);  // Adress chip
   i2c_write(0b0111110001); //Write muting value
   i2c_stop();
      }
}
///////////////////////////////////////////////////////////////////


all the best
Arsenic



Joined: 23 Sep 2016
Posts: 12

View user's profile Send private message

PostPosted: Mon Nov 20, 2017 10:28 pm     Reply with quote

I don't understand the datasheet. How you raise/decrease the volume?
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> Code Library All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group