fixed, just an address problem. In the past I was using 0b11010000 (8 bits) but I understood that with maple I have to give the 7 bits address 0b1101000.
Current beta Wire library implementation with support for hardware I2C
(56 posts) (12 voices)-
Posted 3 years ago #
-
Can you post your entire code? The snippet won't help me find the bug if any. Why don't you pass a pointer to the instance of HardWire (or WireBase) for your IMU library?
Posted 3 years ago # -
there is the entire source code :
Main
Class header
Class source
Some definitions I usethe program fails if I declare the HardWire instance as global but works fine this way.
And to pass a pointer of the HardWire instance to my library, it has to be global because if I create the object it in the setup function, it will be destroyed at the end of it...Posted 3 years ago # -
You can create an instance in the main code that is global, much like how you're setting up Timer1; Then pass it onto your class, then you just need to store a pointer within your class. I can't see anything wrong at this stage, however I'll see what I can find to see why it's not working correctly.
Posted 3 years ago # -
I found the problem (I have the same strange problem with another thing I started). I don't know why but the PIN_MAP is not initialized when the constructors are called (i.e gpio_device, timer_device and adc_device point to NULL). I think I'll stop polluting this post and create a new one if I can't find any solution
Posted 3 years ago # -
>PIN_MAP is not initialized when the constructors are called
I doubt that. It sounds more like you use different pack-struct compiler options for libmaple and your main program, which is fatal.Posted 3 years ago # -
ala42 > How can I fix that? Indeed, the program works great on MapleIDE but not with my Eclipse configuration (just these initializations, otherwise, everything is ok).
Posted 3 years ago # -
The latest TwoWire.h excludes itself if HardWire.h is already included (because they use the same #define declaration). This prevents you from including both software and hardware classes, which seems like a bug.
Thanks for your effort on this crenn (and others).
Posted 3 years ago # -
Whoops! That's certainly a bug! I'll fix that one shortly, although a release won't occur for another week or so until I do some more work on the library, primarily making the code not use tabs and conforms to the libmaple coding standards.
EDIT: Here's the change to fix that:
Open up TwoWire.h in a text editor such as Notepad++ and goto Lines 41 and 42 and replace it with this:
#ifndef _TWOWIRE_H_
#define _TWOWIRE_H_Posted 3 years ago # -
>ala42 > How can I fix that? Indeed, the program works great on MapleIDE but not with >my Eclipse configuration (just these initializations, otherwise, everything is ok).
Check your makefile for the 'pack-struct' compiler option and remove it.
Posted 3 years ago # -
>Check your makefile for the 'pack-struct' compiler option and remove it.
this is the g++ invocation command (the makefile is generated automatically by eclipse).arm-none-eabi-g++ -O0 -g3 -Wall -mthumb -mcpu=cortex-m3 -c -fmessage-length=0
there are some defines and include paths too but no signs of a pack struct somewhere
Posted 3 years ago # -
Just letting everyone know, the library is due to be included in the master branch of libmaple soon after a few formatting and fixes were done. All future releases of libmaple will include this library (unless a better library is made).
Posted 3 years ago # -
Merged. Thanks, crenn!
https://github.com/leaflabs/libmaple/commit/b98596cbda81efeedfb20692b267e10b754a3798
Posted 3 years ago # -
Not a problem. I see you touched up the files after the commits, could have sworn I went through and made it 80-column strict. Oh well.
Also what does the include optimisation do exactly?
Could have sworn that I got a warning or error about new lines at the end of files when I made the patch, which is why I removed them.EDIT: mbolivar, there is a slight problem when using the library from github with IDE v0.0.12, can you recommend a fix for this?
For others who want to use this library, I've uploaded it here:
http://www.crennsmind.com/Code/Maple/Libraries/WireBase/Wire-120630.zipUnzip the file into the libraries directory.
Posted 3 years ago # -
Not a problem. I see you touched up the files after the commits, could have sworn I went through and made it 80-column strict. Oh well.
It's OK; there weren't many lines to change. Note that editor support for detecting long lines goes a long way. For example, I've configured my text editor to display characters that are past the line length limit in an ugly color, so I notice them immediately.
Also what does the include optimisation do exactly?
It speeds up cpp when files are included multiple times:
http://gcc.gnu.org/onlinedocs/cppinternals/Guard-Macros.html
Could have sworn that I got a warning or error about new lines at the end of files when I made the patch, which is why I removed them.
The warning is for files which don't have a newline at the end, not for files that do ;).
EDIT: mbolivar, there is a slight problem when using the library from github with IDE v0.0.12, can you recommend a fix for this?
Please be more specific; "there's a problem" doesn't really tell me anything useful.
If you're talking about the include style having changed (e.g.
#include <libmaple/i2c.h>
instead of#include "i2c.h"
), there's no fix: the new include style is here to stay. See the blog post for more details:http://leaflabs.com/2012/07/libmaple-new-include-style-on-the-way/
Keeping a "backport" of the library for IDE v0.0.12 as you have done is a sensible and nice thing, so thanks for doing it.
Posted 3 years ago #
Reply »
You must log in to post.