Skip to content

Commit 3a86847

Browse files
committed
Merge branch 'api-avr4809' of github.com:bcmi-labs/ArduinoCore-avr-api into api-avr4809-master
# Conflicts: # cores/arduino/wiring.c # variants/uno2018/pins_arduino.h
2 parents f0d3bda + bb51d6d commit 3a86847

File tree

3 files changed

+36
-18
lines changed

3 files changed

+36
-18
lines changed

boards.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# See: http://code.google.com/p/arduino/wiki/Platforms
22

3-
menu.cpu=Processor
3+
menu.revision=Revision
44

55
##############################################################
66

@@ -15,6 +15,11 @@ uno2018.upload.maximum_size=32256
1515
uno2018.upload.maximum_data_size=2048
1616
uno2018.upload.speed=115200
1717

18+
uno2018.menu.revision.rev2=RevB
19+
uno2018.menu.revision.rev2.build.extra_flags=
20+
uno2018.menu.revision.rev1=RevA (Engineering sample)
21+
uno2018.menu.revision.rev1.build.extra_flags=-DREV_A_ENGINEERING_SAMPLE
22+
1823
uno2018.bootloader.tool=avrdude
1924
uno2018.bootloader.low_fuses=0xFF
2025
uno2018.bootloader.high_fuses=0xDE

cores/arduino/wiring.c

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -277,12 +277,12 @@ void init()
277277
/* Disable system clock prescaler - F_CPU should now be ~16MHz */
278278
_PROTECTED_WRITE(CLKCTRL_MCLKCTRLB, 0x00);
279279

280-
// /* Calculate actual F_CPU with error values from signature row */
281-
// int8_t sigrow_val = SIGROW.OSC16ERR5V;
282-
// int64_t cpu_freq = F_CPU;
283-
// cpu_freq *= (1024 + sigrow_val);
284-
// cpu_freq /= 1024;
285-
// F_CPU_CORRECTED = (uint32_t)cpu_freq;
280+
/* Calculate actual F_CPU with error values from signature row */
281+
int8_t sigrow_val = SIGROW.OSC16ERR5V;
282+
int64_t cpu_freq = F_CPU;
283+
cpu_freq *= (1024 + sigrow_val);
284+
cpu_freq /= 1024;
285+
F_CPU_CORRECTED = (uint32_t)cpu_freq;
286286

287287
/***************************** TIMERS FOR PWM *********************************/
288288

@@ -392,10 +392,20 @@ void init()
392392

393393
/****************************** USART *****************************************/
394394

395-
// /* Configure PORTMUX for USARTS */
396-
// PORTMUX.USARTROUTEA = (PORTMUX_USART1_ALT1_gc // MAIN
397-
// | PORTMUX_USART0_ALT1_gc // SPARE
398-
// | PORTMUX_USART3_ALT1_gc); // DEBUG
395+
#ifdef REV_A_ENGINEERING_SAMPLE
396+
/* Configure PORTMUX for USARTS */
397+
//PORTMUX.USARTROUTEA = (PORTMUX_USART1_ALT1_gc // MAIN
398+
//| PORTMUX_USART0_ALT1_gc // SPARE
399+
//| PORTMUX_USART3_ALT1_gc); // DEBUG
400+
401+
PORTMUX.USARTROUTEA = (PORTMUX_USART0_ALT1_gc // SPARE
402+
| PORTMUX_USART3_ALT1_gc); // DEBUG
403+
#else
404+
/* Configure PORTMUX for USARTS */
405+
PORTMUX.USARTROUTEA = (PORTMUX_USART1_ALT1_gc // MAIN
406+
| PORTMUX_USART0_ALT1_gc // SPARE
407+
| PORTMUX_USART3_ALT1_gc); // DEBUG
408+
#endif
399409

400410
/********************* TCB3 for system time tracking **************************/
401411

variants/uno2018/pins_arduino.h

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ static const uint8_t MOSI = PIN_SPI_MOSI;
4646
static const uint8_t MISO = PIN_SPI_MISO;
4747
static const uint8_t SCK = PIN_SPI_SCK;
4848

49-
#define PIN_WIRE_SDA (20)
50-
#define PIN_WIRE_SCL (21)
49+
#define PIN_WIRE_SDA (18)
50+
#define PIN_WIRE_SCL (19)
5151

5252
static const uint8_t SDA = PIN_WIRE_SDA;
5353
static const uint8_t SCL = PIN_WIRE_SCL;
@@ -56,20 +56,23 @@ static const uint8_t SCL = PIN_WIRE_SCL;
5656
// USART1 on mega4809 (alternative pins)
5757
// Mapped to HWSERIAL0 in Serial library
5858
#define HWSERIAL0 (&USART1)
59+
//!!BUG in device header file. The RXC and DRE vectors are swapped!!
5960
#define HWSERIAL0_DRE_VECTOR (USART1_DRE_vect)
60-
#define HWSERIAL0_DRE_VECTOR_NUM (USART1_DRE_vect_num)
6161
#define HWSERIAL0_RXC_VECTOR (USART1_RXC_vect)
62-
// #define PIN_WIRE_HWSERIAL0_RX (0)
63-
// #define PIN_WIRE_HWSERIAL0_TX (1)
62+
#ifdef REV_A_ENGINEERING_SAMPLE
6463
#define PIN_WIRE_HWSERIAL0_RX (12)
6564
#define PIN_WIRE_HWSERIAL0_TX (11)
65+
#else
66+
#define PIN_WIRE_HWSERIAL0_RX (0)
67+
#define PIN_WIRE_HWSERIAL0_TX (1)
68+
#endif
6669

6770
// Uno2 Debug USART (not available on headers, only via the EDGB virtual COM port)
6871
// USART3 on mega4809 (alternative pins)
6972
// Mapped to HWSERIAL1 in Serial library
7073
#define HWSERIAL1 (&USART3)
74+
//!!BUG in device header file. The RXC and DRE vectors are swapped!!
7175
#define HWSERIAL1_DRE_VECTOR (USART3_DRE_vect)
72-
#define HWSERIAL1_DRE_VECTOR_NUM (USART3_DRE_vect_num)
7376
#define HWSERIAL1_RXC_VECTOR (USART3_RXC_vect)
7477
#define PIN_WIRE_HWSERIAL1_RX (26)
7578
#define PIN_WIRE_HWSERIAL1_TX (27)
@@ -78,8 +81,8 @@ static const uint8_t SCL = PIN_WIRE_SCL;
7881
// USART0 on mega4809 (alternative pins)
7982
// Mapped to HWSERIAL2 in Serial library
8083
#define HWSERIAL2 (&USART0)
84+
//!!BUG in device header file. The RXC and DRE vectors are swapped!!
8185
#define HWSERIAL2_DRE_VECTOR (USART0_DRE_vect)
82-
#define HWSERIAL2_DRE_VECTOR_NUM (USART0_DRE_vect_num)
8386
#define HWSERIAL2_RXC_VECTOR (USART0_RXC_vect)
8487
#define PIN_WIRE_HWSERIAL2_RX (23)
8588
#define PIN_WIRE_HWSERIAL2_TX (24)

0 commit comments

Comments
 (0)