-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add IO expander - still have I2C conflict bug * Add IOexpander and Move Speaker to Main Timer putting speaker updated on main timer (instead of it's own ISR) avoids I2C conflicts with other peripherals I2C expander added and supported in variants * Only init IOexpander if it exists * Remove redundant lib files
- Loading branch information
1 parent
fb98d43
commit 7bd18fe
Showing
10 changed files
with
234 additions
and
418 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
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
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
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
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,46 @@ | ||
#include "io_pins.h" | ||
#include <TCA9555.h> | ||
#include <Wire.h> | ||
|
||
// First try to load up any config from variants | ||
#ifdef VARIANT | ||
#include "variant.h" | ||
#endif | ||
|
||
// Pin configuration for the IO Expander (0=output 1=input) | ||
#ifndef IOEX_REG_CONFIG_PORT0 | ||
#define IOEX_REG_CONFIG_PORT0 B11111111 // default all inputs | ||
#endif | ||
|
||
#ifndef IOEX_REG_CONFIG_PORT1 | ||
#define IOEX_REG_CONFIG_PORT1 B11111111 // default all inputs | ||
#endif | ||
|
||
// Create IO Expander | ||
TCA9535 IOEX(IOEX_ADDR); | ||
|
||
void ioexInit() { | ||
|
||
// start IO Expander | ||
bool result = IOEX.begin(); | ||
Serial.print("IOEX.begin succes: "); | ||
Serial.println(result); | ||
|
||
// configure IO expander pins | ||
result = IOEX.pinMode8(0, IOEX_REG_CONFIG_PORT0); | ||
Serial.print("IOEX.pinModeP0 succes: "); | ||
Serial.println(result); | ||
IOEX.pinMode8(1, IOEX_REG_CONFIG_PORT1); | ||
Serial.print("IOEX.pinModeP1 succes: "); | ||
Serial.println(result); | ||
} | ||
|
||
void ioexDigitalWrite(bool onIOEX, uint8_t pin, uint8_t value) { | ||
// if we're writing a pin on the IO Expander | ||
if (onIOEX) { | ||
bool result = IOEX.write1(pin, value); | ||
} else { | ||
digitalWrite(pin, value); | ||
} | ||
} | ||
|
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,14 @@ | ||
#pragma once | ||
#include <Arduino.h> | ||
|
||
/* IO Expander | ||
[datasheet](https://wmsc.lcsc.com/wmsc/upload/file/pdf/v2/lcsc/2304251416_XINLUDA-XL9535QF24_C5444301.pdf) | ||
Chip is configured with I2C address: 0x20 | ||
*/ | ||
|
||
#define IOEX_ADDR 0x20 | ||
|
||
void ioexInit(); | ||
|
||
void ioexDigitalWrite(bool onIOEX, uint8_t pin, uint8_t value); |
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.