summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorRyan <fauxpark@gmail.com>2024-02-17 00:18:26 +1100
committerGitHub <noreply@github.com>2024-02-17 00:18:26 +1100
commitb8646bc40bd616167da150f6da4eda372f7de23d (patch)
tree8029e1180ff0666a07d8ef896461333a836611fa /docs
parent6890c1aeb82c0c2239841db57e1bd99c3a0651a5 (diff)
Update naming convention for GPIO control macros (#23085)
Diffstat (limited to 'docs')
-rw-r--r--docs/custom_quantum_functions.md10
-rw-r--r--docs/feature_led_indicators.md12
-rw-r--r--docs/gpio_control.md38
-rw-r--r--docs/i2c_driver.md4
4 files changed, 32 insertions, 32 deletions
diff --git a/docs/custom_quantum_functions.md b/docs/custom_quantum_functions.md
index 957633837c..bc3b28bbba 100644
--- a/docs/custom_quantum_functions.md
+++ b/docs/custom_quantum_functions.md
@@ -119,11 +119,11 @@ void keyboard_pre_init_user(void) {
// Call the keyboard pre init code.
// Set our LED pins as output
- setPinOutput(B0);
- setPinOutput(B1);
- setPinOutput(B2);
- setPinOutput(B3);
- setPinOutput(B4);
+ gpio_set_pin_output(B0);
+ gpio_set_pin_output(B1);
+ gpio_set_pin_output(B2);
+ gpio_set_pin_output(B3);
+ gpio_set_pin_output(B4);
}
```
diff --git a/docs/feature_led_indicators.md b/docs/feature_led_indicators.md
index 1f71cdb1c8..b35a174490 100644
--- a/docs/feature_led_indicators.md
+++ b/docs/feature_led_indicators.md
@@ -56,16 +56,16 @@ This is a template indicator function that can be implemented on keyboard level
bool led_update_kb(led_t led_state) {
bool res = led_update_user(led_state);
if(res) {
- // writePin sets the pin high for 1 and low for 0.
+ // gpio_write_pin sets the pin high for 1 and low for 0.
// In this example the pins are inverted, setting
// it low/0 turns it on, and high/1 turns the LED off.
// This behavior depends on whether the LED is between the pin
// and VCC or the pin and GND.
- writePin(B0, !led_state.num_lock);
- writePin(B1, !led_state.caps_lock);
- writePin(B2, !led_state.scroll_lock);
- writePin(B3, !led_state.compose);
- writePin(B4, !led_state.kana);
+ gpio_write_pin(B0, !led_state.num_lock);
+ gpio_write_pin(B1, !led_state.caps_lock);
+ gpio_write_pin(B2, !led_state.scroll_lock);
+ gpio_write_pin(B3, !led_state.compose);
+ gpio_write_pin(B4, !led_state.kana);
}
return res;
}
diff --git a/docs/gpio_control.md b/docs/gpio_control.md
index 12413dfc8e..90798fc87b 100644
--- a/docs/gpio_control.md
+++ b/docs/gpio_control.md
@@ -2,29 +2,29 @@
QMK has a GPIO control abstraction layer which is microcontroller agnostic. This is done to allow easy access to pin control across different platforms.
-## Functions :id=functions
-
-The following functions provide basic control of GPIOs and are found in `platforms/<platform>/gpio.h`.
-
-| Function | Description | Old AVR Examples | Old ChibiOS/ARM Examples |
-|------------------------------|-----------------------------------------------------|-------------------------------------------------|--------------------------------------------------|
-| `setPinInput(pin)` | Set pin as input with high impedance (High-Z) | `DDRB &= ~(1<<2)` | `palSetLineMode(pin, PAL_MODE_INPUT)` |
-| `setPinInputHigh(pin)` | Set pin as input with builtin pull-up resistor | `DDRB &= ~(1<<2); PORTB \|= (1<<2)` | `palSetLineMode(pin, PAL_MODE_INPUT_PULLUP)` |
-| `setPinInputLow(pin)` | Set pin as input with builtin pull-down resistor | N/A (Not supported on AVR) | `palSetLineMode(pin, PAL_MODE_INPUT_PULLDOWN)` |
-| `setPinOutput(pin)` | Set pin as output (alias of `setPinOutputPushPull`) | `DDRB \|= (1<<2)` | `palSetLineMode(pin, PAL_MODE_OUTPUT_PUSHPULL)` |
-| `setPinOutputPushPull(pin)` | Set pin as output, push/pull mode | `DDRB \|= (1<<2)` | `palSetLineMode(pin, PAL_MODE_OUTPUT_PUSHPULL)` |
-| `setPinOutputOpenDrain(pin)` | Set pin as output, open-drain mode | N/A (Not implemented on AVR) | `palSetLineMode(pin, PAL_MODE_OUTPUT_OPENDRAIN)` |
-| `writePinHigh(pin)` | Set pin level as high, assuming it is an output | `PORTB \|= (1<<2)` | `palSetLine(pin)` |
-| `writePinLow(pin)` | Set pin level as low, assuming it is an output | `PORTB &= ~(1<<2)` | `palClearLine(pin)` |
-| `writePin(pin, level)` | Set pin level, assuming it is an output | `(level) ? PORTB \|= (1<<2) : PORTB &= ~(1<<2)` | `(level) ? palSetLine(pin) : palClearLine(pin)` |
-| `readPin(pin)` | Returns the level of the pin | `_SFR_IO8(pin >> 4) & _BV(pin & 0xF)` | `palReadLine(pin)` |
-| `togglePin(pin)` | Invert pin level, assuming it is an output | `PORTB ^= (1<<2)` | `palToggleLine(pin)` |
+## Macros :id=macros
+
+The following macros provide basic control of GPIOs and are found in `platforms/<platform>/gpio.h`.
+
+|Macro |Description |
+|-------------------------------------|---------------------------------------------------------------------|
+|`gpio_set_pin_input(pin)` |Set pin as input with high impedance (High-Z) |
+|`gpio_set_pin_input_high(pin)` |Set pin as input with builtin pull-up resistor |
+|`gpio_set_pin_input_low(pin)` |Set pin as input with builtin pull-down resistor (unavailable on AVR)|
+|`gpio_set_pin_output(pin)` |Set pin as output (alias of `gpio_set_pin_output_push_pull`) |
+|`gpio_set_pin_output_push_pull(pin)` |Set pin as output, push/pull mode |
+|`gpio_set_pin_output_open_drain(pin)`|Set pin as output, open-drain mode (unavailable on AVR and ATSAM) |
+|`gpio_write_pin_high(pin)` |Set pin level as high, assuming it is an output |
+|`gpio_write_pin_low(pin)` |Set pin level as low, assuming it is an output |
+|`gpio_write_pin(pin, level)` |Set pin level, assuming it is an output |
+|`gpio_read_pin(pin)` |Returns the level of the pin |
+|`gpio_toggle_pin(pin)` |Invert pin level, assuming it is an output |
## Advanced Settings :id=advanced-settings
-Each microcontroller can have multiple advanced settings regarding its GPIO. This abstraction layer does not limit the use of architecture-specific functions. Advanced users should consult the datasheet of their desired device and include any needed libraries. For AVR, the standard avr/io.h library is used; for STM32, the ChibiOS [PAL library](https://chibios.sourceforge.net/docs3/hal/group___p_a_l.html) is used.
+Each microcontroller can have multiple advanced settings regarding its GPIO. This abstraction layer does not limit the use of architecture-specific functions. Advanced users should consult the datasheet of their desired device. For AVR, the standard `avr/io.h` library is used; for STM32, the ChibiOS [PAL library](https://chibios.sourceforge.net/docs3/hal/group___p_a_l.html) is used.
-## Atomic Operation
+## Atomic Operation :id=atomic-operation
The above functions are not always guaranteed to work atomically. Therefore, if you want to prevent interruptions in the middle of operations when using multiple combinations of the above functions, use the following `ATOMIC_BLOCK_FORCEON` macro.
diff --git a/docs/i2c_driver.md b/docs/i2c_driver.md
index 868715a62c..9a3c08b90b 100644
--- a/docs/i2c_driver.md
+++ b/docs/i2c_driver.md
@@ -127,8 +127,8 @@ This function is weakly defined, meaning it can be overridden if necessary for y
```c
void i2c_init(void) {
- setPinInput(B6); // Try releasing special pins for a short time
- setPinInput(B7);
+ gpio_set_pin_input(B6); // Try releasing special pins for a short time
+ gpio_set_pin_input(B7);
wait_ms(10); // Wait for the release to happen
palSetPadMode(GPIOB, 6, PAL_MODE_ALTERNATE(4) | PAL_STM32_OTYPE_OPENDRAIN | PAL_STM32_PUPDR_PULLUP); // Set B6 to I2C function