Skip to content

Commit 3a36bcf

Browse files
committed
Merge pull request arduino#288 from tbowmo/samd
added initializers for variables needed on AVR platform
2 parents 3fb4074 + e7b6e63 commit 3a36bcf

File tree

3 files changed

+24
-10
lines changed

3 files changed

+24
-10
lines changed

libraries/MySensors/core/MyHwSAMD.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,15 +116,15 @@ void hwSleep(unsigned long ms) {
116116
ms = ms + 1;
117117
}
118118

119-
bool hwSleep(uint8_t interrupt, uint8_t mode, unsigned long ms) {
119+
int8_t hwSleep(uint8_t interrupt, uint8_t mode, unsigned long ms) {
120120
// TODO: Not supported!
121121
interrupt = interrupt;
122122
mode = mode;
123123
ms = ms;
124124
return false;
125125
}
126126

127-
uint8_t hwSleep(uint8_t interrupt1, uint8_t mode1, uint8_t interrupt2, uint8_t mode2, unsigned long ms) {
127+
int8_t hwSleep(uint8_t interrupt1, uint8_t mode1, uint8_t interrupt2, uint8_t mode2, unsigned long ms) {
128128
// TODO: Not supported!
129129
interrupt1 = interrupt1;
130130
mode1 = mode1;

libraries/MySensors/drivers/ATSHA204/ATSHA204.cpp

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,19 @@
77
// As well as the bit value for each of those registers
88
ATSHA204Class::ATSHA204Class(uint8_t pin)
99
{
10-
device_pin = pin; // Find the bit value of the pin
10+
#if defined(ARDUINO_ARCH_AVR)
11+
device_pin = digitalPinToBitMask(pin); // Find the bit value of the pin
12+
uint8_t port = digitalPinToPort(pin); // temoporarily used to get the next three registers
13+
14+
// Point to data direction register port of pin
15+
device_port_DDR = portModeRegister(port);
16+
// Point to output register of pin
17+
device_port_OUT = portOutputRegister(port);
18+
// Point to input register of pin
19+
device_port_IN = portInputRegister(port);
20+
#else
21+
device_pin = pin;
22+
#endif
1123
}
1224

1325
void ATSHA204Class::getSerialNumber(uint8_t * response)
@@ -71,21 +83,21 @@ uint8_t ATSHA204Class::swi_send_bytes(uint8_t count, uint8_t *buffer)
7183
{
7284
if (bit_mask & buffer[i])
7385
{
74-
SHA204_POUT_LOW() //*device_port_OUT &= ~device_pin;
86+
SHA204_POUT_LOW(); //*device_port_OUT &= ~device_pin;
7587
delayMicroseconds(BIT_DELAY); //BIT_DELAY_1;
76-
SHA204_POUT_HIGH() //*device_port_OUT |= device_pin;
88+
SHA204_POUT_HIGH(); //*device_port_OUT |= device_pin;
7789
delayMicroseconds(7*BIT_DELAY); //BIT_DELAY_7;
7890
}
7991
else
8092
{
8193
// Send a zero bit.
82-
SHA204_POUT_LOW() //*device_port_OUT &= ~device_pin;
94+
SHA204_POUT_LOW(); //*device_port_OUT &= ~device_pin;
8395
delayMicroseconds(BIT_DELAY); //BIT_DELAY_1;
84-
SHA204_POUT_HIGH() //*device_port_OUT |= device_pin;
96+
SHA204_POUT_HIGH(); //*device_port_OUT |= device_pin;
8597
delayMicroseconds(BIT_DELAY); //BIT_DELAY_1;
86-
SHA204_POUT_LOW() //*device_port_OUT &= ~device_pin;
98+
SHA204_POUT_LOW(); //*device_port_OUT &= ~device_pin;
8799
delayMicroseconds(BIT_DELAY); //BIT_DELAY_1;
88-
SHA204_POUT_HIGH() //*device_port_OUT |= device_pin;
100+
SHA204_POUT_HIGH(); //*device_port_OUT |= device_pin;
89101
delayMicroseconds(5*BIT_DELAY); //BIT_DELAY_5;
90102
}
91103
}

libraries/MySensors/drivers/ATSHA204/ATSHA204.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,9 @@ class ATSHA204Class
240240
{
241241
private:
242242
uint8_t device_pin;
243-
// volatile uint8_t *device_port_DDR, *device_port_OUT, *device_port_IN;
243+
#ifdef ARDUINO_ARCH_AVR
244+
volatile uint8_t *device_port_DDR, *device_port_OUT, *device_port_IN;
245+
#endif
244246
void sha204c_calculate_crc(uint8_t length, uint8_t *data, uint8_t *crc);
245247
uint8_t sha204c_check_crc(uint8_t *response);
246248
void swi_set_signal_pin(uint8_t is_high);

0 commit comments

Comments
 (0)