Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
KT0915.h
00001 #ifndef __KT0915_H 00002 #define __KT0915_H 00003 00004 #include "mbed.h" 00005 00006 #define KT0915_address 0x6A 00007 00008 /** Library for KT0915 00009 */ 00010 class KT0915 00011 { 00012 public: 00013 /** Create a KT0915 instance connected to specified I2C pins 00014 * 00015 * @param sda I2C-bus SDA pin 00016 * @param scl I2C-bus SCL pin 00017 */ 00018 KT0915(PinName sda,PinName scl); 00019 /**Initialize KT0915 00020 * 00021 *Set paramaters below 00022 * 00023 *0x02:0b0000000000000111 FM space:100KHz, R/L mute:disable 00024 * 00025 *0x04:0b1110000010010000 FM/AM/device mute:disable, bass:disable DAC cap:60uF 00026 * 00027 *0x05:0b1001100000100000 Mono:enable, de-emphasis:50uF, blend:disable 00028 * 00029 *0x0A:0b0000010000000000 LDO:highest, FM AFC:enable 00030 * 00031 *0x0C:0b0000000000101100 FM wide freq:enable 00032 * 00033 *0x0F:0b1000100000000000 Stanby:disable, volume:0 00034 * 00035 *0x16:0b0000000011000010 Mode:FM, use internal defined band, Audio gain:0dB, AM AFC:enable 00036 * 00037 *0x22:0b1010001011101100 AM AGC fast win:fastest, AM AGC short win:slowest 00038 * 00039 *AM bandwidth:6KHz, AM gain:12dB, Left Inverse Control:enable 00040 * 00041 *0x23:0bxxx111xxxxxxxxxx low th:B 00042 * 00043 *0x2E:0b0010100010001100 softmute:fast, AM softmute start level:0b100 00044 * 00045 *softmute target volume:0b0100, softmute mode:RSSI, FM softmute start threshold:0b100 00046 * 00047 *0x33:0b0101010000000001 AM space:9KHz 00048 * 00049 *0x3F:0bxxxxxxxxx001x011 RF AGC patch 00050 */ 00051 00052 void init(void); 00053 00054 /**read KT0915_WHO_AM_I 00055 * 00056 *return 0x4B54 00057 */ 00058 int getID(void); 00059 00060 /**set volume 00061 * 00062 *vol...0~31 00063 */ 00064 void set_vol(int vol); 00065 00066 /**set frequency and tune 00067 * 00068 *AM...mode=1, freq=frequency (KHz) 00069 * 00070 *FM...mode=0, freq=100*frequency (MHz) 00071 */ 00072 void set_freq(bool mode,int freq); 00073 00074 /**set xtal frequency 00075 * 00076 *xtal=32,38,12000,24000 (KHz) 00077 * 00078 *If your xtal is 32.768Khz,set to 32. 00079 */ 00080 void set_xtal(int xtal); 00081 00082 /**read RSSI (dB) 00083 * 00084 *AM...mode=0 00085 * 00086 *FM...mode=1 00087 */ 00088 int get_rssi(bool mode); 00089 00090 /**set channel space 00091 * 00092 *AM...mode=0, space=1,9,10 (KHz) 00093 * 00094 *If space=1, bandwidth sets 2KHz. 00095 * 00096 *If space=9 or 10, bandwidth sets 6KHz. 00097 * 00098 *FM...mode=1, space=50,100,200 (KHz) 00099 */ 00100 void set_space(bool mode,int space); 00101 00102 /**read SNR (dB) 00103 * 00104 *for FM only 00105 */ 00106 int get_snr(bool mode); 00107 00108 /**read Chip Ready Indicator 00109 * 00110 *0...Chip is not ready. 00111 * 00112 *1...Chip is ready. 00113 */ 00114 bool get_ready(void); 00115 00116 /**re-cali*/ 00117 void cali(void); 00118 00119 private: 00120 I2C _KT0915; 00121 void write_reg(int memory_address,int byte1,int byte2); 00122 void read_reg(int memory_address,int *byte1,int *byte2); 00123 int data1,data2; 00124 }; 00125 00126 #endif
Generated on Thu Jul 14 2022 08:00:47 by
1.7.2