TOP Contributors

  1. MIKROE (2784 codes)
  2. Alcides Ramos (385 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 (139845 times)
  2. FAT32 Library (72209 times)
  3. Network Ethernet Library (57392 times)
  4. USB Device Library (47740 times)
  5. Network WiFi Library (43364 times)
  6. FT800 Library (42700 times)
  7. GSM click (29980 times)
  8. mikroSDK (28440 times)
  9. PID Library (26989 times)
  10. microSD click (26398 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

RS232 to I2C Click

Rating:

0

Author: MIKROE

Last Updated: 2024-10-31

Package Version: 2.1.0.12

mikroSDK Library: 2.0.0.0

Category: RS232

Downloaded: 280 times

Not followed.

License: MIT license  

RS232 to I2C Click is a compact add-on board representing a universal usable RS232 to I2C converter. This board features the ZDU0110RFX, a bridge between a UART port and an I2C bus from Zilog, which at the same time represents the connection between the MCU and the RS232 line driver and receiver, the MAX3232. The ZDU0110RFX provides full-duplex asynchronous communications with a 128 byte FIFO buffer, of which 64 bytes each are allocated to receive and transmit operations. It also contains a 4kbit EEPROM and GPIO with programmable interrupt capability; programmable interrupts and interrupt lines for UART and GPIO notifications.

No Abuse Reported

Do you want to subscribe in order to receive notifications regarding "RS232 to I2C Click" changes.

Do you want to unsubscribe in order to stop receiving notifications regarding "RS232 to I2C Click" changes.

Do you want to report abuse regarding "RS232 to I2C Click".

  • Information
  • Comments (0)

mikroSDK Library Blog


RS232 to I2C Click

RS232 to I2C Click is a compact add-on board representing a universal usable RS232 to I2C converter. This board features the ZDU0110RFX, a bridge between a UART port and an I2C bus from Zilog, which at the same time represents the connection between the MCU and the RS232 line driver and receiver, the MAX3232. The ZDU0110RFX provides full-duplex asynchronous communications with a 128 byte FIFO buffer, of which 64 bytes each are allocated to receive and transmit operations. It also contains a 4kbit EEPROM and GPIO with programmable interrupt capability; programmable interrupts and interrupt lines for UART and GPIO notifications.

rs232toi2c_click.png

Click Product page


Click library

  • Author : Stefan Filipovic
  • Date : Jan 2022.
  • Type : I2C type

Software Support

We provide a library for the RS232 to I2C Click as well as a demo application (example), developed using MikroElektronika compilers. The demo can run on all the main MikroElektronika development boards.

Package can be downloaded/installed directly from NECTO Studio Package Manager(recommended way), downloaded from our LibStock™ or found on Mikroe github account.

Library Description

This library contains API for RS232 to I2C Click driver.

Standard key functions :

  • rs232toi2c_cfg_setup Config Object Initialization function.

    void rs232toi2c_cfg_setup ( rs232toi2c_cfg_t *cfg );
  • rs232toi2c_init Initialization function.

    err_t rs232toi2c_init ( rs232toi2c_t *ctx, rs232toi2c_cfg_t *cfg );
  • rs232toi2c_default_cfg Click Default Configuration function.

    err_t rs232toi2c_default_cfg ( rs232toi2c_t *ctx );

Example key functions :

  • rs232toi2c_write_tx_fifo This function writes a desired number of data bytes to the TX fifo.

    err_t rs232toi2c_write_tx_fifo ( rs232toi2c_t *ctx, uint8_t *data_in, uint8_t data_len );
  • rs232toi2c_read_rx_fifo This function reads all data from RX fifo.

    err_t rs232toi2c_read_rx_fifo ( rs232toi2c_t *ctx, uint8_t *data_out, uint8_t *data_len );
  • rs232toi2c_get_int_pin This function returns the INT pin logic state.

    uint8_t rs232toi2c_get_int_pin ( rs232toi2c_t *ctx );

Example Description

This example demonstrates the use of an RS232 to I2C Click board by showing the communication between the two Click board configured as a receiver and transmitter.

The demo application is composed of two sections :

Application Init

Initializes the driver and performs the Click default configuration which sets the default UART configuration with 9600 baud rate.


void application_init ( void )
{
    log_cfg_t log_cfg;  /**< Logger config object. */
    rs232toi2c_cfg_t rs232toi2c_cfg;  /**< Click config object. */

    /** 
     * Logger initialization.
     * Default baud rate: 115200
     * Default log level: LOG_LEVEL_DEBUG
     * @note If USB_UART_RX and USB_UART_TX 
     * are defined as HAL_PIN_NC, you will 
     * need to define them manually for log to work. 
     * See @b LOG_MAP_USB_UART macro definition for detailed explanation.
     */
    LOG_MAP_USB_UART( log_cfg );
    log_init( &logger, &log_cfg );
    log_info( &logger, " Application Init " );

    // Click initialization.
    rs232toi2c_cfg_setup( &rs232toi2c_cfg );
    RS232TOI2C_MAP_MIKROBUS( rs232toi2c_cfg, MIKROBUS_1 );
    if ( I2C_MASTER_ERROR == rs232toi2c_init( &rs232toi2c, &rs232toi2c_cfg ) ) 
    {
        log_error( &logger, " Communication init." );
        for ( ; ; );
    }

    if ( RS232TOI2C_ERROR == rs232toi2c_default_cfg ( &rs232toi2c ) )
    {
        log_error( &logger, " Default configuration." );
        for ( ; ; );
    }

    uint32_t system_version;
    if ( RS232TOI2C_OK == rs232toi2c_read_system_version ( &rs232toi2c, &system_version ) )
    {
        log_printf ( &logger, " System Version: 0x%.6LX\r\n", system_version );
    }
#ifdef DEMO_APP_TRANSMITTER
    log_printf( &logger, " Application Mode: Transmitter\r\n" );
#else
    log_printf( &logger, " Application Mode: Receiver\r\n" );
#endif
    log_info( &logger, " Application Task " );
}

Application Task

Depending on the selected mode, it reads all the received data and sends an adequate response back or sends the desired message and waits for a response every 2 seconds.

void application_task ( void )
{
#ifdef DEMO_APP_TRANSMITTER
    if ( RS232TOI2C_OK == rs232toi2c_write_tx_fifo( &rs232toi2c, DEMO_TEXT_MESSAGE, strlen( DEMO_TEXT_MESSAGE ) ) )
    {
        log_printf( &logger, " The message \"%s\" has been sent!\r\n", ( char * ) DEMO_TEXT_MESSAGE );
        uint16_t timeout_cnt = 5000;
        // wait for an RX interrupt
        while ( rs232toi2c_get_int_pin ( &rs232toi2c ) && timeout_cnt )
        {
            Delay_ms ( 1 );
            timeout_cnt--;
        }
        if ( timeout_cnt )
        {
            uint8_t data_buf[ 256 ] = { 0 };
            uint8_t data_len = 0;
            if ( RS232TOI2C_OK == rs232toi2c_read_rx_fifo( &rs232toi2c, data_buf, &data_len ) )
            {
                log_printf( &logger, " Response: " );
                for ( uint8_t cnt = 0; cnt < data_len; cnt++ )
                {
                    log_printf( &logger, "%c", data_buf[ cnt ] );
                }
            }
        }
        else
        {
            log_error ( &logger, "TIMEOUT - no response received" );
        }
        log_printf( &logger, "\r\n\n" );
        Delay_ms ( 1000 );
        Delay_ms ( 1000 );
    }
#else
    // wait for an RX interrupt
    while ( rs232toi2c_get_int_pin ( &rs232toi2c ) );

    uint8_t data_buf[ 256 ] = { 0 };
    uint8_t data_len = 0;
    if ( RS232TOI2C_OK == rs232toi2c_read_rx_fifo( &rs232toi2c, data_buf, &data_len ) )
    {
        log_printf( &logger, " A new message has received: \"" );
        for ( uint8_t cnt = 0; cnt < data_len; cnt++ )
        {
            log_printf( &logger, "%c", data_buf[ cnt ] );
        }
        log_printf( &logger, "\"\r\n" );
        if ( strstr ( data_buf, DEMO_TEXT_MESSAGE ) )
        {
            if ( RS232TOI2C_OK == rs232toi2c_write_tx_fifo( &rs232toi2c, RESPONSE_OK, strlen( RESPONSE_OK ) ) )
            {
                log_printf( &logger, " Response \"%s\" has been sent to the sender!\r\n\n", ( char * ) RESPONSE_OK );
            }
        }
        else
        {
            if ( RS232TOI2C_OK == rs232toi2c_write_tx_fifo( &rs232toi2c, RESPONSE_ERROR, strlen( RESPONSE_ERROR ) ) )
            {
                log_printf( &logger, " Response \"%s\" has been sent to the sender!\r\n\n", ( char * ) RESPONSE_ERROR );
            }
        }
    }
#endif
}

The full application code, and ready to use projects can be installed directly from NECTO Studio Package Manager(recommended way), downloaded from our LibStock™ or found on Mikroe github account.

Other Mikroe Libraries used in the example:

  • MikroSDK.Board
  • MikroSDK.Log
  • Click.RS232toI2C

Additional notes and informations

Depending on the development board you are using, you may need USB UART Click, USB UART 2 Click or RS232 Click to connect to your PC, for development systems with no UART to USB interface available on the board. UART terminal is available in all MikroElektronika compilers.


ALSO FROM THIS AUTHOR

ISM RX 2 click

5

ISM RX 2 Click is a compact add-on board that contains a pin configurable, low current, sub-GHz EZRadio® receiver. This board features the Si4356, a standalone Sub-GHz RF receiver IC, from Silicon Labs, which provides a true plug-and-play receive option.

[Learn More]

Vibra Sense 2 Click

0

Vibra Sense 2 Click is a compact add-on board that contains a piezo sensor suitable for vibration measurements. This board features the LDT0-028K, a flexible 28 μm thick piezoelectric PVDF polymer film with screen-printed silver ink electrodes, laminated to a 0.125 mm polyester substrate, and fitted with two crimped contacts from TE Connectivity.

[Learn More]

Stepper 4 click

0

Stepper 4 click carries a TB67S269FTG - a two-phase bipolar stepping motor driver using a PWM chopper, with a clock in decoder built in. Rating is 50 V/2.0 A. Microstepping resolution is externally manipulated, as well as output current scaling.

[Learn More]