-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathled.h
30 lines (26 loc) · 865 Bytes
/
led.h
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
// Led Initialisation
#include "MKL25Z4.h"
void initLED(void)
{
// Enable Clock to PORTB and PORTD
SIM->SCGC5 |= ((SIM_SCGC5_PORTB_MASK) | (SIM_SCGC5_PORTD_MASK));
// Configure MUX settings to make all 3 pins GPIO
PORTB->PCR[RED_LED] &= ~PORT_PCR_MUX_MASK;
PORTB->PCR[RED_LED] |= PORT_PCR_MUX(1);
PORTB->PCR[GREEN_LED] &= ~PORT_PCR_MUX_MASK;
PORTB->PCR[GREEN_LED] |= PORT_PCR_MUX(1);
PORTD->PCR[BLUE_LED] &= ~PORT_PCR_MUX_MASK;
PORTD->PCR[BLUE_LED] |= PORT_PCR_MUX(1);
// Set Data Direction Registers for PortB and PortD
PTB->PDDR |= (MASK(RED_LED) | MASK(GREEN_LED));
PTD->PDDR |= MASK(BLUE_LED);
PTB->PSOR |= (MASK(RED_LED) | MASK(GREEN_LED));
PTD->PSOR |= MASK(BLUE_LED);
}
void flashLed(void)
{
PTB->PCOR |= MASK(RED_LED);
delay(100000);
PTB->PCOR |= MASK(GREEN_LED);
delay(100000);
}