LibDriver PCA9685
Loading...
Searching...
No Matches
driver_pca9685.h File Reference

driver pca9685 header file More...

#include <stdio.h>
#include <stdint.h>
#include <string.h>
Include dependency graph for driver_pca9685.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  pca9685_handle_s
 pca9685 handle structure definition More...
struct  pca9685_info_s
 pca9685 information structure definition More...

Macros

#define PCA9685_OSCILLATOR_INTERNAL_FREQUENCY   25000000
 pca9685 internal oscillator frequency
#define DRIVER_PCA9685_LINK_INIT(HANDLE, STRUCTURE)
 initialize pca9685_handle_t structure
#define DRIVER_PCA9685_LINK_IIC_INIT(HANDLE, FUC)
 link iic_init function
#define DRIVER_PCA9685_LINK_IIC_DEINIT(HANDLE, FUC)
 link iic_deinit function
#define DRIVER_PCA9685_LINK_IIC_READ(HANDLE, FUC)
 link iic_read function
#define DRIVER_PCA9685_LINK_IIC_WEITE(HANDLE, FUC)
 link iic_write function
#define DRIVER_PCA9685_LINK_OE_GPIO_INIT(HANDLE, FUC)
 link oe_gpio_init function
#define DRIVER_PCA9685_LINK_OE_GPIO_DEINIT(HANDLE, FUC)
 link oe_gpio_deinit function
#define DRIVER_PCA9685_LINK_OE_GPIO_WRITE(HANDLE, FUC)
 link oe_gpio_write function
#define DRIVER_PCA9685_LINK_DELAY_MS(HANDLE, FUC)
 link delay_ms function
#define DRIVER_PCA9685_LINK_DEBUG_PRINT(HANDLE, FUC)
 link debug_print function

Typedefs

typedef struct pca9685_handle_s pca9685_handle_t
 pca9685 handle structure definition
typedef struct pca9685_info_s pca9685_info_t
 pca9685 information structure definition

Enumerations

enum  pca9685_address_t {
  PCA9685_ADDRESS_A000000 = 0x00 , PCA9685_ADDRESS_A000001 = 0x01 , PCA9685_ADDRESS_A000010 = 0x02 , PCA9685_ADDRESS_A000011 = 0x03 ,
  PCA9685_ADDRESS_A000100 = 0x04 , PCA9685_ADDRESS_A000101 = 0x05 , PCA9685_ADDRESS_A000110 = 0x06 , PCA9685_ADDRESS_A000111 = 0x07 ,
  PCA9685_ADDRESS_A001000 = 0x08 , PCA9685_ADDRESS_A001001 = 0x09 , PCA9685_ADDRESS_A001010 = 0x0A , PCA9685_ADDRESS_A001011 = 0x0B ,
  PCA9685_ADDRESS_A001100 = 0x0C , PCA9685_ADDRESS_A001101 = 0x0D , PCA9685_ADDRESS_A001110 = 0x0E , PCA9685_ADDRESS_A001111 = 0x0F ,
  PCA9685_ADDRESS_A010000 = 0x10 , PCA9685_ADDRESS_A010001 = 0x11 , PCA9685_ADDRESS_A010010 = 0x12 , PCA9685_ADDRESS_A010011 = 0x13 ,
  PCA9685_ADDRESS_A010100 = 0x14 , PCA9685_ADDRESS_A010101 = 0x15 , PCA9685_ADDRESS_A010110 = 0x16 , PCA9685_ADDRESS_A010111 = 0x17 ,
  PCA9685_ADDRESS_A011000 = 0x18 , PCA9685_ADDRESS_A011001 = 0x19 , PCA9685_ADDRESS_A011010 = 0x1A , PCA9685_ADDRESS_A011011 = 0x1B ,
  PCA9685_ADDRESS_A011100 = 0x1C , PCA9685_ADDRESS_A011101 = 0x1D , PCA9685_ADDRESS_A011110 = 0x1E , PCA9685_ADDRESS_A011111 = 0x1F ,
  PCA9685_ADDRESS_A100000 = 0x20 , PCA9685_ADDRESS_A100001 = 0x21 , PCA9685_ADDRESS_A100010 = 0x22 , PCA9685_ADDRESS_A100011 = 0x23 ,
  PCA9685_ADDRESS_A100100 = 0x24 , PCA9685_ADDRESS_A100101 = 0x25 , PCA9685_ADDRESS_A100110 = 0x26 , PCA9685_ADDRESS_A100111 = 0x27 ,
  PCA9685_ADDRESS_A101000 = 0x28 , PCA9685_ADDRESS_A101001 = 0x29 , PCA9685_ADDRESS_A101010 = 0x2A , PCA9685_ADDRESS_A101011 = 0x2B ,
  PCA9685_ADDRESS_A101100 = 0x2C , PCA9685_ADDRESS_A101101 = 0x2D , PCA9685_ADDRESS_A101110 = 0x2E , PCA9685_ADDRESS_A101111 = 0x2F ,
  PCA9685_ADDRESS_A110000 = 0x30 , PCA9685_ADDRESS_A110001 = 0x31 , PCA9685_ADDRESS_A110010 = 0x32 , PCA9685_ADDRESS_A110011 = 0x33 ,
  PCA9685_ADDRESS_A110100 = 0x34 , PCA9685_ADDRESS_A110101 = 0x35 , PCA9685_ADDRESS_A110110 = 0x36 , PCA9685_ADDRESS_A110111 = 0x37 ,
  PCA9685_ADDRESS_A111000 = 0x38 , PCA9685_ADDRESS_A111001 = 0x39 , PCA9685_ADDRESS_A111010 = 0x3A , PCA9685_ADDRESS_A111011 = 0x3B ,
  PCA9685_ADDRESS_A111100 = 0x3C , PCA9685_ADDRESS_A111101 = 0x3D , PCA9685_ADDRESS_A111110 = 0x3E , PCA9685_ADDRESS_A111111 = 0x3F
}
 pca9685 address enumeration definition More...
enum  pca9685_bool_t { PCA9685_BOOL_FALSE = 0x00 , PCA9685_BOOL_TRUE = 0x01 }
 pca9685 bool enumeration definition More...
enum  pca9685_output_change_t { PCA9685_OUTPUT_CHANGE_STOP = 0x00 , PCA9685_OUTPUT_CHANGE_ACK = 0x01 }
 pca9685 output change enumeration definition More...
enum  pca9685_output_driver_t { PCA9685_OUTPUT_DRIVER_OPEN_DRAIN = 0x00 , PCA9685_OUTPUT_DRIVER_TOTEM_POLE = 0x01 }
 pca9685 output driver enumeration definition More...
enum  pca9685_output_disable_type_t { PCA9685_OUTPUT_DISABLE_TYPE_LEDN_LOW = 0x00 , PCA9685_OUTPUT_DISABLE_TYPE_OUTDRV_1_LEDN_LOW_OUTDRV_0_HIGH_IMPEDANCE = 0x01 , PCA9685_OUTPUT_DISABLE_TYPE_HIGH_IMPEDANCE = 0x02 }
 pca9685 output disable type enumeration definition More...
enum  pca9685_channel_t {
  PCA9685_CHANNEL_0 = 0x00 , PCA9685_CHANNEL_1 = 0x01 , PCA9685_CHANNEL_2 = 0x02 , PCA9685_CHANNEL_3 = 0x03 ,
  PCA9685_CHANNEL_4 = 0x04 , PCA9685_CHANNEL_5 = 0x05 , PCA9685_CHANNEL_6 = 0x06 , PCA9685_CHANNEL_7 = 0x07 ,
  PCA9685_CHANNEL_8 = 0x08 , PCA9685_CHANNEL_9 = 0x09 , PCA9685_CHANNEL_10 = 0x0A , PCA9685_CHANNEL_11 = 0x0B ,
  PCA9685_CHANNEL_12 = 0x0C , PCA9685_CHANNEL_13 = 0x0D , PCA9685_CHANNEL_14 = 0x0E , PCA9685_CHANNEL_15 = 0x0F
}
 pca9685 channel enumeration definition More...

Functions

uint8_t pca9685_info (pca9685_info_t *info)
 get chip's information
uint8_t pca9685_set_addr_pin (pca9685_handle_t *handle, pca9685_address_t addr_pin)
 set the address pin
uint8_t pca9685_get_addr_pin (pca9685_handle_t *handle, pca9685_address_t *addr_pin)
 get the address pin
uint8_t pca9685_set_addr (pca9685_handle_t *handle, uint8_t addr)
 set the address
uint8_t pca9685_get_addr (pca9685_handle_t *handle, uint8_t *addr)
 get the address
uint8_t pca9685_init (pca9685_handle_t *handle)
 initialize the chip
uint8_t pca9685_deinit (pca9685_handle_t *handle)
 close the chip
uint8_t pca9685_write_channel (pca9685_handle_t *handle, pca9685_channel_t channel, uint16_t on_count, uint16_t off_count)
 write led channels
uint8_t pca9685_read_channel (pca9685_handle_t *handle, pca9685_channel_t channel, uint16_t *on_count, uint16_t *off_count)
 read led channels
uint8_t pca9685_write_all_channel (pca9685_handle_t *handle, uint16_t on_count, uint16_t off_count)
 write all led channels
uint8_t pca9685_pwm_convert_to_register (pca9685_handle_t *handle, float delay_percent, float high_duty_cycle_percent, uint16_t *on_count, uint16_t *off_count)
 convert the pwm to the register raw data
uint8_t pca9685_pwm_convert_to_data (pca9685_handle_t *handle, uint16_t on_count, uint16_t off_count, float *delay_percent, float *high_duty_cycle_percent)
 convert the register raw data to the pwm
uint8_t pca9685_set_active (pca9685_handle_t *handle, pca9685_bool_t enable)
 set the chip active
uint8_t pca9685_set_prescaler (pca9685_handle_t *handle, uint8_t prescaler)
 set the clock pres cale
uint8_t pca9685_get_prescaler (pca9685_handle_t *handle, uint8_t *prescaler)
 get the clock pre scale
uint8_t pca9685_output_frequency_convert_to_register (pca9685_handle_t *handle, uint32_t oscillator, uint16_t output_freq, uint8_t *reg)
 convert the output frequency to the register raw data
uint8_t pca9685_output_frequency_convert_to_data (pca9685_handle_t *handle, uint32_t oscillator, uint8_t reg, uint16_t *output_freq)
 convert the register raw data to the output frequency
uint8_t pca9685_set_restart (pca9685_handle_t *handle, pca9685_bool_t enable)
 enable or disable restart
uint8_t pca9685_get_restart (pca9685_handle_t *handle, pca9685_bool_t *enable)
 get the restart status
uint8_t pca9685_set_external_clock_pin (pca9685_handle_t *handle, pca9685_bool_t enable)
 enable or disable the external clock pin
uint8_t pca9685_get_external_clock_pin (pca9685_handle_t *handle, pca9685_bool_t *enable)
 get the external clock pin status
uint8_t pca9685_set_register_auto_increment (pca9685_handle_t *handle, pca9685_bool_t enable)
 enable or disable the register auto increment
uint8_t pca9685_get_register_auto_increment (pca9685_handle_t *handle, pca9685_bool_t *enable)
 get the register auto increment status
uint8_t pca9685_set_sleep_mode (pca9685_handle_t *handle, pca9685_bool_t enable)
 enable or disable the sleep mode
uint8_t pca9685_get_sleep_mode (pca9685_handle_t *handle, pca9685_bool_t *enable)
 get the sleep mode status
uint8_t pca9685_set_respond_subaddress_1 (pca9685_handle_t *handle, pca9685_bool_t enable)
 enable or disable respond sub address 1
uint8_t pca9685_get_respond_subaddress_1 (pca9685_handle_t *handle, pca9685_bool_t *enable)
 get the respond sub address 1 status
uint8_t pca9685_set_respond_subaddress_2 (pca9685_handle_t *handle, pca9685_bool_t enable)
 enable or disable respond sub address 2
uint8_t pca9685_get_respond_subaddress_2 (pca9685_handle_t *handle, pca9685_bool_t *enable)
 get the respond sub address 2 status
uint8_t pca9685_set_respond_subaddress_3 (pca9685_handle_t *handle, pca9685_bool_t enable)
 enable or disable respond sub address 3
uint8_t pca9685_get_respond_subaddress_3 (pca9685_handle_t *handle, pca9685_bool_t *enable)
 get the respond sub address 3 status
uint8_t pca9685_set_respond_all_call (pca9685_handle_t *handle, pca9685_bool_t enable)
 enable or disable respond all call
uint8_t pca9685_get_respond_all_call (pca9685_handle_t *handle, pca9685_bool_t *enable)
 get the respond all call status
uint8_t pca9685_set_output_invert (pca9685_handle_t *handle, pca9685_bool_t enable)
 enable or disable output invert
uint8_t pca9685_get_output_invert (pca9685_handle_t *handle, pca9685_bool_t *enable)
 get the output invert status
uint8_t pca9685_set_output_change (pca9685_handle_t *handle, pca9685_output_change_t change)
 set the output change type
uint8_t pca9685_get_output_change (pca9685_handle_t *handle, pca9685_output_change_t *change)
 get the output change type
uint8_t pca9685_set_output_driver (pca9685_handle_t *handle, pca9685_output_driver_t driver)
 set the output driver type
uint8_t pca9685_get_output_driver (pca9685_handle_t *handle, pca9685_output_driver_t *driver)
 get the output driver type
uint8_t pca9685_set_output_disable_type (pca9685_handle_t *handle, pca9685_output_disable_type_t type)
 set the output disable type
uint8_t pca9685_get_output_disable_type (pca9685_handle_t *handle, pca9685_output_disable_type_t *type)
 get the output disable type
uint8_t pca9685_set_subaddress_1 (pca9685_handle_t *handle, uint8_t addr)
 set the sub address 1
uint8_t pca9685_get_subaddress_1 (pca9685_handle_t *handle, uint8_t *addr)
 get the sub address 1
uint8_t pca9685_set_subaddress_2 (pca9685_handle_t *handle, uint8_t addr)
 set the sub address 2
uint8_t pca9685_get_subaddress_2 (pca9685_handle_t *handle, uint8_t *addr)
 get the sub address 2
uint8_t pca9685_set_subaddress_3 (pca9685_handle_t *handle, uint8_t addr)
 set the sub address 3
uint8_t pca9685_get_subaddress_3 (pca9685_handle_t *handle, uint8_t *addr)
 get the sub address 3
uint8_t pca9685_set_all_call_address (pca9685_handle_t *handle, uint8_t addr)
 set the all call address
uint8_t pca9685_get_all_call_address (pca9685_handle_t *handle, uint8_t *addr)
 set the all call address
uint8_t pca9685_set_reg (pca9685_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len)
 set the chip register
uint8_t pca9685_get_reg (pca9685_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len)
 get the chip register

Detailed Description

driver pca9685 header file

Copyright (c) 2015 - present LibDriver All rights reserved

The MIT License (MIT)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Version
1.0.0
Author
Shifeng Li
Date
2022-02-20

history

Date Version Author Description
2022/02/20 1.0 Shifeng Li first upload

Definition in file driver_pca9685.h.