diff --git a/libraries/MySensors/core/MySigningAtsha204.cpp b/libraries/MySensors/core/MySigningAtsha204.cpp index a0eca68..9d57d6e 100644 --- a/libraries/MySensors/core/MySigningAtsha204.cpp +++ b/libraries/MySensors/core/MySigningAtsha204.cpp @@ -24,7 +24,6 @@ * HMAC-SHA256 authentication with a readout-protected key. * */ -#if defined(ARDUINO_ARCH_AVR) #include "MySigning.h" @@ -281,4 +280,3 @@ uint8_t* signerSha256(const uint8_t* data, size_t sz) { DEBUG_SIGNING_PRINTBUF(F("SHA256: "), &_singning_rx_buffer[SHA204_BUFFER_POS_DATA], 32); return &_singning_rx_buffer[SHA204_BUFFER_POS_DATA]; } -#endif // #if defined(ARDUINO_ARCH_AVR) diff --git a/libraries/MySensors/core/MyTransport.cpp b/libraries/MySensors/core/MyTransport.cpp index b40f6ef..055bd6f 100644 --- a/libraries/MySensors/core/MyTransport.cpp +++ b/libraries/MySensors/core/MyTransport.cpp @@ -199,11 +199,11 @@ inline void transportProcess() { #if defined (MY_GATEWAY_FEATURE) #ifdef MY_SIGNING_REQUEST_SIGNATURES if (DO_SIGN(sender)) - _sendRoute(build(_msg, _nc.nodeId, sender, NODE_SENSOR_ID, C_INTERNAL, I_REQUEST_SIGNING, false).set(true)); + _sendRoute(build(_msg, _nc.nodeId, sender, NODE_SENSOR_ID, C_INTERNAL, I_REQUEST_SIGNING, false).set((uint8_t)true)); else - _sendRoute(build(_msg, _nc.nodeId, sender, NODE_SENSOR_ID, C_INTERNAL, I_REQUEST_SIGNING, false).set(false)); + _sendRoute(build(_msg, _nc.nodeId, sender, NODE_SENSOR_ID, C_INTERNAL, I_REQUEST_SIGNING, false).set((uint8_t)false)); #else - _sendRoute(build(_msg, _nc.nodeId, sender, NODE_SENSOR_ID, C_INTERNAL, I_REQUEST_SIGNING, false).set(false)); + _sendRoute(build(_msg, _nc.nodeId, sender, NODE_SENSOR_ID, C_INTERNAL, I_REQUEST_SIGNING, false).set((uint8_t)false)); #endif #endif return; // Signing request is an internal MySensor protocol message, no need to inform caller about this diff --git a/libraries/MySensors/drivers/ATSHA204/ATSHA204.cpp b/libraries/MySensors/drivers/ATSHA204/ATSHA204.cpp index 113038f..a38c5ec 100644 --- a/libraries/MySensors/drivers/ATSHA204/ATSHA204.cpp +++ b/libraries/MySensors/drivers/ATSHA204/ATSHA204.cpp @@ -1,5 +1,3 @@ -#if defined(ARDUINO_ARCH_AVR) - #include "Arduino.h" #include "ATSHA204.h" @@ -9,15 +7,7 @@ // As well as the bit value for each of those registers ATSHA204Class::ATSHA204Class(uint8_t pin) { - device_pin = digitalPinToBitMask(pin); // Find the bit value of the pin - uint8_t port = digitalPinToPort(pin); // temoporarily used to get the next three registers - - // Point to data direction register port of pin - device_port_DDR = portModeRegister(port); - // Point to output register of pin - device_port_OUT = portOutputRegister(port); - // Point to input register of pin - device_port_IN = portInputRegister(port); + device_pin = pin; // Find the bit value of the pin } void ATSHA204Class::getSerialNumber(uint8_t * response) @@ -52,12 +42,12 @@ void ATSHA204Class::getSerialNumber(uint8_t * response) void ATSHA204Class::swi_set_signal_pin(uint8_t is_high) { - *device_port_DDR |= device_pin; + pinMode(device_pin, OUTPUT); if (is_high) - *device_port_OUT |= device_pin; + digitalWrite(device_pin, HIGH); else - *device_port_OUT &= ~device_pin; + digitalWrite(device_pin, LOW); } uint8_t ATSHA204Class::swi_send_bytes(uint8_t count, uint8_t *buffer) @@ -68,8 +58,8 @@ uint8_t ATSHA204Class::swi_send_bytes(uint8_t count, uint8_t *buffer) noInterrupts(); //swi_disable_interrupts(); // Set signal pin as output. - *device_port_OUT |= device_pin; - *device_port_DDR |= device_pin; + pinMode(device_pin, OUTPUT); + digitalWrite(device_pin, HIGH); // Wait turn around time. delayMicroseconds(RX_TX_DELAY); //RX_TX_DELAY; @@ -80,21 +70,21 @@ uint8_t ATSHA204Class::swi_send_bytes(uint8_t count, uint8_t *buffer) { if (bit_mask & buffer[i]) { - *device_port_OUT &= ~device_pin; + digitalWrite(device_pin, LOW); //*device_port_OUT &= ~device_pin; delayMicroseconds(BIT_DELAY); //BIT_DELAY_1; - *device_port_OUT |= device_pin; + digitalWrite(device_pin, HIGH); //*device_port_OUT |= device_pin; delayMicroseconds(7*BIT_DELAY); //BIT_DELAY_7; } else { // Send a zero bit. - *device_port_OUT &= ~device_pin; + digitalWrite(device_pin, LOW); //*device_port_OUT &= ~device_pin; delayMicroseconds(BIT_DELAY); //BIT_DELAY_1; - *device_port_OUT |= device_pin; + digitalWrite(device_pin, HIGH); //*device_port_OUT |= device_pin; delayMicroseconds(BIT_DELAY); //BIT_DELAY_1; - *device_port_OUT &= ~device_pin; + digitalWrite(device_pin, LOW); //*device_port_OUT &= ~device_pin; delayMicroseconds(BIT_DELAY); //BIT_DELAY_1; - *device_port_OUT |= device_pin; + digitalWrite(device_pin, HIGH); //*device_port_OUT |= device_pin; delayMicroseconds(5*BIT_DELAY); //BIT_DELAY_5; } } @@ -120,7 +110,7 @@ uint8_t ATSHA204Class::swi_receive_bytes(uint8_t count, uint8_t *buffer) noInterrupts(); //swi_disable_interrupts(); // Configure signal pin as input. - *device_port_DDR &= ~device_pin; + pinMode(device_pin, INPUT); // Receive bits and store in buffer. for (i = 0; i < count; i++) @@ -138,7 +128,7 @@ uint8_t ATSHA204Class::swi_receive_bytes(uint8_t count, uint8_t *buffer) while (--timeout_count > 0) { // Wait for falling edge. - if ((*device_port_IN & device_pin) == 0) + if (digitalRead(device_pin) == 0) break; } @@ -151,7 +141,7 @@ uint8_t ATSHA204Class::swi_receive_bytes(uint8_t count, uint8_t *buffer) do { // Wait for rising edge. - if ((*device_port_IN & device_pin) != 0) + if (digitalRead(device_pin) != 0) { // For an Atmel microcontroller this might be faster than "pulse_count++". pulse_count = 1; @@ -174,7 +164,7 @@ uint8_t ATSHA204Class::swi_receive_bytes(uint8_t count, uint8_t *buffer) // Detect possible edge indicating zero bit. do { - if ((*device_port_IN & device_pin) == 0) + if (digitalRead(device_pin) == 0) { // For an Atmel microcontroller this might be faster than "pulse_count++". pulse_count = 2; @@ -188,7 +178,7 @@ uint8_t ATSHA204Class::swi_receive_bytes(uint8_t count, uint8_t *buffer) { do { - if ((*device_port_IN & device_pin) != 0) + if (digitalRead(device_pin) != 0) break; } while (timeout_count-- > 0); } @@ -575,4 +565,3 @@ uint8_t ATSHA204Class::sha204c_check_crc(uint8_t *response) ? SHA204_SUCCESS : SHA204_BAD_CRC; } -#endif // defined(ARDUINO_ARCH_AVR) \ No newline at end of file diff --git a/libraries/MySensors/drivers/ATSHA204/ATSHA204.h b/libraries/MySensors/drivers/ATSHA204/ATSHA204.h index 9e87939..0c18849 100644 --- a/libraries/MySensors/drivers/ATSHA204/ATSHA204.h +++ b/libraries/MySensors/drivers/ATSHA204/ATSHA204.h @@ -224,7 +224,7 @@ class ATSHA204Class { private: uint8_t device_pin; - volatile uint8_t *device_port_DDR, *device_port_OUT, *device_port_IN; +// volatile uint8_t *device_port_DDR, *device_port_OUT, *device_port_IN; void sha204c_calculate_crc(uint8_t length, uint8_t *data, uint8_t *crc); uint8_t sha204c_check_crc(uint8_t *response); void swi_set_signal_pin(uint8_t is_high);