-
Notifications
You must be signed in to change notification settings - Fork 3
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
Fwxv 255 moved I2C to PCA #257
Open
warren-xu
wants to merge
3
commits into
main
Choose a base branch
from
FWXV-255-move-centre-console-i-2-c-button-read-to-pca-interface
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<!-- | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You should probably get rid of this folder |
||
General guidelines | ||
These are just guidelines, not strict rules - document however seems best. | ||
A README for a firmware-only project (e.g. Babydriver, MPXE, bootloader, CAN explorer) should answer the following questions: | ||
- What is it? | ||
- What problem does it solve? | ||
- How do I use it? (with usage examples / example commands, etc) | ||
- How does it work? (architectural overview) | ||
A README for a board project (powering a hardware board, e.g. power distribution, centre console, charger, BMS carrier) should answer the following questions: | ||
- What is the purpose of the board? | ||
- What are all the things that the firmware needs to do? | ||
- How does it fit into the overall system? | ||
- How does it work? (architectural overview, e.g. what each module's purpose is or how data flows through the firmware) | ||
--> | ||
# gpio_leds | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"libs": [ | ||
"FreeRTOS", | ||
"ms-common" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
#include <stdbool.h> | ||
|
||
#include "delay.h" | ||
#include "gpio.h" | ||
#include "gpio_it.h" | ||
#include "interrupt.h" | ||
#include "log.h" | ||
#include "misc.h" | ||
#include "tasks.h" | ||
|
||
Event BTN_INT_EVENT = 5; | ||
GpioAddress addr1 = { .port = GPIO_PORT_B, .pin = 5 }; | ||
GpioAddress addr2 = { .port = GPIO_PORT_B, .pin = 4 }; | ||
GpioAddress addr3 = { .port = GPIO_PORT_B, .pin = 3 }; | ||
GpioAddress addr4 = { .port = GPIO_PORT_A, .pin = 15 }; | ||
GpioAddress addr5 = { // button | ||
.port = GPIO_PORT_A, | ||
.pin = 7 | ||
}; | ||
|
||
InterruptSettings settings = { .type = INTERRUPT_TYPE_INTERRUPT, | ||
.priority = INTERRUPT_PRIORITY_NORMAL, | ||
.edge = INTERRUPT_EDGE_RISING }; | ||
TASK(GPIO_LED, TASK_STACK_512) { | ||
gpio_init_pin(&addr1, GPIO_OUTPUT_PUSH_PULL, GPIO_STATE_HIGH); | ||
gpio_init_pin(&addr2, GPIO_OUTPUT_PUSH_PULL, GPIO_STATE_HIGH); | ||
gpio_init_pin(&addr3, GPIO_OUTPUT_PUSH_PULL, GPIO_STATE_HIGH); | ||
gpio_init_pin(&addr4, GPIO_OUTPUT_PUSH_PULL, GPIO_STATE_HIGH); | ||
gpio_init_pin(&addr5, GPIO_INPUT_PULL_DOWN, GPIO_STATE_LOW); | ||
|
||
while (true) { | ||
uint32_t notification; | ||
|
||
notify_get(¬ification); | ||
if (notify_check_event(¬ification, BTN_INT_EVENT)) { | ||
gpio_toggle_state(&addr1); | ||
delay_ms(1000); | ||
gpio_toggle_state(&addr2); | ||
delay_ms(1000); | ||
gpio_toggle_state(&addr3); | ||
delay_ms(1000); | ||
gpio_toggle_state(&addr4); | ||
delay_ms(1000); | ||
} | ||
} | ||
} | ||
void run_slow_cycle() { | ||
gpio_it_trigger_interrupt(&addr5); | ||
} | ||
int main(void) { | ||
interrupt_init(); | ||
|
||
gpio_it_register_interrupt(&addr5, &settings, BTN_INT_EVENT, GPIO_LED); | ||
gpio_init(); | ||
tasks_init(); | ||
log_init(); | ||
|
||
// tasks_init_task(leds_task, TASK_PRIORITY(2), NULL); | ||
|
||
tasks_start(); | ||
LOG_DEBUG("Blinking LEDs...\n"); | ||
|
||
return 0; | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
What is
INPUT0
andINPUT1
? Can't seem to find them.But basically you'll always only read and write 1 byte?
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 was trying to find at what address the PCA9555 registers are at, but I couldn't find them so I assumed it was INPUT0 and INPUT1. Do you know where I should be reading from?
Yeah, essentially the function will read and write one byte for both registers and output them as a 16-bit int.
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.
If you look at the datasheet pg 19, it should be there