Skip to content

Commit b803536

Browse files
committed
fix compilation
1 parent f702ed5 commit b803536

File tree

5 files changed

+22
-20
lines changed

5 files changed

+22
-20
lines changed

cores/arduino/Arduino.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,9 @@ extern const uint8_t PROGMEM digital_pin_to_interrupt[];
9090
#define analogPinToBitMask(pin) ( (pin < NUM_ANALOG_INPUTS) ? (1 << analogPinToBitPosition(pin)) : NOT_A_PIN )
9191
#define digitalPinToTimer(pin) ( (pin < NUM_TOTAL_PINS) ? pgm_read_byte(digital_pin_to_timer + pin) : NOT_ON_TIMER )
9292

93-
#define portToPortStruct(port) ( (port > NOT_A_PORT) ? ((PORT_t *)&PORTA + port) : NULL)
93+
#define portToPortStruct(port) ((PORT_t *)&PORTA + port)
9494
#define digitalPinToPortStruct(pin) ( (pin < NUM_TOTAL_PINS) ? ((PORT_t *)&PORTA + digitalPinToPort(pin)) : NULL)
95-
#define getPINnCTRLregister(port, bit_pos) ( ((port != NULL) && (bit_pos > NOT_A_PIN)) ? ((uint8_t *)&(port->PIN0CTRL) + bit_pos) : NULL )
95+
#define getPINnCTRLregister(port, bit_pos) ( (port != NULL) ? ((uint8_t *)&(port->PIN0CTRL) + bit_pos) : NULL )
9696
#define digitalPinToInterrupt(p) ( pgm_read_byte(digital_pin_to_interrupt + p) )
9797
#define portPinToInterrupt(port, bit_pos) ( pgm_read_byte(port_interrupt_offset + port) + bit_pos )
9898

cores/arduino/UART_private.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ UartClass::UartClass(
3333
volatile USART_t *hwserial_module,
3434
volatile uint8_t hwserial_rx_pin,
3535
volatile uint8_t hwserial_tx_pin) :
36-
hwserial_module(hwserial_module),
36+
_hwserial_module(hwserial_module),
3737
_hwserial_rx_pin(hwserial_rx_pin),
3838
_hwserial_tx_pin(hwserial_tx_pin),
3939
_rx_buffer_head(0), _rx_buffer_tail(0),

cores/arduino/WInterrupts.c

+3-10
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,7 @@
3434

3535
static volatile voidFuncPtr intFunc[EXTERNAL_NUM_INTERRUPTS];
3636

37-
//#define DISABLE PORT_ISC_INTDISABLE_gc
38-
//#define CHANGE PORT_ISC_BOTHEDGES_gc
39-
//#define RISING PORT_ISC_RISING_gc
40-
//#define FALLING PORT_ISC_FALLING_gc
41-
//#define LOW_LEVEL PORT_ISC_LEVEL_gc
42-
43-
44-
void attachInterrupt(uint8_t interruptNum, void (*userFunc)(void), PinStatus mode) {
37+
void attachInterrupt(uint8_t pin, void (*userFunc)(void), PinStatus mode) {
4538

4639
/* Get bit position and check pin validity */
4740
uint8_t bit_pos = digitalPinToBitPosition(pin);
@@ -51,7 +44,7 @@ void attachInterrupt(uint8_t interruptNum, void (*userFunc)(void), PinStatus mod
5144
uint8_t interruptNum = digitalPinToInterrupt(pin);
5245

5346
/* Check interrupt number and apply function pointer to correct array index */
54-
if((interruptNum < EXTERNAL_NUM_INTERRUPTS) && (interruptNum > NOT_AN_INTERRUPT)) {
47+
if(interruptNum < EXTERNAL_NUM_INTERRUPTS) {
5548
intFunc[interruptNum] = userFunc;
5649

5750
// Configure the interrupt mode (trigger on low input, any change, rising
@@ -91,7 +84,7 @@ void attachInterrupt(uint8_t interruptNum, void (*userFunc)(void), PinStatus mod
9184
}
9285
}
9386

94-
void detachInterrupt(uint8_t interruptNum) {
87+
void detachInterrupt(uint8_t pin) {
9588
/* Get bit position and check pin validity */
9689
uint8_t bit_pos = digitalPinToBitPosition(pin);
9790
if(bit_pos == NOT_A_PIN) return;

cores/arduino/wiring_analog.c

+8-4
Original file line numberDiff line numberDiff line change
@@ -137,12 +137,15 @@ void analogWrite(uint8_t pin, int val)
137137
/* Get timer */
138138
uint8_t digital_pin_timer = digitalPinToTimer(pin);
139139

140+
uint16_t* timer_cmp_out;
141+
TCB_t *timer_B;
142+
140143
/* Find out Port and Pin to correctly handle port mux, and timer. */
141-
switch (digital_pin_timer)
142-
{
144+
switch (digital_pin_timer) {
145+
143146
case TIMERA0:
144147
/* Calculate correct compare buffer register */
145-
uint16_t* timer_cmp_out = ((uint16_t*) (&TCA0.SINGLE.CMP0BUF)) + bit_pos;
148+
timer_cmp_out = ((uint16_t*) (&TCA0.SINGLE.CMP0BUF)) + bit_pos;
146149

147150
/* Configure duty cycle for correct compare channel */
148151
(*timer_cmp_out) = (val);
@@ -151,14 +154,15 @@ void analogWrite(uint8_t pin, int val)
151154
TCA0.SINGLE.CTRLB |= (1 << (TCA_SINGLE_CMP0EN_bp + bit_pos));
152155

153156
break;
157+
154158
case TIMERB0:
155159
case TIMERB1:
156160
case TIMERB2:
157161
case TIMERB3:
158162

159163
/* Get pointer to timer, TIMERB0 order definition in Arduino.h*/
160164
//assert (((TIMERB0 - TIMERB3) == 2));
161-
TCB_t *timer_B = ((TCB_t *)&TCB0 + (digital_pin_timer - TIMERB0));
165+
timer_B = ((TCB_t *)&TCB0 + (digital_pin_timer - TIMERB0));
162166

163167
/* set duty cycle */
164168
timer_B->CCMPH = val;

cores/arduino/wiring_digital.c

+8-3
Original file line numberDiff line numberDiff line change
@@ -90,38 +90,43 @@ void pinMode(uint8_t pin, PinMode mode)
9090
//
9191
//static inline void turnOffPWM(uint8_t timer) __attribute__ ((always_inline));
9292
//static inline void turnOffPWM(uint8_t timer)
93-
static void turnOffPWM(uint8_t timer)
93+
static void turnOffPWM(uint8_t pin)
9494
{
9595
/* Actually turn off compare channel, not the timer */
9696

9797
/* Get pin's timer */
9898
uint8_t timer = digitalPinToTimer(pin);
9999
if(timer == NOT_ON_TIMER) return;
100100

101+
uint8_t bit_pos;
102+
TCB_t *timerB;
103+
101104
switch (timer) {
102105

103106
/* TCA0 */
104107
case TIMERA0:
105108
/* Bit position will give output channel */
106-
uint8_t bit_pos = digitalPinToBitPosition(pin);
109+
bit_pos = digitalPinToBitPosition(pin);
107110

108111
/* Disable corresponding channel */
109112
TCA0.SINGLE.CTRLB &= ~(1 << (TCA_SINGLE_CMP0EN_bp + bit_pos));
110113

111114
break;
115+
112116
/* TCB - only one output */
113117
case TIMERB0:
114118
case TIMERB1:
115119
case TIMERB2:
116120
case TIMERB3:
117121

118-
TCB_t *timerB = (TCB_t *)&TCB0 + (timer - TIMERB0);
122+
timerB = (TCB_t *)&TCB0 + (timer - TIMERB0);
119123

120124
/* Disable TCB compare channel */
121125
timerB->CTRLB &= ~(TCB_CCMPEN_bm);
122126

123127
break;
124128
default:
129+
break;
125130
}
126131
}
127132

0 commit comments

Comments
 (0)