PU2CLR Si4735 Arduino Library  2.0.7
Arduino Library for Si47XX Devices - By Ricardo Lima Caratti
FM RDS/RBDS

Functions

bool SI4735::getRdsReceived ()
 Get the Rds Received FIFO. More...
 
bool SI4735::getRdsSyncLost ()
 Get the Rds Sync Lost object. More...
 
bool SI4735::getRdsSyncFound ()
 Get the Rds Sync Found. More...
 
bool SI4735::getRdsNewBlockA ()
 Get the Rds New Block A. More...
 
bool SI4735::getRdsNewBlockB ()
 Get the Rds New Block B. More...
 
bool SI4735::getRdsSync ()
 Get the Rds Sync. More...
 
bool SI4735::getGroupLost ()
 Get the Group Lost. More...
 
uint8_t SI4735::getNumRdsFifoUsed ()
 Get the Num Rds Fifo Used. More...
 
void SI4735::setFifoCount (uint16_t value)
 Sets the minimum number of RDS groups stored in the RDS FIFO before RDSRECV is set. More...
 
bool SI4735::getEndIndicatorGroupA ()
 Check if 0xD or 0xA special characters were received for group A. More...
 
void SI4735::resetEndIndicatorGroupA ()
 Resets 0xD or 0xA special characters condition (makes it false) More...
 
bool SI4735::getEndIndicatorGroupB ()
 Check if 0xD or 0xA special characters were received for group B. More...
 
void SI4735::resetEndIndicatorGroupB ()
 Resets 0xD or 0xA special characters condition (makes it false) More...
 
void SI4735::getRdsStatus ()
 Gets RDS Status. More...
 
void SI4735::rdsClearFifo ()
 Empty FIFO. More...
 
void SI4735::rdsClearInterrupt ()
 Clears RDSINT. More...
 
void SI4735::RdsInit ()
 Starts the control member variables for RDS. More...
 
void SI4735::clearRdsBuffer2A ()
 Clear RDS buffer 2A (text) More...
 
void SI4735::clearRdsBuffer2B ()
 Clear RDS buffer 2B (text) More...
 
void SI4735::clearRdsBuffer0A ()
 Clear RDS buffer 0A (text) More...
 
void SI4735::setRdsConfig (uint8_t RDSEN, uint8_t BLETHA, uint8_t BLETHB, uint8_t BLETHC, uint8_t BLETHD)
 Sets RDS property. More...
 
void SI4735::setRdsIntSource (uint8_t RDSRECV, uint8_t RDSSYNCLOST, uint8_t RDSSYNCFOUND, uint8_t RDSNEWBLOCKA, uint8_t RDSNEWBLOCKB)
 Configures interrupt related to RDS. More...
 
void SI4735::getRdsStatus (uint8_t INTACK, uint8_t MTFIFO, uint8_t STATUSONLY)
 Gets the RDS status. Store the status in currentRdsStatus member. RDS COMMAND FM_RDS_STATUS. More...
 
uint16_t SI4735::getRdsPI (void)
 Returns the programa type. More...
 
uint8_t SI4735::getRdsGroupType (void)
 Returns the Group Type (extracted from the Block B) More...
 
uint8_t SI4735::getRdsFlagAB (void)
 Returns the current Text Flag A/B
More...
 
uint8_t SI4735::getRdsTextSegmentAddress (void)
 Returns the address of the text segment. More...
 
uint8_t SI4735::getRdsVersionCode (void)
 Gets the version code (extracted from the Block B) More...
 
uint8_t SI4735::getRdsProgramType (void)
 Returns the Program Type (extracted from the Block B) More...
 
void SI4735::getNext2Block (char *)
 Process data received from group 2B. More...
 
void SI4735::getNext4Block (char *)
 Process data received from group 2A. More...
 
char * SI4735::getRdsText (void)
 Gets the RDS Text when the message is of the Group Type 2 version A. More...
 
char * SI4735::getRdsText0A (void)
 Gets the station name and other messages. More...
 
char * SI4735::getRdsText2A (void)
 Gets the Text processed for the 2A group. More...
 
char * SI4735::getRdsText2B (void)
 Gets the Text processed for the 2B group. More...
 
char * SI4735::getRdsTime (void)
 Gets the RDS time and date when the Group type is 4. More...
 
void SI4735::mjdConverter (uint32_t mjd, uint32_t *year, uint32_t *month, uint32_t *day)
 Converts the MJD number to integers Year, month and day. More...
 
bool SI4735::getRdsDateTime (uint16_t *year, uint16_t *month, uint16_t *day, uint16_t *hour, uint16_t *minute)
 Decodes the RDS time to LOCAL Julian Day and time. More...
 
char * SI4735::getRdsDateTime (void)
 Gets the RDS the Time and Date when the Group type is 4. More...
 

Detailed Description

Todo:
RDS Dynamic PS or Scrolling PS support

Function Documentation

◆ getRdsReceived()

bool SI4735::getRdsReceived ( )
inline

Get the Rds Received FIFO.

if FIFO is 1, it means the minimum number of groups was filled

Returns
true if minimum number of groups was filled.

Referenced by SI4735::getRdsPI(), SI4735::getRdsText0A(), and SI4735::getRdsText2A().

◆ getRdsSyncLost()

bool SI4735::getRdsSyncLost ( )
inline

Get the Rds Sync Lost object.

returns true (1) if Lost RDS synchronization is detected.

Returns
true if Lost RDS synchronization detected.

◆ getRdsSyncFound()

bool SI4735::getRdsSyncFound ( )
inline

Get the Rds Sync Found.

return true if found RDS synchronization

Returns
true if found RDS synchronization

◆ getRdsNewBlockA()

bool SI4735::getRdsNewBlockA ( )
inline

Get the Rds New Block A.

Returns true if valid Block A data has been received.

Returns
true or false

Referenced by SI4735::getRdsPI().

◆ getRdsNewBlockB()

bool SI4735::getRdsNewBlockB ( )
inline

Get the Rds New Block B.

Returns true if valid Block B data has been received.

Returns
true or false

◆ getRdsSync()

bool SI4735::getRdsSync ( )
inline

Get the Rds Sync.

Returns true if RDS currently synchronized.

Returns
true or false

◆ getGroupLost()

bool SI4735::getGroupLost ( )
inline

Get the Group Lost.

Returns true if one or more RDS groups discarded due to FIFO overrun.

Returns
true or false

◆ getNumRdsFifoUsed()

uint8_t SI4735::getNumRdsFifoUsed ( )
inline

Get the Num Rds Fifo Used.

Return the number of RDS FIFO used

Returns
uint8_t Total RDS FIFO used

◆ setFifoCount()

void SI4735::setFifoCount ( uint16_t  value)
inline

Sets the minimum number of RDS groups stored in the RDS FIFO before RDSRECV is set.

Return the number of RDS FIFO used

Parameters
valuefrom 0 to 25. Default value is 0.

◆ getEndIndicatorGroupA()

bool SI4735::getEndIndicatorGroupA ( )
inline

Check if 0xD or 0xA special characters were received for group A.

See also
resetEndIndicatorGroupA
Returns
true or false

References SI4735::rdsEndGroupA.

◆ resetEndIndicatorGroupA()

void SI4735::resetEndIndicatorGroupA ( )
inline

Resets 0xD or 0xA special characters condition (makes it false)

See also
getEndIndicatorGroupA

References SI4735::rdsEndGroupA.

◆ getEndIndicatorGroupB()

bool SI4735::getEndIndicatorGroupB ( )
inline

Check if 0xD or 0xA special characters were received for group B.

See also
resetEndIndicatorGroupB
Returns
true or false

References SI4735::rdsEndGroupB.

◆ resetEndIndicatorGroupB()

void SI4735::resetEndIndicatorGroupB ( )
inline

Resets 0xD or 0xA special characters condition (makes it false)

See also
getEndIndicatorGroupB

References SI4735::rdsEndGroupB.

◆ getRdsStatus() [1/2]

void SI4735::getRdsStatus ( )
inline

Gets RDS Status.

Same result of calling getRdsStatus(0,0,0).

Please, call getRdsStatus(uint8_t INTACK, uint8_t MTFIFO, uint8_t STATUSONLY) instead getRdsStatus() if you want other behaviour.

See also
SI4735::getRdsStatus(uint8_t INTACK, uint8_t MTFIFO, uint8_t STATUSONLY)

◆ rdsClearFifo()

void SI4735::rdsClearFifo ( )
inline

Empty FIFO.

Clear RDS Receive FIFO.

See also
getRdsStatus

◆ rdsClearInterrupt()

void SI4735::rdsClearInterrupt ( )
inline

Clears RDSINT.

INTACK Interrupt Acknowledge; 0 = RDSINT status preserved. 1 = Clears RDSINT.

See also
getRdsStatus

◆ RdsInit()

void SI4735::RdsInit ( )

Starts the control member variables for RDS.

RDS implementation

This method is called by setRdsConfig()

See also
setRdsConfig()

References SI4735::clearRdsBuffer0A(), SI4735::clearRdsBuffer2A(), and SI4735::clearRdsBuffer2B().

Referenced by SI4735::setRdsConfig().

◆ clearRdsBuffer2A()

void SI4735::clearRdsBuffer2A ( )
protected

Clear RDS buffer 2A (text)

References SI4735::rds_buffer2A.

Referenced by SI4735::getRdsStatus(), and SI4735::RdsInit().

◆ clearRdsBuffer2B()

void SI4735::clearRdsBuffer2B ( )
protected

Clear RDS buffer 2B (text)

References SI4735::rds_buffer2B.

Referenced by SI4735::getRdsStatus(), and SI4735::RdsInit().

◆ clearRdsBuffer0A()

void SI4735::clearRdsBuffer0A ( )
protected

Clear RDS buffer 0A (text)

References SI4735::rds_buffer0A.

Referenced by SI4735::getRdsStatus(), and SI4735::RdsInit().

◆ setRdsConfig()

void SI4735::setRdsConfig ( uint8_t  RDSEN,
uint8_t  BLETHA,
uint8_t  BLETHB,
uint8_t  BLETHC,
uint8_t  BLETHD 
)

Sets RDS property.

Configures RDS settings to enable RDS processing (RDSEN) and set RDS block error thresholds.

When a RDS Group is received, all block errors must be less than or equal the associated block error threshold for the group to be stored in the RDS FIFO.

IMPORTANT: All block errors must be less than or equal the associated block error threshold for the group to be stored in the RDS FIFO.

Value Description
0 No errors
1 1–2 bit errors detected and corrected
2 3–5 bit errors detected and corrected
3 Uncorrectable

Recommended Block Error Threshold options:

Exemples Description
2,2,2,2 No group stored if any errors are uncorrected
3,3,3,3 Group stored regardless of errors
0,0,0,0 No group stored containing corrected or uncorrected errors
3,2,3,3 Group stored with corrected errors on B, regardless of errors on A, C, or D
See also
Si47XX PROGRAMMING GUIDE; AN332 (REV 1.0); page 104
Parameters
uint8_tRDSEN RDS Processing Enable; 1 = RDS processing enabled.
uint8_tBLETHA Block Error Threshold BLOCKA.
uint8_tBLETHB Block Error Threshold BLOCKB.
uint8_tBLETHC Block Error Threshold BLOCKC.
uint8_tBLETHD Block Error Threshold BLOCKD.

References SI4735::RdsInit(), and SI4735::waitToSend().

◆ setRdsIntSource()

void SI4735::setRdsIntSource ( uint8_t  RDSRECV,
uint8_t  RDSSYNCLOST,
uint8_t  RDSSYNCFOUND,
uint8_t  RDSNEWBLOCKA,
uint8_t  RDSNEWBLOCKB 
)

Configures interrupt related to RDS.

Use this method if want to use interrupt

See also
Si47XX PROGRAMMING GUIDE; AN332 (REV 1.0); page 103
Parameters
RDSRECVIf set, generate RDSINT when RDS FIFO has at least FM_RDS_INT_FIFO_COUNT entries.
RDSSYNCLOSTIf set, generate RDSINT when RDS loses synchronization.
RDSSYNCFOUNDset, generate RDSINT when RDS gains synchronization.
RDSNEWBLOCKAIf set, generate an interrupt when Block A data is found or subsequently changed
RDSNEWBLOCKBIf set, generate an interrupt when Block B data is found or subsequently changed

References SI4735::waitToSend().

◆ getRdsStatus() [2/2]

void SI4735::getRdsStatus ( uint8_t  INTACK,
uint8_t  MTFIFO,
uint8_t  STATUSONLY 
)

Gets the RDS status. Store the status in currentRdsStatus member. RDS COMMAND FM_RDS_STATUS.

See also
Si47XX PROGRAMMING GUIDE; AN332 (REV 1.0); pages 55 and 77
Parameters
INTACKInterrupt Acknowledge; 0 = RDSINT status preserved. 1 = Clears RDSINT.
MTFIFO0 = If FIFO not empty, read and remove oldest FIFO entry; 1 = Clear RDS Receive FIFO.
STATUSONLYDetermines if data should be removed from the RDS FIFO.

References SI4735::clearRdsBuffer0A(), SI4735::clearRdsBuffer2A(), SI4735::clearRdsBuffer2B(), and SI4735::waitToSend().

◆ getRdsPI()

uint16_t SI4735::getRdsPI ( void  )

Returns the programa type.

Read the Block A content

See also
Si47XX PROGRAMMING GUIDE; AN332 (REV 1.0); pages 77 and 78
Returns
BLOCKAL

References SI4735::getRdsNewBlockA(), and SI4735::getRdsReceived().

◆ getRdsGroupType()

uint8_t SI4735::getRdsGroupType ( void  )

Returns the Group Type (extracted from the Block B)

Returns
BLOCKBL

◆ getRdsFlagAB()

uint8_t SI4735::getRdsFlagAB ( void  )

Returns the current Text Flag A/B

Returns
uint8_t current Text Flag A/B

◆ getRdsTextSegmentAddress()

uint8_t SI4735::getRdsTextSegmentAddress ( void  )

Returns the address of the text segment.

2A - Each text segment in version 2A groups consists of four characters. A messages of this group can be have up to 64 characters.

2B - In version 2B groups, each text segment consists of only two characters. When the current RDS status is using this version, the maximum message length will be 32 characters.

Returns
uint8_t the address of the text segment.

◆ getRdsVersionCode()

uint8_t SI4735::getRdsVersionCode ( void  )

Gets the version code (extracted from the Block B)

Returns
0=A or 1=B

◆ getRdsProgramType()

uint8_t SI4735::getRdsProgramType ( void  )

Returns the Program Type (extracted from the Block B)

See also
https://en.wikipedia.org/wiki/Radio_Data_System
Returns
program type (an integer betwenn 0 and 31)

◆ getNext2Block()

void SI4735::getNext2Block ( char *  c)

Process data received from group 2B.

Parameters
cchar array reference to the "group 2B" text

References SI4735::rdsEndGroupB.

Referenced by SI4735::getRdsText0A(), and SI4735::getRdsText2B().

◆ getNext4Block()

void SI4735::getNext4Block ( char *  c)

Process data received from group 2A.

Parameters
cchar array reference to the "group 2A" text

References SI4735::rdsEndGroupA.

Referenced by SI4735::getRdsText(), and SI4735::getRdsText2A().

◆ getRdsText()

char * SI4735::getRdsText ( void  )

Gets the RDS Text when the message is of the Group Type 2 version A.

Returns
char* The string (char array) with the content (Text) received from group 2A

References SI4735::getNext4Block(), SI4735::rds_buffer2A, and SI4735::rdsTextAdress2A.

◆ getRdsText0A()

char * SI4735::getRdsText0A ( void  )

Gets the station name and other messages.

Todo:
RDS Dynamic PS or Scrolling PS
Returns
char* should return a string with the station name. However, some stations send other kind of messages

References SI4735::getNext2Block(), SI4735::getRdsReceived(), SI4735::rds_buffer0A, and SI4735::rdsTextAdress0A.

◆ getRdsText2A()

char * SI4735::getRdsText2A ( void  )

Gets the Text processed for the 2A group.

Returns
char* string with the Text of the group A2

References SI4735::getNext4Block(), SI4735::getRdsReceived(), SI4735::rds_buffer2A, and SI4735::rdsTextAdress2A.

◆ getRdsText2B()

char * SI4735::getRdsText2B ( void  )

Gets the Text processed for the 2B group.

Returns
char* string with the Text of the group AB

References SI4735::getNext2Block(), SI4735::rds_buffer2B, and SI4735::rdsTextAdress2B.

◆ getRdsTime()

char * SI4735::getRdsTime ( void  )

Gets the RDS time and date when the Group type is 4.

Returns theUTC Time and offset (to convert it to local time)

return examples:

12:31 +03:00

21:59 -02:30

Returns
point to char array. Format: +/-hh:mm (offset)

References SI4735::rds_time.

◆ mjdConverter()

void SI4735::mjdConverter ( uint32_t  mjd,
uint32_t *  year,
uint32_t *  month,
uint32_t *  day 
)

Converts the MJD number to integers Year, month and day.

()

Calculates day, month and year based on MJD

This MJD algorithm is an adaptation of the javascript code found at http://www.csgnetwork.com/julianmodifdateconv.html

Parameters
mjdmjd number
yearyear variable reference
monthmonth variable reference
dayday variable reference

◆ getRdsDateTime() [1/2]

bool SI4735::getRdsDateTime ( uint16_t *  rYear,
uint16_t *  rMonth,
uint16_t *  rDay,
uint16_t *  rHour,
uint16_t *  rMinute 
)

Decodes the RDS time to LOCAL Julian Day and time.

This method gets the RDS date time massage and converts it from MJD to JD and UTC time to local time

The Date and Time service may not work correctly depending on the FM station that provides the service.

I have noticed that some FM stations do not use the service properly in my location.

Example:

uint16_t year, month, day, hour, minute;
.
.
si4735.getRdsStatus();
si4735.getRdsDateTime(&year, &month, &day, &hour, &minute);
.
.
Parameters
rYearyear variable reference
rMonthmonth variable reference
rDayday variable reference
rHourlocal hour variable reference
rMinutelocal minute variable reference
Returns
true, it the RDS Date and time were processed

◆ getRdsDateTime() [2/2]

char * SI4735::getRdsDateTime ( void  )

Gets the RDS the Time and Date when the Group type is 4.

Returns the Date, UTC Time and offset (to convert it to local time)

return examples:

2021-07-29 12:31 +03:00

1964-05-09 21:59 -02:30

Returns
array of char yy-mm-dd hh:mm +/-hh:mm offset

References SI4735::rds_time.