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

I2C.c: Undefined identifier 'TWDR' #33

Closed
uvwxy opened this issue Nov 18, 2017 · 2 comments
Closed

I2C.c: Undefined identifier 'TWDR' #33

uvwxy opened this issue Nov 18, 2017 · 2 comments

Comments

@uvwxy
Copy link

uvwxy commented Nov 18, 2017

First of all, great job putting all this together. I'm using sduino via makefile include on macOs. So far I got the blink example to work using the stlink v2 😀👍

My next step is to get the Mini SSD1307 example to work. Currently I get the following compile error:

[...]/sduino/hardware/sduino/stm8/libraries/I2C/I2C.c:398: error 20: Undefined identifier 'TWDR'
make: *** [build-stm8sblue/platformlibs/I2C/I2C.c.rel] Error 1

The code at the location is the following:

uint8_t I2C_read(uint8_t address, uint8_t numberBytes)
{
  bytesAvailable = 0;
  bufferIndex = 0;
  if(numberBytes == 0){numberBytes++;}
  nack = numberBytes - 1;
  returnStatus = 0;
  returnStatus = start();
  if(returnStatus){return(returnStatus);}
  returnStatus = sendAddress(SLA_R(address));
  if(returnStatus)
  {
    if(returnStatus == 1){return(5);}
    return(returnStatus);
  }
  for(uint8_t i = 0; i < numberBytes; i++)
  {
    if( i == nack )
    {
      returnStatus = receiveByte(0);
      if(returnStatus == 1){return(6);}

      if(returnStatus != MR_DATA_NACK){return(returnStatus);}
    }
    else
    {
      returnStatus = receiveByte(1);
      if(returnStatus == 1){return(6);}
      if(returnStatus != MR_DATA_ACK){return(returnStatus);}
    }
    data[i] = TWDR;
    bytesAvailable = i+1;
    totalBytes = i+1;
  }
  returnStatus = stop();
  if(returnStatus)
  {
    if(returnStatus == 1){return(7);}
    return(returnStatus);
  }
  return(returnStatus);
}

Should the line with data[i] be set to address?

Hint: I have used esp8266's with 128x64 oled displays with I2C/SPI successfully so far, but have no clue about the details of I2C.

@uvwxy
Copy link
Author

uvwxy commented Nov 18, 2017

I set data[i] = address just to get past the compiler error ... and the example works.

Closing, as we already have this ticket: #28

@aryeguetta
Copy link

I am trying this example with my STM8S103F board and I am getting:
Global variables use 1141 bytes (111%) of dynamic memory, leaving -117 bytes for local variables. Maximum is 1024 bytes.
What should I do to make it works?
Thanks

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