Flashing LEDs with K22F - debugged and tested

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Flashing LEDs with K22F - debugged and tested

479 Views
jverive
Contributor III

#include "fsl_device_registers.h"

#include "board.h"

static int i = 0;

// LEDs are common-anode, with cathodes connected to port pins.

// Therefore, logic high (1) turns them off, and logic low

// (0) turns them on.

short OFF = 1;

short ON = 0;

int main(void)

{

     hardware_init();

     GPIO_DRV_SetPinDir(kGpioLED1, kGpioDigitalOutput); //Green LED

     GPIO_DRV_SetPinDir(kGpioLED2, kGpioDigitalOutput); //Red LED

     GPIO_DRV_SetPinDir(kGpioLED3, kGpioDigitalOutput); //Blue LED

     GPIO_DRV_WritePinOutput(kGpioLED1, OFF); //Green LED initially off

     GPIO_DRV_WritePinOutput(kGpioLED2, OFF); //Red LED initially off

     GPIO_DRV_WritePinOutput(kGpioLED3, OFF); //Blue LED initially off

     while (1)

          {

          for (i = 0; i<0xFFFFFF; i++)

          {

          }

          GPIO_DRV_WritePinOutput(kGpioLED1, ON); //Green LED on

          for (i = 0; i<0xFFFFFF; i++)

          {

          }

          GPIO_DRV_WritePinOutput(kGpioLED1, OFF); //Green LED off

          for (i = 0; i<0xFFFFFF; i++)

          {

          }

          GPIO_DRV_WritePinOutput(kGpioLED2, ON); //Red LED on

          for (i = 0; i<0xFFFFFF; i++)

          {

          }

          GPIO_DRV_WritePinOutput(kGpioLED2, OFF); //Red LED off

          for (i = 0; i<0xFFFFFF; i++)

          {

          };

          GPIO_DRV_WritePinOutput(kGpioLED3, ON); //Blue LED on

          for (i = 0; i<0xFFFFFF; i++)

          {

          }

          GPIO_DRV_WritePinOutput(kGpioLED3, OFF); //Blue LED off

          }

     return 0;

}

Tags (3)
0 Kudos
1 Reply

329 Views
adriancano
NXP Employee
NXP Employee

Hi,

Thank you for the contribution. Here is the link of your Document in the community

Working GPIO flash demo for FRDM-K22F

This is just to inform some other members about your contributions because this is posted as a question.

Best regards,

Adrian

0 Kudos