|
26 | 26 |
|
27 | 27 | #include"SparkFun_ARGOS_ARTIC_R2_Arduino_Library.h"
|
28 | 28 |
|
29 |
| -boolean ARTIC_R2::begin(uint8_t user_CSPin, uint8_t user_RSTPin, uint8_t user_BOOTPin, uint8_t user_PWRENPin, uint8_t user_INT1Pin, uint8_t user_INT2Pin, uint8_t user_GAIN8Pin, uint8_t user_GAIN16Pin, uint32_t spiPortSpeed, SPIClass &spiPort) |
| 29 | +boolean ARTIC_R2::begin(int user_CSPin, int user_RSTPin, int user_BOOTPin, int user_PWRENPin, int user_INT1Pin, int user_INT2Pin, int user_GAIN8Pin, int user_GAIN16Pin, unsignedlong spiPortSpeed, SPIClass &spiPort) |
30 | 30 | {
|
31 | 31 | if (_printDebug == true)
|
32 | 32 | _debugPort->println(F("begin: ARTIC is starting..."));
|
@@ -83,8 +83,11 @@ boolean ARTIC_R2::begin(uint8_t user_CSPin, uint8_t user_RSTPin, uint8_t user_BO
|
83 | 83 | delay(ARTIC_R2_TX_POWER_ON_DELAY_MS);
|
84 | 84 | }
|
85 | 85 |
|
| 86 | +delay(ARTIC_R2_POWER_ON_DELAY_MS); // Make sure the power has been turned off for at least ARTIC_R2_POWER_ON_DELAY_MS |
| 87 | + |
86 | 88 | enableARTICpower(); // Enable power for the ARTIC R2
|
87 |
| -delay(ARTIC_R2_POWER_ON_DELAY_MS); |
| 89 | + |
| 90 | +delay(ARTIC_R2_POWER_ON_DELAY_MS); // Wait for ARTIC_R2_POWER_ON_DELAY_MS |
88 | 91 |
|
89 | 92 | // Now ramp up the TX gain to 24, if the _gain8 and _gain16 pins are defined, to reduce the current surge
|
90 | 93 | if ((_gain8 >= 0) && (_gain16 >= 0))
|
@@ -938,7 +941,7 @@ ARTIC_R2_MCU_Command_Result ARTIC_R2::sendConfigurationCommand(uint8_t command)
|
938 | 941 | else
|
939 | 942 | {
|
940 | 943 | clearInterrupts(3); // Clear both interrupts - because we probably should?
|
941 |
| -
|
| 944 | + |
942 | 945 | return ARTIC_R2_MCU_COMMAND_UNCERTAIN; // Hopefully this is impossible?
|
943 | 946 | }
|
944 | 947 | }
|
@@ -3986,68 +3989,3 @@ boolean ARTIC_R2::printAOPbulletin(bulletin_data_t bulletin, Stream &port)
|
3986 | 3989 | else
|
3987 | 3990 | returnfalse;
|
3988 | 3991 | }
|
3989 |
| - |
3990 |
| -// Write word to the external flash memory. |
3991 |
| -// *** This is pure guesswork! *** |
3992 |
| -// Returns true if write was attempted. |
3993 |
| -// Returns false if firmware version is < ARTIC006 |
3994 |
| -boolean ARTIC_R2::writeToFlashMemory(uint32_t word) |
3995 |
| -{ |
3996 |
| -// Check that we are using firmware ARTIC006 or later |
3997 |
| -if (ARTIC_R2_FIRMWARE_VERSION < 6) |
3998 |
| - { |
3999 |
| -if (_printDebug == true) |
4000 |
| - _debugPort->println("writeToFlashMemory: not supported by this firmware!"); |
4001 |
| - |
4002 |
| -returnfalse; // Abort! ARTIC004 does not support this. |
4003 |
| - } |
4004 |
| - |
4005 |
| -// Prepare a burstmode write to MEM_LOC_FLASH_PROG_BUFFER in XMEM |
4006 |
| - ARTIC_R2_Burstmode_Register burstmode; // Prepare the burstmode register configuration |
4007 |
| - burstmode.BURSTMODE_REGISTER = 0x00000000; // Clear all unused bits |
4008 |
| - burstmode.BURSTMODE_REGISTER_BITS.BURSTMODE_REG_SPI_ADDR = ARTIC_R2_BURSTMODE_REG_WRITE; |
4009 |
| - burstmode.BURSTMODE_REGISTER_BITS.BURSTMODE_START_ADDR = MEM_LOC_FLASH_PROG_BUFFER; |
4010 |
| - burstmode.BURSTMODE_REGISTER_BITS.BURST_R_RW_MODE = ARTIC_R2_WRITE_BURST; |
4011 |
| - burstmode.BURSTMODE_REGISTER_BITS.BURST_MEM_SEL = ARTIC_R2_X_MEMORY; |
4012 |
| - burstmode.BURSTMODE_REGISTER_BITS.BURST_MODE_ON = 1; |
4013 |
| - |
4014 |
| -configureBurstmodeRegister(burstmode); // Configure the burstmode register |
4015 |
| - |
4016 |
| -delayMicroseconds(_delay24cycles); // Wait for 24 clock cycles |
4017 |
| - |
4018 |
| -write24BitWord(word); // Write the word |
4019 |
| - |
4020 |
| -delayMicroseconds(_delay24cycles); // Wait for 24 clock cycles |
4021 |
| - |
4022 |
| -// Read the data back again and debug-print it |
4023 |
| - |
4024 |
| - burstmode.BURSTMODE_REGISTER = 0x00000000; // Clear all unused bits |
4025 |
| - burstmode.BURSTMODE_REGISTER_BITS.BURSTMODE_REG_SPI_ADDR = ARTIC_R2_BURSTMODE_REG_WRITE; |
4026 |
| - burstmode.BURSTMODE_REGISTER_BITS.BURSTMODE_START_ADDR = MEM_LOC_FLASH_PROG_BUFFER; |
4027 |
| - burstmode.BURSTMODE_REGISTER_BITS.BURST_R_RW_MODE = ARTIC_R2_READ_BURST; |
4028 |
| - burstmode.BURSTMODE_REGISTER_BITS.BURST_MEM_SEL = ARTIC_R2_X_MEMORY; |
4029 |
| - burstmode.BURSTMODE_REGISTER_BITS.BURST_MODE_ON = 1; |
4030 |
| - |
4031 |
| -configureBurstmodeRegister(burstmode); // Configure the burstmode register |
4032 |
| - |
4033 |
| -delayMicroseconds(_delay24cycles); // Wait for 24 clock cycles |
4034 |
| - |
4035 |
| -uint8_t buffer[3]; // Buffer for the SPI data |
4036 |
| -uint8_t *ptr = buffer; // Pointer to the buffer |
4037 |
| - |
4038 |
| -readMultipleWords(ptr, 24, 1); // Read 1 24-bit word |
4039 |
| - |
4040 |
| -delayMicroseconds(_delay24cycles); // Wait for 24 clock cycles - just in case we need to do another burst mode transfer straight away |
4041 |
| - |
4042 |
| -if (_printDebug == true) |
4043 |
| - { |
4044 |
| - _debugPort->print("writeToFlashMemory: MEM_LOC_FLASH_PROG_BUFFER contains 0x"); |
4045 |
| -if (buffer[0] < 0x10) _debugPort->print("0"); |
4046 |
| - _debugPort->print(buffer[0], HEX); |
4047 |
| -if (buffer[1] < 0x10) _debugPort->print("0"); |
4048 |
| - _debugPort->print(buffer[1], HEX); |
4049 |
| -if (buffer[2] < 0x10) _debugPort->print("0"); |
4050 |
| - _debugPort->println(buffer[2], HEX); |
4051 |
| - } |
4052 |
| -returntrue; |
4053 |
| -} |
0 commit comments