PU2CLR KT0915 Arduino Library  1.0.1
This is an Arduino Library to control the KT0915 device
Basic Methods

PU2CLR KT0915 Arduino Library. More...

Functions

void KT0915::setI2CBusAddress (int deviceAddress)
 Set I2C bus address. More...
 
void KT0915::setRegister (int reg, uint16_t parameter)
 Sets the a value to a given KT09XX register. More...
 
uint16_t KT0915::getRegister (int reg)
 Gets a given KT09XX register content. More...
 
uint16_t KT0915::getDeviceId ()
 Gets the Device Id. More...
 
bool KT0915::isCrystalReady ()
 Gets the Crystal Status information. More...
 
void KT0915::setReferenceClockType (uint8_t crystal, uint8_t ref_clock=0)
 Sets the Crystal Type. More...
 
void KT0915::enable (uint8_t on_off)
 Sets the enable pin (9) of the KT0915 high or low. More...
 
void KT0915::setTuneDialModeOn (uint32_t minimu_frequency, uint32_t maximum_frequency)
 Sets Tune Dial Mode Interface On
More...
 
void KT0915::setTuneDialModeOff ()
 Turns the Tune Dial Mode interface Off. More...
 
void KT0915::setVolumeDialModeOn ()
 Sets Volume Dial Mode Interface On. More...
 
void KT0915::setVolumeDialModeOff ()
 Turns the Volume Dial Mode interface Off. More...
 
void KT0915::setKeyMode (uint8_t value)
 Key Mode setup. More...
 
void KT0915::setKeyControl (uint8_t audioControl, uint8_t channelControl)
 Sets the Audio and Channel Key Control. More...
 
void KT0915::setAudioGain (uint8_t gain)
 Audio Gain. More...
 
void KT0915::setVolume (uint8_t value)
 Sets the audio volume level. More...
 
void KT0915::setVolumeUp ()
 Increases the audio volume. More...
 
void KT0915::setVolumeDown ()
 Decreases the audio volume. More...
 
uint8_t KT0915::getVolume ()
 Returns the current audio volume. More...
 
void KT0915::setAudioBass (uint8_t bass)
 Sets the bass level. More...
 
void KT0915::setAudioAntiPop (uint8_t value)
 Sets Audio DAC Anti-pop Configuration. More...
 
void KT0915::setLeftChannelInverseControl (uint8_t enable_disable)
 Sets the Left Channel Inverse Control. More...
 
void KT0915::setup (int enable_pin, uint8_t oscillator_type=OSCILLATOR_32KHZ, uint8_t ref_clock=REF_CLOCK_DISABLE)
 Receiver startup. More...
 

Detailed Description

PU2CLR KT0915 Arduino Library.

KT0915 Arduino Library implementation. This is an Arduino library for the KT0915, BROADCAST RECEIVER.

It works with I2C protocol and can provide an easier interface to control the KT0915 device.

This library was built based on KT0915 Datasheet from KTMicro (Monolithic Digital FM/MW/SW/LW Receiver Radio-on-a-Chip TM).

This library can be freely distributed using the MIT Free Software model.

Author
Ricardo LIma Caratti (pu2cl.nosp@m.r@gm.nosp@m.ail.c.nosp@m.om)

Basic

Low level functions used to operate with the KT09XX registers

Function Documentation

◆ setI2CBusAddress()

void KT0915::setI2CBusAddress ( int  deviceAddress)

Set I2C bus address.

Parameters
deviceAddressI2C address

Definition at line 25 of file KT0915.cpp.

References KT0915::deviceAddress.

◆ setRegister()

void KT0915::setRegister ( int  reg,
uint16_t  parameter 
)

Sets the a value to a given KT09XX register.

Parameters
regregister number to be written (0x1 ~ 0x3C) - See #define REG_ in KT0915.h
parametercontent you want to store

Definition at line 37 of file KT0915.cpp.

◆ getRegister()

uint16_t KT0915::getRegister ( int  reg)

Gets a given KT09XX register content.

It is a basic function to get a value from a given KT0915 device register

Parameters
regregister number to be read (0x1 ~ 0x3C) - See #define REG_ in KT0915.h
Returns
the register content

Definition at line 60 of file KT0915.cpp.

◆ getDeviceId()

uint16_t KT0915::getDeviceId ( )

Gets the Device Id.

Returns
uint16_t 16 bits word with the device id number

Definition at line 83 of file KT0915.cpp.

◆ isCrystalReady()

bool KT0915::isCrystalReady ( )

Gets the Crystal Status information.

Returns
true
false

Definition at line 96 of file KT0915.cpp.

◆ setReferenceClockType()

void KT0915::setReferenceClockType ( uint8_t  crystal,
uint8_t  ref_clock = 0 
)

Sets the Crystal Type.

Configures the Crystal or reference clock you are using in your circuit.

For a low frequency crystal oscillator, selects 32.768KHz or 38KHz crystals.

Alternatively, you can use a CMOS level external reference clock may be used by setting

the parameter ref_clock to 1 (REF_CLOCK_ENABLE) and setting the reference clock according to the table below.

  • Crystal type table
    Dec binary Description defined constant
    0 0000 32.768KHz OSCILLATOR_32KHZ
    1 0001 6.5MHz OSCILLATOR_6_5MHZ
    2 0010 7.6MHz OSCILLATOR_7_6MHZ
    3 0011 12MHz OSCILLATOR_12MHZ
    4 0100 13MHz OSCILLATOR_13MHZ
    5 0101 15.2MHz OSCILLATOR_15_2MHZ
    6 0110 19.2MHz OSCILLATOR_19_2MHZ
    7 0111 24MHz OSCILLATOR_24MHZ
    8 1000 26MHz OSCILLATOR_26MHZ
    9 1001 ?? 38KHz ?? OSCILLATOR_38KHz
Parameters
crystalReference Clock Selection. See table above.
ref_clock0 = Crystal (default); 1 = Reference clock enabled.

Definition at line 128 of file KT0915.cpp.

◆ enable()

void KT0915::enable ( uint8_t  on_off)

Sets the enable pin (9) of the KT0915 high or low.

This function can be used to enable (1) and disable (0) the KT0915 device. You have to select a MCU (Arduino) pin for this function.

Also, you can set -1 to used this control via circuit.

See also
setup
Parameters
on_off1 = enable; 0 = disable

Definition at line 150 of file KT0915.cpp.

References KT0915::enablePin.

◆ setTuneDialModeOn()

void KT0915::setTuneDialModeOn ( uint32_t  minimu_frequency,
uint32_t  maximum_frequency 
)

Sets Tune Dial Mode Interface On

Todo:
You need to check mechanical Tune features

This method sets the KT0915 to deal with a mechanical tuning via an external 100K resistor.

KT0915 supports a unique Dial Mode (mechanical tuning wheel with a variable resistor) which is

enabled by GPIO1 to 2 (10). The dial can be a variable resistor with the tap connected to CH (pin 1).

See also
KT0915; Monolithic Digital FM/MW/SW/LW Receiver Radio on a Chip(TM); pages 19 and 20.
Parameters
minimu_frequencyStart frequency for the user band
maximum_frequencyFinal frequency for the user band

Definition at line 173 of file KT0915.cpp.

◆ setTuneDialModeOff()

void KT0915::setTuneDialModeOff ( )

Turns the Tune Dial Mode interface Off.

See also
setTuneDialModeOn, setKeyMode, setKeyControl
KT0915; Monolithic Digital FM/MW/SW/LW Receiver Radio on a Chip(TM); page 20.

Definition at line 215 of file KT0915.cpp.

◆ setVolumeDialModeOn()

void KT0915::setVolumeDialModeOn ( )

Sets Volume Dial Mode Interface On.

This method sets the KT0915 to deal with a mechanical volume control via an external 100K resistor.

KT0915 supports a unique Dial Mode which is enabled by GPIO2 to 2 (10).

The dial can be a variable resistor with the tap connected to VOL (pin 16).

See also
KT0915; Monolithic Digital FM/MW/SW/LW Receiver Radio on a Chip(TM); page 20.

Definition at line 237 of file KT0915.cpp.

◆ setVolumeDialModeOff()

void KT0915::setVolumeDialModeOff ( )

Turns the Volume Dial Mode interface Off.

See also
setVolumeDialModeOn, setKeyMode, setKeyControl
KT0915; Monolithic Digital FM/MW/SW/LW Receiver Radio on a Chip(TM); page 20.

Definition at line 251 of file KT0915.cpp.

◆ setKeyMode()

void KT0915::setKeyMode ( uint8_t  value)

Key Mode setup.

Todo:
Check this function

KT0915 allows user to control the channel and volume by using keys/buttons to send digital control signals to CH and VOL pins. Please refer to Section 4 for a typical application circuit. The key mode is enabled by setting GPIO1<1:0> and GPIO2<1:0> to 01.

Mode A:

If KEY_MODE<1:0> is set to 00, Mode A is selected. In this mode, each time the CHP (CHM) is pressed, the channel frequency increases (decreases) by one step. The step sizes are defined by FMSPACE<1:0> and AMSPACE<1:0>. If the CHP (CHM) key is pressed for and held for a certain time (defined by TIME1<1:0>), the channel frequency will continue to increase (decrease) automatically at a certain pace (as defined by TIME2<2:0>) until the key is released.

Mode B:

If KEY_MODE<1:0> is set to 01, Mode B is selected. In this mode, each time the CHP (CHM) is pressed, the channel increases (decreases) by one step. The step sizes are defined by FMSPACE<1:0> and AMSPACE<1:0>. If the CHP (CHM) key is pressed and held for a specific time (TIME1<1:0>), the channel will continue to increase (decrease) automatically at a certain pace (TIME2<2:0>) even if the key is released. The movement is stopped when the key is pressed again.

See also
KT0915; Monolithic Digital FM/MW/SW/LW Receiver Radio on a Chip(TM); pages 8 and 23.
Parameters
value00 = Working mode A; 01 = Working mode B; Others = Reserved

Definition at line 271 of file KT0915.cpp.

◆ setKeyControl()

void KT0915::setKeyControl ( uint8_t  audioControl,
uint8_t  channelControl 
)

Sets the Audio and Channel Key Control.

Todo:
Check this function

VOL Pin Mode Selection 00 = High Z; 01 = Key controlled volume increase/decrease; 10 = Dial controlled volume increase/decrease; 11 = Reserved

CH Pin Mode Selection; 00 = High Z; 01 = Key controlled channel increase / decrease; 10 = Dial controlled channel increase / decrease; 11 = Reserved

See also
KT0915; Monolithic Digital FM/MW/SW/LW Receiver Radio on a Chip(TM); page 20.
Parameters
audioControlVOL Pin Mode Selection; 00 = High Z; 01 = Key controlled volume increase/decrease; 10 = Dial controlled volume increase/decrease; 11 = Reserved
channelControlCH Pin Mode Selection; 00 = High Z; 01 = Key controlled channel increase / decrease; 10 = Dial controlled channel increase / decrease 11 = Reserved

Definition at line 289 of file KT0915.cpp.

◆ setAudioGain()

void KT0915::setAudioGain ( uint8_t  gain)

Audio Gain.

This function set the audio gain you want to use. See table below.

value Gain Selection
0 3dB
1 6dB
2 -3dB
3 0dB
Parameters
gainSee table above

Definition at line 312 of file KT0915.cpp.

◆ setVolume()

void KT0915::setVolume ( uint8_t  volume)

Sets the audio volume level.

This method is used to control the audio volume level. The value 0 mutes the device and 31 sets the device to the maximum volume.

Parameters
volumebetween 0 and 31.

Definition at line 326 of file KT0915.cpp.

◆ setVolumeUp()

void KT0915::setVolumeUp ( )

Increases the audio volume.

Definition at line 341 of file KT0915.cpp.

◆ setVolumeDown()

void KT0915::setVolumeDown ( )

Decreases the audio volume.

Definition at line 353 of file KT0915.cpp.

◆ getVolume()

uint8_t KT0915::getVolume ( )

Returns the current audio volume.

Returns a value between 0 and 31.

Returns
uint8_t Value between 0 and 31.

Definition at line 366 of file KT0915.cpp.

◆ setAudioBass()

void KT0915::setAudioBass ( uint8_t  bass)

Sets the bass level.

Bass Boost Effect Mode Selection

Value Level
0 Disable
1 Low
2 Med
3 High
Parameters
on_offsee table above

Definition at line 385 of file KT0915.cpp.

◆ setAudioAntiPop()

void KT0915::setAudioAntiPop ( uint8_t  value)

Sets Audio DAC Anti-pop Configuration.

Bass Boost Effect Mode Selection

Value AC - coupling capacitor
0 100uF
1 60uF
2 20uF
3 10uF
Parameters
on_offsee table above

Definition at line 421 of file KT0915.cpp.

◆ setLeftChannelInverseControl()

void KT0915::setLeftChannelInverseControl ( uint8_t  enable_disable)

Sets the Left Channel Inverse Control.

If enable, inverts the left channel audio signal

A fully differential audio signal can be got from LOUT an ROUT if the INV_LEFT_AUDIO bit and MONO bit are set to 1.

Parameters
valueENABLE_ON (1); ENABLE_OFF (0)

Definition at line 435 of file KT0915.cpp.

◆ setup()

void KT0915::setup ( int  enable_pin,
uint8_t  oscillator_type = OSCILLATOR_32KHZ,
uint8_t  ref_clock = REF_CLOCK_DISABLE 
)

Receiver startup.

You have to use this method to configure the way that the device will work. For example: enable and disable device control; oscillator type and reference clock type (crystal or external)

The tabe below shows the oscillator frequencies supported by the device.

If you omit the crystal type parameter, will be considered 0 (32.768KHz).

For a low frequency crystal oscillator, selects 32.768KHz or 38KHz crystals.

Alternatively, you can use a CMOS level external reference clock may be used by setting

the parameter ref_clock to 1 (REF_CLOCK_ENABLE) and setting the reference clock according to the table below.

The code below shows how to use the setup function.

the enable_pin parameter sets the way you are controlling the KT0915 pin 9.

#include <KT0915.h>
#define RESET_PIN 12 // set it to -1 if you want to use the RST pin of your MCU.
KT0915 radio;
void setup() {
// Set the parameter enablePin to -1 if you are controlling the enable status via circuit; Select OSCILLATOR_32KHZ, OSCILLATOR_12MHZ etc
// radio.setup(RESET_PIN); Instead the line below, if you use this line, the crystal type considered will be 32.768KHz.
}

Oscillator frequencies supported

Dec binary Description defined constant
0 0000 32.768KHz OSCILLATOR_32KHZ
1 0001 6.5MHz OSCILLATOR_6_5MHZ
2 0010 7.6MHz OSCILLATOR_7_6MHZ
3 0011 12MHz OSCILLATOR_12MHZ
4 0100 13MHz OSCILLATOR_13MHZ
5 0101 15.2MHz OSCILLATOR_15_2MHZ
6 0110 19.2MHz OSCILLATOR_19_2MHZ
7 0111 24MHz OSCILLATOR_24MHZ
8 1000 26MHz OSCILLATOR_26MHZ
9 1001 38KHz OSCILLATOR_38KHz
See also
KT0915; Monolithic Digital FM/MW/SW/LW Receiver Radio on a Chip(TM); 3.6 Crystal and reference clock; page 9.
setReferenceClockType
Parameters
enablePinif >= 0, then you control the device enable or disable status. if -1, you are using the circuit to crontole that.
oscillator_typeoscillator type. You can use crystal or external clock. See comments and table above.
ref_clockset to 0 if you are using crystal (Reference clock disabled - default); set to 1 if you are using an external reference clock.

Definition at line 487 of file KT0915.cpp.

References KT0915::enablePin.

OSCILLATOR_12MHZ
#define OSCILLATOR_12MHZ
Definition: KT0915.h:38
KT0915.h
KT0915
KT0915 Class.
Definition: KT0915.h:520
REF_CLOCK_DISABLE
#define REF_CLOCK_DISABLE
Definition: KT0915.h:47
KT0915::setup
void setup(int enable_pin, uint8_t oscillator_type=OSCILLATOR_32KHZ, uint8_t ref_clock=REF_CLOCK_DISABLE)
Receiver startup.
Definition: KT0915.cpp:487