Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
SRGDamia1 committed Aug 29, 2019
2 parents d75c5b9 + a6948d5 commit 00ba220
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 31 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ Temporary Items


# Atom / PlatformIO
.pio
.pioenvs
.piolibdeps
.clang_complete
Expand All @@ -59,5 +60,4 @@ lib/readme.txt
include/readme.txt
platformio.ini
.vscode

examples/debug_print/
4 changes: 2 additions & 2 deletions examples/d_simple_logger/d_simple_logger.ino
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ byte charToDec(char i){
// maps a decimal number between 0 and 61 (inclusive) to
// allowable address characters '0'-'9', 'a'-'z', 'A'-'Z',
char decToChar(byte i){
if((i >= 0) && (i <= 9)) return i + '0';
if(i <= 9) return i + '0';
if((i >= 10) && (i <= 36)) return i + 'a' - 10;
if((i >= 37) && (i <= 62)) return i + 'A' - 37;
else return i;
Expand Down Expand Up @@ -180,7 +180,7 @@ void takeMeasurement(char i){
command += i;
command += "D0!"; // SDI-12 command to get data [address][D][dataOption][!]
mySDI12.sendCommand(command);
while(!mySDI12.available()>1); // wait for acknowlegement
while(!(mySDI12.available()>1)){} // wait for acknowlegement
delay(300); // let the data transfer
printBufferToScreen();
mySDI12.clearBuffer();
Expand Down
4 changes: 2 additions & 2 deletions examples/e_simple_parsing/e_simple_parsing.ino
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ byte charToDec(char i){
// maps a decimal number between 0 and 61 (inclusive) to
// allowable address characters '0'-'9', 'a'-'z', 'A'-'Z',
char decToChar(byte i){
if((i >= 0) && (i <= 9)) return i + '0';
if(i <= 9) return i + '0';
if((i >= 10) && (i <= 36)) return i + 'a' - 10;
if((i >= 37) && (i <= 62)) return i + 'A' - 37;
else return i;
Expand Down Expand Up @@ -231,7 +231,7 @@ void takeMeasurement(char i){
command += i;
command += "D0!"; // SDI-12 command to get data [address][D][dataOption][!]
mySDI12.sendCommand(command);
while(!mySDI12.available()>1); // wait for acknowlegement
while(!(mySDI12.available()>1)){} // wait for acknowlegement
delay(300); // let the data transfer
printBufferToScreen();
mySDI12.clearBuffer();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ byte charToDec(char i){
// maps a decimal number between 0 and 61 (inclusive) to
// allowable address characters '0'-'9', 'a'-'z', 'A'-'Z',
char decToChar(byte i){
if((i >= 0) && (i <= 9)) return i + '0';
if(i <= 9) return i + '0';
if((i >= 10) && (i <= 36)) return i + 'a' - 10;
if((i >= 37) && (i <= 62)) return i + 'A' - 37;
else return i;
Expand Down Expand Up @@ -143,7 +143,7 @@ void takeMeasurement(char i){
command += i;
command += "D0!"; // SDI-12 command to get data [address][D][dataOption][!]
mySDI12.sendCommand(command);
while(!mySDI12.available()>1); // wait for acknowlegement
while(!(mySDI12.available()>1)){} // wait for acknowlegement
delay(300); // let the data transfer
printBufferToScreen();
mySDI12.clearBuffer();
Expand Down
4 changes: 2 additions & 2 deletions examples/k_concurrent_logger/k_concurrent_logger.ino
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ byte charToDec(char i){
// maps a decimal number between 0 and 61 (inclusive) to
// allowable address characters '0'-'9', 'a'-'z', 'A'-'Z',
char decToChar(byte i){
if((i >= 0) && (i <= 9)) return i + '0';
if(i <= 9) return i + '0';
if((i >= 10) && (i <= 36)) return i + 'a' - 10;
if((i >= 37) && (i <= 62)) return i + 'A' - 37;
else return i;
Expand Down Expand Up @@ -189,7 +189,7 @@ void getResults(char i){
// Serial.print(">>>");
// Serial.println(command);

while(!mySDI12.available()>1); // wait for acknowlegement
while(!(mySDI12.available()>1)){} // wait for acknowlegement
delay(300); // let the data transfer
printBufferToScreen();
mySDI12.clearBuffer();
Expand Down
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Arduino-SDI-12",
"version": "1.3.5",
"version": "1.3.6",
"keywords": "SDI-12, sdi12, communication, bus, sensor, Decagon",
"description": "Arduino library for SDI-12 communications to a wide variety of environmental sensors.",
"repository":
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=Arduino-SDI-12
version=1.3.5
version=1.3.6
author=Kevin M. Smith <[email protected]>, Shannon Hicks <[email protected]>
maintainer=Sara Damiano <[email protected]>
sentence=Arduino library for SDI-12 communications to a wide variety of environmental sensors.
Expand Down
7 changes: 7 additions & 0 deletions src/SDI12.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -616,6 +616,13 @@ void SDI12::setPinInterrupts(bool enable)
}
// We don't detach the function from the interrupt for AVR processors
}
#else
if (enable) {
return;
}
else {
return;
}
#endif
}

Expand Down
48 changes: 28 additions & 20 deletions src/SDI12_boards.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,33 +168,41 @@ SDI12Timer::SDI12Timer(){}
// Select generic clock generator 4 (Arduino core uses 0, 1, and 3. RTCZero uses 2)
// Many examples use clock generator 4.. consider yourself warned!
// I would use a higher clock number, but some of the cores don't include them for some reason
REG_GCLK_GENDIV = GCLK_GENDIV_ID(4) | // Select Generic Clock Generator 4
GCLK_GENDIV_DIV(3) ; // Divide the clock source by divisor 3
while (GCLK->STATUS.bit.SYNCBUSY); // Wait for synchronization
REG_GCLK_GENDIV =
GCLK_GENDIV_ID(4) | // Select Generic Clock Generator 4
GCLK_GENDIV_DIV(3); // Divide the clock source by divisor 3
while (GCLK->STATUS.bit.SYNCBUSY)
; // Wait for synchronization

// Write the generic clock generator 4 configuration
REG_GCLK_GENCTRL = GCLK_GENCTRL_ID(4) | // Select GCLK4
GCLK_GENCTRL_SRC_DFLL48M | // Select the 48MHz clock source
GCLK_GENCTRL_IDC & // Set the duty cycle to 50/50 HIGH/LOW
~GCLK_GENCTRL_RUNSTDBY & // Do NOT run in stand by
~GCLK_GENCTRL_DIVSEL | // Divide clock source by GENDIV.DIV: 48MHz/3=16MHz
GCLK_GENCTRL_GENEN; // Enable the generic clock clontrol
while (GCLK->STATUS.bit.SYNCBUSY); // Wait for synchronization
REG_GCLK_GENCTRL =
(GCLK_GENCTRL_ID(4) | // Select GCLK4
GCLK_GENCTRL_SRC_DFLL48M | // Select the 48MHz clock source
GCLK_GENCTRL_IDC | // Set the duty cycle to 50/50 HIGH/LOW
GCLK_GENCTRL_GENEN) & // Enable the generic clock clontrol
~GCLK_GENCTRL_RUNSTDBY & // Do NOT run in stand by
~GCLK_GENCTRL_DIVSEL; // Divide clock source by GENDIV.DIV: 48MHz/3=16MHz
// ^^ & ~ for DIVSEL because not not divided
while (GCLK->STATUS.bit.SYNCBUSY); // Wait for synchronization

// Feed GCLK4 to TC3 (also feeds to TCC2, the two must have the same source)
// TC3 (and TCC2) seem to be free, so I'm using them
// TC4 is used by Tone, TC5 is tied to the same clock as TC4
// TC6 and TC7 are not available on all boards
REG_GCLK_CLKCTRL = GCLK_CLKCTRL_GEN_GCLK4 | // Select Generic Clock Generator 4
GCLK_CLKCTRL_CLKEN | // Enable the generic clock generator
GCLK_CLKCTRL_ID_TCC2_TC3; // Feed the Generic Clock Generator 4 to TCC2 and TC3
while (GCLK->STATUS.bit.SYNCBUSY); // Wait for synchronization

REG_TC3_CTRLA |= TC_CTRLA_PRESCALER_DIV1024 | // Set prescaler to 1024, 16MHz/1024 = 15.625kHz
TC_CTRLA_WAVEGEN_NFRQ | // Put the timer TC3 into normal frequency (NFRQ) mode
TC_CTRLA_MODE_COUNT8 | // Put the timer TC3 into 8-bit mode
TC_CTRLA_ENABLE; // Enable TC3
while (TC3->COUNT16.STATUS.bit.SYNCBUSY); // Wait for synchronization
REG_GCLK_CLKCTRL =
GCLK_CLKCTRL_GEN_GCLK4 | // Select Generic Clock Generator 4
GCLK_CLKCTRL_CLKEN | // Enable the generic clock generator
GCLK_CLKCTRL_ID_TCC2_TC3; // Feed the Generic Clock Generator 4 to TCC2 and TC3
while (GCLK->STATUS.bit.SYNCBUSY)
; // Wait for synchronization

REG_TC3_CTRLA |=
TC_CTRLA_PRESCALER_DIV1024 | // Set prescaler to 1024, 16MHz/1024 = 15.625kHz
TC_CTRLA_WAVEGEN_NFRQ | // Put the timer TC3 into normal frequency (NFRQ) mode
TC_CTRLA_MODE_COUNT8 | // Put the timer TC3 into 8-bit mode
TC_CTRLA_ENABLE; // Enable TC3
while (TC3->COUNT16.STATUS.bit.SYNCBUSY)
; // Wait for synchronization
}
// NOT resetting the SAMD timer settings
void SDI12Timer::resetSDI12TimerPrescale(void)
Expand Down

0 comments on commit 00ba220

Please sign in to comment.