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 (139560 times)
  2. FAT32 Library (72041 times)
  3. Network Ethernet Library (57254 times)
  4. USB Device Library (47607 times)
  5. Network WiFi Library (43219 times)
  6. FT800 Library (42551 times)
  7. GSM click (29930 times)
  8. mikroSDK (28292 times)
  9. PID Library (26930 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

USB-C Sink 2 Click

Rating:

0

Author: MIKROE

Last Updated: 2024-10-31

Package Version: 2.1.0.7

mikroSDK Library: 2.0.0.0

Category: USB-C PD

Downloaded: 148 times

Not followed.

License: MIT license  

USB-C Sink 2 Click is a compact add-on board with a standalone autonomous USB power delivery controller. This board features the AP33772, a high-performance USB PD sink controller from Diodes Incorporated. It supports dead battery mode to allow a system to be powered from an external source directly, establishes a valid source-to-sink connection, and negotiates a USB power delivery (PD) contract with a PD-capable source device. It also supports a flexible PD3.0 and PPS for applications that require direct voltage and current requests, with fine-tuning capabilities.

No Abuse Reported

Do you want to subscribe in order to receive notifications regarding "USB-C Sink 2 Click" changes.

Do you want to unsubscribe in order to stop receiving notifications regarding "USB-C Sink 2 Click" changes.

Do you want to report abuse regarding "USB-C Sink 2 Click".

  • Information
  • Comments (0)

mikroSDK Library Blog


USB-C Sink 2 Click

USB-C Sink 2 Click is a compact add-on board with a standalone autonomous USB power delivery controller. This board features the AP33772, a high-performance USB PD sink controller from Diodes Incorporated. It supports dead battery mode to allow a system to be powered from an external source directly, establishes a valid source-to-sink connection, and negotiates a USB power delivery (PD) contract with a PD-capable source device. It also supports a flexible PD3.0 and PPS for applications that require direct voltage and current requests, with fine-tuning capabilities.

usbcsink2_click.png

Click Product page


Click library

  • Author : Nenad Filipovic
  • Date : Jun 2023.
  • Type : ADC/I2C type

Software Support

We provide a library for the USB-C Sink 2 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 USB-C Sink 2 Click driver.

Standard key functions :

  • usbcsink2_cfg_setup Config Object Initialization function.

    void usbcsink2_cfg_setup ( usbcsink2_cfg_t *cfg );
  • usbcsink2_init Initialization function.

    err_t usbcsink2_init ( usbcsink2_t *ctx, usbcsink2_cfg_t *cfg );
  • usbcsink2_default_cfg Click Default Configuration function.

    err_t usbcsink2_default_cfg ( usbcsink2_t *ctx );

Example key functions :

  • usbcsink2_write_rdo USB-C Sink 2 write the RDO function.

    err_t usbcsink2_write_rdo ( usbcsink2_t *ctx, uint8_t *rdo );
  • usbcsink2_get_pdo_voltage USB-C Sink 2 get the voltage function.

    err_t usbcsink2_get_pdo_voltage ( usbcsink2_t *ctx, float *voltage_mv );
  • usbcsink2_get_pdo_current USB-C Sink 2 get the current function.

    err_t usbcsink2_get_pdo_current ( usbcsink2_t *ctx, float *current_ma );

Example Description

This example demonstrates the use of the USB-C Sink 2 Click board™ by setting DC power requests and control for Type-C connector-equipped devices (TCD).

The demo application is composed of two sections :

Application Init

Initializes I2C and ADC modules and log UART. After driver initialization the app set default settings.

void application_init ( void )
{
    log_cfg_t log_cfg;  /**< Logger config object. */
    usbcsink2_cfg_t usbcsink2_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.
    usbcsink2_cfg_setup( &usbcsink2_cfg );
    USBCSINK2_MAP_MIKROBUS( usbcsink2_cfg, MIKROBUS_1 );
    err_t init_flag = usbcsink2_init( &usbcsink2, &usbcsink2_cfg );
    if ( ( ADC_ERROR == init_flag ) || ( I2C_MASTER_ERROR == init_flag ) )
    {
        log_error( &logger, " Communication init." );
        for ( ; ; );
    }

    if ( USBCSINK2_ERROR == usbcsink2_default_cfg ( &usbcsink2 ) )
    {
        log_error( &logger, " Default configuration." );
        for ( ; ; );
    }

    log_info( &logger, " Application Task " );
    log_printf( &logger, "---------------------------\r\n" );
    Delay_ms ( 100 );
}

Application Task

In this example, the app configures Power Data Objects (PDO) highest priority profile and requests power from a standard USB PD source adapter. After connecting the PD source and USB-C Sink 2 Click with the Type-C cable, the app gets the total number of valid PDO's and switches all PDO configurations every 10 seconds. When the PD source accepts the request, the app displays information about VOUT Voltage [mV] and Current [mA] and the temperature [degree Celsius] of the USB-C connector.

void application_task ( void ) 
{
    static float voltage_mv = 0, current_ma = 0;
    static uint8_t temperature = 0;
    for ( uint8_t pdo_num = 0; pdo_num < usbcsink2.number_of_valid_pdo; pdo_num++ )
    {
        usbcsink2.pdo_data[ pdo_num * 4 + 3 ] = ( pdo_num + 1 ) << 4;
        if ( USBCSINK2_OK == usbcsink2_write_rdo( &usbcsink2, &usbcsink2.pdo_data[ pdo_num * 4 ] ) )
        {
            log_printf( &logger, " --- PDO[ %d ] ---\r\n", ( uint16_t ) pdo_num );
        }

        if ( USBCSINK2_OK == usbcsink2_wait_rdo_req_success( &usbcsink2 ) )
        {
            if ( USBCSINK2_OK == usbcsink2_get_pdo_voltage( &usbcsink2, &voltage_mv ) )
            {
                log_printf( &logger, " Voltage : %.2f mV\r\n", voltage_mv );
            }

            if ( USBCSINK2_OK == usbcsink2_get_pdo_current( &usbcsink2, &current_ma ) )
            {
                log_printf( &logger, " Current : %.2f mA\r\n", current_ma );
            }

            if ( USBCSINK2_OK == usbcsink2_get_temperature( &usbcsink2, &temperature ) )
            {
                log_printf( &logger, " Temperature : %d C\r\n", ( uint16_t ) temperature );
            }
            log_printf( &logger, "---------------------------\r\n" );
            Delay_ms ( 1000 );
            Delay_ms ( 1000 );
            Delay_ms ( 1000 );
            Delay_ms ( 1000 );
            Delay_ms ( 1000 );
            Delay_ms ( 1000 );
            Delay_ms ( 1000 );
            Delay_ms ( 1000 );
            Delay_ms ( 1000 );
            Delay_ms ( 1000 );
        }
    }
}

Note

FAULT LED flickering notified of the system status:

  • Charging: Breathing light (2 sec dimming), 1 cycle is 4 sec.
  • Fully charged: Continuously lit Charging current < 500mA.
  • Mismatch: 1s flicker Voltage or power mismatch. Non-PD power source, 1 cycle is 2sec.
  • Fault: 300ms flicker OVP, 1 cycle is 600ms.

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.USBCSink2

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

Driver click

5

Driver click features an IC with seven integrated high-current sink drivers drivers, which can be used to drive a wide range of loads via simple parallel interface.

[Learn More]

Smart Sens Click

0

Smart Sens Click is a compact add-on board that contains an intelligent sensor hub with an integrated IMU sensor. This board utilizes the BHI260 and BMM150, an environmental sensor and magnetometer from Bosch Sensortech. The BHI260 includes a programmable and powerful 32-bit MCU, a 6-axis IMU, and a robust software framework. In addition to its internal functions, it also performs signal data processing from the BMM150 that performs measurements of the magnetic field in three perpendicular axes.

[Learn More]

Current 7 Click

0

Current 7 Click is a compact add-on board providing a precise and accurate current sensing solution. This board features the INA282, a wide common-mode range, bidirectional, high-accuracy current shunt monitor from Texas Instruments. The INA282 represents a voltage output current shunt monitor that can sense drops across shunts at common-mode voltages from –14 V to +80 V, independent of the supply voltage, which operates in a range from 2.7V up to 18V supply. The zero-drift topology enables high-precision measurements with maximum input offset voltages as low as 70μV. Also, the user is allowed to process the output signal in analog or digital form.

[Learn More]