-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
19 changed files
with
735 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
platforms: | ||
rpipico: | ||
board: rp2040:rp2040:rpipico | ||
package: rp2040:rp2040 | ||
gcc: | ||
features: | ||
defines: | ||
- ARDUINO_ARCH_RP2040 | ||
warnings: | ||
flags: | ||
|
||
packages: | ||
rp2040:rp2040: | ||
url: https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json | ||
|
||
compile: | ||
# Choosing to run compilation tests on 2 different Arduino platforms | ||
platforms: | ||
- uno | ||
# - due | ||
# - zero | ||
# - leonardo | ||
- m4 | ||
- esp32 | ||
- esp8266 | ||
# - mega2560 | ||
- rpipico | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# These are supported funding model platforms | ||
|
||
github: RobTillaart | ||
custom: "https://www.paypal.me/robtillaart" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
name: Arduino-lint | ||
|
||
on: [push, pull_request] | ||
jobs: | ||
lint: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 5 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: arduino/arduino-lint-action@v1 | ||
with: | ||
library-manager: update | ||
compliance: strict |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
name: Arduino CI | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
runTest: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 20 | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: ruby/setup-ruby@v1 | ||
with: | ||
ruby-version: 2.6 | ||
- run: | | ||
gem install arduino_ci | ||
arduino_ci.rb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
name: JSON check | ||
|
||
on: | ||
push: | ||
paths: | ||
- '**.json' | ||
pull_request: | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 5 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: json-syntax-check | ||
uses: limitusus/json-syntax-check@v2 | ||
with: | ||
pattern: "\\.json$" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
// | ||
// FILE: AD7367.cpp | ||
// AUTHOR: Rob Tillaart | ||
// VERSION: 0.1.0 | ||
// DATE: 2025-01-10 | ||
// PURPOSE: Arduino library for the AD7367, 2 channel simultaneous sampling 14 bit ADC. | ||
|
||
|
||
#include "AD7367.h" | ||
|
||
|
||
AD7367::AD7367(uint8_t select, uint8_t clock, uint8_t convert, uint8_t busy, uint8_t data0, uint8_t data1) | ||
{ | ||
_type = 67; | ||
_bits = 14; | ||
_select = select; | ||
_clock = clock; | ||
_convert = convert; | ||
_busy = busy; | ||
_data0 = data0; | ||
_data1 = data1; | ||
} | ||
|
||
// sets internal state | ||
void AD7367::begin() | ||
{ | ||
pinMode(_select, OUTPUT); | ||
pinMode(_clock, OUTPUT); | ||
pinMode(_convert, OUTPUT); | ||
pinMode(_busy, INPUT); | ||
pinMode(_data0, INPUT); | ||
pinMode(_data1, INPUT); | ||
|
||
digitalWrite(_select, HIGH); | ||
digitalWrite(_clock, HIGH); | ||
digitalWrite(_convert, HIGH); | ||
} | ||
|
||
|
||
uint8_t AD7367::getType() | ||
{ | ||
return _type; | ||
} | ||
|
||
|
||
int AD7367::read() | ||
{ | ||
// simulation | ||
// _value[0] = random(16384); // 14 bits = 16383, 12 bits = 4095 | ||
// _value[1] = random(16384); | ||
|
||
// datasheet page 07 + 20 | ||
// trigger conversion | ||
triggerConversion(); | ||
// wait for conversion to be done | ||
while (conversionBusy()); | ||
return readAsync(); | ||
} | ||
|
||
|
||
void AD7367::triggerConversion() | ||
{ | ||
// Trigger conversion by 10 ns pulse. | ||
// might need a delayMicroseconds(1); on very fast processors. | ||
// needs a configuration flag, although checking the flag is already 10 ns. | ||
// Are NOP's portable? | ||
digitalWrite(_convert, LOW); | ||
// delayMicroseconds(1); | ||
digitalWrite(_convert, HIGH); | ||
} | ||
|
||
|
||
bool AD7367::conversionBusy() | ||
{ | ||
return digitalRead(_busy) == HIGH; | ||
} | ||
|
||
|
||
bool AD7367::conversionReady() | ||
{ | ||
return digitalRead(_busy) == LOW; | ||
} | ||
|
||
|
||
int AD7367::readAsync() | ||
{ | ||
digitalWrite(_select, LOW); | ||
// use local variables for clocking | ||
int d0 = 0; | ||
int d1 = 0; | ||
// clock in the bits | ||
for (int i = 0; i < _bits; i++) | ||
{ | ||
digitalWrite(_clock, LOW); | ||
digitalWrite(_clock, HIGH); | ||
d0 <<= 1; | ||
d0 |= digitalRead(_data0); | ||
d1 <<= 1; | ||
d1 |= digitalRead(_data1); | ||
} | ||
_value[0] = d0; | ||
_value[1] = d1; | ||
return 0; | ||
} | ||
|
||
|
||
int AD7367::getValue(uint8_t channel) | ||
{ | ||
return _value[channel]; | ||
} | ||
|
||
|
||
int AD7367::getBits() | ||
{ | ||
return _bits; | ||
} | ||
|
||
|
||
////////////////////////////////////////////////////////////////// | ||
// | ||
// PROTECTED | ||
// | ||
|
||
|
||
|
||
///////////////////////////////////////////////////////////////////////////// | ||
// | ||
// DERIVED CLASS AD7366 | ||
// | ||
AD7366::AD7366(uint8_t select, uint8_t clock, uint8_t convert, uint8_t busy, uint8_t data0, uint8_t data1) | ||
:AD7367(select, clock, convert, busy, data0, data1) | ||
{ | ||
_type = 66; | ||
_bits = 12; | ||
} | ||
|
||
|
||
// -- END OF FILE -- | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
#pragma once | ||
// | ||
// FILE: AD7367.h | ||
// AUTHOR: Rob Tillaart | ||
// VERSION: 0.1.0 | ||
// DATE: 2025-01-10 | ||
// PURPOSE: Arduino library for the AD7367, 2 channel simultaneous sampling 14 bit ADC. | ||
// Also AD7366 == 12 bits. | ||
|
||
|
||
#include "Arduino.h" | ||
|
||
#define AD7367_LIB_VERSION (F("0.1.0")) | ||
|
||
|
||
class AD7367 | ||
{ | ||
public: | ||
// CONSTRUCTOR | ||
// pins to set. | ||
AD7367(uint8_t select, uint8_t clock, uint8_t convert, uint8_t busy, uint8_t data0, uint8_t data1); | ||
|
||
void begin(); | ||
uint8_t getType(); // returns 66 or 67 | ||
int getBits(); // returns 12 or 14 | ||
|
||
// READ | ||
int read(); | ||
// READ ASYNC | ||
void triggerConversion(); | ||
bool conversionBusy(); | ||
bool conversionReady(); | ||
int readAsync(); | ||
// GET VALUE | ||
int getValue(uint8_t channel); // channel = 0 or 1 | ||
|
||
|
||
protected: | ||
uint8_t _type; | ||
uint8_t _bits; | ||
uint8_t _select; | ||
uint8_t _clock; | ||
uint8_t _convert; | ||
uint8_t _busy; | ||
uint8_t _data0; | ||
uint8_t _data1; | ||
int16_t _value[2] = {0, 0}; | ||
}; | ||
|
||
|
||
|
||
///////////////////////////////////////////////////////////////////////////// | ||
// | ||
// DERIVED CLASS AD7366 | ||
// | ||
class AD7366 : public AD7367 | ||
{ | ||
public: | ||
AD7366(uint8_t select, uint8_t clock, uint8_t convert, uint8_t busy, uint8_t data0, uint8_t data1); | ||
}; | ||
|
||
|
||
// -- END OF FILE -- | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Change Log AD7367 | ||
|
||
All notable changes to this project will be documented in this file. | ||
|
||
The format is based on [Keep a Changelog](http://keepachangelog.com/) | ||
and this project adheres to [Semantic Versioning](http://semver.org/). | ||
|
||
|
||
## [0.1.0] - 2025-01-10 | ||
- initial version | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.