Updated core atsha204 driver for avr/samd compatability, renamed macro names in fat library
This commit is contained in:
@@ -89,10 +89,10 @@ void atsha204Class::swi_set_signal_pin(uint8_t is_high)
|
||||
{
|
||||
SHA204_SET_OUTPUT();
|
||||
if (is_high) {
|
||||
SHA204_SET_HIGH();
|
||||
SHA204_POUT_HIGH();
|
||||
}
|
||||
else {
|
||||
SHA204_SET_LOW();
|
||||
SHA204_POUT_LOW();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -105,7 +105,7 @@ uint8_t atsha204Class::swi_send_bytes(uint8_t count, uint8_t *buffer)
|
||||
noInterrupts(); //swi_disable_interrupts();
|
||||
|
||||
// Set signal pin as output.
|
||||
SHA204_SET_HIGH();
|
||||
SHA204_POUT_HIGH();
|
||||
SHA204_SET_OUTPUT();
|
||||
// Wait turn around time.
|
||||
delayMicroseconds(RX_TX_DELAY); //RX_TX_DELAY;
|
||||
@@ -116,21 +116,21 @@ uint8_t atsha204Class::swi_send_bytes(uint8_t count, uint8_t *buffer)
|
||||
{
|
||||
if (bit_mask & buffer[i])
|
||||
{
|
||||
SHA204_SET_LOW();
|
||||
SHA204_POUT_LOW();
|
||||
delayMicroseconds(BIT_DELAY); //BIT_DELAY_1;
|
||||
SHA204_SET_HIGH();
|
||||
SHA204_POUT_HIGH();
|
||||
delayMicroseconds(7*BIT_DELAY); //BIT_DELAY_7;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Send a zero bit.
|
||||
SHA204_SET_LOW();
|
||||
SHA204_POUT_LOW();
|
||||
delayMicroseconds(BIT_DELAY); //BIT_DELAY_1;
|
||||
SHA204_SET_HIGH();
|
||||
SHA204_POUT_HIGH();
|
||||
delayMicroseconds(BIT_DELAY); //BIT_DELAY_1;
|
||||
SHA204_SET_LOW();
|
||||
SHA204_POUT_LOW();
|
||||
delayMicroseconds(BIT_DELAY); //BIT_DELAY_1;
|
||||
SHA204_SET_HIGH();
|
||||
SHA204_POUT_HIGH();
|
||||
delayMicroseconds(5*BIT_DELAY); //BIT_DELAY_5;
|
||||
}
|
||||
}
|
||||
@@ -174,7 +174,7 @@ uint8_t atsha204Class::swi_receive_bytes(uint8_t count, uint8_t *buffer)
|
||||
while (--timeout_count > 0)
|
||||
{
|
||||
// Wait for falling edge.
|
||||
if (SHA204_READ_PIN() == 0)
|
||||
if (SHA204_PIN_READ() == 0)
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -187,7 +187,7 @@ uint8_t atsha204Class::swi_receive_bytes(uint8_t count, uint8_t *buffer)
|
||||
do
|
||||
{
|
||||
// Wait for rising edge.
|
||||
if (SHA204_READ_PIN() != 0)
|
||||
if (SHA204_PIN_READ() != 0)
|
||||
{
|
||||
// For an Atmel microcontroller this might be faster than "pulse_count++".
|
||||
pulse_count = 1;
|
||||
@@ -210,7 +210,7 @@ uint8_t atsha204Class::swi_receive_bytes(uint8_t count, uint8_t *buffer)
|
||||
// Detect possible edge indicating zero bit.
|
||||
do
|
||||
{
|
||||
if (SHA204_READ_PIN() == 0)
|
||||
if (SHA204_PIN_READ() == 0)
|
||||
{
|
||||
// For an Atmel microcontroller this might be faster than "pulse_count++".
|
||||
pulse_count = 2;
|
||||
@@ -224,7 +224,7 @@ uint8_t atsha204Class::swi_receive_bytes(uint8_t count, uint8_t *buffer)
|
||||
{
|
||||
do
|
||||
{
|
||||
if (SHA204_READ_PIN() != 0)
|
||||
if (SHA204_PIN_READ() != 0)
|
||||
break;
|
||||
} while (timeout_count-- > 0);
|
||||
}
|
||||
|
||||
@@ -284,15 +284,15 @@
|
||||
#if !defined(ARDUINO_ARCH_AVR) // For everything else than AVR use pinMode / digitalWrite
|
||||
#define SHA204_SET_OUTPUT() pinMode(device_pin, OUTPUT)
|
||||
#define SHA204_SET_INPUT() pinMode(device_pin, INPUT)
|
||||
#define SHA204_SET_HIGH() digitalWrite(device_pin, HIGH)
|
||||
#define SHA204_SET_LOW() digitalWrite(device_pin, LOW)
|
||||
#define SHA204_READ_PIN() digitalRead(device_pin)
|
||||
#define SHA204_POUT_HIGH() digitalWrite(device_pin, HIGH)
|
||||
#define SHA204_POUT_LOW() digitalWrite(device_pin, LOW)
|
||||
#define SHA204_PIN_READ() digitalRead(device_pin)
|
||||
#else
|
||||
#define SHA204_SET_INPUT() *device_port_DDR &= ~device_pin
|
||||
#define SHA204_SET_OUTPUT() *device_port_DDR |= device_pin
|
||||
#define SHA204_SET_HIGH() *device_port_OUT |= device_pin
|
||||
#define SHA204_SET_LOW() *device_port_OUT &= ~device_pin
|
||||
#define SHA204_READ_PIN() (*device_port_IN & device_pin)
|
||||
#define SHA204_POUT_HIGH() *device_port_OUT |= device_pin
|
||||
#define SHA204_POUT_LOW() *device_port_OUT &= ~device_pin
|
||||
#define SHA204_PIN_READ() (*device_port_IN & device_pin)
|
||||
#endif
|
||||
|
||||
class atsha204Class
|
||||
|
||||
Reference in New Issue
Block a user