Skip to content

Commit 2d1aed7

Browse files
authored
Update GPIO macro usages in core (qmk#23093)
1 parent 6810aaf commit 2d1aed7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+334
-334
lines changed

drivers/bluetooth/bluefruit_le.cpp

+9-9
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ static bool sdep_recv_pkt(struct sdep_msg *msg, uint16_t timeout) {
188188
bool ready = false;
189189

190190
do {
191-
ready = readPin(BLUEFRUIT_LE_IRQ_PIN);
191+
ready = gpio_read_pin(BLUEFRUIT_LE_IRQ_PIN);
192192
if (ready) {
193193
break;
194194
}
@@ -231,7 +231,7 @@ static void resp_buf_read_one(bool greedy) {
231231
return;
232232
}
233233

234-
if (readPin(BLUEFRUIT_LE_IRQ_PIN)) {
234+
if (gpio_read_pin(BLUEFRUIT_LE_IRQ_PIN)) {
235235
struct sdep_msg msg;
236236

237237
again:
@@ -242,7 +242,7 @@ static void resp_buf_read_one(bool greedy) {
242242
dprintf("recv latency %dms\n", TIMER_DIFF_16(timer_read(), last_send));
243243
}
244244

245-
if (greedy && resp_buf.peek(last_send) && readPin(BLUEFRUIT_LE_IRQ_PIN)) {
245+
if (greedy && resp_buf.peek(last_send) && gpio_read_pin(BLUEFRUIT_LE_IRQ_PIN)) {
246246
goto again;
247247
}
248248
}
@@ -293,16 +293,16 @@ void bluefruit_le_init(void) {
293293
state.configured = false;
294294
state.is_connected = false;
295295

296-
setPinInput(BLUEFRUIT_LE_IRQ_PIN);
296+
gpio_set_pin_input(BLUEFRUIT_LE_IRQ_PIN);
297297

298298
spi_init();
299299

300300
// Perform a hardware reset
301-
setPinOutput(BLUEFRUIT_LE_RST_PIN);
302-
writePinHigh(BLUEFRUIT_LE_RST_PIN);
303-
writePinLow(BLUEFRUIT_LE_RST_PIN);
301+
gpio_set_pin_output(BLUEFRUIT_LE_RST_PIN);
302+
gpio_write_pin_high(BLUEFRUIT_LE_RST_PIN);
303+
gpio_write_pin_low(BLUEFRUIT_LE_RST_PIN);
304304
wait_ms(10);
305-
writePinHigh(BLUEFRUIT_LE_RST_PIN);
305+
gpio_write_pin_high(BLUEFRUIT_LE_RST_PIN);
306306

307307
wait_ms(1000); // Give it a second to initialize
308308

@@ -508,7 +508,7 @@ void bluefruit_le_task(void) {
508508
resp_buf_read_one(true);
509509
send_buf_send_one(SdepShortTimeout);
510510

511-
if (resp_buf.empty() && (state.event_flags & UsingEvents) && readPin(BLUEFRUIT_LE_IRQ_PIN)) {
511+
if (resp_buf.empty() && (state.event_flags & UsingEvents) && gpio_read_pin(BLUEFRUIT_LE_IRQ_PIN)) {
512512
// Must be an event update
513513
if (at_command_P(PSTR("AT+EVENTSTATUS"), resbuf, sizeof(resbuf))) {
514514
uint32_t mask = strtoul(resbuf, NULL, 16);

drivers/eeprom/eeprom_i2c.c

+6-6
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ void eeprom_driver_init(void) {
5757
i2c_init();
5858
#if defined(EXTERNAL_EEPROM_WP_PIN)
5959
/* We are setting the WP pin to high in a way that requires at least two bit-flips to change back to 0 */
60-
writePin(EXTERNAL_EEPROM_WP_PIN, 1);
61-
setPinInputHigh(EXTERNAL_EEPROM_WP_PIN);
60+
gpio_write_pin(EXTERNAL_EEPROM_WP_PIN, 1);
61+
gpio_set_pin_input_high(EXTERNAL_EEPROM_WP_PIN);
6262
#endif
6363
}
6464

@@ -100,8 +100,8 @@ void eeprom_write_block(const void *buf, void *addr, size_t len) {
100100
uintptr_t target_addr = (uintptr_t)addr;
101101

102102
#if defined(EXTERNAL_EEPROM_WP_PIN)
103-
setPinOutput(EXTERNAL_EEPROM_WP_PIN);
104-
writePin(EXTERNAL_EEPROM_WP_PIN, 0);
103+
gpio_set_pin_output(EXTERNAL_EEPROM_WP_PIN);
104+
gpio_write_pin(EXTERNAL_EEPROM_WP_PIN, 0);
105105
#endif
106106

107107
while (len > 0) {
@@ -134,7 +134,7 @@ void eeprom_write_block(const void *buf, void *addr, size_t len) {
134134

135135
#if defined(EXTERNAL_EEPROM_WP_PIN)
136136
/* We are setting the WP pin to high in a way that requires at least two bit-flips to change back to 0 */
137-
writePin(EXTERNAL_EEPROM_WP_PIN, 1);
138-
setPinInputHigh(EXTERNAL_EEPROM_WP_PIN);
137+
gpio_write_pin(EXTERNAL_EEPROM_WP_PIN, 1);
138+
gpio_set_pin_input_high(EXTERNAL_EEPROM_WP_PIN);
139139
#endif
140140
}

drivers/gpio/sn74x138.c

+12-12
Original file line numberDiff line numberDiff line change
@@ -27,39 +27,39 @@ static const pin_t address_pins[ADDRESS_PIN_COUNT] = SN74X138_ADDRESS_PINS;
2727

2828
void sn74x138_init(void) {
2929
for (int i = 0; i < ADDRESS_PIN_COUNT; i++) {
30-
setPinOutput(address_pins[i]);
31-
writePinLow(address_pins[i]);
30+
gpio_set_pin_output(address_pins[i]);
31+
gpio_write_pin_low(address_pins[i]);
3232
}
3333

3434
#if defined(SN74X138_E1_PIN)
35-
setPinOutput(SN74X138_E1_PIN);
36-
writePinHigh(SN74X138_E1_PIN);
35+
gpio_set_pin_output(SN74X138_E1_PIN);
36+
gpio_write_pin_high(SN74X138_E1_PIN);
3737
#endif
3838

3939
#if defined(SN74X138_E2_PIN)
40-
setPinOutput(SN74X138_E2_PIN);
41-
writePinHigh(SN74X138_E2_PIN);
40+
gpio_set_pin_output(SN74X138_E2_PIN);
41+
gpio_write_pin_high(SN74X138_E2_PIN);
4242
#endif
4343
#if defined(SN74X138_E3_PIN)
44-
setPinOutput(SN74X138_E3_PIN);
45-
writePinLow(SN74X138_E3_PIN);
44+
gpio_set_pin_output(SN74X138_E3_PIN);
45+
gpio_write_pin_low(SN74X138_E3_PIN);
4646
#endif
4747
}
4848

4949
void sn74x138_set_enabled(bool enabled) {
5050
#if defined(SN74X138_E1_PIN)
51-
writePin(SN74X138_E1_PIN, !enabled);
51+
gpio_write_pin(SN74X138_E1_PIN, !enabled);
5252
#endif
5353
#if defined(SN74X138_E2_PIN)
54-
writePin(SN74X138_E2_PIN, !enabled);
54+
gpio_write_pin(SN74X138_E2_PIN, !enabled);
5555
#endif
5656
#if defined(SN74X138_E3_PIN)
57-
writePin(SN74X138_E3_PIN, enabled);
57+
gpio_write_pin(SN74X138_E3_PIN, enabled);
5858
#endif
5959
}
6060

6161
void sn74x138_set_addr(uint8_t address) {
6262
for (int i = 0; i < ADDRESS_PIN_COUNT; i++) {
63-
writePin(address_pins[i], address & (1 << i));
63+
gpio_write_pin(address_pins[i], address & (1 << i));
6464
}
6565
}

drivers/gpio/sn74x154.c

+9-9
Original file line numberDiff line numberDiff line change
@@ -27,32 +27,32 @@ static const pin_t address_pins[ADDRESS_PIN_COUNT] = SN74X154_ADDRESS_PINS;
2727

2828
void sn74x154_init(void) {
2929
for (int i = 0; i < ADDRESS_PIN_COUNT; i++) {
30-
setPinOutput(address_pins[i]);
31-
writePinLow(address_pins[i]);
30+
gpio_set_pin_output(address_pins[i]);
31+
gpio_write_pin_low(address_pins[i]);
3232
}
3333

3434
#if defined(SN74X154_E0_PIN)
35-
setPinOutput(SN74X154_E0_PIN);
36-
writePinHigh(SN74X154_E0_PIN);
35+
gpio_set_pin_output(SN74X154_E0_PIN);
36+
gpio_write_pin_high(SN74X154_E0_PIN);
3737
#endif
3838

3939
#if defined(SN74X154_E1_PIN)
40-
setPinOutput(SN74X154_E1_PIN);
41-
writePinHigh(SN74X154_E1_PIN);
40+
gpio_set_pin_output(SN74X154_E1_PIN);
41+
gpio_write_pin_high(SN74X154_E1_PIN);
4242
#endif
4343
}
4444

4545
void sn74x154_set_enabled(bool enabled) {
4646
#if defined(SN74X154_E0_PIN)
47-
writePin(SN74X154_E0_PIN, !enabled);
47+
gpio_write_pin(SN74X154_E0_PIN, !enabled);
4848
#endif
4949
#if defined(SN74X154_E1_PIN)
50-
writePin(SN74X154_E1_PIN, !enabled);
50+
gpio_write_pin(SN74X154_E1_PIN, !enabled);
5151
#endif
5252
}
5353

5454
void sn74x154_set_addr(uint8_t address) {
5555
for (int i = 0; i < ADDRESS_PIN_COUNT; i++) {
56-
writePin(address_pins[i], address & (1 << i));
56+
gpio_write_pin(address_pins[i], address & (1 << i));
5757
}
5858
}

drivers/haptic/solenoid.c

+7-7
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ void solenoid_set_dwell(uint8_t dwell) {
6161
* @param index select which solenoid to check/stop
6262
*/
6363
void solenoid_stop(uint8_t index) {
64-
writePin(solenoid_pads[index], !solenoid_active_state[index]);
64+
gpio_write_pin(solenoid_pads[index], !solenoid_active_state[index]);
6565
solenoid_on[index] = false;
6666
solenoid_buzzing[index] = false;
6767
}
@@ -78,7 +78,7 @@ void solenoid_fire(uint8_t index) {
7878
solenoid_on[index] = true;
7979
solenoid_buzzing[index] = true;
8080
solenoid_start[index] = timer_read();
81-
writePin(solenoid_pads[index], solenoid_active_state[index]);
81+
gpio_write_pin(solenoid_pads[index], solenoid_active_state[index]);
8282
}
8383

8484
/**
@@ -128,12 +128,12 @@ void solenoid_check(void) {
128128
if ((elapsed[i] % (SOLENOID_BUZZ_ACTUATED + SOLENOID_BUZZ_NONACTUATED)) < SOLENOID_BUZZ_ACTUATED) {
129129
if (!solenoid_buzzing[i]) {
130130
solenoid_buzzing[i] = true;
131-
writePin(solenoid_pads[i], solenoid_active_state[i]);
131+
gpio_write_pin(solenoid_pads[i], solenoid_active_state[i]);
132132
}
133133
} else {
134134
if (solenoid_buzzing[i]) {
135135
solenoid_buzzing[i] = false;
136-
writePin(solenoid_pads[i], !solenoid_active_state[i]);
136+
gpio_write_pin(solenoid_pads[i], !solenoid_active_state[i]);
137137
}
138138
}
139139
}
@@ -156,8 +156,8 @@ void solenoid_setup(void) {
156156
#else
157157
solenoid_active_state[i] = high;
158158
#endif
159-
writePin(solenoid_pads[i], !solenoid_active_state[i]);
160-
setPinOutput(solenoid_pads[i]);
159+
gpio_write_pin(solenoid_pads[i], !solenoid_active_state[i]);
160+
gpio_set_pin_output(solenoid_pads[i]);
161161
if ((!HAPTIC_OFF_IN_LOW_POWER) || (usb_device_state == USB_DEVICE_STATE_CONFIGURED)) {
162162
solenoid_fire(i);
163163
}
@@ -170,6 +170,6 @@ void solenoid_setup(void) {
170170
*/
171171
void solenoid_shutdown(void) {
172172
for (uint8_t i = 0; i < NUMBER_OF_SOLENOIDS; i++) {
173-
writePin(solenoid_pads[i], !solenoid_active_state[i]);
173+
gpio_write_pin(solenoid_pads[i], !solenoid_active_state[i]);
174174
}
175175
}

drivers/lcd/hd44780.c

+24-24
Original file line numberDiff line numberDiff line change
@@ -57,67 +57,67 @@ static const pin_t data_pins[4] = HD44780_DATA_PINS;
5757
#define HD44780_ENABLE_DELAY_US 1
5858

5959
static void hd44780_latch(void) {
60-
writePinHigh(HD44780_E_PIN);
60+
gpio_write_pin_high(HD44780_E_PIN);
6161
wait_us(HD44780_ENABLE_DELAY_US);
62-
writePinLow(HD44780_E_PIN);
62+
gpio_write_pin_low(HD44780_E_PIN);
6363
}
6464

6565
void hd44780_write(uint8_t data, bool isData) {
66-
writePin(HD44780_RS_PIN, isData);
67-
writePinLow(HD44780_RW_PIN);
66+
gpio_write_pin(HD44780_RS_PIN, isData);
67+
gpio_write_pin_low(HD44780_RW_PIN);
6868

6969
for (int i = 0; i < 4; i++) {
70-
setPinOutput(data_pins[i]);
70+
gpio_set_pin_output(data_pins[i]);
7171
}
7272

7373
// Write high nibble
7474
for (int i = 0; i < 4; i++) {
75-
writePin(data_pins[i], (data >> 4) & (1 << i));
75+
gpio_write_pin(data_pins[i], (data >> 4) & (1 << i));
7676
}
7777
hd44780_latch();
7878

7979
// Write low nibble
8080
for (int i = 0; i < 4; i++) {
81-
writePin(data_pins[i], data & (1 << i));
81+
gpio_write_pin(data_pins[i], data & (1 << i));
8282
}
8383
hd44780_latch();
8484

8585
for (int i = 0; i < 4; i++) {
86-
writePinHigh(data_pins[i]);
86+
gpio_write_pin_high(data_pins[i]);
8787
}
8888
}
8989

9090
uint8_t hd44780_read(bool isData) {
9191
uint8_t data = 0;
9292

93-
writePin(HD44780_RS_PIN, isData);
94-
writePinHigh(HD44780_RW_PIN);
93+
gpio_write_pin(HD44780_RS_PIN, isData);
94+
gpio_write_pin_high(HD44780_RW_PIN);
9595

9696
for (int i = 0; i < 4; i++) {
97-
setPinInput(data_pins[i]);
97+
gpio_set_pin_input(data_pins[i]);
9898
}
9999

100-
writePinHigh(HD44780_E_PIN);
100+
gpio_write_pin_high(HD44780_E_PIN);
101101
wait_us(HD44780_ENABLE_DELAY_US);
102102

103103
// Read high nibble
104104
for (int i = 0; i < 4; i++) {
105-
data |= (readPin(data_pins[i]) << i);
105+
data |= (gpio_read_pin(data_pins[i]) << i);
106106
}
107107

108108
data <<= 4;
109109

110-
writePinLow(HD44780_E_PIN);
110+
gpio_write_pin_low(HD44780_E_PIN);
111111
wait_us(HD44780_ENABLE_DELAY_US);
112-
writePinHigh(HD44780_E_PIN);
112+
gpio_write_pin_high(HD44780_E_PIN);
113113
wait_us(HD44780_ENABLE_DELAY_US);
114114

115115
// Read low nibble
116116
for (int i = 0; i < 4; i++) {
117-
data |= (readPin(data_pins[i]) << i);
117+
data |= (gpio_read_pin(data_pins[i]) << i);
118118
}
119119

120-
writePinLow(HD44780_E_PIN);
120+
gpio_write_pin_low(HD44780_E_PIN);
121121

122122
return data;
123123
}
@@ -171,20 +171,20 @@ void hd44780_set_ddram_address(uint8_t address) {
171171
}
172172

173173
void hd44780_init(bool cursor, bool blink) {
174-
setPinOutput(HD44780_RS_PIN);
175-
setPinOutput(HD44780_RW_PIN);
176-
setPinOutput(HD44780_E_PIN);
174+
gpio_set_pin_output(HD44780_RS_PIN);
175+
gpio_set_pin_output(HD44780_RW_PIN);
176+
gpio_set_pin_output(HD44780_E_PIN);
177177

178178
for (int i = 0; i < 4; i++) {
179-
setPinOutput(data_pins[i]);
179+
gpio_set_pin_output(data_pins[i]);
180180
}
181181

182182
wait_ms(HD44780_INIT_DELAY_MS);
183183

184184
// Manually configure for 4-bit mode - can't use hd44780_command() yet
185185
// HD44780U datasheet, Fig. 24 (p46)
186-
writePinHigh(data_pins[0]); // Function set
187-
writePinHigh(data_pins[1]); // DL = 1
186+
gpio_write_pin_high(data_pins[0]); // Function set
187+
gpio_write_pin_high(data_pins[1]); // DL = 1
188188
hd44780_latch();
189189
wait_ms(5);
190190
// Send again
@@ -194,7 +194,7 @@ void hd44780_init(bool cursor, bool blink) {
194194
hd44780_latch();
195195
wait_us(64);
196196

197-
writePinLow(data_pins[0]); // DL = 0
197+
gpio_write_pin_low(data_pins[0]); // DL = 0
198198
hd44780_latch();
199199
wait_us(64);
200200

drivers/lcd/st7565.c

+8-8
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,10 @@ static void InvertCharacter(uint8_t *cursor) {
9292
}
9393

9494
bool st7565_init(display_rotation_t rotation) {
95-
setPinOutput(ST7565_A0_PIN);
96-
writePinHigh(ST7565_A0_PIN);
97-
setPinOutput(ST7565_RST_PIN);
98-
writePinHigh(ST7565_RST_PIN);
95+
gpio_set_pin_output(ST7565_A0_PIN);
96+
gpio_write_pin_high(ST7565_A0_PIN);
97+
gpio_set_pin_output(ST7565_RST_PIN);
98+
gpio_write_pin_high(ST7565_RST_PIN);
9999

100100
st7565_rotation = st7565_init_user(rotation);
101101

@@ -488,18 +488,18 @@ void st7565_task(void) {
488488
__attribute__((weak)) void st7565_task_user(void) {}
489489

490490
void st7565_reset(void) {
491-
writePinLow(ST7565_RST_PIN);
491+
gpio_write_pin_low(ST7565_RST_PIN);
492492
wait_ms(20);
493-
writePinHigh(ST7565_RST_PIN);
493+
gpio_write_pin_high(ST7565_RST_PIN);
494494
wait_ms(20);
495495
}
496496

497497
spi_status_t st7565_send_cmd(uint8_t cmd) {
498-
writePinLow(ST7565_A0_PIN);
498+
gpio_write_pin_low(ST7565_A0_PIN);
499499
return spi_write(cmd);
500500
}
501501

502502
spi_status_t st7565_send_data(uint8_t *data, uint16_t length) {
503-
writePinHigh(ST7565_A0_PIN);
503+
gpio_write_pin_high(ST7565_A0_PIN);
504504
return spi_transmit(data, length);
505505
}

0 commit comments

Comments
 (0)