Closed joellecam closed 8 months ago
Hi Joel (?), Will try to have a look this evening, otherwise tomorrow.
I am from Netherlands, which time zone are you in? (Helps with my planning)
Hi Rob,
I am French in Normandy. using a chip select decoder is required in many design.
Another observation is that you need to learn some bit math AND OR XOR etc. This set_cs_high(uint8_t out) function would do the same.
void decode3to8::set_cs_low(uint8_t out)
{
if out > 7 return;
::digitalWrite(In2, out & 0x04);
::digitalWrite(In1, out & 0x02);
::digitalWrite(In0, out & 0x01);
}
In your .h file you use
#ifndef _74HC138_H_
#define _74HC138_H_
It is enough to place on the first line
#pragma once
I try to modify the MCP23S17 with the addition of a chip selector between MCU and MCP23S17.
What are you trying to accomplish, in more detail?
@joellecam had a second look at the error message in your original question.
I modify the MCP23S17.cpp by this
MCP23S17::MCP23S17(uint8_t select, uint8_t address,__DECODE1ON8__ * decode3to8 = &dec3t8 , __SPI_CLASS__ * spi = &SPI )
{
_address = (address << 1);
_select = select;
_error = MCP23S17_OK;
_mySPI = spi;
_hwSPI = true;
_mydec3to8 = decode3to8 ;
}
should be
MCP23S17::MCP23S17(uint8_t select, uint8_t address,__DECODE1ON8__ * decode3to8, __SPI_CLASS__ * spi )
{
_address = (address << 1);
_select = select;
_error = MCP23S17_OK;
_mySPI = spi;
_hwSPI = true;
_mydec3to8 = decode3to8 ;
}
The default parameters should only be given in the .h file
Hi Rob,
Thanks you very much. I have no error. I try the code in the next month after I receive the PCB
Best regards Joël
OK, I close the issue. FYI, inspired by your library I decided to write my own and one for the 74HC154 too (4 to 16)
https://assets.nexperia.com/documents/data-sheet/74HC_HCT154.pdf
@joellecam
just published the two libraries
There is also a 1 to 2 multiplexer in this range but that is left for the future. If you have time, please give them (or the 138 only) a try.
Again thanks for the inspiration.
I try to modify the MCP23S17 with the addition of a chip selector between MCU and MCP23S17. 74HC138 is perfect for making 7 chipselect with 3 output of the MCU . I made this library 74HC138 v1.0.zip
I am not an expert in CPP and I try this but I have an error
in your MCP23S17.h library I modify this
and this at the end of the MCP23S17.h
I modify the MCP23S17.cpp by this
and on the rest of cpp code I change evey:
But I have an error with VScode and I don't understant what is?
Have you ideas ? where I do wrong?
(updated code tags for readability)