summaryrefslogtreecommitdiff
path: root/bsp/renesas/ra2l1-cpk/src/hal_entry.c
blob: 1c616225455f0e48bed4e8ac3f73782ba8e50825 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/*
 * Copyright (c) 2006-2021, RT-Thread Development Team
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Change Logs:
 * Date           Author        Notes
 * 2021-10-10     Sherman       first version
 */
#include <rtthread.h>
#include "hal_data.h"
#include <rtdevice.h>

#define LED1_PIN    "P502" /* Onboard LED pins */
#define USER_INPUT  "P004"

void hal_entry(void)
{
    rt_kprintf("\nHello RT-Thread!\n");
    rt_uint32_t led1_pin = rt_pin_get(LED1_PIN);
    while (1)
    {
        rt_pin_write(led1_pin, PIN_HIGH);
        rt_thread_mdelay(500);
        rt_pin_write(led1_pin, PIN_LOW);
        rt_thread_mdelay(500);
    }
}

void irq_callback_test(void *args)
{
    rt_kprintf("\n IRQ03 triggered \n");
}

void icu_sample(void)
{
    /* init */
    rt_uint32_t pin = rt_pin_get(USER_INPUT);
    rt_kprintf("\n pin number : 0x%04X \n", pin);
    rt_err_t err = rt_pin_attach_irq(pin, PIN_IRQ_MODE_RISING, irq_callback_test, RT_NULL);
    if (RT_EOK != err)
    {
        rt_kprintf("\n attach irq failed. \n");
    }
    err = rt_pin_irq_enable(pin, PIN_IRQ_ENABLE);
    if (RT_EOK != err)
    {
        rt_kprintf("\n enable irq failed. \n");
    }
}
MSH_CMD_EXPORT(icu_sample, icu sample);