-
Notifications
You must be signed in to change notification settings - Fork 671
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implemement PxSEL setting into pinMode Function #74
Comments
@StefanSch, thanks for the suggestion and the detailed analysis. Will review it over the weekend. |
@StefanSch, where would the UART_SET_PxSEL2 and UART_SET_PxSEL1 come from and why the check for these? It seems that if a check needs to be done for these then a check might also be necessary for other types of peripherals. If that is the case then this might become a very big #if statement? Also, the primary purpose of this function is to set the pin to INPUT or OUTPUT. Overloading it with so that it allows to configure the pin for other modes might be overkill. Thoughts? Robert |
Hi Robert, i made a test implementation and uploaded it in the Branch: Branch_F2274_Fr57xx_support May you can have a look there, i think this will make many things much more clear. Back to your questions: Best regards, |
I'm wondering what the purpose of this would be? digital_write is supposed to deal with I/O on the pin. If it is touches the PSELX registers, it is only to turn off the alternate functionality and return the pin back to GPIO mode. I'm guessing that if you are manipulating the PSELX pins, you are doing it to gain access to the alternate functions of the pins. I think this would be better served in some class that is dealing with that alternate functionality. For example, using the UART in the FR5739, you have to manipulate the PSEL to access the UART capability. I think it best to bury that type of register manipulation code in the HardwareSerial not exposing the PSEL functionality as a special case of the digitalWrite. digitalWrite is slow enough already I'd hate to see it get any slower. What is the kind of performance hit do we take if we add these extra PSEL tests to digitalWrite? -rick |
Hi Nick, the critical point if working with several different MSP430 device and families is that the usage of the PxSEL register differs between them slightly. This is not to much but at some devices there are two registers at some they are called PxSEL and PxSEL2 others have PxSEL0.PxSEL1. If we can not centralize this to a unique function and have the definitions packed into the device specific pins_energia.h file, it would be required to handle all this differences in the individual module files using the PxSEL register ( UART / I2C - Wire / PWM - Tone / ....) |
What code would use this pinSelMode() function? Is this for end user usage? Or for internals? |
I see this more for internal functions. Not sure if this should/need to be also provided to the end user. |
For internal code, I would like to see us start to use more C++ templates to deal with this type of thing. It would be great if we could move run time code and logic into compile time logic. This is a perfect case for it. We know all the variables at compile time and adding lookup tables just steals bytes from the available flash space. |
Hi Team,
i am not sure if the implementation of the handling of the PxSEL bits is mode in the best way.
After some analysis i would like to make an suggestion for a change see below.
(Sore for the long thread !!!)
It basically implements the full functionality into the pinMode function.
It would also allow to have a define in the device specific header file (pins_energia.h) file which define how the PxSEL bits have to be set to enable a certain function e.g. UART RX
usage:
Required changes to files:
Energia.h
wiring_digital.c
The text was updated successfully, but these errors were encountered: