Merge pull request #288 from tbowmo/samd

added initializers for variables needed on AVR platform
This commit is contained in:
Thomas Mørch
2015-12-11 00:38:02 +01:00
3 changed files with 24 additions and 10 deletions
+2 -2
View File
@@ -116,7 +116,7 @@ void hwSleep(unsigned long ms) {
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!
interrupt = interrupt;
mode = mode;
@@ -124,7 +124,7 @@ bool hwSleep(uint8_t interrupt, uint8_t mode, unsigned long ms) {
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!
interrupt1 = interrupt1;
mode1 = mode1;
@@ -7,7 +7,19 @@
// As well as the bit value for each of those registers
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)
@@ -71,21 +83,21 @@ uint8_t ATSHA204Class::swi_send_bytes(uint8_t count, uint8_t *buffer)
{
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;
SHA204_POUT_HIGH() //*device_port_OUT |= device_pin;
SHA204_POUT_HIGH(); //*device_port_OUT |= device_pin;
delayMicroseconds(7*BIT_DELAY); //BIT_DELAY_7;
}
else
{
// 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;
SHA204_POUT_HIGH() //*device_port_OUT |= device_pin;
SHA204_POUT_HIGH(); //*device_port_OUT |= device_pin;
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;
SHA204_POUT_HIGH() //*device_port_OUT |= device_pin;
SHA204_POUT_HIGH(); //*device_port_OUT |= device_pin;
delayMicroseconds(5*BIT_DELAY); //BIT_DELAY_5;
}
}
@@ -240,7 +240,9 @@ class ATSHA204Class
{
private:
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);
uint8_t sha204c_check_crc(uint8_t *response);
void swi_set_signal_pin(uint8_t is_high);