0.1.0 ADG732

This commit is contained in:
Rob Tillaart 2023-07-25 20:54:26 +02:00
parent 7d5ef73432
commit 4b2d02895d
14 changed files with 488 additions and 0 deletions

View File

@ -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

4
libraries/ADG732/.github/FUNDING.yml vendored Normal file
View File

@ -0,0 +1,4 @@
# These are supported funding model platforms
github: RobTillaart

View File

@ -0,0 +1,13 @@
name: Arduino-lint
on: [push, pull_request]
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: arduino/arduino-lint-action@v1
with:
library-manager: update
compliance: strict

View File

@ -0,0 +1,17 @@
---
name: Arduino CI
on: [push, pull_request]
jobs:
runTest:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ruby/setup-ruby@v1
with:
ruby-version: 2.6
- run: |
gem install arduino_ci
arduino_ci.rb

View File

@ -0,0 +1,18 @@
name: JSON check
on:
push:
paths:
- '**.json'
pull_request:
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: json-syntax-check
uses: limitusus/json-syntax-check@v1
with:
pattern: "\\.json$"

109
libraries/ADG732/ADG732.h Normal file
View File

@ -0,0 +1,109 @@
#pragma once
//
// FILE: ADG732.h
// AUTHOR: Rob Tillaart
// DATE: 2023-07-24
// VERSION: 0.1.0
// PURPOSE: Arduino library for ADG732 - 32 to 1 channel multiplexer
// URL: https://github.com/RobTillaart/ADG732
#include "Arduino.h"
#define ADG732_LIB_VERSION (F("0.1.0"))
#define ADG732_ALLOFF 0x80
class ADG732
{
public:
ADG732(uint8_t A, uint8_t B, uint8_t C, uint8_t D, uint8_t E, uint8_t CS, uint8_t EN, uint8_t WR)
{
uint8_t arr[5] = { A, B, C, D, E };
ADG732(arr, CS, EN, WR);
}
explicit ADG732(uint8_t address[5], uint8_t CS, uint8_t EN, uint8_t WR)
{
for (int i = 0; i < 5; i++)
{
_addr[i] = address[i];
pinMode(_addr[i], OUTPUT);
digitalWrite(_addr[i], LOW);
}
_CS = CS;
_EN = EN;
_WR = WR;
pinMode(_CS, OUTPUT);
pinMode(_EN, OUTPUT);
pinMode(_WR, OUTPUT);
digitalWrite(_CS, HIGH);
digitalWrite(_EN, HIGH);
digitalWrite(_WR, HIGH);
// default all off.
_channel = ADG732_ALLOFF;
}
void setChannel(uint8_t channel)
{
_channel = channel & 0x1F;
write(_channel, LOW);
}
uint8_t getChannel()
{
return _channel;
}
uint8_t channelCount()
{
return 32;
}
void allOff()
{
_channel = ADG732_ALLOFF;
write(_channel, HIGH);
}
private:
void write(uint8_t data, uint8_t en)
{
digitalWrite(_CS, LOW);
digitalWrite(_WR, LOW);
digitalWrite(_EN, en);
if (en == LOW)
{
uint8_t mask = 0x01;
for (int i = 0; i < 5; i++)
{
digitalWrite(_addr[i], ((data & mask) > 0));
mask <<= 1;
}
digitalWrite(_EN, HIGH);
}
digitalWrite(_WR, HIGH);
digitalWrite(_CS, HIGH);
}
uint8_t _addr[5];
uint8_t _CS;
uint8_t _EN;
uint8_t _WR;
uint8_t _channel;
};
// -- END OF FILE --

View File

@ -0,0 +1,10 @@
# Change Log ADG732
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] - 2023-07-25
- initial version

21
libraries/ADG732/LICENSE Normal file
View File

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2023-2023 Rob Tillaart
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@ -0,0 +1,78 @@
[![Arduino CI](https://github.com/RobTillaart/ADG732/workflows/Arduino%20CI/badge.svg)](https://github.com/marketplace/actions/arduino_ci)
[![Arduino-lint](https://github.com/RobTillaart/ADG732/actions/workflows/arduino-lint.yml/badge.svg)](https://github.com/RobTillaart/ADG732/actions/workflows/arduino-lint.yml)
[![JSON check](https://github.com/RobTillaart/ADG732/actions/workflows/jsoncheck.yml/badge.svg)](https://github.com/RobTillaart/ADG732/actions/workflows/jsoncheck.yml)
[![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/RobTillaart/ADG732/blob/master/LICENSE)
[![GitHub release](https://img.shields.io/github/release/RobTillaart/ADG732.svg?maxAge=3600)](https://github.com/RobTillaart/ADG732/releases)
# ADG732
Arduino library for ADG732 - 32 to 1 channel multiplexer.
## Description
**Experimental**
ADG732 is an Arduino class that controls a 32 to 1 multiplexers
over a **parallel** interface.
Only one of the 32 channels can be connected at the same time.
The library also support to set them all off (17th state).
On power-up, all switches are in the OFF state.
This library can be used e.g. to connect 32 analog devices to
one analog port, or to select between 32 DHT22 sensors.
No tests with hardware have been done yet, so use with care.
Feedback welcome!
#### Related
- https://github.com/RobTillaart/HC4051 (1x8 mux)
- https://github.com/RobTillaart/HC4052 (2x8 mux)
- https://github.com/RobTillaart/HC4053 (3x2 mux)
- https://github.com/RobTillaart/HC4067 (1x16 mux)
- https://github.com/RobTillaart/ADG725 (2x16 mux)
- https://github.com/RobTillaart/ADG732 (2x16 mux)
- https://github.com/RobTillaart/ADG731 (1x32 mux)
- https://github.com/RobTillaart/ADG732 (1x32 mux)
## Interface
```cpp
#include "ADG732.h"
```
- **ADG732(uint8_t A, uint8_t B, uint8_t C, uint8_t D, uint8_t E, uint8_t CS, uint8_t EN, uint8_t WR)** constructor.
- **ADG732(uint8_t address[5], uint8_t CS, uint8_t EN, uint8_t WR)** constructor.
- **void setChannel(uint8_t channel)** set the current channel for both A and B.
Valid values for channel are 0..31.
- **uint8_t getChannel()** get last set channel A == 0..31 or ADG732_ALLOFF.
- **uint8_t channelCount()** returns 32 for ADG732.
- **void allOff()** sets all channels to OFF, none selected.
## Future
#### Must
- improve documentation
- insert schematic
- test with hardware
- keep in sync with ADG731 (interface)
#### Should
- add examples
- check performance
#### Could
#### Wont

View File

@ -0,0 +1,55 @@
//
// FILE: ADG732_demo.ino
// AUTHOR: Rob Tillaart
// PURPOSE: minimal sketch
// URL: https://github.com/RobTillaart/ADG732
#include "ADG732.h"
ADG732 ADG(4, 5, 6, 7, 8, 9, 10, 11);
uint32_t start, stop;
void setup()
{
Serial.begin(115200);
Serial.print("ADG732_LIB_VERSION: ");
Serial.println(ADG732_LIB_VERSION);
delay(100);
start = micros();
for (int ch = 0; ch < 32; ch++)
{
ADG.setChannel(ch);
}
stop = micros();
Serial.print("Time:\t");
Serial.println((stop - start) / 32.0);
delay(100);
start = micros();
ADG.setChannel(1);
stop = micros();
Serial.print("Time:\t");
Serial.println(stop - start);
delay(100);
}
void loop()
{
for (int ch = 0; ch < 32; ch++)
{
ADG.setChannel(ch);
Serial.print(ch);
Serial.print("\t");
Serial.println(ADG.getChannel());
delay(1000);
}
}
// -- END OF FILE --

View File

@ -0,0 +1,17 @@
# Syntax Colouring Map For ADG732
# Data types (KEYWORD1)
ADG732 KEYWORD1
# Methods and Functions (KEYWORD2)
setChannel KEYWORD2
getChannel KEYWORD2
channelCount KEYWORD2
allOff KEYWORD2
# Constants (LITERAL1)
ADG732_LIB_VERSION LITERAL1
ADG732_ALLOFF LITERAL1

View File

@ -0,0 +1,23 @@
{
"name": "ADG732",
"keywords": "ADG732,32,1, multiplexer, MUX",
"description": "Arduino library for ADG732 - 32 to 1 channel multiplexer.",
"authors":
[
{
"name": "Rob Tillaart",
"email": "Rob.Tillaart@gmail.com",
"maintainer": true
}
],
"repository":
{
"type": "git",
"url": "https://github.com/RobTillaart/ADG732"
},
"version": "0.1.0",
"license": "MIT",
"frameworks": "*",
"platforms": "*",
"headers": "ADG732.h"
}

View File

@ -0,0 +1,11 @@
name=ADG732
version=0.1.0
author=Rob Tillaart <rob.tillaart@gmail.com>
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
sentence=Arduino library for ADG732 - 32 to 1 channel multiplexer.
paragraph=
category=Signal Input/Output
url=https://github.com/RobTillaart/ADG732
architectures=*
includes=ADG732.h
depends=

View File

@ -0,0 +1,84 @@
//
// FILE: unit_test_001.cpp
// AUTHOR: Rob Tillaart
// DATE: 2023-07-25
// PURPOSE: unit tests for the ADG732 library
// https://github.com/RobTillaart/ADG732
// https://github.com/Arduino-CI/arduino_ci/blob/master/REFERENCE.md
//
// supported assertions
// ----------------------------
// assertEqual(expected, actual)
// assertNotEqual(expected, actual)
// assertLess(expected, actual)
// assertMore(expected, actual)
// assertLessOrEqual(expected, actual)
// assertMoreOrEqual(expected, actual)
// assertTrue(actual)
// assertFalse(actual)
// assertNull(actual)
#include <ArduinoUnitTests.h>
#include "Arduino.h"
#include "ADG732.h"
unittest_setup()
{
fprintf(stderr, "ADG732_LIB_VERSION: %s\n", (char *) ADG732_LIB_VERSION);
}
unittest_teardown()
{
}
unittest(test_constructor)
{
uint8_t arr[5] = {4, 5, 6, 7, 8};
ADG732 ADG(arr, 10, 11, 12);
assertEqual(32, ADG.channelCount());
assertEqual(ADG732_ALLOFF, ADG.getChannel());
}
unittest(test_constants)
{
assertEqual(0x80, ADG732_ALLOFF );
}
unittest(test_allOff)
{
uint8_t arr[5] = {4, 5, 6, 7, 8};
ADG732 ADG(arr, 10, 11, 12);
ADG.setChannel(13);
assertEqual(13, ADG.getChannel());
ADG.allOff();
assertEqual(ADG732_ALLOFF, ADG.getChannel());
}
unittest(test_channel)
{
uint8_t arr[5] = {4, 5, 6, 7, 8};
ADG732 ADG(arr, 10, 11, 12);
for (int ch = 0; ch < 32; ch++)
{
ADG.setChannel(ch);
assertEqual(ch, ADG.getChannel());
}
}
unittest_main()
// -- END OF FILE --