Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed i2c initialization #1

Merged
merged 1 commit into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions examples/Trill-Craft/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Project Name
TARGET = Trill

# Sources
CPP_SOURCES = Trill-Craft.cpp

# Library Locations
LIBDAISY_DIR = ../..

# Core location, and generic Makefile.
SYSTEM_FILES_DIR = $(LIBDAISY_DIR)/core
include $(SYSTEM_FILES_DIR)/Makefile
40 changes: 40 additions & 0 deletions examples/Trill-Craft/Trill-Craft.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/**
* Read Trill craft capacitive sensor
*/

#include "daisy_seed.h"
#include "dev/trill/Trill.h"

using namespace daisy;

DaisySeed hw;

int main(void)
{
// Initialize the Daisy Seed
hw.Init();

// Start the Serial Logger
hw.StartLog();

// Create a Trill object
Trill trill;

// Initialize the Trill object
int i2cBus = 1; // only 1 and 4 are properly mapped to pins on the Seed
int ret = trill.setup(i2cBus, Trill::CRAFT);
if(ret)
hw.PrintLine("trill.setup() returned %d", ret);

// loop forever
while(1)
{
hw.DelayMs(100);
trill.readI2C();
for(auto &x : trill.rawData ){
hw.Print("%d ", int(x*100000.f));
}
hw.PrintLine("");
}

}
1 change: 1 addition & 0 deletions src/dev/trill/I2c.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ inline int I2c::initI2C_RW(int bus, int address, int dummy)
}
cfg.address = i2cAddress; // this seems unused anyhow
i2cAddress = address;
i2cHandle.Init(cfg);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes! this is the main bit missing to get Trill to work!

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@giuliomoro add this fix to open a PR for review to E-S?

return 0;
}

Expand Down