|
7 | 7 | // As well as the bit value for each of those registers
|
8 | 8 | ATSHA204Class::ATSHA204Class(uint8_t pin)
|
9 | 9 | {
|
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 |
11 | 23 | }
|
12 | 24 |
|
13 | 25 | void ATSHA204Class::getSerialNumber(uint8_t * response)
|
@@ -71,21 +83,21 @@ uint8_t ATSHA204Class::swi_send_bytes(uint8_t count, uint8_t *buffer)
|
71 | 83 | {
|
72 | 84 | if (bit_mask & buffer[i])
|
73 | 85 | {
|
74 |
| - SHA204_POUT_LOW() //*device_port_OUT &= ~device_pin; |
| 86 | + SHA204_POUT_LOW(); //*device_port_OUT &= ~device_pin; |
75 | 87 | delayMicroseconds(BIT_DELAY); //BIT_DELAY_1;
|
76 |
| - SHA204_POUT_HIGH() //*device_port_OUT |= device_pin; |
| 88 | + SHA204_POUT_HIGH(); //*device_port_OUT |= device_pin; |
77 | 89 | delayMicroseconds(7*BIT_DELAY); //BIT_DELAY_7;
|
78 | 90 | }
|
79 | 91 | else
|
80 | 92 | {
|
81 | 93 | // Send a zero bit.
|
82 |
| - SHA204_POUT_LOW() //*device_port_OUT &= ~device_pin; |
| 94 | + SHA204_POUT_LOW(); //*device_port_OUT &= ~device_pin; |
83 | 95 | delayMicroseconds(BIT_DELAY); //BIT_DELAY_1;
|
84 |
| - SHA204_POUT_HIGH() //*device_port_OUT |= device_pin; |
| 96 | + SHA204_POUT_HIGH(); //*device_port_OUT |= device_pin; |
85 | 97 | delayMicroseconds(BIT_DELAY); //BIT_DELAY_1;
|
86 |
| - SHA204_POUT_LOW() //*device_port_OUT &= ~device_pin; |
| 98 | + SHA204_POUT_LOW(); //*device_port_OUT &= ~device_pin; |
87 | 99 | delayMicroseconds(BIT_DELAY); //BIT_DELAY_1;
|
88 |
| - SHA204_POUT_HIGH() //*device_port_OUT |= device_pin; |
| 100 | + SHA204_POUT_HIGH(); //*device_port_OUT |= device_pin; |
89 | 101 | delayMicroseconds(5*BIT_DELAY); //BIT_DELAY_5;
|
90 | 102 | }
|
91 | 103 | }
|
|
0 commit comments