Merge pull request #288 from tbowmo/samd
added initializers for variables needed on AVR platform
This commit is contained in:
@@ -116,7 +116,7 @@ void hwSleep(unsigned long ms) {
|
|||||||
ms = ms + 1;
|
ms = ms + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool hwSleep(uint8_t interrupt, uint8_t mode, unsigned long ms) {
|
int8_t hwSleep(uint8_t interrupt, uint8_t mode, unsigned long ms) {
|
||||||
// TODO: Not supported!
|
// TODO: Not supported!
|
||||||
interrupt = interrupt;
|
interrupt = interrupt;
|
||||||
mode = mode;
|
mode = mode;
|
||||||
@@ -124,7 +124,7 @@ bool hwSleep(uint8_t interrupt, uint8_t mode, unsigned long ms) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t hwSleep(uint8_t interrupt1, uint8_t mode1, uint8_t interrupt2, uint8_t mode2, unsigned long ms) {
|
int8_t hwSleep(uint8_t interrupt1, uint8_t mode1, uint8_t interrupt2, uint8_t mode2, unsigned long ms) {
|
||||||
// TODO: Not supported!
|
// TODO: Not supported!
|
||||||
interrupt1 = interrupt1;
|
interrupt1 = interrupt1;
|
||||||
mode1 = mode1;
|
mode1 = mode1;
|
||||||
|
|||||||
@@ -7,7 +7,19 @@
|
|||||||
// As well as the bit value for each of those registers
|
// As well as the bit value for each of those registers
|
||||||
ATSHA204Class::ATSHA204Class(uint8_t pin)
|
ATSHA204Class::ATSHA204Class(uint8_t pin)
|
||||||
{
|
{
|
||||||
device_pin = pin; // Find the bit value of the pin
|
#if defined(ARDUINO_ARCH_AVR)
|
||||||
|
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);
|
||||||
|
#else
|
||||||
|
device_pin = pin;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void ATSHA204Class::getSerialNumber(uint8_t * response)
|
void ATSHA204Class::getSerialNumber(uint8_t * response)
|
||||||
@@ -71,21 +83,21 @@ uint8_t ATSHA204Class::swi_send_bytes(uint8_t count, uint8_t *buffer)
|
|||||||
{
|
{
|
||||||
if (bit_mask & buffer[i])
|
if (bit_mask & buffer[i])
|
||||||
{
|
{
|
||||||
SHA204_POUT_LOW() //*device_port_OUT &= ~device_pin;
|
SHA204_POUT_LOW(); //*device_port_OUT &= ~device_pin;
|
||||||
delayMicroseconds(BIT_DELAY); //BIT_DELAY_1;
|
delayMicroseconds(BIT_DELAY); //BIT_DELAY_1;
|
||||||
SHA204_POUT_HIGH() //*device_port_OUT |= device_pin;
|
SHA204_POUT_HIGH(); //*device_port_OUT |= device_pin;
|
||||||
delayMicroseconds(7*BIT_DELAY); //BIT_DELAY_7;
|
delayMicroseconds(7*BIT_DELAY); //BIT_DELAY_7;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Send a zero bit.
|
// Send a zero bit.
|
||||||
SHA204_POUT_LOW() //*device_port_OUT &= ~device_pin;
|
SHA204_POUT_LOW(); //*device_port_OUT &= ~device_pin;
|
||||||
delayMicroseconds(BIT_DELAY); //BIT_DELAY_1;
|
delayMicroseconds(BIT_DELAY); //BIT_DELAY_1;
|
||||||
SHA204_POUT_HIGH() //*device_port_OUT |= device_pin;
|
SHA204_POUT_HIGH(); //*device_port_OUT |= device_pin;
|
||||||
delayMicroseconds(BIT_DELAY); //BIT_DELAY_1;
|
delayMicroseconds(BIT_DELAY); //BIT_DELAY_1;
|
||||||
SHA204_POUT_LOW() //*device_port_OUT &= ~device_pin;
|
SHA204_POUT_LOW(); //*device_port_OUT &= ~device_pin;
|
||||||
delayMicroseconds(BIT_DELAY); //BIT_DELAY_1;
|
delayMicroseconds(BIT_DELAY); //BIT_DELAY_1;
|
||||||
SHA204_POUT_HIGH() //*device_port_OUT |= device_pin;
|
SHA204_POUT_HIGH(); //*device_port_OUT |= device_pin;
|
||||||
delayMicroseconds(5*BIT_DELAY); //BIT_DELAY_5;
|
delayMicroseconds(5*BIT_DELAY); //BIT_DELAY_5;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -240,7 +240,9 @@ class ATSHA204Class
|
|||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
uint8_t device_pin;
|
uint8_t device_pin;
|
||||||
// volatile uint8_t *device_port_DDR, *device_port_OUT, *device_port_IN;
|
#ifdef ARDUINO_ARCH_AVR
|
||||||
|
volatile uint8_t *device_port_DDR, *device_port_OUT, *device_port_IN;
|
||||||
|
#endif
|
||||||
void sha204c_calculate_crc(uint8_t length, uint8_t *data, uint8_t *crc);
|
void sha204c_calculate_crc(uint8_t length, uint8_t *data, uint8_t *crc);
|
||||||
uint8_t sha204c_check_crc(uint8_t *response);
|
uint8_t sha204c_check_crc(uint8_t *response);
|
||||||
void swi_set_signal_pin(uint8_t is_high);
|
void swi_set_signal_pin(uint8_t is_high);
|
||||||
|
|||||||
Reference in New Issue
Block a user