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

error: 'regtype' does not name a type #590

Open
FlorentNGN opened this issue May 21, 2024 · 2 comments · May be fixed by #595
Open

error: 'regtype' does not name a type #590

FlorentNGN opened this issue May 21, 2024 · 2 comments · May be fixed by #595

Comments

@FlorentNGN
Copy link

I recently bought an arducam mini 2MP, I connect it to my arduino uno R4 WIFI, I want to run the example code "ArduCAM_Mini_2MP_OV2640_functions", but when I want to compile, it says:
C:\Users\Acer\AppData\Local\Arduino15\libraries\ArduCAM/ArduCAM.h:768:2: error: 'regtype' does not name a type; did you mean 'wctype'?
regtype *P_CS;
^~~~~~~
wctype
C:\Users\Acer\AppData\Local\Arduino15\libraries\ArduCAM/ArduCAM.h:769:2: error: 'regsize' does not name a type
regsize B_CS;
^~~~~~~
C:\Users\Acer\AppData\Local\Arduino15\libraries\ArduCAM\examples\mini\ArduCAM_Mini_2MP_OV2640_functions\ArduCAM_Mini_2MP_OV2640_functions.ino:28:11: error: conflicting declaration 'const int CS'
const int CS = 7;
^~
In file included from C:\Users\Acer\AppData\Local\Arduino15\packages\arduino\hardware\renesas_uno\1.1.0\cores\arduino/Arduino.h:124:0,
from C:\Users\Acer\AppData\Local\Temp\arduino\sketches\D1EF11006A86C86A1F374DBB6FF436D3\sketch\ArduCAM_Mini_2MP_OV2640_functions.ino.cpp:1:
C:\Users\Acer\AppData\Local\Arduino15\packages\arduino\hardware\renesas_uno\1.1.0\variants\UNOWIFIR4/pins_arduino.h:136:22: note: previous declaration as 'const uint8_t CS'
static const uint8_t CS = PIN_SPI_CS;
^~

I don’t understand why, people to help me?

@keeeal
Copy link

keeeal commented Sep 28, 2024

Hey @FlorentNGN,

I am not sure if you are still working on this or managed to get it working, but I am in the same situation (Arduino Uno R4 WIFI, OV5642 instead of your OV2640) and I can explain these errors.

The output you have provided actually describes two different errors with the same root cause.

Problem 1. regtype and regsize are not defined.

These normally get defined in ArduCAM.h depending on the compiler option that specifies the chip used by your Arduino.

#define regtype volatile uint32_t
#define regsize uint32_t

For example, for AVR chips here or for SAM3X8E here, etc etc. The problem is that the Uno R4 WIFI doesn't use a chip in any of the currently specified families. It uses the Renesas RA4M1, for which there is currently no compiler option. The R4 Minima uses this chip too.

Solutions?

  • Maybe one of the other chip's settings are correct for the chip we have but I don't know. I will try some stuff out and come back to this issue if it works. At this stage I don't even know the right way of adding an extra compiler option in the Arduino IDE yet 😂
  • The real solution here would be to work out which compiler option is set by the Arduino compiler to specify a Renesas chip. Then I could add a new def block in the ArduCAM.h file with the right settings in it.

Problem 2. CS is defined twice.

This one is simpler. Arudino provides some constants for each board in a file called pins_arduino.h and for the Uno R4 this includes a constant called CS.

static const uint8_t CS  =  PIN_SPI_CS;

The file is maintained here and for me it was installed at ~/.arduino15/packages/arduino/hardware/renesas_uno/1.2.1/variants/UNOWIFIR4/pins_arduino.h.

Unfortunately the examples in this repo also define a constant called CS. In the OV2640 example it is defined here and in the OV5642 it is here.

const int CS = 7;

Honestly, it feels like Arduino are in the wrong here... Why do they need to define a two-letter constant when PIN_SPI_CS already exists? And if my understanding is correct, the Chip Select pin is not Arduino board specific - It can be any output pin that can be set to high or low and you require more that one of them if you intend to select between more than one SPI device.

Solutions?

  • Rename the CS variable in the example. It gets passed into ArduCAM class initializer a few lines later anyway and never used again.

Conclusion

The Arduino Uno R4 chip is not supported by ArduCAM yet

... but it might be easy to add support.

If I get something working I will add a PR to this repo, at which point other R4 users should be able to use my fix, whether the PR get accepted or not.

@keeeal keeeal linked a pull request Sep 28, 2024 that will close this issue
@keeeal
Copy link

keeeal commented Sep 28, 2024

Okay, so I went on an adventure.

It looks like the compiler options used to specify the R4 Minima and R4 WIFI are ARDUINO_UNOR4_MINIMA and ARDUINO_UNOR4_WIFI respectively.

I discovered that the register size of the Renesas RA4M1 is 16-bit even though it is ostensibly a 32-bit CPU. I also suspect that none of the definitions apart from regtype and regsize matter at all - I don't think any of them are used in this repo.

Finally, I made a PR to add support for Arduino Uno R4 boards.

For future travelers:

If you are using an Arduino Uno R4 and the above PR is not merged, go to my fork of this repo and use that instead.

Good luck!

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

Successfully merging a pull request may close this issue.

2 participants