| FRDM-KW40Z Demo Software Reference Manual Rev 0.0 NXP Semiconductors |

Data Structures | Enumerations | Functions
IR Controller Driver
IR Controller

## Overview

This module implements the APIs to initialize the IR controller driver and send IR commands.

## Data Structures
struct | ir_controller_parameters_t

## Enumerations
enum | ir_controller_status_t { irControllerStatusOk, irControllerStatusInitError, irControllerStatusModuleBusy }

## Functions
ir_controller_status_t | ir_controller_init (void)
ir_controller_status_t | ir_controller_send_command (ir_controller_parameters_t *controllerParamPtr, uint32_t *ptrCommandToSend, uint8_t numberOfBits, uint8_t commandRepeatTimes)
void | ir_controller_task (void)
ir_controller_status_t | ir_controller_get_current_status (void)

## Data Structure Documentation

struct ir_controller_parameters_t

Modulation parameters for each remote controller.

Data Fields
uint16_t | headerOnTime | On time for the header in us.
uint16_t | headerOffTime | Off time for the header in us.
uint16_t | logic0OnTime | On time for the logic 0 signal in us.
uint16_t | logic0OffTime | Off time for the logic 0 signal in us.
uint16_t | logic1OnTime | On time for the logic 1 signal in us.
uint16_t | logic1OffTime | Off time for the logic 1 signal in us.
uint16_t | stopTime | On time for the stop signaling in us.
uint16_t | gapTime | GAP time (the minimum time between one command and the next command) in us.
uint8_t | carrierOnTime | Signal carrier On time in the multiples of 0.125 us. Must be 0 if the carrier is not needed.
uint8_t | carrierOffTime | Signal carrier Off time in the multiples of 0.125 us. Must be 0 if the carrier is not needed

## Enumeration Type Documentation

enum ir_controller_status_t

IR Controller Status.

Enumerator
irControllerStatusOk | No error occurred.
irControllerStatusInitError | An error occurred during the initialization phase.
irControllerStatusModuleBusy | The IR Controller is busy and can't start a new command at this time.

## Function Documentation

ir_controller_status_t ir_controller_init | ( | void |  | ) |

Initializes the IR Controller required modules.

Note
  The pin mux must be initialized separately.

Parameters

  [in] | None |

Returns
  ir_controller_status_t IR Controller module status

ir_controller_status_t ir_controller_send_command | ( | ir_controller_parameters_t * | controllerParamPtr,
|  | uint32_t * | ptrCommandToSend,
|  | uint8_t | numberOfBits,
|  | uint8_t | commandRepeatTimes
| ) |  |

Sends a new IR controller command.

Parameters

  [in] | controllerParamPtr | Controller modulation parameters (See ir_controller_parameters_t)
  [in] | ptrCommandToSend | Pointer to the 32-bit array containing the command to send.

Warning
  Data bits must be LEFT-ALIGNED, Example: If the following 11 bits will be sent (0b0...10110001001 = 0x00000589) the array must be [0xB1, 0x20, 0x00, 0x00 = 0b1011000100100000...)

Parameters

  [in] | numberOfBits | Number of BITS to modulate.
  [in] | commandRepeatTimes | Number of times the command must be repeatedly transmitted.

Returns
  ir_controller_status_t IR Controller module status

void ir_controller_task | ( | void |  | ) |

This task must be executed periodically for a proper module functionality.

Parameters

  [in] | None |

Returns
  None

ir_controller_status_t ir_controller_get_current_status | ( | void |  | ) |

Gets the current status of the IR Controller module

Parameters

  [in] | None |

Returns
  ir_controller_status_t. irControllerStatusOk if free, irControllerStatusModuleBusy if busy