Yenya / ibus-altitude-sensor

I-Bus Altitude Sensor for FlySky Telemetry
GNU General Public License v2.0
28 stars 3 forks source link

Trouble compiling for arduino nano #1

Closed PaulFl closed 6 years ago

PaulFl commented 6 years ago

I modified the makefile in order to compile for the arduino nano instead of the promicro but i then get a bunch of errors: ibus-sensor.c: In function 'serial_init': ibus-sensor.c:85:2: error: 'UBRR1' undeclared (first use in this function) UBRR1 = UBRR_VAL; ^ ibus-sensor.c:85:2: note: each undeclared identifier is reported only once for each function it appears in ibus-sensor.c:87:2: error: 'UCSR1A' undeclared (first use in this function) UCSR1A = 0; ^ ibus-sensor.c:89:2: error: 'UCSR1B' undeclared (first use in this function) UCSR1B = _BV(RXEN1) | _BV(RXCIE1) | _BV(UDRIE1); ^ In file included from /Applications/Arduino.app/Contents/Java/hardware/tools/avr/avr/include/avr/io.h:99:0, from /Applications/Arduino.app/Contents/Java/hardware/tools/avr/avr/include/avr/interrupt.h:38, from ibus-sensor.c:3: ibus-sensor.c:89:15: error: 'RXEN1' undeclared (first use in this function) UCSR1B = _BV(RXEN1) | _BV(RXCIE1) | _BV(UDRIE1); [...] Is there anything I'm doing wrong? Thanks for your help

Yenya commented 6 years ago

The nano has its own sets of parameters in Makefile, make sure you have edited the Makefile to reflect your configuration (Nano + BMP180, I suppose - is it the case?).

Nano (328P) has USART0 (registers UBRR0, UCSR0A, etc.), while ProMicro (32U4) has USART1.

If your Makefile is correct, I'll have a look at it afterwards. Thanks for the report.

PaulFl commented 6 years ago

Thanks for your answer, (my config is nano + bmp280) I did edit the beginning of the makefile: Here is the beginning of my makefile:

TARGET = ibus-sensor

SRC =   $(TARGET).c \
    i2chw/twimaster.c

# For BMP085/BMP180 sensor uncomment this:
#SRC += bmp085/bmp085.c
#SENSOR_DEFS = -DSENSOR_BMP085

# For BMP280 sensor uncomment this:
SRC +=  bmp280/bmp280.c
SENSOR_DEFS = -DSENSOR_BMP280

# For SparkFun Promicro:
#MCU = atmega32u4

# For Arduino Nano:
MCU = atmega328p

Are there other things i should change?

Yenya commented 6 years ago

Oh well. I feel greatly ashamed, but I have to admit that this is a huge oversight on my side: I have not pushed changes to ibus-sensor.c which actually implement support for Nano (the main change being usage of USART0 instead of USART1, but also different I/O pins for LEDs and few other changes). I made other changes for my promicro+BMP180 locally since then, so I have to retest the Nano+BMP280 before pushing it out. Give me few days to do it.

My apology for such a stupid mistake.

PaulFl commented 6 years ago

Ok, I see, thanks a lot I'm looking forward to using you work soon then!

Yenya commented 6 years ago

Paul, could you please test the current HEAD (3da8ba477)? I can compile this for Nano (edit the Makefile as always), but my Nano+BMP280 is buried deep inside my plane, so I cannot test it now. Unfortunately, I only have the Promicro+BMP180 combo for testing now. Thanks!

PaulFl commented 6 years ago

Of course, I'll happily test it tomorrow or the day after (I'm not currently home), I'll keep you updated (I was being a little bit impatient and I actually got it to work with dirty changes to the usart definitions meanwhile...)

Yenya commented 6 years ago

Yes, the quick and dirty way is to replace 1 with 0 in USART register names, and 1 with nothing in interrupt vector names.

Apart from that, Nano has only one on-board LED on a different pin than Promicro, and there are some changes related to battery voltage readout (different ADC channel, different internal voltage reference, and the ADC channel is on a dedicated analog pin, so the DIDRx register setup is not needed). Nothing overly complicated.

PaulFl commented 6 years ago

Yeah, thats what I did I just tested the current HEAD (3da8ba4) and everything works perfectly fine ! Thanks for your help. Just tell me if you ever need me to do some more testing for you.

Yenya commented 6 years ago

Thanks for the report. Closing the issue.