-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Arduino-mega2560 GPIO implementation #2799
Conversation
@ReneHerthel nice! Will review soon |
#define GPIO_14_EN 0 | ||
#define GPIO_15_EN 0 | ||
#define GPIO_NUMOF 12 | ||
#define GPIO_2_EN 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why didn't you implement GPIO_0
and GPIO_1
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's because there are pin 2-13 at PWM- and 0-1 in communication-section on the pinout.
for example: if you want to set pin 2, you have to call the method with 2 (parameter: dev).
But when you change the pin_map, that GPIO_0 is first, you will have the wrong pin all time, so i decided to implement it this way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, should i change it from GPIO_2 to GPIO_0... ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The advantage of the periph_conf is that you can abstract the hardware-dependent stuff from your driver. That means the "GPIO_0" could for example either be port E pin 5 or port H pin 6... Please change this and all dependencies. You don't need to implement 15 GPIO pins (even if it would be nice :-) ). It is more important to prevent potential pin conflicts for later driver implementations. Tha means: Try to avoid implemention GPIOs when blocking other peripheral pins with that. Example: If there are just 3 pins that can be configured as SPI-pins, don't implement the GPIO functionality on them. Ok?
I don't know this board in detail. Where is the relation between PWM and GPIO? Isn't it possible to implement them independently? |
|
||
int gpio_init_out(gpio_t dev, gpio_pp_t pushpull) | ||
{ | ||
return -1; | ||
uint8_t pin; | ||
pin = gpio_pin_map[dev - 2]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know, you started your implementation at GPIO_2
but I don't know the reason for this. What if one tries to initialize GPIO_0
(which has the value 0
) here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't noticed that. Thanks
The interrupt functionality is missing |
@ReneHerthel nice work and congrats to your first RIOT-PR :-) ! |
uint8_t pin; | ||
pin = gpio_pin_map[dev - 2]; | ||
switch(dev) { | ||
case 2: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be much prettier using the GPIO names here. (So 2
will become GPIO_2
and so on)
@PeterKietzmann Hmm, yes it is always low, when you apply But you mean, it should print Or you think that the register changed automatically, when you apply something with an high value or GND? And the E5 thing, no idea at the moment :-/ |
@ReneHerthel please adapt Haukes proposed changes. Regarding the read function: of course you want to get to logical value that corresponds to an external "logocal" signal. Why should you want to read a value that you set by yourself? Then the function is not implemented correctly. Regarding interrupts: Let's see if the same applies to INT6 and INT7. Maybe that gives exposure. If not we need to spend some time in this together (or so).. |
@PeterKietzmann Btw. can you tell me which two pins are for INT6 and INT7? I found out it should be PE6 and PE7, but I don't know which physical pins they are on the board. Thats why I don't implement it before.. |
@ReneHerthel honestly I don't know either. But as this is a CPU dependant implementation we should not care. Imagine this CPU is used on an other board design. There, it may appear that all interrupt lines have a hardware pin. So the |
@PeterKietzmann Ah, okey. Anyway, I'll come tomorrow, so we can finish this and maybe test it with an oscilloscope :-) |
@@ -0,0 +1,255 @@ | |||
/* | |||
* Copyright (C) 2015 haw-hamburg |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Write it like "HAW Hamburg" please
@ReneHerthel, now everything works as expected and the code quality has really improved over the weeks. Please address my last minor comments and add a commit. I think we can merge it then :-) |
f964a73
to
d05151f
Compare
Travis fails for two groups and I don't understand why. Could it be related to #3777?
@haukepetersen , @kaspar030, @phiros any ideas? |
@PeterKietzmann #3777 is unlikely to cause this. |
But travis seems to be very unresponsive right now... Can't even restart the build. |
Okay. Maybe we should give him some time and try to restart later... |
It was a long way. But finally things come to an end :-) . ACK and go |
Arduino-mega2560 GPIO implementation
@ReneHerthel congratulations for your first contribution! |
@OlegHahm and sorry for merging that in FeatureFreeze. It was important due to motivational reasons ;-) |
@ReneHerthel please document the pin layout in the wiki |
-Implements some GPIO functionality for arduino-mega2560, with cpu ATmega2560, for pins 2 -13 at PWM