0.2.1 ADC08XS

This commit is contained in:
Rob Tillaart 2024-03-03 13:37:27 +01:00
parent 3a7ca3fdd1
commit fbd91dd0b0
11 changed files with 124 additions and 11 deletions

View File

@ -6,7 +6,7 @@ jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: arduino/arduino-lint-action@v1
with:
library-manager: update

View File

@ -8,7 +8,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: 2.6

View File

@ -10,7 +10,7 @@ jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: json-syntax-check
uses: limitusus/json-syntax-check@v1
with:

View File

@ -1,7 +1,7 @@
//
// FILE: ADC08XS.cpp
// AUTHOR: Rob Tillaart
// VERSION: 0.2.0
// VERSION: 0.2.1
// DATE: 2024-01-13
// PURPOSE: Arduino library for ADC082S, ADC084S, ADC102S, ADC104S, ADC122S, ADC124S,
// 8, 10, 12 bits, 2 or 4 channel ADC (SPI).
@ -45,6 +45,7 @@ void ADC08XS::begin(uint8_t select)
{
_select = select;
pinMode(_select, OUTPUT);
// pulse
digitalWrite(_select, HIGH);
digitalWrite(_select, LOW);
digitalWrite(_select, HIGH);

View File

@ -2,7 +2,7 @@
//
// FILE: ADC08XS.h
// AUTHOR: Rob Tillaart
// VERSION: 0.2.0
// VERSION: 0.2.1
// DATE: 2024-01-13
// PURPOSE: Arduino library for ADC082S, ADC084S, ADC102S, ADC104S, ADC122S, ADC124S,
// 8, 10, 12 bits, 2 or 4 channel ADC (SPI).
@ -14,7 +14,7 @@
#include "SPI.h"
#define ADC08XS_LIB_VERSION (F("0.2.0"))
#define ADC08XS_LIB_VERSION (F("0.2.1"))
#ifndef __SPI_CLASS__

View File

@ -6,6 +6,11 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).
## [0.2.1] - 2024-03-03
- Fix #6, add example for SPI1
- update Github/actions to v4 (build-CI)
- minor edits
## [0.2.0] - 2024-01-19
- Fix #4, improve SPI dependency

View File

@ -123,7 +123,7 @@ All six classes have identical interfaces as the ADC082S.
- **ADC082S_MC(uint8_t dataIn, uint8_t dataOut, uint8_t clock)**
- **void begin(uint8_t select)** set SELECT or CS pin.
- **int16_t maxValue()** returns maxReading of ADC, => 255, 1023, 4095
depending on number of bits / class.
depending on number of bits of the actual ADC.
- **uint8_t maxChannel()** returns 2 or 4 depending on the class.
@ -132,7 +132,8 @@ depending on number of bits / class.
- **uint16_t read(uint8_t channel)** reads the value of the device.
The parameter channel must be 0,1,2,3, depending on device.
Invalid channels will always return zero 0.
- **int deltaRead(chanA, chanB)** read channel A and B and return the difference.
- **int deltaRead(uint8_t chanA, uint8_t chanB)** read channel A and B
and return the difference.
Note that the value can be negative if read(B) > read(A) or zero.
if chanA == chanB there will be two reads of the same channel just
a few microseconds apart, most often returning 0.
@ -146,7 +147,7 @@ please read datasheet of the ADC first to get optimal speed.
- **void lowPower()** put device in low power mode.
- **void wakeUp()** put device in normal power mode.
- **isLowPower()** returns true if in low power mode, so wakeUp needed().
- **bool isLowPower()** returns true if in low power mode, so wakeUp needed().
Alternative way to wake up the device is to
do a dummy **read()**.

View File

@ -0,0 +1,27 @@
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

View File

@ -0,0 +1,79 @@
//
// FILE: ADC08XS_read_SPI1.ino
// AUTHOR: Rob Tillaart
// PURPOSE: demo
// URL: https://github.com/RobTillaart/ADC08XS
#include "ADC08XS.h"
ADC082S adc01(&SPI1); // use HWSPI
ADC124S adc02(5, 6, 7); // use SWSPI
uint32_t start, stop;
void setup()
{
Serial.begin(115200);
Serial.println(__FILE__);
Serial.print("ADC08XS_LIB_VERSION: ");
Serial.println(ADC08XS_LIB_VERSION);
SPI1.begin();
adc01.begin(10);
adc02.begin(4);
Serial.println();
Serial.println("ADC\tMAXVALUE");
Serial.print("adc01\t");
Serial.println(adc01.maxValue());
delay(10);
start = micros();
uint16_t val = adc01.read(0);
stop = micros();
Serial.print("hwspi:\t");
Serial.print(stop - start);
Serial.print("\t");
Serial.println(val);
Serial.print("adc02\t");
Serial.println(adc02.maxValue());
delay(10);
start = micros();
val = adc02.read(0);
stop = micros();
Serial.print("swspi:\t");
Serial.print(stop - start);
Serial.print("\t");
Serial.println(val);
Serial.println();
}
void loop()
{
uint16_t val0 = adc01.read(0);
uint16_t val1 = adc01.read(1);
Serial.print("adc01:\t");
Serial.print(val0);
Serial.print("\t");
Serial.println(val1);
Serial.print("adc02:\t");
for (uint8_t ch = 0 ; ch < adc02.maxChannel(); ch++)
{
uint16_t val = adc02.read(ch);
Serial.print(val);
Serial.print("\t");
}
Serial.println();
delay(5000);
}
// -- END OF FILE --

View File

@ -15,7 +15,7 @@
"type": "git",
"url": "https://github.com/RobTillaart/ADC08XS.git"
},
"version": "0.2.0",
"version": "0.2.1",
"license": "MIT",
"frameworks": "*",
"platforms": "*",

View File

@ -1,5 +1,5 @@
name=ADC08XS
version=0.2.0
version=0.2.1
author=Rob Tillaart <rob.tillaart@gmail.com>
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
sentence=Arduino library for ADC08XS 8, 10, 12 bit ADC (SPI), 2 or 4 channel.