Crates.io | si4703 |
lib.rs | si4703 |
version | 0.1.0 |
source | src |
created_at | 2019-12-03 21:05:41.395129 |
updated_at | 2019-12-03 21:05:41.395129 |
description | Platform-agnostic Rust driver for the Si4703 and Si4702 FM radio turners (receivers). |
homepage | https://github.com/eldruin/si4703-rs |
repository | https://github.com/eldruin/si4703-rs |
max_upload_size | |
id | 186220 |
size | 130,175 |
This is a platform agnostic Rust driver for the Si4703 and Si4702 FM radio turners
(receivers) using the embedded-hal
traits and I2C.
This driver allows you to:
enable()
.mute()
.configure_seek()
.seek_with_stc_int_pin()
.tune_with_stc_int_pin()
.set_volume()
.set_band()
.set_channel_spacing()
.set_gpio1()
.enable_softmute()
.enable_auto_gain_control()
.enable_oscillator()
.enable_stc_interrupts()
.enable_audio_high_z()
.set_deemphasis()
.set_stereo_to_mono_blend_level()
.set_output_mode()
.output_mode()
.channel()
.device_id()
.chip_id()
.reset_and_select_i2c_method1()
.enable_rds()
.enable_rds_interrupts()
.rds_ready()
.rds_synchronized()
.rds_data()
.get_rds_radio_text()
.fill_with_rds_radio_text()
.The Si4702/03-C19 extends Silicon Laboratories Si4700/Si4701 FM tuner family, and further increases the ease and attractiveness of adding FM radio reception to mobile devices through small size and board area, minimum component count, flexible programmability, and superior, proven performance.
The device offers significant programmability, and caters to the subjective nature of FM listeners and variable FM broadcast environments world-wide through a simplified programming interface and mature functionality.
The Si4703-C incorporates a digital processor for the European Radio Data System (RDS) and the US Radio Broadcast Data System (RBDS) including all required symbol decoding, block synchronization, error detection, and error correction functions.
RDS enables data such as station identification and song name to be displayed to the user. The Si4703-C offers a detailed RDS view and a standard view, allowing adopters to selectively choose granularity of RDS status, data, and block errors.
Datasheets:
Further documentation:
To use this driver, import this crate and an embedded_hal
implementation,
then instantiate the appropriate device.
In the following example an instance of the device Si4703 will be created.
An instance of the Si4702 device can be created with the method:
Si4703::new_si4702(...)
.
Please find additional examples using hardware in this repository: driver-examples
use embedded_hal::blocking::delay::DelayMs;
use linux_embedded_hal::{Delay, I2cdev, Pin};
use nb::block;
use si4703::{
reset_and_select_i2c_method1, ChannelSpacing, DeEmphasis, SeekDirection, SeekMode, Si4703,
Volume,
};
fn main() {
let mut delay = Delay {};
{
// Reset and communication protocol selection must be done beforehand
let mut sda = Pin::new(2);
let mut rst = Pin::new(17);
reset_and_select_i2c_method1(&mut rst, &mut sda, &mut delay).unwrap();
}
let dev = I2cdev::new("/dev/i2c-1").unwrap();
let mut radio = Si4703::new(dev);
radio.enable_oscillator().unwrap();
// Wait for the oscillator to stabilize
delay.delay_ms(500_u16);
radio.enable().unwrap();
// Wait for powerup
delay.delay_ms(110_u16);
radio.set_volume(Volume::Dbfsm28).unwrap();
radio.set_deemphasis(DeEmphasis::Us50).unwrap();
radio.set_channel_spacing(ChannelSpacing::Khz100).unwrap();
radio.unmute().unwrap();
let stc_int = Pin::new(27);
// Seek using STC interrupt pin
block!(radio.seek_with_stc_int_pin(SeekMode::Wrap, SeekDirection::Up, &stc_int)).unwrap();
let channel = radio.channel().unwrap_or(-1.0);
println!("Found channel at {:1} MHz", channel);
}
For questions, issues, feature requests, and other changes, please file an issue in the github project.
Licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.