Blink LED
Description
Blinks LED2 on GAP9 EVK
Exercized hardware
LED-2 (GPIO86)
How to run
cmake -B build
cmake --build build --target menuconfig
cmake --build build --target run
Code
#include "pmsis.h"
#define BLINK_DELAY_US (500 * 1000)
#define BLINK_ITERATIONS (11)
int main(void)
{
printf("Entering Blink LED2 example\n");
/* set pad to gpio mode */
/* This will open the gpio automatically */
pi_pad_function_set(PAD_GPIO_LED2, PI_PAD_FUNC1);
/* configure gpio output */
pi_gpio_flags_e flags = PI_GPIO_OUTPUT;
pi_gpio_pin_configure(PAD_GPIO_LED2, flags);
/* blink the LED */
for (int i = 0; i < BLINK_ITERATIONS; i++)
{
pi_gpio_pin_toggle(PAD_GPIO_LED2);
pi_time_wait_us(BLINK_DELAY_US);
}
printf("Exiting Blink LED2 example\n");
return 0;
}
# Copyright (c) 2022 GreenWaves Technologies SAS
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. Neither the name of GreenWaves Technologies SAS nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
cmake_minimum_required(VERSION 3.19)
###############################################################################
# Panel Control
###############################################################################
set(TARGET_NAME "blink_led")
set(TARGET_SRCS blink_led.c)
###############################################################################
# CMake pre initialization
###############################################################################
include($ENV{GAP_SDK_HOME}/utils/cmake/setup.cmake)
set(BLINK_PAD "PI_PAD_086")
add_definitions("-DPAD_GPIO_LED2=${BLINK_PAD}")
project(${TARGET_NAME} C ASM)
add_executable(${TARGET_NAME} ${TARGET_SRCS})
###############################################################################
# CMake post initialization
###############################################################################
setupos(${TARGET_NAME})