-
Notifications
You must be signed in to change notification settings - Fork 0
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
GPIO x86 Implementation #6
Conversation
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.
Mostly looks good, small changes.
Also please update the x86/gpio_mcu.h. I want to reduce the number of ports available in x86 because there are very few times we access port H.
typedef enum {
GPIO_PORT_A = 0,
GPIO_PORT_B,
GPIO_PORT_C,
GPIO_PORT_H,
NUM_GPIO_PORTS,
} GpioPort;
Remove GPIO_PORT_H. Thanks!
libraries/ms-common/src/x86/gpio.c
Outdated
@@ -17,28 +17,130 @@ | |||
#include "gpio_mcu.h" | |||
#include "status.h" | |||
|
|||
static GpioMode s_gpio_pin_modes[GPIO_TOTAL_PINS]; | |||
static uint8_t s_gpio_pin_state[GPIO_TOTAL_PINS]; | |||
static GpioMode s_gpio_alternative_function_modes[GPIO_TOTAL_PINS]; |
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.
rename to s_gpio_alt_functions?
libraries/ms-common/src/x86/gpio.c
Outdated
return STATUS_CODE_UNIMPLEMENTED; | ||
for (uint32_t k = 0; k < GPIO_TOTAL_PINS; ++k) { | ||
s_gpio_pin_state[k] = GPIO_STATE_LOW; | ||
s_gpio_alternative_function_modes[k] = 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.
= GPIO_ALT_NONE
The 0 works aswell, its just using the define makes the code more readable
libraries/ms-common/src/x86/gpio.c
Outdated
|
||
s_gpio_pin_modes[index] = pin_mode; | ||
s_gpio_pin_state[index] = init_state; | ||
s_gpio_alternative_function_modes[index] = 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.
= GPIO_ALT_NONE
@@ -17,28 +17,130 @@ | |||
#include "gpio_mcu.h" |
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.
Please add the header seen in other files:
/************************************************************************************************
- gpio.c
- GPIO Library Source Code
- Created: 2024-11-02
- Midnight Sun Team #24 - MSXVI
************************************************************************************************/
And sort the #includes into the correct sections:
/* Standard library headers */
/* Inter-component Headers */
/* Intra-component Headers */
libraries/ms-common/src/x86/gpio.c
Outdated
return status_code(STATUS_CODE_INVALID_ARGS); | ||
} | ||
|
||
if (s_gpio_alternative_function_modes[index] != 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.
Don't need this check, alternate function pins can be driven high and low. Typically it is not done by our code but still, shouldn't be here
libraries/ms-common/src/x86/gpio.c
Outdated
|
||
uint32_t index = address -> port * (uint32_t)GPIO_PINS_PER_PORT + address -> pin; | ||
|
||
if (s_gpio_alternative_function_modes[index] != 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.
Same here, alternative function pins can be driven high/low
Make sure your PR has a proper name, changed to |
* created mpu header and source file * Updated mpu.h and mpu.c files
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.
lgtm
No description provided.