PU2CLR KT0915 Arduino Library
1.0.1
This is an Arduino Library to control the KT0915 device
|
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... | |
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.
Low level functions used to operate with the KT09XX registers
void KT0915::setI2CBusAddress | ( | int | deviceAddress | ) |
Set I2C bus address.
deviceAddress | I2C address |
Definition at line 25 of file KT0915.cpp.
References KT0915::deviceAddress.
void KT0915::setRegister | ( | int | reg, |
uint16_t | parameter | ||
) |
Sets the a value to a given KT09XX register.
reg | register number to be written (0x1 ~ 0x3C) - See #define REG_ in KT0915.h |
parameter | content you want to store |
Definition at line 37 of file KT0915.cpp.
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
reg | register number to be read (0x1 ~ 0x3C) - See #define REG_ in KT0915.h |
Definition at line 60 of file KT0915.cpp.
uint16_t KT0915::getDeviceId | ( | ) |
Gets the Device Id.
Definition at line 83 of file KT0915.cpp.
bool KT0915::isCrystalReady | ( | ) |
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.
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 |
crystal | Reference Clock Selection. See table above. |
ref_clock | 0 = Crystal (default); 1 = Reference clock enabled. |
Definition at line 128 of file KT0915.cpp.
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.
on_off | 1 = enable; 0 = disable |
Definition at line 150 of file KT0915.cpp.
References KT0915::enablePin.
void KT0915::setTuneDialModeOn | ( | uint32_t | minimu_frequency, |
uint32_t | maximum_frequency | ||
) |
Sets Tune Dial Mode Interface On
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).
minimu_frequency | Start frequency for the user band |
maximum_frequency | Final frequency for the user band |
Definition at line 173 of file KT0915.cpp.
void KT0915::setTuneDialModeOff | ( | ) |
Turns the Tune Dial Mode interface Off.
Definition at line 215 of file KT0915.cpp.
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).
Definition at line 237 of file KT0915.cpp.
void KT0915::setVolumeDialModeOff | ( | ) |
Turns the Volume Dial Mode interface Off.
Definition at line 251 of file KT0915.cpp.
void KT0915::setKeyMode | ( | uint8_t | value | ) |
Key Mode setup.
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.
value | 00 = Working mode A; 01 = Working mode B; Others = Reserved |
Definition at line 271 of file KT0915.cpp.
void KT0915::setKeyControl | ( | uint8_t | audioControl, |
uint8_t | channelControl | ||
) |
Sets the Audio and Channel Key Control.
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
audioControl | VOL Pin Mode Selection; 00 = High Z; 01 = Key controlled volume increase/decrease; 10 = Dial controlled volume increase/decrease; 11 = Reserved |
channelControl | CH 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.
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 |
gain | See table above |
Definition at line 312 of file KT0915.cpp.
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.
volume | between 0 and 31. |
Definition at line 326 of file KT0915.cpp.
void KT0915::setVolumeUp | ( | ) |
Increases the audio volume.
Definition at line 341 of file KT0915.cpp.
void KT0915::setVolumeDown | ( | ) |
Decreases the audio volume.
Definition at line 353 of file KT0915.cpp.
uint8_t KT0915::getVolume | ( | ) |
Returns the current audio volume.
Returns a value between 0 and 31.
Definition at line 366 of file KT0915.cpp.
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 |
on_off | see table above |
Definition at line 385 of file KT0915.cpp.
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 |
on_off | see table above |
Definition at line 421 of file KT0915.cpp.
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.
value | ENABLE_ON (1); ENABLE_OFF (0) |
Definition at line 435 of file KT0915.cpp.
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.
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 |
enablePin | if >= 0, then you control the device enable or disable status. if -1, you are using the circuit to crontole that. |
oscillator_type | oscillator type. You can use crystal or external clock. See comments and table above. |
ref_clock | set 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.