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

Status I2C_ - Type 'Status' could not be resolved #4

Closed
stehgold opened this issue Oct 4, 2014 · 6 comments
Closed

Status I2C_ - Type 'Status' could not be resolved #4

stehgold opened this issue Oct 4, 2014 · 6 comments

Comments

@stehgold
Copy link

stehgold commented Oct 4, 2014

Hi,

I'm using Eclipse with gnuarm plugin http://gnuarmeclipse.sourceforge.net/, trying to read BMP085 pressure sensors. Where is Status defined ? I'll try uint32_t for now.

Have a nice weekend,
Stephan

@geoffreymbrown
Copy link
Owner

it's defined in I2C.h

#ifndef I2C_H#define I2C_H #include <stm32f10x_i2c.h> typedef enum {Error =
0, Success = !Error } Status; Status I2C_Read(I2C_TypeDef* I2Cx, uint8_t*
buf, uint32_t nbuf, uint8_t SlaveAddress);Status I2C_Write(I2C_TypeDef* I2Cx
, const uint8_t* buf, uint32_t nbuf, uint8_t SlaveAddress);void
I2C_LowLevel_Init(I2C_TypeDef* I2Cx, int ClockSpeed, int OwnAddress); #endif

On Sat, Oct 4, 2014 at 9:20 AM, Stephan Goldenberg <notifications@github.com

wrote:

Hi,

I'm using Eclipse with gnuarm plugin http://gnuarmeclipse.sourceforge.net/,
trying to read BMP085 pressure sensors. Where is Status defined ? I'll try
uint32_t for now.

Have a nice weekend,
Stephan


Reply to this email directly or view it on GitHub
#4.

@stehgold
Copy link
Author

stehgold commented Oct 5, 2014

Ah, OK. This is not in the text I have.

@stehgold stehgold closed this as completed Oct 5, 2014
@stehgold
Copy link
Author

stehgold commented Oct 5, 2014

Hmm, does not compile. It's choking on this 'Timed(x)' construct and doesn't seem to like lables.

Edit: Ooops, that was me. I forgot the lines '// Wait for stop' and on in I2C_Read(). Compiles now :)

13:49:36 **** Incremental Build of configuration Debug for project stm32vl_i2c ****
make all
Building file: ../src/i2c.c
Invoking: Cross ARM C Compiler
arm-none-eabi-gcc -mcpu=cortex-m3 -mthumb -Og -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -Wall -Wextra -g3 -DDEBUG -DUSE_FULL_ASSERT -DTRACE -DOS_USE_TRACE_ITM -DSTM32F10X_MD_VL -DUSE_STDPERIPH_DRIVER -DHSE_VALUE=8000000 -DTimed=1 -I"../include" -I"../system/include" -I"../system/include/cmsis" -I"../system/include/stm32f1-stdperiph" -std=gnu11 -MMD -MP -MF"src/i2c.d" -MT"src/i2c.o" -c -o "src/i2c.o" "../src/i2c.c"
In file included from ../src/i2c.c:8:0:
../src/i2c.h:18:0: warning: "Timed" redefined [enabled by default]
#define Timed(x) Timeout = 0xFFFF; while (x){if (Timeout-- == 0) goto errReturn;}
^
:0:0: note: this is the location of the previous definition
../src/i2c.c: In function 'I2C_Read':
../src/i2c.c:166:3: error: label 'errReturn' used but not defined
Timed(!I2C_CheckEvent(I2Cx, I2C_EVENT_MASTER_BYTE_RECEIVED));
^
src/subdir.mk:24: recipe for target 'src/i2c.o' failed
make: *** [src/i2c.o] Error 1

@stehgold stehgold reopened this Oct 5, 2014
@stehgold stehgold closed this as completed Oct 5, 2014
@stehgold
Copy link
Author

stehgold commented Oct 7, 2014

Hmm, no errors, no warnings - not working. ;( Using an LA I can see START - 0xEE (SlaveAddress) - ACK - 0xAA (RegisterAddress) - ACK - STOP. Now 2 bytes should be read: I see START and nothing more (SDA and SCL stay low), the SlaveAddress gets never send. MCU is trapped in exit.c. Hardware is working fine with Tiva Launchpad.

@geoffreymbrown
Copy link
Owner

I'm not sure I have enough info to help. When I get back home from
vacation in AZ next weekend I can send you a complete i2c application. At
the moment all I have is an ipad.

Geoffrey

On Tuesday, October 7, 2014, Stephan Goldenberg notifications@github.com
wrote:

Hmm, no errors, no warnings - not working. ;( Using an LA I can see START

  • 0xEE (SlaveAddress) - ACK - 0xAA (RegisterAddress) - ACK - STOP. Now 2
    bytes should be read: I see START and nothing more (SDA and SCL stay low),
    the SlaveAddress gets never send. MCU is trapped in exit.c. Hardware is
    working fine with Tiva Launchpad.


Reply to this email directly or view it on GitHub
#4 (comment)
.

@stehgold
Copy link
Author

stehgold commented Oct 7, 2014

Oooh, sorry. Enjoy your off time !

I got fishy and removed the Timed(... line after generate start and now anything is fine. MCU doesn't get trapped and I get sane values from the sensor. 26C, 989hPa - 1003hPa reported for my area. I don't know why waiting for I2C_EVENT_MASTER_MODE_SELECT fails.

Status I2C_Read(I2C_TypeDef* I2Cx, uint8_t* buf, uint32_t nbyte, uint8_t SlaveAddress){
__IO uint32_t Timeout = 0;
if (!nbyte) return Success;
// Wait for idle I2C interface
Timed(I2C_GetFlagStatus(I2Cx, I2C_FLAG_BUSY));
// Enable Acknowledgement, clear POS flag
I2C_AcknowledgeConfig(I2Cx, ENABLE);
I2C_NACKPositionConfig(I2Cx, I2C_NACKPosition_Current);
// Initiate Start Sequence (wait for EV5)
I2C_GenerateSTART(I2Cx, ENABLE);
// Timed(!I2C_GetFlagStatus(I2Cx, I2C_EVENT_MASTER_MODE_SELECT)); <- THIS LINE fails
// Send Address
I2C_Send7bitAddress(I2Cx, SlaveAddress, I2C_Direction_Receiver);
...

Enjoy your vacation,
Stephan

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants