Bringing back AVR specific code, for time critical operations

This commit is contained in:
Thomas Mørch
2015-12-10 17:11:37 +01:00
parent 9ba8a9ba99
commit e2f45251a0
2 changed files with 57 additions and 24 deletions
+18
View File
@@ -279,11 +279,29 @@
#define ADDRESS_OTPMODE 18 // Sets the One-time-programmable mode
#define ADDRESS_SELECTOR 19 // Controls writability of Selector
/* Low level HW access macros */
/* function calls is not working, as it will have too much overhead */
#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)
#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)
#endif
class atsha204Class
{
private:
uint8_t device_pin;
#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);
uint8_t sha204c_check_crc(uint8_t *response);
void swi_set_signal_pin(uint8_t is_high);