2024-01-27 17:43:49 +00:00
|
|
|
#include "MKL05Z4.h"
|
|
|
|
|
|
|
|
// *********** LED Defines ******************
|
|
|
|
|
|
|
|
#define POS_RED (8)
|
|
|
|
#define POS_GREEN (9)
|
|
|
|
#define POS_BLUE (10)
|
|
|
|
|
|
|
|
#define PORTB_LED_RED_MASK (1 << POS_RED)
|
|
|
|
#define PORTB_LED_GREEN_MASK (1 << POS_GREEN)
|
|
|
|
#define PORTB_LED_BLUE_MASK (1 << POS_BLUE)
|
|
|
|
|
|
|
|
#define PORTB_LEDS_MASK (PORTB_LED_RED_MASK | \
|
|
|
|
PORTB_LED_GREEN_MASK | \
|
|
|
|
PORTB_LED_BLUE_MASK)
|
|
|
|
|
|
|
|
/* Port Pin GPIO for LED */
|
|
|
|
#define PORT_PCR_MUX_SELECT_1_MASK \
|
|
|
|
(1 << PORT_PCR_MUX_SHIFT)
|
|
|
|
#define PORT_PCR_SET_GPIO \
|
|
|
|
(PORT_PCR_ISF_MASK | PORT_PCR_MUX_SELECT_1_MASK)
|
|
|
|
|
|
|
|
// *********************************************
|
|
|
|
|
|
|
|
void Init_LEDs (void) {
|
2024-01-27 21:31:46 +00:00
|
|
|
/* Enable clock for PORT B module */
|
|
|
|
SIM_SCGC5 |= SIM_SCGC5_PORTB_MASK;
|
|
|
|
|
|
|
|
/* Select PORT B Pin 8 for GPIO to red LED */
|
|
|
|
PORTB_PCR(POS_RED) = PORT_PCR_SET_GPIO;
|
|
|
|
/* Select PORT B Pin 9 for GPIO to green LED */
|
|
|
|
PORTB_PCR(POS_GREEN) = PORT_PCR_SET_GPIO;
|
|
|
|
/* Select PORT B Pin 10 for GPIO to blue LED */
|
|
|
|
PORTB_PCR(POS_BLUE) = PORT_PCR_SET_GPIO;
|
|
|
|
|
|
|
|
// FGPIOB_PDDR = PORTB_LEDS_MASK;
|
|
|
|
FGPIOB_PCOR = PORTB_LED_BLUE_MASK;
|
|
|
|
FGPIOB_PSOR = PORTB_LED_GREEN_MASK;
|
|
|
|
FGPIOB_PSOR = PORTB_LED_RED_MASK;
|
|
|
|
|
|
|
|
/* Turn off LEDs */
|
|
|
|
// FGPIOB_PSOR = PORTB_LEDS_MASK;
|
2024-01-27 17:43:49 +00:00
|
|
|
}
|
2024-01-27 17:05:34 +00:00
|
|
|
|
|
|
|
void main()
|
|
|
|
{
|
2024-01-27 21:31:46 +00:00
|
|
|
Init_LEDs();
|
|
|
|
for (;;);
|
2024-01-27 17:05:34 +00:00
|
|
|
}
|