Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Firmware
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ACS
Public
Teaching materials
LEGOS
Firmware
Merge requests
!8
Reworked pca9956 driver
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Reworked pca9956 driver
pca9956
into
master
Overview
0
Commits
1
Pipelines
1
Changes
2
Merged
Jonathan Klimt
requested to merge
pca9956
into
master
2 years ago
Overview
0
Commits
1
Pipelines
1
Changes
2
Expand
0
0
Merge request reports
Compare
master
master (base)
and
latest version
latest version
c9743cc2
1 commit,
2 years ago
2 files
+
146
−
133
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
2
Search (e.g. *.vue) (Ctrl+P)
components/pca9956/include/pca9956.h
+
58
−
28
Options
@@ -5,43 +5,73 @@
#ifndef _PCA9956_H_
#define _PCA9956_H_
#include
"driver/gpio.h"
#include
"driver/i2c.h"
#include
"esp_err.h"
// Datasheet https://www.nxp.com/docs/en/data-sheet/PCA9956B.pdf
// I2C Addresses
//#define PCA9956_ADDRESS_02 (0x40) // 1000000 (A1+A0=GND)
//#define PCA9956_ADDRESS_04 (0x41) // 1000001 (A1=GND, A0=VDD)
//#define PCA9956_ADDRESS_06 (0x42) // 1000010 (A1=GND, A0=SDA)
//#define PCA9956_ADDRESS_08 (0x43) // 1000011 (A1=GND, A0=SCL)
//#define PCA9956_ADDRESS_0A (0x44) // 1000100 (A1=VDD, A0=GND)
//#define PCA9956_ADDRESS_0C (0x45) // 1000101 (A1+A0=VDD)
//#define PCA9956_ADDRESS_0E (0x46) // 1000110 (A1=VDD, A0=SDA)
//#define PCA9956_ADDRESS_10 (0x47) // 1000111 (A1=VDD, A0=SCL)
//#define PCA9956_ADDRESS_12 (0x48) // 1001000 (A1=SDA, A0=GND)
//#define PCA9956_ADDRESS_49 (0x49) // 1001001 (A1=SDA, A0=VDD)
//#define PCA9956_ADDRESS_4A (0x4A) // 1001010 (A1+A0=SDA)
//#define PCA9956_ADDRESS_4B (0x4B) // 1001011 (A1=SDA, A0=SCL)
//#define PCA9956_ADDRESS_4C (0x4C) // 1001100 (A1=SCL, A0=GND)
//#define PCA9956_ADDRESS_4D (0x4D) // 1001101 (A1=SCL, A0=VDD)
//#define PCA9956_ADDRESS_4E (0x4E) // 1001110 (A1=SCL, A0=SDA)
//#define PCA9956_ADDRESS_4F (0x4F) // 1001111 (A1+A0=SCL)
//.... Bis FAh (Siehe S.10 Datasheet) , das schreib ich jetzt mal nicht aus
#define I2C_MASTER_TX_BUF_DISABLE 0 // I2C master do not need buffer
#define I2C_MASTER_RX_BUF_DISABLE 0 // I2C master do not need buffer
#define I2C_MASTER_FREQ_HZ 400000 // I2C master clock frequency
#ifdef __cplusplus
extern
"C"
{
#endif
void
pca_9956_single_switch
(
uint8_t
ch
,
uint8_t
duty
);
void
pca_9956_single_fade
(
uint8_t
ch
,
uint8_t
duty
,
int
fade_time_ms
);
// Not implemented yet
void
pca_9956_single_current
(
uint8_t
ch
,
float
r_ext
,
float
i_max_mA
);
/**
* @brief PCA9956 device handle. Should be created with pca9956_init
*
* @param[in] pca device handle
* @param[in] ch LED Channel
* @param[in] duty LED Duty Cycle
*/
typedef
struct
pca9956_t
{
uint8_t
address
;
i2c_port_t
i2c_num
;
float
r_ext
;
float
i_max_mA
;
gpio_num_t
oe_pin
;
}
pca9956_t
;
/**
* @brief Set PCA9956 Single LED PWM Value
*
* @param[in] pca device handle
* @param[in] ch LED Channel
* @param[in] duty LED Duty Cycle
*/
void
pca9956_single_switch
(
pca9956_t
*
pca
,
uint8_t
ch
,
uint8_t
duty
);
/**
* @brief Configure the maximum current for a single channel.
*
* @param[in] pca device handle
* @param[in] ch the channel to configure
* @param[in] i_max_mA the maximum current in mA
*/
void
pca9956_set_max_current
(
pca9956_t
*
pca
,
uint8_t
ch
,
float
i_max_mA
);
/**
* @brief Checks the PCA9956's error status and prints the error registers in
* case of an error
*
* @param[in] pca device handle
*
* @return
* - ESP_OK Success
* - ESP_FAIL Device reports error
*/
esp_err_t
pca9956_error_check
(
pca9956_t
*
pca
);
esp_err_t
pca9956_init
(
i2c_port_t
v_i2c_num
,
uint8_t
addr
,
float
r_ext
);
/**
* @brief Init PCA9956 power monitor
*
* @param[in] v_i2c_num I2C port
* @param[in] addr I2C device address
* @param[in] r_ext the external current limiting resistor
* @param[in] oe_pin the gpio pin connected to the PCA9956 output-enable.
*
* @return handle struct for the configured PCA9956
*/
pca9956_t
pca9956_init
(
i2c_port_t
v_i2c_num
,
uint8_t
addr
,
float
r_ext
,
gpio_num_t
oe_pin
);
#ifdef __cplusplus
}
Loading