Intermediate
30 min

Explore the roots of computing with 8800 Retro Click and STM32G474RE

Step back in time: Experience the legacy of Altair 8800

8800 Retro Click with Nucleo 64 with STM32G474RE MCU

Published Nov 08, 2024

Click board™

8800 Retro Click

Dev. board

Nucleo 64 with STM32G474RE MCU

Compiler

NECTO Studio

MCU

STM32G474RE

Discover the simplicity and charm of early computing with 8800 Retro Click, an innovative tribute to the legendary Altair 8800

A

A

Hardware Overview

How does it work?

8800 Retro Click is based on the AS1115, a compact dot-matrix 8x8 LED driver from AMS-AG. It includes a 4-bit PWM for each segment and only one resistor for LED current adjustment (LED brightness). The AS1115 comprises an integrated BCD code-B/HEX decoder, multiplex scan circuitry, segment and display drivers, and 64-bit memory. Internal memory stores the shift register settings, eliminating the need for continuous device reprogramming. This board is ideal for seven-segment or dot matrix user interface displays and other white goods or personal electronic applications. The LED columns have common cathodes connected to the digit-drive lines,

where each of the 64 LEDs can be addressed separately. On initial Power-Up, the AS1115 registers are reset to their default values, the display is blanked, and the device goes into Shutdown mode. At this time, all registers should be programmed for Normal operation. The AS1115 features a low Shutdown current of typically 200nA and an operational current of typically 350μA. 8800 Retro Click communicates with MCU using a standard I2C 2-Wire interface, with a clock frequency of up to 1MHz in the Fast Mode Plus. In addition, the AS1115 can read back 16 buttons and offers a detailed short/open LED error diagnostic. Therefore, to get a valid readback of buttons, it is

recommended to read out the keyscan registers immediately after the IRQ interrupt pin, available on the INT pin of the mikroBUS™ socket, is triggered. In addition to the number-digits programming, this Click board™ can also be reset by software. This Click board™ can be operated only with a 3.3V logic voltage level. The board must perform appropriate logic voltage level conversion before using MCUs with different logic levels. Also, it comes equipped with a library containing functions and an example code that can be used as a reference for further development.

8800 Retro Click top side image
8800 Retro Click bottom side image

Features overview

Development board

Nucleo-64 with STM32G474R MCU offers a cost-effective and adaptable platform for developers to explore new ideas and prototype their designs. This board harnesses the versatility of the STM32 microcontroller, enabling users to select the optimal balance of performance and power consumption for their projects. It accommodates the STM32 microcontroller in the LQFP64 package and includes essential components such as a user LED, which doubles as an ARDUINO® signal, alongside user and reset push-buttons, and a 32.768kHz crystal oscillator for precise timing operations. Designed with expansion and flexibility in mind, the Nucleo-64 board features an ARDUINO® Uno V3 expansion connector and ST morpho extension pin

headers, granting complete access to the STM32's I/Os for comprehensive project integration. Power supply options are adaptable, supporting ST-LINK USB VBUS or external power sources, ensuring adaptability in various development environments. The board also has an on-board ST-LINK debugger/programmer with USB re-enumeration capability, simplifying the programming and debugging process. Moreover, the board is designed to simplify advanced development with its external SMPS for efficient Vcore logic supply, support for USB Device full speed or USB SNK/UFP full speed, and built-in cryptographic features, enhancing both the power efficiency and security of projects. Additional connectivity is

provided through dedicated connectors for external SMPS experimentation, a USB connector for the ST-LINK, and a MIPI® debug connector, expanding the possibilities for hardware interfacing and experimentation. Developers will find extensive support through comprehensive free software libraries and examples, courtesy of the STM32Cube MCU Package. This, combined with compatibility with a wide array of Integrated Development Environments (IDEs), including IAR Embedded Workbench®, MDK-ARM, and STM32CubeIDE, ensures a smooth and efficient development experience, allowing users to fully leverage the capabilities of the Nucleo-64 board in their projects.

Nucleo 64 with STM32G474RE MCU double side image

Microcontroller Overview

MCU Card / MCU

STM32G474RE front image

Architecture

ARM Cortex-M4

MCU Memory (KB)

512

Silicon Vendor

STMicroelectronics

Pin count

64

RAM (Bytes)

128k

You complete me!

Accessories

Click Shield for Nucleo-64 comes equipped with two proprietary mikroBUS™ sockets, allowing all the Click board™ devices to be interfaced with the STM32 Nucleo-64 board with no effort. This way, Mikroe allows its users to add any functionality from our ever-growing range of Click boards™, such as WiFi, GSM, GPS, Bluetooth, ZigBee, environmental sensors, LEDs, speech recognition, motor control, movement sensors, and many more. More than 1537 Click boards™, which can be stacked and integrated, are at your disposal. The STM32 Nucleo-64 boards are based on the microcontrollers in 64-pin packages, a 32-bit MCU with an ARM Cortex M4 processor operating at 84MHz, 512Kb Flash, and 96KB SRAM, divided into two regions where the top section represents the ST-Link/V2 debugger and programmer while the bottom section of the board is an actual development board. These boards are controlled and powered conveniently through a USB connection to program and efficiently debug the Nucleo-64 board out of the box, with an additional USB cable connected to the USB mini port on the board. Most of the STM32 microcontroller pins are brought to the IO pins on the left and right edge of the board, which are then connected to two existing mikroBUS™ sockets. This Click Shield also has several switches that perform functions such as selecting the logic levels of analog signals on mikroBUS™ sockets and selecting logic voltage levels of the mikroBUS™ sockets themselves. Besides, the user is offered the possibility of using any Click board™ with the help of existing bidirectional level-shifting voltage translators, regardless of whether the Click board™ operates at a 3.3V or 5V logic voltage level. Once you connect the STM32 Nucleo-64 board with our Click Shield for Nucleo-64, you can access hundreds of Click boards™, working with 3.3V or 5V logic voltage levels.

Click Shield for Nucleo-64 accessories 1 image

Used MCU Pins

mikroBUS™ mapper

NC
NC
AN
NC
NC
RST
NC
NC
CS
NC
NC
SCK
NC
NC
MISO
NC
NC
MOSI
Power Supply
3.3V
3.3V
Ground
GND
GND
NC
NC
PWM
Interrupt
PC14
INT
NC
NC
TX
NC
NC
RX
I2C Clock
PB8
SCL
I2C Data
PB9
SDA
NC
NC
5V
Ground
GND
GND
1

Take a closer look

Click board™ Schematic

8800 Retro Click Schematic schematic

Step by step

Project assembly

Click Shield for Nucleo-64 accessories 1 image hardware assembly

Start by selecting your development board and Click board™. Begin with the Nucleo 64 with STM32G474RE MCU as your development board.

Click Shield for Nucleo-64 accessories 1 image hardware assembly
Nucleo 64 with STM32G474RE MCU front image hardware assembly
LTE Cat.1 6 Click front image hardware assembly
Prog-cut hardware assembly
Nucleo-64 with STM32GXXX MCU Access MB 1 Micro B Conn - upright/background hardware assembly
Necto image step 2 hardware assembly
Necto image step 3 hardware assembly
Necto image step 4 hardware assembly
NECTO Compiler Selection Step Image hardware assembly
Necto image step 6 hardware assembly
Clicker 4 for STM32F4 HA MCU Step hardware assembly
Necto No Display image step 8 hardware assembly
Necto image step 9 hardware assembly
Necto image step 10 hardware assembly
Debug Image Necto Step hardware assembly

Track your results in real time

Application Output

1. Application Output - In Debug mode, the 'Application Output' window enables real-time data monitoring, offering direct insight into execution results. Ensure proper data display by configuring the environment correctly using the provided tutorial.

2. UART Terminal - Use the UART Terminal to monitor data transmission via a USB to UART converter, allowing direct communication between the Click board™ and your development system. Configure the baud rate and other serial settings according to your project's requirements to ensure proper functionality. For step-by-step setup instructions, refer to the provided tutorial.

3. Plot Output - The Plot feature offers a powerful way to visualize real-time sensor data, enabling trend analysis, debugging, and comparison of multiple data points. To set it up correctly, follow the provided tutorial, which includes a step-by-step example of using the Plot feature to display Click board™ readings. To use the Plot feature in your code, use the function: plot(*insert_graph_name*, variable_name);. This is a general format, and it is up to the user to replace 'insert_graph_name' with the actual graph name and 'variable_name' with the parameter to be displayed.

Software Support

Library Description

This library contains API for 8800 Retro Click driver.

Key functions:

  • c8800retro_display_char - This function displays a single character from the predefined charset (IBM BIOS 8x8 font array)

  • c8800retro_get_keypad - This function reads KEYA and KEYB registers and stores the register's inverted value to the keypad variable

  • c8800retro_display_string - This function scrolls a desired string on LEDs.

Open Source

Code example

The complete application code and a ready-to-use project are available through the NECTO Studio Package Manager for direct installation in the NECTO Studio. The application code can also be found on the MIKROE GitHub account.

/*!
 * @file main.c
 * @brief 8800Retro Click example
 *
 * # Description
 * This example demonstrates the use of 8800 Retro click board.
 *
 * The demo application is composed of two sections :
 *
 * ## Application Init
 * Initializes the driver and issues the click default configuration, 
 * then asks the user to select the demo example using the on-board KeyPad.
 *
 * ## Application Task
 * There are 4 different demo examples: KeyPad 4x4, Full charset, Text, and Image.
 * This function will run the previously selected demo example in the loop. 
 * The user can always switch the example by pressing the button D4 three times in a row. 
 * In order to run the demo examples successfully, please follow the instructions logged
 * on the USB UART.
 * 
 * @author Stefan Filipovic
 *
 */

#include "board.h"
#include "log.h"
#include "c8800retro.h"

/**
 * @brief 8800 Retro Click demo example values.
 * @details Enum values for demo examples selection.
 */
typedef enum
{
    DEMO_KEYPAD4x4,
    DEMO_FULL_CHARSET,
    DEMO_TEXT,
    DEMO_IMAGE,

} c8800retro_demo_example_t;

static c8800retro_t c8800retro;
static log_t logger;

static c8800retro_demo_example_t demo_example = DEMO_KEYPAD4x4;
uint8_t c8800retro_demo_string[ 9 ] = { ' ', 'M', 'i', 'k', 'r', 'o', 'E', ' ', 0 };
uint8_t c8800retro_demo_logo_mikroe[ 8 ] = { 0x7F, 0xFF, 0xC0, 0xFF, 0xFF, 0xC0, 0xFF, 0x7F };

/**
 * @brief 8800 Retro select demo example function.
 * @details This function asks the user to select the demo example via desired buttons.
 * @param[in] ctx : Click context object.
 * See #c8800retro_t object definition for detailed explanation.
 * @return @li @c  0 - Success,
 *         @li @c -1 - Error.
 *
 * See #err_t definition for detailed explanation.
 * @note Follow the procedure written on the USB UART to select the desired demo example.
 */
static err_t c8800retro_select_demo_example( c8800retro_t *ctx );

/**
 * @brief 8800 Retro demo KeyPad 4x4 example function.
 * @details This function executes the KeyPad 4x4 demo example.
 * @param[in] ctx : Click context object.
 * See #c8800retro_t object definition for detailed explanation.
 * @return @li @c  0 - Success,
 *         @li @c -1 - Error.
 *
 * See #err_t definition for detailed explanation.
 * @note Follow the procedure written on the USB UART to jump out the function.
 */
static err_t c8800retro_demo_keypad4x4( c8800retro_t *ctx );

/**
 * @brief 8800 Retro demo Full charset example function.
 * @details This function executes the Full charset demo example.
 * @param[in] ctx : Click context object.
 * See #c8800retro_t object definition for detailed explanation.
 * @return @li @c  0 - Success,
 *         @li @c -1 - Error.
 *
 * See #err_t definition for detailed explanation.
 * @note Follow the procedure written on the USB UART to jump out the function.
 */
static err_t c8800retro_demo_full_charset( c8800retro_t *ctx );

/**
 * @brief 8800 Retro demo text example function.
 * @details This function executes the Text demo example.
 * @param[in] ctx : Click context object.
 * See #c8800retro_t object definition for detailed explanation.
 * @param[in] scroll_mode : @li @c 0 - Horizontal left.
 *                          @li @c 1 - Horizontal right.
 *                          @li @c 2 - Vertical up.
 *                          @li @c 3 - Vertical down.
 * @param[in] scroll_speed_ms : Scroll speed in miliseconds.
 * @param[in] text : Text string (up to 32 characters).
 * @return @li @c  0 - Success,
 *         @li @c -1 - Error.
 *
 * See #err_t definition for detailed explanation.
 * @note Follow the procedure written on the USB UART to jump out the function.
 */
static err_t c8800retro_demo_text( c8800retro_t *ctx, uint8_t scroll_mode, uint16_t scroll_speed_ms, uint8_t *text );

/**
 * @brief 8800 Retro demo image example function.
 * @details This function executes the Image demo example.
 * @param[in] ctx : Click context object.
 * See #c8800retro_t object definition for detailed explanation.
 * @param[in] p_image : Pointer to image buffer (array of 8 bytes).
 * @return @li @c  0 - Success,
 *         @li @c -1 - Error.
 *
 * See #err_t definition for detailed explanation.
 * @note Follow the procedure written on the USB UART to jump out the function.
 */
static err_t c8800retro_demo_image( c8800retro_t *ctx, uint8_t *p_image );

void application_init ( void ) 
{
    log_cfg_t log_cfg;                /**< Logger config object. */
    c8800retro_cfg_t c8800retro_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.
    c8800retro_cfg_setup( &c8800retro_cfg );
    C8800RETRO_MAP_MIKROBUS( c8800retro_cfg, MIKROBUS_1 );
    err_t init_flag = c8800retro_init( &c8800retro, &c8800retro_cfg );
    if ( I2C_MASTER_ERROR == init_flag ) 
    {
        log_error( &logger, " Application Init Error. " );
        log_info( &logger, " Please, run program again... " );

        for ( ; ; );
    }

    c8800retro_default_cfg( &c8800retro );
    c8800retro_select_demo_example( &c8800retro );
}

void application_task ( void ) 
{
    switch ( demo_example )
    {
        case DEMO_KEYPAD4x4:
        {
            c8800retro_demo_keypad4x4 ( &c8800retro );
            break;
        }
        case DEMO_FULL_CHARSET:
        {
            c8800retro_demo_full_charset ( &c8800retro );
            break;
        }
        case DEMO_TEXT:
        {
            c8800retro_demo_text ( &c8800retro, C8800RETRO_SCROLL_HORIZONTAL_LEFT, 
                                                C8800RETRO_SCROLL_SPEED_MEDIUM, 
                                                c8800retro_demo_string );
            break;
        }
        case DEMO_IMAGE:
        {
            c8800retro_demo_image ( &c8800retro, c8800retro_demo_logo_mikroe );
            break;
        }
        default:
        {
            break;
        }
    }
}

void main ( void ) 
{
    application_init( );

    for ( ; ; ) 
    {
        application_task( );
    }
}

static err_t c8800retro_select_demo_example( c8800retro_t *ctx )
{
    err_t error_flag = c8800retro_clear_display( ctx );
    error_flag |= c8800retro_clear_interrupt( ctx );
    
    for ( ; ; )
    {
        uint16_t keypad = C8800RETRO_KEY_NONE;
        
        log_printf( &logger, "\r\n Press one of the following buttons to select the demo example: \r\n" );
        log_printf( &logger, " A1: KeyPad 4x4 \r\n" );
        log_printf( &logger, " A2: Full charset \r\n" );
        log_printf( &logger, " A3: Text \r\n" );
        log_printf( &logger, " A4: Image \r\n" );
        
        // Pressed button
        while( c8800retro_get_int_pin( ctx ) );
        error_flag |= c8800retro_get_keypad( ctx, &keypad );
        while( !c8800retro_get_int_pin( ctx ) );
        
        // Released button
        while( c8800retro_get_int_pin( ctx ) );
        error_flag |= c8800retro_clear_interrupt( ctx );
        while( !c8800retro_get_int_pin( ctx ) );
        
        switch ( keypad )
        {
            case C8800RETRO_KEY_A1:
            {
                demo_example = DEMO_KEYPAD4x4;
                return error_flag;
            }
            case C8800RETRO_KEY_A2:
            {
                demo_example = DEMO_FULL_CHARSET;
                return error_flag;
            }
            case C8800RETRO_KEY_A3:
            {
                demo_example = DEMO_TEXT;
                return error_flag;
            }
            case C8800RETRO_KEY_A4:
            {
                demo_example = DEMO_IMAGE;
                return error_flag;
            }
            default:
            {
                log_printf( &logger, " Wrong button! \r\n" );
                break;
            }
        }
    }
}

static err_t c8800retro_demo_keypad4x4( c8800retro_t *ctx )
{
    log_printf( &logger, "\r\n ---- KeyPad 4x4 demo example ---- \r\n" );
    log_printf( &logger, " Keypad layout: \r\n" );
    log_printf( &logger, " 1  2  3  A \r\n" );
    log_printf( &logger, " 4  5  6  B \r\n" );
    log_printf( &logger, " 7  8  9  C \r\n" );
    log_printf( &logger, " *  0  #  D \r\n" );
    log_printf( &logger, " Press the button D4 three times to switch the example \r\n " );
    uint8_t d4_cnt = 0;
    
    err_t error_flag = c8800retro_clear_display( ctx );
    error_flag |= c8800retro_clear_interrupt( ctx );
    
    for ( ; ; )
    {
        uint16_t keypad = C8800RETRO_KEY_NONE;
        
        // Pressed button
        while( c8800retro_get_int_pin( ctx ) );
        error_flag |= c8800retro_get_keypad( ctx, &keypad );
        while( !c8800retro_get_int_pin( ctx ) );
        
        // Released button
        while( c8800retro_get_int_pin( ctx ) );
        error_flag |= c8800retro_clear_interrupt( ctx );
        while( !c8800retro_get_int_pin( ctx ) );
        
        if ( keypad & C8800RETRO_KEY_D4 )
        {
            d4_cnt++;
        }
        else
        {
            d4_cnt = 0;
        }
        switch ( keypad )
        {
            case C8800RETRO_KEY_A1:
            {
                error_flag |= c8800retro_display_char( ctx, '1' );
                log_printf( &logger, "1" );
                break;
            }
            case C8800RETRO_KEY_A2:
            {
                error_flag |= c8800retro_display_char( ctx, '2' );
                log_printf( &logger, "2" );
                break;
            }
            case C8800RETRO_KEY_A3:
            {
                error_flag |= c8800retro_display_char( ctx, '3' );
                log_printf( &logger, "3" );
                break;
            }
            case C8800RETRO_KEY_A4:
            {
                error_flag |= c8800retro_display_char( ctx, 'A' );
                log_printf( &logger, "A" );
                break;
            }
            case C8800RETRO_KEY_B1:
            {
                error_flag |= c8800retro_display_char( ctx, '4' );
                log_printf( &logger, "4" );
                break;
            }
            case C8800RETRO_KEY_B2:
            {
                error_flag |= c8800retro_display_char( ctx, '5' );
                log_printf( &logger, "5" );
                break;
            }
            case C8800RETRO_KEY_B3:
            {
                error_flag |= c8800retro_display_char( ctx, '6' );
                log_printf( &logger, "6" );
                break;
            }
            case C8800RETRO_KEY_B4:
            {
                error_flag |= c8800retro_display_char( ctx, 'B' );
                log_printf( &logger, "B" );
                break;
            }
            case C8800RETRO_KEY_C1:
            {
                error_flag |= c8800retro_display_char( ctx, '7' );
                log_printf( &logger, "7" );
                break;
            }
            case C8800RETRO_KEY_C2:
            {
                error_flag |= c8800retro_display_char( ctx, '8' );
                log_printf( &logger, "8" );
                break;
            }
            case C8800RETRO_KEY_C3:
            {
                error_flag |= c8800retro_display_char( ctx, '9' );
                log_printf( &logger, "9" );
                break;
            }
            case C8800RETRO_KEY_C4:
            {
                error_flag |= c8800retro_display_char( ctx, 'C' );
                log_printf( &logger, "C" );
                break;
            }
            case C8800RETRO_KEY_D1:
            {
                error_flag |= c8800retro_display_char( ctx, '*' );
                log_printf( &logger, "*" );
                break;
            }
            case C8800RETRO_KEY_D2:
            {
                error_flag |= c8800retro_display_char( ctx, '0' );
                log_printf( &logger, "0" );
                break;
            }
            case C8800RETRO_KEY_D3:
            {
                error_flag |= c8800retro_display_char( ctx, '#' );
                log_printf( &logger, "#" );
                break;
            }
            case C8800RETRO_KEY_D4:
            {
                error_flag |= c8800retro_display_char( ctx, 'D' );
                log_printf( &logger, "D" );
                break;
            }
            default:
            {
                break;
            }
        }
        
        if ( d4_cnt == 3 )
        {
            error_flag |= c8800retro_select_demo_example( ctx );
            return error_flag;
        }
    }
    
    return error_flag;
}

static err_t c8800retro_demo_full_charset( c8800retro_t *ctx )
{
    log_printf( &logger, "\r\n ---- Full charset demo example ---- \r\n" );
    log_printf( &logger, " Press the button D4 three times to switch the example \r\n" );
    
    err_t error_flag = c8800retro_clear_display( ctx );
    error_flag |= c8800retro_clear_interrupt( ctx );
    
    for ( ; ; )
    {
        for ( uint8_t cnt = 0; cnt <= 255; cnt++ )
        {
            if ( cnt == 128 )
            {
                cnt = 160;
            }
            error_flag |= c8800retro_display_char( ctx, cnt );
            
            Delay_ms( 200 );
            if ( !c8800retro_get_int_pin( ctx ) )
            {
                uint16_t keypad = C8800RETRO_KEY_NONE;
                uint8_t d4_cnt = 0;
                while ( d4_cnt < 3 )
                {
                    // Pressed button
                    while( c8800retro_get_int_pin( ctx ) );
                    error_flag |= c8800retro_get_keypad( ctx, &keypad );
                    while( !c8800retro_get_int_pin( ctx ) );
                    
                    // Released button
                    while( c8800retro_get_int_pin( ctx ) );
                    error_flag |= c8800retro_clear_interrupt( ctx );
                    while( !c8800retro_get_int_pin( ctx ) );
                    
                    if ( ( keypad & C8800RETRO_KEY_D4 ) != C8800RETRO_KEY_D4 )
                    {
                        break;
                    }
                    d4_cnt++;
                }
                if ( d4_cnt == 3 )
                {
                    error_flag |= c8800retro_select_demo_example( ctx );
                    return error_flag;
                }
            }
            if ( C8800RETRO_ERROR == error_flag )
            {
                log_printf( &logger, "\r\n Error occured. \r\n" );
                return error_flag;
            }
        }
    }
}

static err_t c8800retro_demo_text( c8800retro_t *ctx, uint8_t scroll_mode, uint16_t scroll_speed_ms, uint8_t *text )
{
    log_printf( &logger, "\r\n ---- Text demo example ---- \r\n" );
    log_printf( &logger, " Once it finish scrolling, press the button D4 three times in the next" );
    log_printf( &logger, " 3 seconds to switch the example \r\n" );
    
    err_t error_flag = c8800retro_clear_display( ctx );
    error_flag |= c8800retro_clear_interrupt( ctx );
    
    for ( ; ; )
    {
        uint16_t timeout = 3000;
        
        log_printf( &logger, "\r\n Text scrolling has started. \r\n" );
        error_flag |= c8800retro_display_string( ctx, scroll_mode, scroll_speed_ms, text );
        
        error_flag |= c8800retro_clear_interrupt( ctx );
        
        log_printf( &logger, "\r\n Text scrolling has finished. Press the button D4 three times in the next" );
        log_printf( &logger, " 3 seconds to switch the example. Otherwise, scrolling will start over. \r\n" );
        
        while ( timeout-- > 0 )
        {
            if ( !c8800retro_get_int_pin( ctx ) )
            {
                uint16_t keypad = C8800RETRO_KEY_NONE;
                uint8_t d4_cnt = 0;
                while ( d4_cnt < 3 )
                {
                    // Pressed button
                    while( c8800retro_get_int_pin( ctx ) );
                    error_flag |= c8800retro_get_keypad( ctx, &keypad );
                    while( !c8800retro_get_int_pin( ctx ) );
                    
                    // Released button
                    while( c8800retro_get_int_pin( ctx ) );
                    error_flag |= c8800retro_clear_interrupt( ctx );
                    while( !c8800retro_get_int_pin( ctx ) );
                    
                    if ( ( keypad & C8800RETRO_KEY_D4 ) != C8800RETRO_KEY_D4 )
                    {
                        break;
                    }
                    d4_cnt++;
                }
                if ( d4_cnt == 3 )
                {
                    error_flag |= c8800retro_select_demo_example( ctx );
                    return error_flag;
                }
            }
            Delay_ms ( 1 );
        }
        
        if ( C8800RETRO_ERROR == error_flag )
        {
            log_printf( &logger, "\r\n Error occured. \r\n" );
            return error_flag;
        }
    }
}

static err_t c8800retro_demo_image( c8800retro_t *ctx, uint8_t *p_image )
{
    log_printf( &logger, "\r\n ---- Image demo example ---- \r\n" );
    log_printf( &logger, " Press the button D4 three times to switch the example \r\n" );
    
    err_t error_flag = c8800retro_clear_display( ctx );
    error_flag |= c8800retro_clear_interrupt( ctx );
    
    error_flag |= c8800retro_display_image( ctx, p_image );
            
    for ( ; ; )
    {
        if ( !c8800retro_get_int_pin( ctx ) )
        {
            uint16_t keypad = C8800RETRO_KEY_NONE;
            uint8_t d4_cnt = 0;
            while ( d4_cnt < 3 )
            {
                // Pressed button
                while( c8800retro_get_int_pin( ctx ) );
                error_flag |= c8800retro_get_keypad( ctx, &keypad );
                while( !c8800retro_get_int_pin( ctx ) );
                
                // Released button
                while( c8800retro_get_int_pin( ctx ) );
                error_flag |= c8800retro_clear_interrupt( ctx );
                while( !c8800retro_get_int_pin( ctx ) );
                
                if ( ( keypad & C8800RETRO_KEY_D4 ) != C8800RETRO_KEY_D4 )
                {
                    break;
                }
                d4_cnt++;
            }
            if ( d4_cnt == 3 )
            {
                error_flag |= c8800retro_select_demo_example( ctx );
                return error_flag;
            }
        }
        if ( C8800RETRO_ERROR == error_flag )
        {
            log_printf( &logger, "\r\n Error occured. \r\n" );
            return error_flag;
        }
    }
}

// ------------------------------------------------------------------------ END

Additional Support

Resources

Love this project?

'Buy This Kit' button takes you directly to the shopping cart where you can easily add or remove products.