I wrote this file include because I need to use the MCP23017.
I have not tried it yet but checking it I think there should be no problems.
I hope it can be useful ...
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Excellent! I will have to give it a go! I love the 23017, One of the first expanders I ever messed with. Your code looks very neat and bilingual too! Thanks @jackjames.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Well I second what Moto Geek said.
I think that is the neatest code presentation I have ever seen.
If that represents your Laziness It far exceeds my best documentation efforts :>)
Great contribution.
However, I should point out that one is already included with GCBASIC.
C:\GCB@Syn\GreatCowBasic\Include\MCP23017.h, you may want to have a look through that folder for any other devices you may need, it could save you some time. But then again it could deprive you of the creative fun of rolling your own :)
Cheers
Chris
Last edit: Chris Roper 2018-03-13
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
@Chris
Yes, I had already seen the include file MCP23017.H.
In fact the two routines
MCP23017_sendbyte
and
MCP23017_readbyte
were copied from that file.
... Then I added my ...
I am used to working with complex programs that have tens of thousands of lines of code, so if they are not well commented and you read them over time it is difficult to understand them right away.
Last edit: jackjames 2018-03-13
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
A quick look and nice one. I use these and like them. I only used 8 lines for out to stepper motors so far but was easy. 8 more to use. It seems i2c not hi2c. Anobium recomended change to detect hi2c or i2c. How, detect #define HI2C_DATA ? posted elsewhere.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I deleted the MCP23017 include and used yours in a program that worked but now doesn't. 2 errors i2c ports not defined. I dug the old one out the recycle bin and restored and program works again. The recycled one was i2c only.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
@jackjames. We now have a forked development for this library. When you have tested and got it working ... is the plan to replace the existing library?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
@Stan:
Seeing some example files I noticed that when using the hardware I2C you have to define:
; ----- Define Hardware settings - choose hardware or software I2C - NOT BOTH !!
'' Define I2C settings
'#define HI2C_BAUD_RATE 400
'HI2CMode Master
--------> '#define HI2C_DATA ' This is required when using I2C hardware <--------
Therefore HI2C_DATA must be defined with the I2C hardware.
I have not found the definition of I2C_DATA anywhere.
@Stan:
I have verified the error and it is due to the fact that the definition MCP23017IoDirA used in your file in the new include file is called IODIRA without the prefix MCP2317.
I had written this file to use it with another compiler so the definitions were named before deciding to get it to GCBasic.
Now, to keep them compatible with the old one I renamed all the definitions with the same name used in the old file.
I think I have eliminated the problems. Let me know how the test goes ...***
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Sorry @jackjame, not tested interrupt..needs an interrupt to test the interrupts. been busy.
Another forum user wanted to use spi version. Again I didn't get a round tuit.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I wrote this file include because I need to use the MCP23017.
I have not tried it yet but checking it I think there should be no problems.
I hope it can be useful ...
Here is the file:
Excellent! I will have to give it a go! I love the 23017, One of the first expanders I ever messed with. Your code looks very neat! Thanks @jackjames.
Excellent! I will have to give it a go! I love the 23017, One of the first expanders I ever messed with. Your code looks very neat and bilingual too! Thanks @jackjames.
In reality it was only commented in Italian, my language, then I added the translation in English and the part in Italian remained for my laziness ...
Well I second what Moto Geek said.
I think that is the neatest code presentation I have ever seen.
If that represents your Laziness It far exceeds my best documentation efforts :>)
Great contribution.
However, I should point out that one is already included with GCBASIC.
C:\GCB@Syn\GreatCowBasic\Include\MCP23017.h, you may want to have a look through that folder for any other devices you may need, it could save you some time. But then again it could deprive you of the creative fun of rolling your own :)
Cheers
Chris
Last edit: Chris Roper 2018-03-13
@Chris
Yes, I had already seen the include file MCP23017.H.
In fact the two routines
MCP23017_sendbyte
and
MCP23017_readbyte
were copied from that file.
... Then I added my ...
I am used to working with complex programs that have tens of thousands of lines of code, so if they are not well commented and you read them over time it is difficult to understand them right away.
Last edit: jackjames 2018-03-13
A quick look and nice one. I use these and like them. I only used 8 lines for out to stepper motors so far but was easy. 8 more to use. It seems i2c not hi2c. Anobium recomended change to detect hi2c or i2c. How, detect #define HI2C_DATA ? posted elsewhere.
Try looking in the existing Libraries and the GCBASIC Help Files:
http://gcbasic.sourceforge.net/help/__ifdef.html
Last edit: Chris Roper 2018-03-13
@Chris. thanks for bringing to my attention #ifdef HI2C_DATA
I'll change the expander incude to try.
I modified the file to use it with I2c and Hi2C.
Excellent.
I deleted the MCP23017 include and used yours in a program that worked but now doesn't. 2 errors i2c ports not defined. I dug the old one out the recycle bin and restored and program works again. The recycled one was i2c only.
@jackjames. We now have a forked development for this library. When you have tested and got it working ... is the plan to replace the existing library?
@Anobium:
YES.
@Stan:
Seeing some example files I noticed that when using the hardware I2C you have to define:
; ----- Define Hardware settings - choose hardware or software I2C - NOT BOTH !!
'' Define I2C settings
'#define HI2C_BAUD_RATE 400
'HI2CMode Master
--------> '#define HI2C_DATA ' This is required when using I2C hardware <--------
Therefore HI2C_DATA must be defined with the I2C hardware.
I have not found the definition of I2C_DATA anywhere.
Last edit: jackjames 2018-03-13
I just used your last mcp23017 and new errors. Old version works ok.
Test for hi2c and if not must be i2c
Last edit: stan cartwright 2018-03-14
I'm using anobium's version. Differrent define names?
@Stan:
I have verified the error and it is due to the fact that the definition MCP23017IoDirA used in your file in the new include file is called IODIRA without the prefix MCP2317.
I had written this file to use it with another compiler so the definitions were named before deciding to get it to GCBasic.
Now, to keep them compatible with the old one I renamed all the definitions with the same name used in the old file.
I think I have eliminated the problems. Let me know how the test goes ...***
@jackjames, your last mcp23017.h worked ok with the test program I was using.
I only tested porta out.
OK- Thanks
And it detects hi2c or i2c. I changed this from i2c and it works.
I'll test the device more, I'll try interrupt on portb change next and get back only if a problem. regards @stan
OK- Thanks
@Stan:
Did you do any other checks?
Do you think it is valid to be included in the 'include' files of the GCB?
Sorry @jackjame, not tested interrupt..needs an interrupt to test the interrupts. been busy.
Another forum user wanted to use spi version. Again I didn't get a round tuit.