no-OS
Functions
adp5589.c File Reference

Implementation of ADP5589 Driver. More...

#include <stdlib.h>
#include "adp5589.h"
#include "no_os_alloc.h"
Include dependency graph for adp5589.c:

Functions

void adp5589_set_register_value (struct adp5589_dev *dev, uint8_t register_address, uint8_t register_value)
 Writes data into a register. More...
 
uint8_t adp5589_get_register_value (struct adp5589_dev *dev, uint8_t register_address)
 Reads the value of a register. More...
 
int8_t adp5589_init (struct adp5589_dev **device, struct adp5589_init_param init_param)
 Initializes the communication peripheral and checks if the ADP5589 part is present. More...
 
int32_t adp5589_remove (struct adp5589_dev *dev)
 Free the resources allocated by adp5589_init(). More...
 
void adp5589_init_pwm (struct adp5589_dev *dev)
 Initializes the PWM generator in continuous mode. More...
 
void adp5589_init_key (struct adp5589_dev *dev, uint8_t pmod_port)
 Initializes keyboard decoder. More...
 
void adp5589_set_pwm (struct adp5589_dev *dev, uint16_t pwm_off_time, uint16_t pwm_on_time)
 Sets the PWM On and Off times. More...
 
void adp5589_gpio_direction (struct adp5589_dev *dev, uint8_t reg, uint8_t val)
 Sets the direction of the pins. More...
 
uint8_t adp5589_get_pin_state (struct adp5589_dev *dev, uint8_t reg)
 Reads the state of the pins. More...
 
void adp5589_set_pin_state (struct adp5589_dev *dev, uint8_t reg, uint8_t state)
 Sets the state of the pins. More...
 
uint8_t adp5589_key_decode (uint8_t reg, uint8_t event_type, uint8_t pmod_port)
 Decodes the key on the Pmod-KYPD. More...
 
void adp5589_key_lock (struct adp5589_dev *dev, uint8_t first_event, uint8_t second_event, uint8_t pmod_port)
 Locks the ADP5589 and requests Password for unlock. More...
 

Detailed Description

Implementation of ADP5589 Driver.

Author
Mihai Bancisor (Mihai.nosp@m..Ban.nosp@m.cisor.nosp@m.@ana.nosp@m.log.c.nosp@m.om)

Copyright 2012(c) Analog Devices, Inc.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  3. Neither the name of Analog Devices, Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES, INC. “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANALOG DEVICES, INC. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Function Documentation

◆ adp5589_get_pin_state()

uint8_t adp5589_get_pin_state ( struct adp5589_dev dev,
uint8_t  reg 
)

Reads the state of the pins.

Parameters
dev- The device structure.
reg- The address of the status register to be read.
Returns
val - The value of the register.

◆ adp5589_get_register_value()

uint8_t adp5589_get_register_value ( struct adp5589_dev dev,
uint8_t  register_address 
)

Reads the value of a register.

Parameters
dev- The device structure.
register_address- Address of the register.
Returns
register_value - Value of the register.
Here is the caller graph for this function:

◆ adp5589_gpio_direction()

void adp5589_gpio_direction ( struct adp5589_dev dev,
uint8_t  reg,
uint8_t  val 
)

Sets the direction of the pins.

Parameters
dev- The device structure.
dev- The device structure.
reg- The address of the direction register to be written.
val- The data to be written to the direction register.
Returns
None.

◆ adp5589_init()

int8_t adp5589_init ( struct adp5589_dev **  device,
struct adp5589_init_param  init_param 
)

Initializes the communication peripheral and checks if the ADP5589 part is present.

Parameters
device- The device structure.
init_param- The structure that contains the device initial parameters.
Returns
status - Result of the initialization procedure. Example: -1 - I2C peripheral was not initialized or ADP5589 part is not present. 0 - I2C peripheral is initialized and ADP5589 part is present.

◆ adp5589_init_key()

void adp5589_init_key ( struct adp5589_dev dev,
uint8_t  pmod_port 
)

Initializes keyboard decoder.

Parameters
dev- The device structure.
pmod_port- J1 or J2 connector of PmodIOXP Example: PMOD_IOXP_J1 - J1 connector. PMOD_IOXP_J2 - J2 connector.
Returns
None.

◆ adp5589_init_pwm()

void adp5589_init_pwm ( struct adp5589_dev dev)

Initializes the PWM generator in continuous mode.

Parameters
dev- The device structure.
Returns
None.

◆ adp5589_key_decode()

uint8_t adp5589_key_decode ( uint8_t  reg,
uint8_t  event_type,
uint8_t  pmod_port 
)

Decodes the key on the Pmod-KYPD.

Parameters
reg- The value of the FIFO register
pmod_port- J1 or J2 connector of PmodIOXP Example: PMOD_IOXP_J1 - J1 connector. PMOD_IOXP_J2 - J2 connector.
event_type- Pressed or released. Example: ADP5589_EVENT_KEY_RELEASED ADP5589_EVENT_KEY_PRESSED
Returns
key - Actual Key on the Pmod-KYPD.

◆ adp5589_key_lock()

void adp5589_key_lock ( struct adp5589_dev dev,
uint8_t  first_event,
uint8_t  second_event,
uint8_t  pmod_port 
)

Locks the ADP5589 and requests Password for unlock.

Parameters
dev- The device structure.
first_event- First event occured.
second_event- Second event occured.
pmod_port- J1 or J2 connector of PmodIOXP Example: PMOD_IOXP_J1 - J1 connector. PMOD_IOXP_J2 - J2 connector.
Returns
key - Actual Key on the Pmod-KYPD.

◆ adp5589_remove()

int32_t adp5589_remove ( struct adp5589_dev dev)

Free the resources allocated by adp5589_init().

Parameters
dev- The device structure.
Returns
0 in case of success, negative error code otherwise.

◆ adp5589_set_pin_state()

void adp5589_set_pin_state ( struct adp5589_dev dev,
uint8_t  reg,
uint8_t  state 
)

Sets the state of the pins.

Parameters
dev- The device structure.
reg- The address of the status register to be read.
state- The value to be written to the pins.
Returns
none

◆ adp5589_set_pwm()

void adp5589_set_pwm ( struct adp5589_dev dev,
uint16_t  pwm_off_time,
uint16_t  pwm_on_time 
)

Sets the PWM On and Off times.

Parameters
dev- The device structure.
pwm_off_time- The amount of time in uS for which the PWM pulse is LOW.
pwm_on_time- The amount of time in uS for which the PWM pulse is HIGH.
Returns
None.

◆ adp5589_set_register_value()

void adp5589_set_register_value ( struct adp5589_dev dev,
uint8_t  register_address,
uint8_t  register_value 
)

Writes data into a register.

Parameters
dev- The device structure.
register_address- Address of the register.
register_value- Data value to write.
Returns
None.
Here is the caller graph for this function: