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]
Rating:
Author: MIKROE
Last Updated: 2020-09-11
Package Version: 1.0.0.0
mikroSDK Library: 1.0.0.0
Category: Port expander
Downloaded: 2521 times
Not followed.
License: MIT license
EXPAND 6 Click is a compact add-on board that contains an I2C configurable multi-port I/O expander with independently configurable pins as bi-directional input/outputs or PWM outputs. This board features the CY8C9520A, 20-bit I/O expander with EEPROM, and 4 independently configurable 8-bit PWM outputs from Cypress Semiconductor.
Do you want to subscribe in order to receive notifications regarding "EXPAND 6" changes.
Do you want to unsubscribe in order to stop receiving notifications regarding "EXPAND 6" changes.
Do you want to report abuse regarding "EXPAND 6".
Library Description
The library covers necessary functions that enables the usage of the EXPAND 6 click board. User can check or set the state of every pin, set PWM output or use on board user available EEPROM.
Key functions:
uint8_t expand6_read_pin ( uint16_t pin, uint8_t inv );
- Function is used to read the state of a defined pin.void expand6_write_pin ( uint16_t pin, uint8_t pin_val );
- Function is used to set a single output pin's logic level.void expand6_sel_pwm_pin ( uint16_t pin, uint8_t pwm_en );
- Function is used to enable or disable PWM output on a specific pin.Examples description
The application is composed of three sections :
void application_task ( )
{
mikrobus_logWrite( " PORT 0 ", _LOG_LINE );
for ( pin_num = 0; pin_num < 8; pin_num++ )
{
expand6_write_port( EXPAND6_PORT_0, 0xFF );
expand6_write_pin( pin_num, EXPAND6_LOW );
mikrobus_logWrite( "Pin ", _LOG_TEXT );
ByteToStr( pin_num, log_txt );
Ltrim( log_txt );
mikrobus_logWrite( log_txt, _LOG_TEXT );
mikrobus_logWrite( " is low!", _LOG_LINE );
Delay_ms( 500 );
expand6_write_port( EXPAND6_PORT_0, 0xFF );
}
Delay_ms( 1000 );
mikrobus_logWrite( " PORT 1 ", _LOG_LINE );
for ( pin_num = 8; pin_num < 16; pin_num++ )
{
expand6_write_port( EXPAND6_PORT_1, 0xFF );
expand6_write_pin( pin_num, EXPAND6_LOW );
mikrobus_logWrite( "Pin ", _LOG_TEXT );
ByteToStr( pin_num, log_txt );
Ltrim( log_txt );
mikrobus_logWrite( log_txt, _LOG_TEXT );
mikrobus_logWrite( " is low!", _LOG_LINE );
Delay_ms( 500 );
expand6_write_port( EXPAND6_PORT_1, 0xFF );
}
Delay_ms( 1000 );
mikrobus_logWrite( " PORT 2 ", _LOG_LINE );
for ( pin_num = 16; pin_num < 20; pin_num++ )
{
expand6_write_port( EXPAND6_PORT_2, 0xFF );
expand6_write_pin( pin_num, EXPAND6_LOW );
mikrobus_logWrite( "Pin ", _LOG_TEXT );
ByteToStr( pin_num, log_txt );
Ltrim( log_txt );
mikrobus_logWrite( log_txt, _LOG_TEXT );
mikrobus_logWrite( " is low!", _LOG_LINE );
Delay_ms( 500 );
expand6_write_port( EXPAND6_PORT_2, 0xFF );
}
mikrobus_logWrite( "-------------------", _LOG_LINE );
Delay_ms( 1000 );
}
Other mikroE Libraries used in the example:
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. The terminal available in all MikroElektronika compilers, or any other terminal application of your choice, can be used to read the message.