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.
Dependents: RDA5807M-FM-Radio EFM32 RDA5807M RDS Radio
RDA5807M.h
00001 00002 #include "mbed.h" 00003 00004 class RDA5807M 00005 { 00006 public: 00007 00008 RDA5807M(PinName sda, PinName scl); 00009 00010 ~RDA5807M(); 00011 00012 //-------------------------------------------------------------- 00013 // Global Functions 00014 //-------------------------------------------------------------- 00015 void WriteAll(void); 00016 void WriteReg(int address,int data); 00017 void Init(void); 00018 void Readregisters(void); 00019 void Reset(void); 00020 void PowerOn(void); 00021 void PowerOff(void); 00022 void RDS(void); 00023 void Mute(void); 00024 void Mono(void); 00025 void Softmute(void); 00026 void SoftBlend(void); 00027 void BassBoost(void); 00028 void AFC(void); 00029 void Volume(int vol); 00030 void SeekUp(void); 00031 void SeekDown(void); 00032 void Frequency(float Freq); 00033 void Channel(void); 00034 void getRDS(void); 00035 00036 // Initialise internal variables before starting or after a change to another channel. 00037 void RDSinit(); 00038 00039 // Pass all available RDS data through this function. 00040 void ProcessData(); 00041 00042 //-------------------------------------------------------------- 00043 // Definitions 00044 //-------------------------------------------------------------- 00045 /* I2C Address */ 00046 #define RDASequential 0x20 // Write address 00047 #define RDARandom 0x22 // Read address 00048 /* Initialization Options */ 00049 #define StartingFreq 87.00 00050 #define EndingFreq 108.00 00051 #define DefaultFreq 87.50 00052 #define InitialVolume 4 00053 /* RDA5807M Function Code */ 00054 /* Register 0x02H (16Bits) */ 00055 #define RDA_DHIZ 0x8000 00056 #define RDA_MUTE 0x8000 00057 #define RDA_MONO_ON 0x2000 00058 #define RDA_MONO_OFF 0xDFFF 00059 #define RDA_BASS_ON 0x1000 00060 #define RDA_BASS_OFF 0xEFFF 00061 #define RDA_RCLK_MODE 0x0800 00062 #define RDA_RCLK_DIRECT 0x0400 00063 #define RDA_SEEK_UP 0x0300 00064 #define RDA_SEEK_DOWN 0x0100 00065 #define RDA_SEEK_STOP 0xFCFF 00066 #define RDA_SEEK_WRAP 0x0080 00067 #define RDA_SEEK_NOWRAP 0xFF7F 00068 #define RDA_CLK_0327 0x0000 00069 #define RDA_CLK_1200 0x0010 00070 #define RDA_CLK_2400 0x0050 00071 #define RDA_CLK_1300 0x0020 00072 #define RDA_CLK_2600 0x0060 00073 #define RDA_CLK_1920 0x0030 00074 #define RDA_CLK_3840 0x0070 00075 #define RDA_RDS_ON 0x0008 00076 #define RDA_RDS_OFF 0xFFF7 00077 #define RDA_NEW 0x0004 00078 #define RDA_RESET 0x0002 00079 #define RDA_POWER 0x0001 00080 /* Register 0x03H (16Bits) */ 00081 #define RDA_TUNE_ON 0x0010 00082 #define RDA_TUNE_OFF 0xFFEF 00083 //-------------------------------------------------------------- 00084 // Global Variables 00085 //-------------------------------------------------------------- 00086 // 00087 int tuneok,nochannel,power,volume,softblend,bass,mute,softmute,mono,afc,stereo,signal,fmready,fmstation; 00088 int rdsblockerror,rdssynchro,rdsready,rds,block1,block2,block3,block4; 00089 00090 char StationName[10]; // Station Name. 8 characters 00091 char RDSText[66]; // RDS test message 64 characters 00092 char CTtime[12]; // CT time string formatted as 'CT hh:mm' 00093 int minutes; // CT minutes transmitted on the minute 00094 float freq; // Tuned frequency 00095 00096 //-------------------------------------------------------------- 00097 00098 private: 00099 00100 I2C i2c; 00101 00102 unsigned int RDA5807M_WriteReg[8],RDA5807M_ReadReg[7],RDA5807M_RDS[32]; 00103 00104 // ----- actual RDS values 00105 int textAB, lasttextAB, lastTextIDX; 00106 int rdsGroupType, rdsTP, rdsPTY; 00107 00108 int mins; // RDS time in minutes 00109 int lastmins; 00110 int i,n; 00111 int idx; // index of rdsText 00112 int offset; // RDS time offset and sign 00113 char c1, c2; 00114 char RDSTxt[66]; 00115 char PSName[10]; // including trailing '\00' character. 00116 char PSName1[10]; 00117 char PSName2[10]; 00118 };
Generated on Wed Jul 20 2022 21:48:03 by
1.7.2