Skip to content

Boards Code Examples

  • How do I utilize board.h header from Board Support Package?
/* Project name:
 *   How do I utilize `board.h` header from Board Support Package?
 * Copyright:
 *   (c) MIKROE, 2024.
 * Description:
 *   - Example is meant for demonstrating Board Support Package
 *     functionality using mikroSDK 2.0.
 * Library dependencies?
 *   - Make sure `Driver.GPIO.Out` and `Board` libraries are enabled
 *      NECTO's Library Manager to ensure a successful build.
 * How to test this code example?
 *   - Navigate to NECTO's [Planet Debug](https://www.mikroe.com/planet-debug)
 *     feature, connect to a development board, flash the code,
 *     and freely test all the other preprocessor directives from
 *     `board.h` header file.
 */

// ------------------------------------------------------------------ INCLUDES
#include "board.h"
#include "drv_digital_out.h"
#include "delays.h"

int main(void)
{
    // Initialize the LED pin as a digital output
    digital_out_t led;

    // Utilize preprocessor directive from `board.h`
    digital_out_init( &led, MIKROBUS_1_PWM );

    // Main loop: toggle LED state
    while (1)
    {
        // Turn the LED on
        digital_out_high( &led );
        Delay_ms(500);  // Wait for 500 milliseconds

        // Turn the LED off
        digital_out_low( &led );
        Delay_ms(500);  // Wait for 500 milliseconds
    }

    return 0;
}