blob: ece8a62a1c8b4eac94d752772bd59005efd3625c (
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
52
53
54
55
56
|
/*
* Copyright (c) 2019, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2019-05-05 jg1uaa the first version
*/
#include <rtthread.h>
#include <rthw.h>
/* for Z111xP board (LED is connected to PIO3_5, low=ON) */
#define IOCON_PIO3_5 HWREG32(0x40044048)
#define GPIO3DIR HWREG32(0x50038000)
#define GPIO3DATA_5 HWREG32(0x50030080)
static void led_off(void)
{
GPIO3DATA_5 = 0x20;
}
static void led_on(void)
{
GPIO3DATA_5 = 0x00;
}
static void led_setup(void)
{
IOCON_PIO3_5 = 0xd0; // (default)
GPIO3DIR = 0x20; // select output
led_off();
}
static void led_demo(void)
{
led_setup();
while (1) {
led_on();
rt_thread_delay(50); // 500msec, tick@100Hz
led_off();
rt_thread_delay(50);
}
}
int main(int argc, char **argv)
{
rt_kprintf("Hello, world!\n");
led_demo();
/* NOTREACHED */
return 0;
}
|