lgt8fx icon indicating copy to clipboard operation
lgt8fx copied to clipboard

MD-328D(LGT8F328D) SPI: compile error

Open jg1uaa opened this issue 3 years ago • 11 comments

When building sketch that uses SPI interface for MD-328D, compile error (undefined SPFR) occurs. There is no SPFR in lgt8f/cores/lgt8f/lgtx8e.h and we can avoid this issue adding same definitions from lgt8xd.h.

I think lgtx8e.h needs to be revised. Does anyone who can work E2PROM and any other peripherals properlly?

jg1uaa avatar Jun 06 '21 07:06 jg1uaa

My board working with 328D. (Dallas temperature sensor + ENC 28J60 SPI ethernet adapter + Webserver) 328D+Ethernet_small

LaZsolt avatar Jun 06 '21 19:06 LaZsolt

Ahh. I'm not remembered, my sckech not include SPI library.

LaZsolt avatar Jun 06 '21 19:06 LaZsolt

Wow, this red board looks cool. where did you buy it?

BTW, SPI.cpp compile error occurs;

  • SPIClass::transfer(void *buf, void *retbuf, size_t count) at SPI.cpp is compiled when LGT8F defined
  • it requires SPFR (and its bitfield) definition
  • only cores/lgt8f/lgtx8p.h has the definition

So simply adding it to cores/lgt8f/lgtx8e.h is a solution. but SPIClass::transfer(void *buf, void *retbuf, size_t count) supports for LGT8F328P, not D. In SPI.h, only LGT8F328P has special code... Is this care required for D variant or not? This is difficult to judge.

jg1uaa avatar Jun 09 '21 12:06 jg1uaa

MassDuino's package and Larduino_HSP(https://github.com/LGTMCU/Larduino_HSP/) does not have SPIClass::transfer(void *buf, void *retbuf, size_t count) at SPI.cpp and SPI.h.

I don't know why this method is implemented and used for. I think this should be limited for LGT8FX8P, not for LGT8F.

jg1uaa avatar Jun 09 '21 18:06 jg1uaa

Wow, this red board looks cool. where did you buy it?

https://www.aliexpress.com/wholesale?catId=0&initiative_id=SB_20210609104247&SearchText=lgt8F328d

Is this care required for D variant or not?

To use SPI interface of LGT 328D variant, the SPI.h of Arduino package working perfect. Soo to using SPI of 328D, no need to use this dbuezas/lgt8fx package's SPI.h. I dont know how to 'tell' it to the compiler.

LaZsolt avatar Jun 09 '21 18:06 LaZsolt

D variant defines LGT8FX8E and LGT8F symbol, so #if defined (LGT8F) ~ #endif is compiled. it is easy to limit SPIClass::transfer for P variant, but adding source from Arduino for D variant is required...?

jg1uaa avatar Jun 09 '21 19:06 jg1uaa

adding source from Arduino for D variant is required

Yes, this could be a solution.

LaZsolt avatar Jun 09 '21 19:06 LaZsolt

Anyway, the red WEMOS XI V1.0.0 LGT8F328D board's bootloader not working. I uploaded this board your with your optiboot using Larduino ISP. After this the serial upload will work. https://github.com/dbuezas/lgt8fx/issues/118#issuecomment-803510917

LaZsolt avatar Jun 09 '21 19:06 LaZsolt

I just ordered WEMOS XI, thanks for inforation about this board and bootloader.

jg1uaa avatar Jun 09 '21 19:06 jg1uaa

Hmm, this SPI problem comes from PR #45 , revise needed.

jg1uaa avatar Jun 10 '21 11:06 jg1uaa

Yes, this special performance function should be limited to the P variant, so the ifdef has to change :/ The D variant has to be treated equal to a real Atmega: no such function.

jayzakk avatar Jun 10 '21 11:06 jayzakk

@jg1uaa Is this issue resolved by this commit? Can you test wil current 1.0.7 release?

dwillmore avatar Jan 12 '23 19:01 dwillmore

Sorry, I checked only building process was no problem. Checking with real hardware is not yet. But I think this issue can be closed.

jg1uaa avatar Feb 10 '23 08:02 jg1uaa

Sorry, I checked only building process was no problem. Checking with real hardware is not yet. But I think this issue can be closed.

There were no problem reported until now so I've closed this issue.

LaZsolt avatar May 21 '23 15:05 LaZsolt