This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

twi_sw_master.c compilation error

Hello,

I am working with the nRF DK trying to read a sensor over I2C. I wrote some code in Keil uVision and I finally could read the sensor. The problem now is, for some weird reason I can't figure out, the twi_sw_master.c file gives some compilation errors.

    compiling twi_sw_master.c...
RTE\nRF_Drivers\nRF51422_xxAB\twi_sw_master.c(136): error:  #254: type name is not allowed
          for (uint_fast8_t i=18; i--;)
RTE\nRF_Drivers\nRF51422_xxAB\twi_sw_master.c(136): error:  #65: expected a ";"
          for (uint_fast8_t i=18; i--;)
RTE\nRF_Drivers\nRF51422_xxAB\twi_sw_master.c(136): error:  #20: identifier "i" is undefined
          for (uint_fast8_t i=18; i--;)
RTE\nRF_Drivers\nRF51422_xxAB\twi_sw_master.c(311): error:  #254: type name is not allowed
      for (uint_fast8_t i = 0x80; i != 0; i>>=1)
RTE\nRF_Drivers\nRF51422_xxAB\twi_sw_master.c(311): error:  #65: expected a ";"
      for (uint_fast8_t i = 0x80; i != 0; i>>=1)
RTE\nRF_Drivers\nRF51422_xxAB\twi_sw_master.c(311): error:  #20: identifier "i" is undefined
      for (uint_fast8_t i = 0x80; i != 0; i>>=1)
RTE\nRF_Drivers\nRF51422_xxAB\twi_sw_master.c(384): error:  #254: type name is not allowed
      for (uint_fast8_t i = 0x80; i != 0; i>>=1)
RTE\nRF_Drivers\nRF51422_xxAB\twi_sw_master.c(384): error:  #65: expected a ";"
      for (uint_fast8_t i = 0x80; i != 0; i>>=1)
RTE\nRF_Drivers\nRF51422_xxAB\twi_sw_master.c(384): error:  #20: identifier "i" is undefined
      for (uint_fast8_t i = 0x80; i != 0; i>>=1)
RTE\nRF_Drivers\nRF51422_xxAB\twi_sw_master.c(474): warning:  #1-D: last line of file ends without a newline
  /*lint --flb "Leave library region" */
RTE\nRF_Drivers\nRF51422_xxAB\twi_sw_master.c: 1 warning, 9 errors
".\Objects\mag3110.axf" - 9 Error(s), 1 Warning(s).
Target not created.
Build Time Elapsed:  00:00:01

I can't understand what the problem is. I researched about #254 error but the explanation doesn't help that much.

This is the file:

github.com/.../twi_sw_master.c

I used that file because I was getting compiling errors with the original one. I am getting the same errors with the new.

Does anyone know what the problem is?

Thank you.

Related