Working GPIO flash demo for FRDM-K22F

Document created by Jeff Verive on Oct 6, 2014
Version 1Show Document
  • View in full screen mode

The following (after the "- - - - - -" is debugged code for flashing Green, Red, and Blue LEDs on the FRDM-K22F module.

 

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

 

#include "fsl_device_registers.h"

#include "board.h"

 

 

static int i = 0;

 

 

int main(void)

{

  // 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;

  

     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;

}

Attachments

    Outcomes