Skip to content

Commit 21e40d5

Browse files
Disabling pull-ups and pull-downs
RPI Pico has pull-downs enabled on GPIOs at start-up. LPC bus specs say it should be pull-ups on LAD pins (which exist on the motherboard). To not mess up the LPC bus, all pull-ups and pull-downs are disabled. LED pin initialization is set in the same manner, making it easy to understand for beginners.
1 parent 3f5b0ad commit 21e40d5

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ I usually use old or junk parts on my projects to reduce electronic waste and su
3434
- Filter LPC I/0 frame with start, cycle/dir and address
3535
- Abort frame support
3636
- Defining pin bases and counts (Refactoring)
37+
- Disabling pull-ups and pull-downs
3738

3839
### Compilation
3940

src/main.c

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,25 @@ void gpio_initialization() {
3535

3636
// Set the Status LED GPIO pin as output.
3737
gpio_set_dir(LED_STATUS_PIN, GPIO_OUT);
38-
39-
// Init the POST Code LED pins.
40-
gpio_init_mask(0xffu << LED_POST_CODE_PIN_BASE);
4138

42-
// Set the POST Code LED pins to high. (led's are common anode)
43-
gpio_set_mask(0xffu << LED_POST_CODE_PIN_BASE);
39+
for(uint i = LPC_BUS_PIN_BASE; i < LPC_BUS_PIN_BASE + LPC_BUS_PIN_COUNT; i++) {
40+
// Init the LAD[0-3] + LCLK + LFRAME pins.
41+
gpio_init(i);
42+
43+
// Disable internal pull up and downs.
44+
gpio_disable_pulls(i);
45+
}
4446

45-
// Set the POST Code LED pins as output.
46-
gpio_set_dir_out_masked(0xffu << LED_POST_CODE_PIN_BASE);
47+
for(uint i = LED_POST_CODE_PIN_BASE; i < LED_POST_CODE_PIN_BASE + LED_POST_CODE_PIN_COUNT; i++) {
48+
// Init the POST Code LED pins. (Also sets the pin to input.)
49+
gpio_init(i);
50+
51+
// Set the POST Code LED pins as output.
52+
gpio_set_dir(i, GPIO_OUT);
53+
54+
// Set the POST Code LED pins to high. (led's are common anode)
55+
gpio_put(i, 1);
56+
}
4757
}
4858

4959
void flash_led_once(void) {

0 commit comments

Comments
 (0)