summaryrefslogtreecommitdiffstats
path: root/app/led.c
blob: 2dc285b753b8ee765dea1d9d0611882d0639788a (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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#include "project.h"

#define LED1 (GPIO8)
#define LED1_PORT GPIOE
#define LED2 (GPIO9)
#define LED2_PORT GPIOE
#define LED3 (GPIO10)
#define LED3_PORT GPIOE
#define LED4 (GPIO11)
#define LED4_PORT GPIOE
#define LED5 (GPIO10)
#define LED5_PORT GPIOB
#define LED6 (GPIO11)
#define LED6_PORT GPIOB
#define LED7 (GPIO12)
#define LED7_PORT GPIOB
#define LED8 (GPIO13)
#define LED8_PORT GPIOB
#define LED9 (GPIO0)
#define LED9_PORT GPIOD
#define LED10 (GPIO1)
#define LED10_PORT GPIOD

static unsigned led_ms;

void
led_init (void)
{
  MAP_OUTPUT_PP (LED1);
  MAP_OUTPUT_PP (LED2);
  MAP_OUTPUT_PP (LED3);
  MAP_OUTPUT_PP (LED4);
  MAP_OUTPUT_PP (LED5);
  MAP_OUTPUT_PP (LED6);
  MAP_OUTPUT_PP (LED7);
  MAP_OUTPUT_PP (LED8);
  MAP_OUTPUT_PP (LED9);
  MAP_OUTPUT_PP (LED10);

  SET (LED1);
  SET (LED2);
  SET (LED3);
  SET (LED4);
  SET (LED5);
  SET (LED6);
  SET (LED7);
  SET (LED8);
  SET (LED9);
  SET (LED10);

}

void led1_set (int v)
{
  if (!v)  SET (LED1);
  else CLEAR (LED1);
}

void led2_set (int v)
{
  if (!v)  SET (LED2);
  else CLEAR (LED2);
}

void led3_set (int v)
{
  if (!v)  SET (LED3);
  else CLEAR (LED3);
}

void
led_clear (void)
{
  SET (LED4);
}

void
led_set()
{
  CLEAR (LED4);
}

void led_blink (unsigned ms)
{
  led_set();
  led_ms = ms;
}


void
led_tick (void)
{
  if (!led_ms) return;

  led_ms--;

  if (!led_ms) led_clear();

}

void led_slow_tick (void)
{
  static int c;


  c++;
  c &= 7;
}