TOP Contributors

  1. MIKROE (2779 codes)
  2. Alcides Ramos (376 codes)
  3. Shawon Shahryiar (307 codes)
  4. jm_palomino (118 codes)
  5. Bugz Bensce (97 codes)
  6. S P (73 codes)
  7. dany (71 codes)
  8. MikroBUS.NET Team (35 codes)
  9. NART SCHINACKOW (34 codes)
  10. Armstrong Subero (27 codes)

Most Downloaded

  1. Timer Calculator (139566 times)
  2. FAT32 Library (72041 times)
  3. Network Ethernet Library (57255 times)
  4. USB Device Library (47615 times)
  5. Network WiFi Library (43219 times)
  6. FT800 Library (42566 times)
  7. GSM click (29930 times)
  8. mikroSDK (28292 times)
  9. PID Library (26933 times)
  10. microSD click (26309 times)
Libstock prefers package manager

Package Manager

We strongly encourage users to use Package manager for sharing their code on Libstock website, because it boosts your efficiency and leaves the end user with no room for error. [more info]

< Back
mikroSDK Library

I2C to SPI click

Rating:

5

Author: MIKROE

Last Updated: 2019-09-13

Package Version: 1.0.0.0

mikroSDK Library: 1.0.0.0

Category: I2C

Downloaded: 2320 times

Not followed.

License: MIT license  

I2C to SPI Click is an all-in-one solution which allows serving as an interface between a standard I2C-bus of a microcontroller and an SPI bus, which allows the microcontroller to communicate directly with SPI devices through its I2C-bus.

No Abuse Reported

Do you want to subscribe in order to receive notifications regarding "I2C to SPI click" changes.

Do you want to unsubscribe in order to stop receiving notifications regarding "I2C to SPI click" changes.

Do you want to report abuse regarding "I2C to SPI click".

  • mikroSDK Library 2.0.0.0
  • Comments (0)

mikroSDK Library Blog

I2C to SPI Click

I2C to SPI Click

Native view of the I2C to SPI Click board.

View full image
I2C to SPI Click

I2C to SPI Click

Front and back view of the I2C to SPI Click board.

View full image

Library Description

The library covers all the necessary functions to control I2C to SPI click board. A library performs interface between a standard I2C-bus of a microcontroller and an SPI bus.

Key functions:

  • void i2ctospi_spiWriteByte( uint8_t slaveDevice, uint8_t functionId, uint8_t regAddr, uint8_t writeData ) - Generic SPI writes the byte of data to data buffer function.
  • uint8_t i2ctospi_spiReadByte( uint8_t slaveDevice, uint8_t functionId, uint8_t regAddr ) - Generic SPI read the byte of data from data buffer function.
  • void i2ctospi_configSPI( uint8_t configData ) - Configure SPI Interface function.

Examples description

The application is composed of the three sections :

  • System Initialization - Initializes GPIO, SPI and LOG structures, sets RST and CS pins as output and INT pin as an input.
  • Application Initialization - Initialization driver enable's - I2C, hardware reset, SS0 ( CS ) configured to be used as slave select outputs, set the configuration of SPI: order MSB first, clock Idle low, leading-edge transition, SPI clock rate to 115kHz, set SPI EEPROM write enable SS0, clear  interrupt, clear RT5 register, sets starting time: hours, minutes and seconds ( enable counting ), also write log.
  • Application Task - This is an example which demonstrates the use of RTC 5 click is wired to I2C to SPI click board. I2C to SPI click communicates with register via the I2C interface, serve as an interface between a standard I2C-bus of a microcontroller and an SPI bus. RTC 5 click communicates with register via SPI interface. In this examples, we display RTC time which we received reading from the target register address of MCP79510 chip on RTC 5 click board via I2C interface of I2C to SPI click board. Results are being sent to the Usart Terminal where you can track their changes. All data logs write on usb uart changes for every 1 sec.
void applicationTask()
{
    timeSeconds = _rtc5GetTimeSeconds();
    Delay_1ms();
    timeMinutes = _rtc5GetTimeMinutes();
    Delay_1ms();
    timeHours = _rtc5GetTimeHours();
    Delay_1ms();

    if ( timeSecondsNew != timeSeconds )
    {
        mikrobus_logWrite( " Time :  ", _LOG_TEXT );

        _displayLogUart( timeHours );
        mikrobus_logWrite( ":", _LOG_TEXT );

        _displayLogUart( timeMinutes );
        mikrobus_logWrite( ":", _LOG_TEXT );

        _displayLogUart( timeSeconds );
        mikrobus_logWrite( "", _LOG_LINE );
 
        mikrobus_logWrite( "------------------", _LOG_LINE );

        timeSecondsNew = timeSeconds;
    }

    Delay_1ms();
}

Additional Functions :

  • void _displayLogUart( uint8_t value ) - Write the value of time or date as a two-digit number.
  • void _rtc5Clear() - Clear RTCC and SRAM memory of RTC 5 click.
  • void _rtc5SetTimeSeconds( uint8_t seconds ) - Set the seconds and enable counting.
  • uint8_t _rtc5GetTimeSeconds() - Get the seconds.
  • void _rtc5SetTimeMinutes( uint8_t minutes ) - Set the minutes.
  • uint8_t _rtc5GetTimeMinutes() - Get the minutes.
  • void _rtc5SetTimeHours( uint8_t hours ) - Set the hours.
  • uint8_t _rtc5GetTimeHours() - Get the hours.

Other mikroE Libraries used in the example:

  • I2C
  • UART
  • Conversions

Additional notes and informations

Depending on the development board you are using, you may need USB UART clickUSB UART 2 click or RS232 click to connect to your PC, for development systems with no UART to USB interface available on the board. The terminal available in all MikroElektronika compilers, or any other terminal application of your choice, can be used to read the message.

ALSO FROM THIS AUTHOR

Ambient 20 Click

0

Ambient 20 Click is a compact add-on board used to measure the amount of the present ambient light. This board features the BU27030NUC, a 16-bit digital-output ambient light sensor with an I2C interface from Rohm Semiconductor. The BU27030NUC has a flexible and wide operating range of up to 20klx with a maximum resolution of 0.0007lux/count, providing an excellent responsivity close to the human eyes' response. It also features inherent 50Hz/60Hz light noise rejection and excellent IR-cut characteristics for high robustness at high sensitivity.

[Learn More]

Thermo 29 Click

0

Thermo 29 Click is a compact add-on board for accurate temperature measurements. This board features the TMP126, a high-accuracy SPI-configurable digital temperature sensor from Texas Instruments. The TMP126 consists of an internal thermal BJT factory-calibrated sensor, 14-bit ADC, and a digital signal processor, offering a high accuracy of ±0.25°C and a temperature resolution of 0.03125°C per LSB. It also has a programmable alarm function that outputs an interrupt signal to the MCU when a specific temperature event occurs.

[Learn More]

LightRanger 3 Click

0

Light Ranger 3 Click is an accurate distance measurement Click board™ based on a ToF ( Time of Flight ) measurement principle. The Simblee™ enabled RFD77402 rangefinder module from RF Digital is a complete measurement stack on the chip.

[Learn More]