Library for KT0915, DSP radio IC

Committer:
ritarosakai
Date:
Wed Jan 10 10:04:55 2018 +0000
Revision:
4:d3d45a8ac7a5
Parent:
3:a86c8f7a4e47
Fixed some comments

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ritarosakai 0:e5bccd46b6db 1 #ifndef __KT0915_H
ritarosakai 0:e5bccd46b6db 2 #define __KT0915_H
ritarosakai 0:e5bccd46b6db 3
ritarosakai 0:e5bccd46b6db 4 #include "mbed.h"
ritarosakai 0:e5bccd46b6db 5
ritarosakai 0:e5bccd46b6db 6 #define KT0915_address 0x6A
ritarosakai 0:e5bccd46b6db 7
ritarosakai 0:e5bccd46b6db 8 /** Library for KT0915
ritarosakai 0:e5bccd46b6db 9 */
ritarosakai 0:e5bccd46b6db 10 class KT0915
ritarosakai 0:e5bccd46b6db 11 {
ritarosakai 0:e5bccd46b6db 12 public:
ritarosakai 0:e5bccd46b6db 13 /** Create a KT0915 instance connected to specified I2C pins
ritarosakai 0:e5bccd46b6db 14 *
ritarosakai 0:e5bccd46b6db 15 * @param sda I2C-bus SDA pin
ritarosakai 0:e5bccd46b6db 16 * @param scl I2C-bus SCL pin
ritarosakai 0:e5bccd46b6db 17 */
ritarosakai 0:e5bccd46b6db 18 KT0915(PinName sda,PinName scl);
ritarosakai 4:d3d45a8ac7a5 19 /**Initialize KT0915
ritarosakai 0:e5bccd46b6db 20 *
ritarosakai 0:e5bccd46b6db 21 *Set paramaters below
ritarosakai 0:e5bccd46b6db 22 *
ritarosakai 0:e5bccd46b6db 23 *0x02:0b0000000000000111 FM space:100KHz, R/L mute:disable
ritarosakai 0:e5bccd46b6db 24 *
ritarosakai 0:e5bccd46b6db 25 *0x04:0b1110000010010000 FM/AM/device mute:disable, bass:disable DAC cap:60uF
ritarosakai 0:e5bccd46b6db 26 *
ritarosakai 0:e5bccd46b6db 27 *0x05:0b1001100000100000 Mono:enable, de-emphasis:50uF, blend:disable
ritarosakai 0:e5bccd46b6db 28 *
ritarosakai 0:e5bccd46b6db 29 *0x0A:0b0000010000000000 LDO:highest, FM AFC:enable
ritarosakai 0:e5bccd46b6db 30 *
ritarosakai 0:e5bccd46b6db 31 *0x0C:0b0000000000101100 FM wide freq:enable
ritarosakai 0:e5bccd46b6db 32 *
ritarosakai 0:e5bccd46b6db 33 *0x0F:0b1000100000000000 Stanby:disable, volume:0
ritarosakai 0:e5bccd46b6db 34 *
ritarosakai 3:a86c8f7a4e47 35 *0x16:0b0000000011000010 Mode:FM, use internal defined band, Audio gain:0dB, AM AFC:enable
ritarosakai 3:a86c8f7a4e47 36 *
ritarosakai 0:e5bccd46b6db 37 *0x22:0b1010001011101100 AM AGC fast win:fastest, AM AGC short win:slowest
ritarosakai 0:e5bccd46b6db 38 *
ritarosakai 0:e5bccd46b6db 39 *AM bandwidth:6KHz, AM gain:12dB, Left Inverse Control:enable
ritarosakai 0:e5bccd46b6db 40 *
ritarosakai 1:bf3cbe137051 41 *0x23:0bxxx111xxxxxxxxxx low th:B
ritarosakai 0:e5bccd46b6db 42 *
ritarosakai 0:e5bccd46b6db 43 *0x2E:0b0010100010001100 softmute:fast, AM softmute start level:0b100
ritarosakai 0:e5bccd46b6db 44 *
ritarosakai 0:e5bccd46b6db 45 *softmute target volume:0b0100, softmute mode:RSSI, FM softmute start threshold:0b100
ritarosakai 0:e5bccd46b6db 46 *
ritarosakai 0:e5bccd46b6db 47 *0x33:0b0101010000000001 AM space:9KHz
ritarosakai 0:e5bccd46b6db 48 *
ritarosakai 1:bf3cbe137051 49 *0x3F:0bxxxxxxxxx001x011 RF AGC patch
ritarosakai 0:e5bccd46b6db 50 */
ritarosakai 0:e5bccd46b6db 51
ritarosakai 0:e5bccd46b6db 52 void init(void);
ritarosakai 0:e5bccd46b6db 53
ritarosakai 0:e5bccd46b6db 54 /**read KT0915_WHO_AM_I
ritarosakai 0:e5bccd46b6db 55 *
ritarosakai 0:e5bccd46b6db 56 *return 0x4B54
ritarosakai 0:e5bccd46b6db 57 */
ritarosakai 0:e5bccd46b6db 58 int getID(void);
ritarosakai 0:e5bccd46b6db 59
ritarosakai 0:e5bccd46b6db 60 /**set volume
ritarosakai 0:e5bccd46b6db 61 *
ritarosakai 0:e5bccd46b6db 62 *vol...0~31
ritarosakai 0:e5bccd46b6db 63 */
ritarosakai 0:e5bccd46b6db 64 void set_vol(int vol);
ritarosakai 0:e5bccd46b6db 65
ritarosakai 0:e5bccd46b6db 66 /**set frequency and tune
ritarosakai 0:e5bccd46b6db 67 *
ritarosakai 0:e5bccd46b6db 68 *AM...mode=1, freq=frequency (KHz)
ritarosakai 0:e5bccd46b6db 69 *
ritarosakai 0:e5bccd46b6db 70 *FM...mode=0, freq=100*frequency (MHz)
ritarosakai 0:e5bccd46b6db 71 */
ritarosakai 0:e5bccd46b6db 72 void set_freq(bool mode,int freq);
ritarosakai 0:e5bccd46b6db 73
ritarosakai 2:108a1ae04859 74 /**set xtal frequency
ritarosakai 2:108a1ae04859 75 *
ritarosakai 2:108a1ae04859 76 *xtal=32,38,12000,24000 (KHz)
ritarosakai 2:108a1ae04859 77 *
ritarosakai 2:108a1ae04859 78 *If your xtal is 32.768Khz,set to 32.
ritarosakai 2:108a1ae04859 79 */
ritarosakai 2:108a1ae04859 80 void set_xtal(int xtal);
ritarosakai 2:108a1ae04859 81
ritarosakai 0:e5bccd46b6db 82 /**read RSSI (dB)
ritarosakai 0:e5bccd46b6db 83 *
ritarosakai 0:e5bccd46b6db 84 *AM...mode=0
ritarosakai 0:e5bccd46b6db 85 *
ritarosakai 0:e5bccd46b6db 86 *FM...mode=1
ritarosakai 0:e5bccd46b6db 87 */
ritarosakai 0:e5bccd46b6db 88 int get_rssi(bool mode);
ritarosakai 0:e5bccd46b6db 89
ritarosakai 2:108a1ae04859 90 /**set channel space
ritarosakai 2:108a1ae04859 91 *
ritarosakai 2:108a1ae04859 92 *AM...mode=0, space=1,9,10 (KHz)
ritarosakai 2:108a1ae04859 93 *
ritarosakai 2:108a1ae04859 94 *If space=1, bandwidth sets 2KHz.
ritarosakai 2:108a1ae04859 95 *
ritarosakai 2:108a1ae04859 96 *If space=9 or 10, bandwidth sets 6KHz.
ritarosakai 2:108a1ae04859 97 *
ritarosakai 2:108a1ae04859 98 *FM...mode=1, space=50,100,200 (KHz)
ritarosakai 2:108a1ae04859 99 */
ritarosakai 2:108a1ae04859 100 void set_space(bool mode,int space);
ritarosakai 2:108a1ae04859 101
ritarosakai 0:e5bccd46b6db 102 /**read SNR (dB)
ritarosakai 0:e5bccd46b6db 103 *
ritarosakai 0:e5bccd46b6db 104 *for FM only
ritarosakai 0:e5bccd46b6db 105 */
ritarosakai 0:e5bccd46b6db 106 int get_snr(bool mode);
ritarosakai 0:e5bccd46b6db 107
ritarosakai 0:e5bccd46b6db 108 /**read Chip Ready Indicator
ritarosakai 0:e5bccd46b6db 109 *
ritarosakai 0:e5bccd46b6db 110 *0...Chip is not ready.
ritarosakai 0:e5bccd46b6db 111 *
ritarosakai 0:e5bccd46b6db 112 *1...Chip is ready.
ritarosakai 0:e5bccd46b6db 113 */
ritarosakai 0:e5bccd46b6db 114 bool get_ready(void);
ritarosakai 0:e5bccd46b6db 115
ritarosakai 0:e5bccd46b6db 116 /**re-cali*/
ritarosakai 0:e5bccd46b6db 117 void cali(void);
ritarosakai 0:e5bccd46b6db 118
ritarosakai 0:e5bccd46b6db 119 private:
ritarosakai 0:e5bccd46b6db 120 I2C _KT0915;
ritarosakai 2:108a1ae04859 121 void write_reg(int memory_address,int byte1,int byte2);
ritarosakai 2:108a1ae04859 122 void read_reg(int memory_address,int *byte1,int *byte2);
ritarosakai 2:108a1ae04859 123 int data1,data2;
ritarosakai 0:e5bccd46b6db 124 };
ritarosakai 0:e5bccd46b6db 125
ritarosakai 0:e5bccd46b6db 126 #endif