Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
esp32_c6_firmware
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
elsys_projct_gr1
esp32_c6_firmware
Commits
c329a641
Commit
c329a641
authored
1 year ago
by
Eirik-MS
Browse files
Options
Downloads
Patches
Plain Diff
added init for i2c DAC
parent
099eeb42
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
main/drivers/i2c_dac_MCP47FEB.c
+33
-0
33 additions, 0 deletions
main/drivers/i2c_dac_MCP47FEB.c
main/drivers/i2c_dac_MCP47FEB.h
+13
-0
13 additions, 0 deletions
main/drivers/i2c_dac_MCP47FEB.h
main/main.c
+4
-0
4 additions, 0 deletions
main/main.c
with
50 additions
and
0 deletions
main/drivers/i2c_dac_MCP47FEB.c
0 → 100644
+
33
−
0
View file @
c329a641
#include
"i2c_dac_MCP47FEB.h"
#include
"i2c_master.h"
#include
"esp_err.h"
i2c_master_bus_config_t
mpc_dac_init_conf
=
{
.
i2c_port
=
I2C_NUM_0
,
.
sda_io_num
=
MPC_SDA_PIN
,
.
scl_io_num
=
MPC_SCL_PIN
,
.
clk_source
=
I2C_CLK_SRC_DEFAULT
,
.
glitch_ignore_cnt
=
7
,
.
intr_priority
=
1
,
.
flags
=
0
};
i2c_device_config_t
mpc_dac_slave_conf
=
{
.
dev_addr_length
=
I2C_ADDR_BIT_LEN_7
,
.
device_address
=
MPC_ADDR_A0
,
.
scl_speed_hz
=
MPC_SPEED
,
};
i2c_master_bus_handle_t
i2c_bus_handler
;
i2c_master_dev_handle_t
mpc_dac_dev
;
void
mpc_dac_init
(){
//Allocate a bus and a device for the I2C DAC
ESP_ERROR_CHECK
(
i2c_new_master_bus
(
&
mpc_dac_init_conf
,
&
i2c_bus_handler
));
ESP_ERROR_CHECK
(
i2c_master_bus_add_device
(
i2c_bus_handler
,
&
mpc_dac_slave_conf
,
&
mpc_dac_dev
));
}
This diff is collapsed.
Click to expand it.
main/drivers/i2c_dac_MCP47FEB.h
0 → 100644
+
13
−
0
View file @
c329a641
#define MCP_I2C_ADDRESS 0x60
#define MPC_SPEED 100000
#define MPC_SDA_PIN 21
#define MPC_SCL_PIN 22
#define MPC_ADDR_A0 0x60
#define MPC_ADDR_A1 0x61
#define MPC_ADDR_A2 0x62
#define MPC_ADDR_A3 0x63
void
mpc_dac_init
();
\ No newline at end of file
This diff is collapsed.
Click to expand it.
main/main.c
+
4
−
0
View file @
c329a641
...
...
@@ -9,6 +9,7 @@
#include
"alarm_buttons.h"
#include
"zigbee_configuration.h"
#include
"sleep_configuration.h"
#include
"i2c_dac_MCP47FEB.h"
// TODO:
// Find a nice way to give a device a unique ID after flashing
...
...
@@ -27,6 +28,9 @@ void app_init(void)
/* Initialize the Zigbee stack */
initialize_zigbee
();
/* Initialize I2C for DAC*/
mpc_dac_init
();
}
void
app_main
(
void
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment