TOP Contributors

  1. MIKROE (2762 codes)
  2. Alcides Ramos (374 codes)
  3. Shawon Shahryiar (307 codes)
  4. jm_palomino (118 codes)
  5. Bugz Bensce (90 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 (139248 times)
  2. FAT32 Library (71743 times)
  3. Network Ethernet Library (57115 times)
  4. USB Device Library (47428 times)
  5. Network WiFi Library (43082 times)
  6. FT800 Library (42403 times)
  7. GSM click (29835 times)
  8. mikroSDK (28073 times)
  9. PID Library (26885 times)
  10. microSD click (26198 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

microSD Click

Rating:

0

Author: MIKROE

Last Updated: 2024-10-31

Package Version: 2.1.0.5

mikroSDK Library: 2.0.0.0

Category: microSD

Downloaded: 199 times

Not followed.

License: MIT license  

Need more additional memory? We've got just the thing for you - microSD Click. It features a microSD card slot for microSD cards used as a mass storage media for portable devices. microSD Click is designed to run on 3.3V power supply. Industry standard SPI interface ensures simple communication at high data rates. Use it for reading or storing data like music, text files, videos and more.

No Abuse Reported

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

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

Do you want to report abuse regarding "microSD Click".

  • mikroSDK Library 1.0.0.0
  • Comments (0)

mikroSDK Library Blog


microSD Click

Need more additional memory? We've got just the thing for you - microSD Click. It features a microSD card slot for microSD cards used as a mass storage media for portable devices. microSD Click is designed to run on 3.3V power supply. Industry standard SPI interface ensures simple communication at high data rates. Use it for reading or storing data like music, text files, videos and more.

microsd_click.png

Click Product page


Click library

  • Author : Stefan Filipovic
  • Date : Aug 2023.
  • Type : SPI type

Software Support

We provide a library for the microSD 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 microSD Click driver.

Standard key functions :

  • microsd_cfg_setup Config Object Initialization function.

    void microsd_cfg_setup ( microsd_cfg_t *cfg );
  • microsd_init Initialization function.

    err_t microsd_init ( microsd_t *ctx, microsd_cfg_t *cfg );

Example key functions :

  • microsd_check_card_detection This function checks and waits for a microSD card to be inserted to the Click board.

    void microsd_check_card_detection ( microsd_t *ctx );
  • microsd_create_directory This function creates a new directory at the selected absolute path. The path should contain a name of the directory to be created.

    void microsd_create_directory ( uint8_t *dir_path );
  • microsd_display_directory This function reads and displays the content of the directory at the selected path.

    void microsd_display_directory ( uint8_t *dir_path );

Example Description

This example demonstrates a basic file system functionality and operations with files and directories using a microSD Click board.

The demo application is composed of two sections :

Application Init

Initializes the driver and logger and performs a several operations with file system that demonstrates the basic usage of microSD Click board.


void application_init ( void )
{
    log_cfg_t log_cfg;  /**< Logger config object. */
    microsd_cfg_t microsd_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.
    microsd_cfg_setup( &microsd_cfg );
    MICROSD_MAP_MIKROBUS( microsd_cfg, MIKROBUS_1 );
    if ( MICROSD_ERROR == microsd_init( &microsd, &microsd_cfg ) )
    {
        log_error( &logger, " Communication init." );
        for ( ; ; );
    }

    microsd_check_card_detection ( &microsd );
    Delay_ms ( 1000 );

    // Mount the initialized logical drive to the initialized physical drive and overall file system
    microsd_mount_drive ( &microsd, PATH_ROOT );

#if FORMAT_CARD
    // Format the logical drive previously mounted to file system with identifying ROOT drive number
    microsd_format_drive ( PATH_ROOT );
#endif
    microsd_display_directory ( PATH_ROOT );
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );

    // Create DIR1 directory
    microsd_create_directory ( PATH_DIR1 );
    Delay_ms ( 500 );

    // Create DIR2 directory
    microsd_create_directory ( PATH_DIR2 );
    Delay_ms ( 500 );

    // Create DIR4 directory
    microsd_create_directory ( PATH_DIR4 );
    Delay_ms ( 500 );

    microsd_display_directory ( PATH_ROOT );
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );

    // Remove DIR4 directory
    microsd_remove_path ( PATH_DIR4 );
    Delay_ms ( 500 );

    microsd_display_directory ( PATH_ROOT );
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );

    microsd_display_directory ( PATH_DIR1 );
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );
    // Rename DIR2 to DIR3
    microsd_rename_path ( PATH_DIR2, PATH_DIR3 );
    Delay_ms ( 500 );

    microsd_display_directory ( PATH_DIR1 );
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );

    microsd_display_directory ( PATH_ROOT );
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );
    // Create the FILE1
    microsd_create_file ( PATH_FILE1 );
    Delay_ms ( 500 );
    microsd_display_directory ( PATH_ROOT );
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );

    uint8_t rw_buffer[ BUFFER_SIZE ] = { 0 };
    // Populate write buffer with bytes ranging from 0 to 255
    for ( uint16_t cnt = 0; cnt < BUFFER_SIZE; cnt++ ) 
    {
        rw_buffer[ cnt ] = cnt & 0xFF;
    }
    microsd_write_to_file ( PATH_FILE1, rw_buffer, BUFFER_SIZE );
    Delay_ms ( 500 );
    microsd_display_directory ( PATH_ROOT );
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );

    microsd_display_directory ( PATH_DIR3 );
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );
    // Create the FILE2
    microsd_create_file ( PATH_FILE2 );
    Delay_ms ( 500 );
    microsd_display_directory ( PATH_DIR3 );
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );

    // Copy data from FILE1 to FILE2
    microsd_copy_file ( PATH_FILE1, PATH_FILE2 );
    Delay_ms ( 500 );
    microsd_display_directory ( PATH_DIR3 );
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );

    // Create DIR5 directory
    microsd_create_directory ( PATH_DIR5 );
    Delay_ms ( 500 );
    microsd_display_directory ( PATH_DIR1 );
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );

    log_info( &logger, " Application Task " );
}

Application Task

Reads and displays on the USB UART the contents of all directories created during application init.

void application_task ( void )
{
    microsd_display_directory ( PATH_ROOT );
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );
    microsd_display_directory ( PATH_DIR1 );
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );
    microsd_display_directory ( PATH_DIR3 );
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );
    microsd_display_directory ( PATH_DIR5 );
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );
    log_printf ( &logger, "\r\n\n" );
}

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

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

RTC 19 Click

0

RTC 19 Click is a compact add-on board that measures the passage of real-time. This board features the MAX31334, an I2C-configurable real-time clock with an integrated power switch from Analog Devices. The MAX31334 provides information like seconds, minutes, hours, days, months, years, and dates based on a 32.768kHz quartz crystal through an I2C serial interface to transmit time and calendar data to the MCU. It also has an alarm function that outputs an interrupt signal to the MCU when the day of the week, hour, or minute matches with the pre-set time, as well as a programmable square-wave output, event detection input with timestamping, and backup supply.

[Learn More]

Flash Click

0

Flash Click is 8,388,608 bits (8 Mbit) on a Click board, organized into 1,048,576 bytes (1 MB). In other words, this Click board is a Flash memory medium with the capacity of 1 MB. The used Flash module has very good endurance and it can withstand up to 100,000 write cycles, with the data retention period of about 20 years.

[Learn More]

Multi Stepper TB67S269 Click

0

Multi Stepper Click is a compact add-on board that contains a bipolar stepper motor driver. This board features the TB67S269FTG, CLOCK-in controlled bipolar stepping motor driver from Toshiba Semiconductor. It supports a PWM constant-current control drive and allows from full-step up to 1/32 steps resolution for less motor noise and smoother control. It has a wide operating voltage range of 10V to 47V with an output current capacity of 1.4A in addition to several built-in error detection circuits.

[Learn More]