Software testing lpcanvca.h
[LPC2xxx_and_RobotSpejbl.git] / app / lpcanvcaTest / led.c
blobfb6c2285eb9992e6d97c74bfe1a6f3c1b6e616bf
1 #include "led.h"
3 struct {
4 volatile uint32_t *ioset, *ioclr, bit;
5 } led_ctl[] = {
6 {(uint32_t*)&IOSET0, (uint32_t*)&IOCLR0, 1<<22},
7 {(uint32_t*)&IOSET0, (uint32_t*)&IOCLR0, 1<<23},
8 {(uint32_t*)&IOSET0, (uint32_t*)&IOCLR0, 1<<24},
9 {(uint32_t*)&IOSET1, (uint32_t*)&IOCLR1, 1<<19}
12 void led_init() {
13 PINSEL1 &= ~0x0003f000;
14 PINSEL2 &= ~0x00000008;
15 IODIR0 |= 0x01c00000;
16 IODIR1 |= 0x00040000;
17 IOCLR0 = 0x01c00000;
18 IOCLR1 = 0x00040000;
21 void led_set(uint8_t led, uint8_t state) {
22 if (state)
23 *led_ctl[led].ioset = led_ctl[led].bit;
24 else
25 *led_ctl[led].ioclr = led_ctl[led].bit;
28 void led_toggle(uint8_t led) {
29 if ((*led_ctl[led].ioset) & led_ctl[led].bit)
30 *led_ctl[led].ioclr = led_ctl[led].bit;
31 else
32 *led_ctl[led].ioset = led_ctl[led].bit;
35 /* Tot vse. */