Contiki 3.x
leds-arch.c
1 #include "K60.h"
2 
3 #include "contiki-conf.h"
4 #include "dev/leds.h"
5 /*---------------------------------------------------------------------------*/
6 void
8 {
9  SIM->SCGC5 |= SIM_SCGC5_PORTC_MASK; /* Enable PORTC clock gate */
10  PORTC->PCR[13] |= 0x00100; /* Setup PTC13 as GPIO */
11  PORTC->PCR[14] |= 0x00100; /* Setup PTC14 as GPIO */
12  PORTC->PCR[15] |= 0x00100; /* Setup PTC15 as GPIO */
13  PTC->PDDR |= 0x0E000; /* Setup PTA14-PTA17 as outputs */
14 }
15 /*---------------------------------------------------------------------------*/
16 unsigned char
17 leds_arch_get(void)
18 {
19  return ((PTC->PDIR & LEDS_CONF_RED) ? LEDS_RED : 0)
20  | ((PTC->PDIR & LEDS_CONF_GREEN) ? LEDS_GREEN : 0)
21  | ((PTC->PDIR & LEDS_CONF_YELLOW) ? LEDS_YELLOW : 0);
22 }
23 /*---------------------------------------------------------------------------*/
24 void
25 leds_arch_set(unsigned char leds)
26 {
27  PTC->PDOR = (PTC->PDOR & ~(LEDS_CONF_RED | LEDS_CONF_GREEN | LEDS_CONF_YELLOW))
28  | ((leds & LEDS_RED) ? LEDS_CONF_RED : 0)
29  | ((leds & LEDS_GREEN) ? LEDS_CONF_GREEN : 0)
30  | ((leds & LEDS_YELLOW) ? LEDS_CONF_YELLOW : 0);
31 }
32 /*---------------------------------------------------------------------------*/
#define LEDS_RED
LED1 (Red) -> PC0.
Definition: board.h:89
void leds_arch_init(void)
Leds implementation.
Definition: leds-arch.c:48
#define SIM
Peripheral SIM base pointer.
Definition: MK60D10.h:7650
#define PTC
Peripheral PTC base pointer.
Definition: MK60D10.h:4665
K60 hardware register header wrapper.
#define LEDS_YELLOW
LED2 (Yellow) -> PC1.
Definition: board.h:80
#define LEDS_GREEN
LED3 (Green) -> PC2.
Definition: board.h:81
#define PORTC
Peripheral PORTC base pointer.
Definition: MK60D10.h:6423