I2cToSpi Click example.
Description
I2C to SPi Click 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. By offering an I2C-bus slave-transmitter or slave-receiver and SPI master, this Click controls all the SPi bus-specific sequences, protocol, and timing. It also has its own internal oscillator, and it supports the SPi chip select output that may be configured as GPIO when not used.
The demo application is composed of two sections :
Application Init
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.
note:
Additional Functions :
- void display_log_uart( uint8_t value ) - Write the value of time or date as a two-digit number.
- void rtc5_clear( i2ctospi_t *ctx, i2ctospi_spi_t *spi ) - Clear RTCC and SRAM memory of RTC 5 click.
- void rtc5_set_time_seconds( i2ctospi_t *ctx, i2ctospi_spi_t *spi, uint8_t seconds ) - Set the seconds and enable counting.
- uint8_t rtc5_get_time_seconds( i2ctospi_t *ctx, i2ctospi_spi_t *spi ) - Get the seconds.
- void rtc5_set_time_minutes( uint8_t minutes ) - Set the minutes.
- uint8_t rtc5_get_time_minutes( i2ctospi_t *ctx, i2ctospi_spi_t *spi ) - Get the minutes.
- void rtc5_set_time_hours( i2ctospi_t *ctx, i2ctospi_spi_t *spi, uint8_t hours ) - Set the hours.
- uint8_t rtc5_get_time_hours( i2ctospi_t *ctx, i2ctospi_spi_t *spi ) - Get the hours.
- Author
- MikroE Team