-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Figuring out how to do board setup and reset
- Loading branch information
1 parent
44a955d
commit 30686d6
Showing
3 changed files
with
66 additions
and
2 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#include "hardware/gpio.h" | ||
#include "hardware/i2c.h" | ||
#include "drivers/tca9555/tca9555.h" | ||
|
||
void board_init() { | ||
gpio_init(8); | ||
gpio_set_dir(8, GPIO_OUT); | ||
gpio_put(8, true); | ||
configure_i2c(); | ||
gpio_put(8, false); | ||
|
||
gpio_init(9); | ||
gpio_set_dir(9, GPIO_OUT); | ||
gpio_put(9, true); | ||
sleep_us(100); | ||
gpio_put(9, false); | ||
sleep_us(10); | ||
gpio_put(9, true); | ||
// Set the first IO expander's initial state | ||
tca_set_output_port(0, 0x0000); | ||
tca_set_polarity_port(0, 0x0000); | ||
tca_set_config_port(0, 0x07BF); | ||
|
||
// Set the second IO expander's initial state | ||
tca_set_output_port(1, 0x0000); | ||
tca_set_polarity_port(1, 0x0000); | ||
tca_set_config_port(1, 0xFCE6); | ||
sleep_us(100); | ||
gpio_put(9, false); | ||
} | ||
|
||
void board_reset(void) { | ||
for (int i = 0; i < 24; ++i) { | ||
gpio_init(i); | ||
hw_clear_bits(&padsbank0_hw->io[i], PADS_BANK0_GPIO0_IE_BITS | | ||
PADS_BANK0_GPIO0_PUE_BITS | | ||
PADS_BANK0_GPIO0_PDE_BITS); | ||
hw_set_bits(&padsbank0_hw->io[i], PADS_BANK0_GPIO0_OD_BITS); | ||
} | ||
|
||
// Set the first IO expander's initial state | ||
tca_set_output_port(0, 0x0000); | ||
tca_set_polarity_port(0, 0x0000); | ||
tca_set_config_port(0, 0x07BF); | ||
|
||
// Set the second IO expander's initial state | ||
tca_set_output_port(1, 0x0000); | ||
tca_set_polarity_port(1, 0x0000); | ||
tca_set_config_port(1, 0xFCE6); | ||
} |
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