TOP Contributors

  1. MIKROE (2650 codes)
  2. Alcides Ramos (350 codes)
  3. Shawon Shahryiar (307 codes)
  4. jm_palomino (112 codes)
  5. Chisanga Mumba (90 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 (136557 times)
  2. FAT32 Library (69762 times)
  3. Network Ethernet Library (55856 times)
  4. USB Device Library (46199 times)
  5. Network WiFi Library (41818 times)
  6. FT800 Library (41023 times)
  7. GSM click (28934 times)
  8. PID Library (26386 times)
  9. mikroSDK (26297 times)
  10. microSD click (25307 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: 1998 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

ccRF 3 click

7

ccRF 3 click carries the CC1120 high-performance RF transceiver for narrowband systems from Texas Instruments. The clicks will enable you to add a low-power consumption radio transceiver at 433 MHz frequency. ccRF 3 click is designed to run on a 3.3V power supply. It communicates with the target microcontroller over SPI interface.

[Learn More]

Accel 7 click

5

Accel 7 click is a three-axis acceleration sensing Click board™. It uses the KXTJ3-1057, a 14bit tri-axis digital accelerometer, which can sense the acceleration up to ±16 g. This sensor is built using the proprietary Kionix micromachining technology, which results with a high accuracy and very good noise immunity.

[Learn More]

ADC 11 click

0

ADC 11 Click is a compact add-on board that contains a high-performance data converter. This board features the LTC1864, a 16-bit 250ksps analog-to-digital converter from Analog Devices. With a typical supply current of only 850µA at the maximum sampling frequency, the LTC1864 is among the lowest power consumption ADCs available. After conversion, the LTC1864 goes into a low-power Sleep mode, further reducing the supply current. That’s why it can run at proper micro-power levels in applications that do not require the maximum sampling rate of the LTC1864. This Click board™ is suitable for high-speed data acquisition, low power battery-operated instrumentation, isolated and remote data acquisition, and many other applications.

[Learn More]