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.
Diff: SparkFun-Si4703.h
- Revision:
- 3:07c7508d029a
- Parent:
- 2:558ef02f39d0
--- a/SparkFun-Si4703.h Sat Aug 08 18:15:36 2015 +0000
+++ b/SparkFun-Si4703.h Thu Nov 29 23:58:19 2018 +0000
@@ -1,4 +1,4 @@
-/*
+/*
Library for Sparkfun Si4703 breakout board.
Simon Monk. 2011-09-09
@@ -47,101 +47,103 @@
class Si4703_Breakout
{
- public:
+public:
Si4703_Breakout(PinName sdioPin, PinName sclkPin, PinName resetPin, Serial *pc);
+ ~Si4703_Breakout();
void powerOn(); // call in setup
void powerOff(); // call in de-setup
- void setChannel(int channel); // 3 digit channel number
- int getChannel(); // returns the current channel
- int seekUp(); // returns the tuned channel or 0
- int seekDown();
- void setVolume(int volume); // 0 to 15
+ void setChannel(uint16_t channel); // channel number ( e.g. : 8750 .. 10800 )
+ uint16_t getChannel(); // returns the current channel
+ uint16_t seek(bool seekDirection);
+ uint16_t seekUp(); // returns the tuned channel or 0
+ uint16_t seekDown(); // -"-
+ void setVolume(uint8_t volume); // 0 to 15
uint8_t getVolume(); // Returns The Current Volume (0 .. 15)
-/* void readRDS(char* message, long timeout); */
- // message should be at least 9 chars
- // result will be null terminated
- // timeout in milliseconds
- uint16_t getRegister(uint8_t regNum); // Returns The Value of a Single Register (0x00 .. 0x0F)
- void printRegs(); // Prints All of The Registers To The Serial Console
+ /* void readRDS(char* message, long timeout); */
+ // message should be at least 9 chars
+ // result will be null terminated
+ // timeout in milliseconds
+ uint16_t getRegister(uint8_t regNum); // Returns The Value of a Single Register (0x00 .. 0x0F)
+ void printRegs(); // Prints All of The Registers To The Serial Console
- private:
+private:
+
PinName _resetPin;
- PinName _sdioPin;
- PinName _sclkPin;
+ PinName _sdioPin;
+ PinName _sclkPin;
mbed::I2C *i2c_;
mbed::Serial *pc;
DigitalOut *_reset_;
DigitalOut *_sdio_;
- void si4703_init();
- uint8_t readRegisters();
- uint8_t updateRegisters();
- int seek(bool seekDirection);
+ void si4703_init();
+ uint8_t readRegisters();
+ uint8_t updateRegisters();
- uint16_t si4703_registers[16]; //There are 16 registers, each 16 bits large
- static const uint16_t FAIL = 0;
- static const uint16_t SUCCESS = 1;
+ uint16_t si4703_registers[16]; //There are 16 registers, each 16 bits large
+ static const uint16_t FAIL = 0;
+ static const uint16_t SUCCESS = 1;
- static const int SI4703 = 0x20; //0b._001.0000 = I2C address of Si4703 - note that the Wire function assumes non-left-shifted I2C address, not 0b.0010.000W
- static const uint16_t I2C_FAIL_MAX = 10; //This is the number of attempts we will try to contact the device before erroring out
- static const uint16_t SEEK_DOWN = 0; //Direction used for seeking. Default is down
- static const uint16_t SEEK_UP = 1;
+ static const uint16_t SI4703 = 0x20; //0b._001.0000 = I2C address of Si4703 - note that the Wire function assumes non-left-shifted I2C address, not 0b.0010.000W
+ static const uint8_t I2C_FAIL_MAX = 10; //This is the number of attempts we will try to contact the device before erroring out
+ static const uint8_t SEEK_DOWN = 0; //Direction used for seeking. Default is down
+ static const uint8_t SEEK_UP = 1;
- //Define the register names
- static const uint16_t DEVICEID = 0x00;
- static const uint16_t CHIPID = 0x01;
- static const uint16_t POWERCFG = 0x02;
- static const uint16_t CHANNEL = 0x03;
- static const uint16_t SYSCONFIG1 = 0x04;
- static const uint16_t SYSCONFIG2 = 0x05;
- static const uint16_t SYSCONFIG3 = 0x06;
- static const uint16_t TEST1 = 0x07;
- static const uint16_t STATUSRSSI = 0x0A;
- static const uint16_t READCHAN = 0x0B;
- static const uint16_t RDSA = 0x0C;
- static const uint16_t RDSB = 0x0D;
- static const uint16_t RDSC = 0x0E;
- static const uint16_t RDSD = 0x0F;
+ //Define the register names
+ static const uint8_t DEVICEID = 0x00;
+ static const uint8_t CHIPID = 0x01;
+ static const uint8_t POWERCFG = 0x02;
+ static const uint8_t CHANNEL = 0x03;
+ static const uint8_t SYSCONFIG1 = 0x04;
+ static const uint8_t SYSCONFIG2 = 0x05;
+ static const uint8_t SYSCONFIG3 = 0x06;
+ static const uint8_t TEST1 = 0x07;
+ static const uint8_t STATUSRSSI = 0x0A;
+ static const uint8_t READCHAN = 0x0B;
+ static const uint8_t RDSA = 0x0C;
+ static const uint8_t RDSB = 0x0D;
+ static const uint8_t RDSC = 0x0E;
+ static const uint8_t RDSD = 0x0F;
- //Register 0x00 - DeviceID
+ //Register 0x00 - DeviceID
// part# = 15:12, mfgid = 11:0
- //Register 0x02 - POWERCFG
- static const uint16_t SMUTE = 15;
- static const uint16_t DMUTE = 14;
- static const uint16_t SKMODE = 10;
- static const uint16_t SEEKUP = 9;
- static const uint16_t SEEK = 8;
- static const uint16_t DISABLE = 6;
- static const uint16_t ENABLE = 0;
+ //Register 0x02 - POWERCFG
+ static const uint8_t SMUTE = 15;
+ static const uint8_t DMUTE = 14;
+ static const uint8_t SKMODE = 10;
+ static const uint8_t SEEKUP = 9;
+ static const uint8_t SEEK = 8;
+ static const uint8_t DISABLE = 6;
+ static const uint8_t ENABLE = 0;
- //Register 0x03 - CHANNEL
- static const uint16_t TUNE = 15;
+ //Register 0x03 - CHANNEL
+ static const uint8_t TUNE = 15;
- //Register 0x04 - SYSCONFIG1
- static const uint16_t RDS = 12;
- static const uint16_t DE = 11;
+ //Register 0x04 - SYSCONFIG1
+ static const uint8_t RDS = 12;
+ static const uint8_t DE = 11;
- //Register 0x05 - SYSCONFIG2
- static const uint16_t SPACE1 = 5;
- static const uint16_t SPACE0 = 4;
- static const uint16_t SEEKTH = 8;
+ //Register 0x05 - SYSCONFIG2
+ static const uint8_t SPACE1 = 5;
+ static const uint8_t SPACE0 = 4;
+ static const uint8_t SEEKTH = 8;
- //Register 0x06 - SYSCONFIG3
- static const uint16_t SKSNR = 4;
- static const uint16_t SKCNT = 0;
+ //Register 0x06 - SYSCONFIG3
+ static const uint8_t SKSNR = 4;
+ static const uint8_t SKCNT = 0;
- //Register 0x0A - STATUSRSSI
- static const uint16_t RDSR = 15;
- static const uint16_t STC = 14;
- static const uint16_t SFBL = 13;
- static const uint16_t AFCRL = 12;
- static const uint16_t RDSS = 11;
- static const uint16_t BLERA = 9;
- static const uint16_t STEREO = 8;
- static const uint16_t RSSI = 0;
+ //Register 0x0A - STATUSRSSI
+ static const uint8_t RDSR = 15;
+ static const uint8_t STC = 14;
+ static const uint8_t SFBL = 13;
+ static const uint8_t AFCRL = 12;
+ static const uint8_t RDSS = 11;
+ static const uint8_t BLERA = 9;
+ static const uint8_t STEREO = 8;
+ static const uint8_t RSSI = 0;
};
#endif