Update GPIO macro usages in core (#23093)

This commit is contained in:
Ryan 2024-02-18 17:08:27 +11:00 committed by GitHub
parent 6810aaf013
commit 2d1aed78a6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
61 changed files with 334 additions and 334 deletions

View File

@ -188,7 +188,7 @@ static bool sdep_recv_pkt(struct sdep_msg *msg, uint16_t timeout) {
bool ready = false; bool ready = false;
do { do {
ready = readPin(BLUEFRUIT_LE_IRQ_PIN); ready = gpio_read_pin(BLUEFRUIT_LE_IRQ_PIN);
if (ready) { if (ready) {
break; break;
} }
@ -231,7 +231,7 @@ static void resp_buf_read_one(bool greedy) {
return; return;
} }
if (readPin(BLUEFRUIT_LE_IRQ_PIN)) { if (gpio_read_pin(BLUEFRUIT_LE_IRQ_PIN)) {
struct sdep_msg msg; struct sdep_msg msg;
again: again:
@ -242,7 +242,7 @@ static void resp_buf_read_one(bool greedy) {
dprintf("recv latency %dms\n", TIMER_DIFF_16(timer_read(), last_send)); dprintf("recv latency %dms\n", TIMER_DIFF_16(timer_read(), last_send));
} }
if (greedy && resp_buf.peek(last_send) && readPin(BLUEFRUIT_LE_IRQ_PIN)) { if (greedy && resp_buf.peek(last_send) && gpio_read_pin(BLUEFRUIT_LE_IRQ_PIN)) {
goto again; goto again;
} }
} }
@ -293,16 +293,16 @@ void bluefruit_le_init(void) {
state.configured = false; state.configured = false;
state.is_connected = false; state.is_connected = false;
setPinInput(BLUEFRUIT_LE_IRQ_PIN); gpio_set_pin_input(BLUEFRUIT_LE_IRQ_PIN);
spi_init(); spi_init();
// Perform a hardware reset // Perform a hardware reset
setPinOutput(BLUEFRUIT_LE_RST_PIN); gpio_set_pin_output(BLUEFRUIT_LE_RST_PIN);
writePinHigh(BLUEFRUIT_LE_RST_PIN); gpio_write_pin_high(BLUEFRUIT_LE_RST_PIN);
writePinLow(BLUEFRUIT_LE_RST_PIN); gpio_write_pin_low(BLUEFRUIT_LE_RST_PIN);
wait_ms(10); wait_ms(10);
writePinHigh(BLUEFRUIT_LE_RST_PIN); gpio_write_pin_high(BLUEFRUIT_LE_RST_PIN);
wait_ms(1000); // Give it a second to initialize wait_ms(1000); // Give it a second to initialize
@ -508,7 +508,7 @@ void bluefruit_le_task(void) {
resp_buf_read_one(true); resp_buf_read_one(true);
send_buf_send_one(SdepShortTimeout); send_buf_send_one(SdepShortTimeout);
if (resp_buf.empty() && (state.event_flags & UsingEvents) && readPin(BLUEFRUIT_LE_IRQ_PIN)) { if (resp_buf.empty() && (state.event_flags & UsingEvents) && gpio_read_pin(BLUEFRUIT_LE_IRQ_PIN)) {
// Must be an event update // Must be an event update
if (at_command_P(PSTR("AT+EVENTSTATUS"), resbuf, sizeof(resbuf))) { if (at_command_P(PSTR("AT+EVENTSTATUS"), resbuf, sizeof(resbuf))) {
uint32_t mask = strtoul(resbuf, NULL, 16); uint32_t mask = strtoul(resbuf, NULL, 16);

View File

@ -57,8 +57,8 @@ void eeprom_driver_init(void) {
i2c_init(); i2c_init();
#if defined(EXTERNAL_EEPROM_WP_PIN) #if defined(EXTERNAL_EEPROM_WP_PIN)
/* We are setting the WP pin to high in a way that requires at least two bit-flips to change back to 0 */ /* We are setting the WP pin to high in a way that requires at least two bit-flips to change back to 0 */
writePin(EXTERNAL_EEPROM_WP_PIN, 1); gpio_write_pin(EXTERNAL_EEPROM_WP_PIN, 1);
setPinInputHigh(EXTERNAL_EEPROM_WP_PIN); gpio_set_pin_input_high(EXTERNAL_EEPROM_WP_PIN);
#endif #endif
} }
@ -100,8 +100,8 @@ void eeprom_write_block(const void *buf, void *addr, size_t len) {
uintptr_t target_addr = (uintptr_t)addr; uintptr_t target_addr = (uintptr_t)addr;
#if defined(EXTERNAL_EEPROM_WP_PIN) #if defined(EXTERNAL_EEPROM_WP_PIN)
setPinOutput(EXTERNAL_EEPROM_WP_PIN); gpio_set_pin_output(EXTERNAL_EEPROM_WP_PIN);
writePin(EXTERNAL_EEPROM_WP_PIN, 0); gpio_write_pin(EXTERNAL_EEPROM_WP_PIN, 0);
#endif #endif
while (len > 0) { while (len > 0) {
@ -134,7 +134,7 @@ void eeprom_write_block(const void *buf, void *addr, size_t len) {
#if defined(EXTERNAL_EEPROM_WP_PIN) #if defined(EXTERNAL_EEPROM_WP_PIN)
/* We are setting the WP pin to high in a way that requires at least two bit-flips to change back to 0 */ /* We are setting the WP pin to high in a way that requires at least two bit-flips to change back to 0 */
writePin(EXTERNAL_EEPROM_WP_PIN, 1); gpio_write_pin(EXTERNAL_EEPROM_WP_PIN, 1);
setPinInputHigh(EXTERNAL_EEPROM_WP_PIN); gpio_set_pin_input_high(EXTERNAL_EEPROM_WP_PIN);
#endif #endif
} }

View File

@ -27,39 +27,39 @@ static const pin_t address_pins[ADDRESS_PIN_COUNT] = SN74X138_ADDRESS_PINS;
void sn74x138_init(void) { void sn74x138_init(void) {
for (int i = 0; i < ADDRESS_PIN_COUNT; i++) { for (int i = 0; i < ADDRESS_PIN_COUNT; i++) {
setPinOutput(address_pins[i]); gpio_set_pin_output(address_pins[i]);
writePinLow(address_pins[i]); gpio_write_pin_low(address_pins[i]);
} }
#if defined(SN74X138_E1_PIN) #if defined(SN74X138_E1_PIN)
setPinOutput(SN74X138_E1_PIN); gpio_set_pin_output(SN74X138_E1_PIN);
writePinHigh(SN74X138_E1_PIN); gpio_write_pin_high(SN74X138_E1_PIN);
#endif #endif
#if defined(SN74X138_E2_PIN) #if defined(SN74X138_E2_PIN)
setPinOutput(SN74X138_E2_PIN); gpio_set_pin_output(SN74X138_E2_PIN);
writePinHigh(SN74X138_E2_PIN); gpio_write_pin_high(SN74X138_E2_PIN);
#endif #endif
#if defined(SN74X138_E3_PIN) #if defined(SN74X138_E3_PIN)
setPinOutput(SN74X138_E3_PIN); gpio_set_pin_output(SN74X138_E3_PIN);
writePinLow(SN74X138_E3_PIN); gpio_write_pin_low(SN74X138_E3_PIN);
#endif #endif
} }
void sn74x138_set_enabled(bool enabled) { void sn74x138_set_enabled(bool enabled) {
#if defined(SN74X138_E1_PIN) #if defined(SN74X138_E1_PIN)
writePin(SN74X138_E1_PIN, !enabled); gpio_write_pin(SN74X138_E1_PIN, !enabled);
#endif #endif
#if defined(SN74X138_E2_PIN) #if defined(SN74X138_E2_PIN)
writePin(SN74X138_E2_PIN, !enabled); gpio_write_pin(SN74X138_E2_PIN, !enabled);
#endif #endif
#if defined(SN74X138_E3_PIN) #if defined(SN74X138_E3_PIN)
writePin(SN74X138_E3_PIN, enabled); gpio_write_pin(SN74X138_E3_PIN, enabled);
#endif #endif
} }
void sn74x138_set_addr(uint8_t address) { void sn74x138_set_addr(uint8_t address) {
for (int i = 0; i < ADDRESS_PIN_COUNT; i++) { for (int i = 0; i < ADDRESS_PIN_COUNT; i++) {
writePin(address_pins[i], address & (1 << i)); gpio_write_pin(address_pins[i], address & (1 << i));
} }
} }

View File

@ -27,32 +27,32 @@ static const pin_t address_pins[ADDRESS_PIN_COUNT] = SN74X154_ADDRESS_PINS;
void sn74x154_init(void) { void sn74x154_init(void) {
for (int i = 0; i < ADDRESS_PIN_COUNT; i++) { for (int i = 0; i < ADDRESS_PIN_COUNT; i++) {
setPinOutput(address_pins[i]); gpio_set_pin_output(address_pins[i]);
writePinLow(address_pins[i]); gpio_write_pin_low(address_pins[i]);
} }
#if defined(SN74X154_E0_PIN) #if defined(SN74X154_E0_PIN)
setPinOutput(SN74X154_E0_PIN); gpio_set_pin_output(SN74X154_E0_PIN);
writePinHigh(SN74X154_E0_PIN); gpio_write_pin_high(SN74X154_E0_PIN);
#endif #endif
#if defined(SN74X154_E1_PIN) #if defined(SN74X154_E1_PIN)
setPinOutput(SN74X154_E1_PIN); gpio_set_pin_output(SN74X154_E1_PIN);
writePinHigh(SN74X154_E1_PIN); gpio_write_pin_high(SN74X154_E1_PIN);
#endif #endif
} }
void sn74x154_set_enabled(bool enabled) { void sn74x154_set_enabled(bool enabled) {
#if defined(SN74X154_E0_PIN) #if defined(SN74X154_E0_PIN)
writePin(SN74X154_E0_PIN, !enabled); gpio_write_pin(SN74X154_E0_PIN, !enabled);
#endif #endif
#if defined(SN74X154_E1_PIN) #if defined(SN74X154_E1_PIN)
writePin(SN74X154_E1_PIN, !enabled); gpio_write_pin(SN74X154_E1_PIN, !enabled);
#endif #endif
} }
void sn74x154_set_addr(uint8_t address) { void sn74x154_set_addr(uint8_t address) {
for (int i = 0; i < ADDRESS_PIN_COUNT; i++) { for (int i = 0; i < ADDRESS_PIN_COUNT; i++) {
writePin(address_pins[i], address & (1 << i)); gpio_write_pin(address_pins[i], address & (1 << i));
} }
} }

View File

@ -61,7 +61,7 @@ void solenoid_set_dwell(uint8_t dwell) {
* @param index select which solenoid to check/stop * @param index select which solenoid to check/stop
*/ */
void solenoid_stop(uint8_t index) { void solenoid_stop(uint8_t index) {
writePin(solenoid_pads[index], !solenoid_active_state[index]); gpio_write_pin(solenoid_pads[index], !solenoid_active_state[index]);
solenoid_on[index] = false; solenoid_on[index] = false;
solenoid_buzzing[index] = false; solenoid_buzzing[index] = false;
} }
@ -78,7 +78,7 @@ void solenoid_fire(uint8_t index) {
solenoid_on[index] = true; solenoid_on[index] = true;
solenoid_buzzing[index] = true; solenoid_buzzing[index] = true;
solenoid_start[index] = timer_read(); solenoid_start[index] = timer_read();
writePin(solenoid_pads[index], solenoid_active_state[index]); gpio_write_pin(solenoid_pads[index], solenoid_active_state[index]);
} }
/** /**
@ -128,12 +128,12 @@ void solenoid_check(void) {
if ((elapsed[i] % (SOLENOID_BUZZ_ACTUATED + SOLENOID_BUZZ_NONACTUATED)) < SOLENOID_BUZZ_ACTUATED) { if ((elapsed[i] % (SOLENOID_BUZZ_ACTUATED + SOLENOID_BUZZ_NONACTUATED)) < SOLENOID_BUZZ_ACTUATED) {
if (!solenoid_buzzing[i]) { if (!solenoid_buzzing[i]) {
solenoid_buzzing[i] = true; solenoid_buzzing[i] = true;
writePin(solenoid_pads[i], solenoid_active_state[i]); gpio_write_pin(solenoid_pads[i], solenoid_active_state[i]);
} }
} else { } else {
if (solenoid_buzzing[i]) { if (solenoid_buzzing[i]) {
solenoid_buzzing[i] = false; solenoid_buzzing[i] = false;
writePin(solenoid_pads[i], !solenoid_active_state[i]); gpio_write_pin(solenoid_pads[i], !solenoid_active_state[i]);
} }
} }
} }
@ -156,8 +156,8 @@ void solenoid_setup(void) {
#else #else
solenoid_active_state[i] = high; solenoid_active_state[i] = high;
#endif #endif
writePin(solenoid_pads[i], !solenoid_active_state[i]); gpio_write_pin(solenoid_pads[i], !solenoid_active_state[i]);
setPinOutput(solenoid_pads[i]); gpio_set_pin_output(solenoid_pads[i]);
if ((!HAPTIC_OFF_IN_LOW_POWER) || (usb_device_state == USB_DEVICE_STATE_CONFIGURED)) { if ((!HAPTIC_OFF_IN_LOW_POWER) || (usb_device_state == USB_DEVICE_STATE_CONFIGURED)) {
solenoid_fire(i); solenoid_fire(i);
} }
@ -170,6 +170,6 @@ void solenoid_setup(void) {
*/ */
void solenoid_shutdown(void) { void solenoid_shutdown(void) {
for (uint8_t i = 0; i < NUMBER_OF_SOLENOIDS; i++) { for (uint8_t i = 0; i < NUMBER_OF_SOLENOIDS; i++) {
writePin(solenoid_pads[i], !solenoid_active_state[i]); gpio_write_pin(solenoid_pads[i], !solenoid_active_state[i]);
} }
} }

View File

@ -57,67 +57,67 @@ static const pin_t data_pins[4] = HD44780_DATA_PINS;
#define HD44780_ENABLE_DELAY_US 1 #define HD44780_ENABLE_DELAY_US 1
static void hd44780_latch(void) { static void hd44780_latch(void) {
writePinHigh(HD44780_E_PIN); gpio_write_pin_high(HD44780_E_PIN);
wait_us(HD44780_ENABLE_DELAY_US); wait_us(HD44780_ENABLE_DELAY_US);
writePinLow(HD44780_E_PIN); gpio_write_pin_low(HD44780_E_PIN);
} }
void hd44780_write(uint8_t data, bool isData) { void hd44780_write(uint8_t data, bool isData) {
writePin(HD44780_RS_PIN, isData); gpio_write_pin(HD44780_RS_PIN, isData);
writePinLow(HD44780_RW_PIN); gpio_write_pin_low(HD44780_RW_PIN);
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
setPinOutput(data_pins[i]); gpio_set_pin_output(data_pins[i]);
} }
// Write high nibble // Write high nibble
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
writePin(data_pins[i], (data >> 4) & (1 << i)); gpio_write_pin(data_pins[i], (data >> 4) & (1 << i));
} }
hd44780_latch(); hd44780_latch();
// Write low nibble // Write low nibble
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
writePin(data_pins[i], data & (1 << i)); gpio_write_pin(data_pins[i], data & (1 << i));
} }
hd44780_latch(); hd44780_latch();
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
writePinHigh(data_pins[i]); gpio_write_pin_high(data_pins[i]);
} }
} }
uint8_t hd44780_read(bool isData) { uint8_t hd44780_read(bool isData) {
uint8_t data = 0; uint8_t data = 0;
writePin(HD44780_RS_PIN, isData); gpio_write_pin(HD44780_RS_PIN, isData);
writePinHigh(HD44780_RW_PIN); gpio_write_pin_high(HD44780_RW_PIN);
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
setPinInput(data_pins[i]); gpio_set_pin_input(data_pins[i]);
} }
writePinHigh(HD44780_E_PIN); gpio_write_pin_high(HD44780_E_PIN);
wait_us(HD44780_ENABLE_DELAY_US); wait_us(HD44780_ENABLE_DELAY_US);
// Read high nibble // Read high nibble
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
data |= (readPin(data_pins[i]) << i); data |= (gpio_read_pin(data_pins[i]) << i);
} }
data <<= 4; data <<= 4;
writePinLow(HD44780_E_PIN); gpio_write_pin_low(HD44780_E_PIN);
wait_us(HD44780_ENABLE_DELAY_US); wait_us(HD44780_ENABLE_DELAY_US);
writePinHigh(HD44780_E_PIN); gpio_write_pin_high(HD44780_E_PIN);
wait_us(HD44780_ENABLE_DELAY_US); wait_us(HD44780_ENABLE_DELAY_US);
// Read low nibble // Read low nibble
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
data |= (readPin(data_pins[i]) << i); data |= (gpio_read_pin(data_pins[i]) << i);
} }
writePinLow(HD44780_E_PIN); gpio_write_pin_low(HD44780_E_PIN);
return data; return data;
} }
@ -171,20 +171,20 @@ void hd44780_set_ddram_address(uint8_t address) {
} }
void hd44780_init(bool cursor, bool blink) { void hd44780_init(bool cursor, bool blink) {
setPinOutput(HD44780_RS_PIN); gpio_set_pin_output(HD44780_RS_PIN);
setPinOutput(HD44780_RW_PIN); gpio_set_pin_output(HD44780_RW_PIN);
setPinOutput(HD44780_E_PIN); gpio_set_pin_output(HD44780_E_PIN);
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
setPinOutput(data_pins[i]); gpio_set_pin_output(data_pins[i]);
} }
wait_ms(HD44780_INIT_DELAY_MS); wait_ms(HD44780_INIT_DELAY_MS);
// Manually configure for 4-bit mode - can't use hd44780_command() yet // Manually configure for 4-bit mode - can't use hd44780_command() yet
// HD44780U datasheet, Fig. 24 (p46) // HD44780U datasheet, Fig. 24 (p46)
writePinHigh(data_pins[0]); // Function set gpio_write_pin_high(data_pins[0]); // Function set
writePinHigh(data_pins[1]); // DL = 1 gpio_write_pin_high(data_pins[1]); // DL = 1
hd44780_latch(); hd44780_latch();
wait_ms(5); wait_ms(5);
// Send again // Send again
@ -194,7 +194,7 @@ void hd44780_init(bool cursor, bool blink) {
hd44780_latch(); hd44780_latch();
wait_us(64); wait_us(64);
writePinLow(data_pins[0]); // DL = 0 gpio_write_pin_low(data_pins[0]); // DL = 0
hd44780_latch(); hd44780_latch();
wait_us(64); wait_us(64);

View File

@ -92,10 +92,10 @@ static void InvertCharacter(uint8_t *cursor) {
} }
bool st7565_init(display_rotation_t rotation) { bool st7565_init(display_rotation_t rotation) {
setPinOutput(ST7565_A0_PIN); gpio_set_pin_output(ST7565_A0_PIN);
writePinHigh(ST7565_A0_PIN); gpio_write_pin_high(ST7565_A0_PIN);
setPinOutput(ST7565_RST_PIN); gpio_set_pin_output(ST7565_RST_PIN);
writePinHigh(ST7565_RST_PIN); gpio_write_pin_high(ST7565_RST_PIN);
st7565_rotation = st7565_init_user(rotation); st7565_rotation = st7565_init_user(rotation);
@ -488,18 +488,18 @@ void st7565_task(void) {
__attribute__((weak)) void st7565_task_user(void) {} __attribute__((weak)) void st7565_task_user(void) {}
void st7565_reset(void) { void st7565_reset(void) {
writePinLow(ST7565_RST_PIN); gpio_write_pin_low(ST7565_RST_PIN);
wait_ms(20); wait_ms(20);
writePinHigh(ST7565_RST_PIN); gpio_write_pin_high(ST7565_RST_PIN);
wait_ms(20); wait_ms(20);
} }
spi_status_t st7565_send_cmd(uint8_t cmd) { spi_status_t st7565_send_cmd(uint8_t cmd) {
writePinLow(ST7565_A0_PIN); gpio_write_pin_low(ST7565_A0_PIN);
return spi_write(cmd); return spi_write(cmd);
} }
spi_status_t st7565_send_data(uint8_t *data, uint16_t length) { spi_status_t st7565_send_data(uint8_t *data, uint16_t length) {
writePinHigh(ST7565_A0_PIN); gpio_write_pin_high(ST7565_A0_PIN);
return spi_transmit(data, length); return spi_transmit(data, length);
} }

View File

@ -43,14 +43,14 @@
} \ } \
} while (0) } while (0)
#define APA102_SEND_BIT(byte, bit) \ #define APA102_SEND_BIT(byte, bit) \
do { \ do { \
writePin(APA102_DI_PIN, (byte >> bit) & 1); \ gpio_write_pin(APA102_DI_PIN, (byte >> bit) & 1); \
io_wait; \ io_wait; \
writePinHigh(APA102_CI_PIN); \ gpio_write_pin_high(APA102_CI_PIN); \
io_wait; \ io_wait; \
writePinLow(APA102_CI_PIN); \ gpio_write_pin_low(APA102_CI_PIN); \
io_wait; \ io_wait; \
} while (0) } while (0)
uint8_t apa102_led_brightness = APA102_DEFAULT_BRIGHTNESS; uint8_t apa102_led_brightness = APA102_DEFAULT_BRIGHTNESS;
@ -114,11 +114,11 @@ static void apa102_send_frame(uint8_t red, uint8_t green, uint8_t blue, uint8_t
} }
void apa102_init(void) { void apa102_init(void) {
setPinOutput(APA102_DI_PIN); gpio_set_pin_output(APA102_DI_PIN);
setPinOutput(APA102_CI_PIN); gpio_set_pin_output(APA102_CI_PIN);
writePinLow(APA102_DI_PIN); gpio_write_pin_low(APA102_DI_PIN);
writePinLow(APA102_CI_PIN); gpio_write_pin_low(APA102_CI_PIN);
} }
void apa102_setleds(rgb_led_t *start_led, uint16_t num_leds) { void apa102_setleds(rgb_led_t *start_led, uint16_t num_leds) {

View File

@ -114,8 +114,8 @@ void aw20216s_init_drivers(void) {
spi_init(); spi_init();
#if defined(AW20216S_EN_PIN) #if defined(AW20216S_EN_PIN)
setPinOutput(AW20216S_EN_PIN); gpio_set_pin_output(AW20216S_EN_PIN);
writePinHigh(AW20216S_EN_PIN); gpio_write_pin_high(AW20216S_EN_PIN);
#endif #endif
aw20216s_init(AW20216S_CS_PIN_1); aw20216s_init(AW20216S_CS_PIN_1);

View File

@ -68,8 +68,8 @@ void is31fl3218_init(void) {
i2c_init(); i2c_init();
#if defined(IS31FL3218_SDB_PIN) #if defined(IS31FL3218_SDB_PIN)
setPinOutput(IS31FL3218_SDB_PIN); gpio_set_pin_output(IS31FL3218_SDB_PIN);
writePinHigh(IS31FL3218_SDB_PIN); gpio_write_pin_high(IS31FL3218_SDB_PIN);
#endif #endif
// In case we ever want to reinitialize (?) // In case we ever want to reinitialize (?)

View File

@ -68,8 +68,8 @@ void is31fl3218_init(void) {
i2c_init(); i2c_init();
#if defined(IS31FL3218_SDB_PIN) #if defined(IS31FL3218_SDB_PIN)
setPinOutput(IS31FL3218_SDB_PIN); gpio_set_pin_output(IS31FL3218_SDB_PIN);
writePinHigh(IS31FL3218_SDB_PIN); gpio_write_pin_high(IS31FL3218_SDB_PIN);
#endif #endif
// In case we ever want to reinitialize (?) // In case we ever want to reinitialize (?)

View File

@ -99,8 +99,8 @@ void is31fl3731_init_drivers(void) {
i2c_init(); i2c_init();
#if defined(IS31FL3731_SDB_PIN) #if defined(IS31FL3731_SDB_PIN)
setPinOutput(IS31FL3731_SDB_PIN); gpio_set_pin_output(IS31FL3731_SDB_PIN);
writePinHigh(IS31FL3731_SDB_PIN); gpio_write_pin_high(IS31FL3731_SDB_PIN);
#endif #endif
for (uint8_t i = 0; i < IS31FL3731_DRIVER_COUNT; i++) { for (uint8_t i = 0; i < IS31FL3731_DRIVER_COUNT; i++) {

View File

@ -98,8 +98,8 @@ void is31fl3731_init_drivers(void) {
i2c_init(); i2c_init();
#if defined(IS31FL3731_SDB_PIN) #if defined(IS31FL3731_SDB_PIN)
setPinOutput(IS31FL3731_SDB_PIN); gpio_set_pin_output(IS31FL3731_SDB_PIN);
writePinHigh(IS31FL3731_SDB_PIN); gpio_write_pin_high(IS31FL3731_SDB_PIN);
#endif #endif
for (uint8_t i = 0; i < IS31FL3731_DRIVER_COUNT; i++) { for (uint8_t i = 0; i < IS31FL3731_DRIVER_COUNT; i++) {

View File

@ -144,8 +144,8 @@ void is31fl3733_init_drivers(void) {
i2c_init(); i2c_init();
#if defined(IS31FL3733_SDB_PIN) #if defined(IS31FL3733_SDB_PIN)
setPinOutput(IS31FL3733_SDB_PIN); gpio_set_pin_output(IS31FL3733_SDB_PIN);
writePinHigh(IS31FL3733_SDB_PIN); gpio_write_pin_high(IS31FL3733_SDB_PIN);
#endif #endif
for (uint8_t i = 0; i < IS31FL3733_DRIVER_COUNT; i++) { for (uint8_t i = 0; i < IS31FL3733_DRIVER_COUNT; i++) {

View File

@ -143,8 +143,8 @@ void is31fl3733_init_drivers(void) {
i2c_init(); i2c_init();
#if defined(IS31FL3733_SDB_PIN) #if defined(IS31FL3733_SDB_PIN)
setPinOutput(IS31FL3733_SDB_PIN); gpio_set_pin_output(IS31FL3733_SDB_PIN);
writePinHigh(IS31FL3733_SDB_PIN); gpio_write_pin_high(IS31FL3733_SDB_PIN);
#endif #endif
for (uint8_t i = 0; i < IS31FL3733_DRIVER_COUNT; i++) { for (uint8_t i = 0; i < IS31FL3733_DRIVER_COUNT; i++) {

View File

@ -115,8 +115,8 @@ void is31fl3736_init_drivers(void) {
i2c_init(); i2c_init();
#if defined(IS31FL3736_SDB_PIN) #if defined(IS31FL3736_SDB_PIN)
setPinOutput(IS31FL3736_SDB_PIN); gpio_set_pin_output(IS31FL3736_SDB_PIN);
writePinHigh(IS31FL3736_SDB_PIN); gpio_write_pin_high(IS31FL3736_SDB_PIN);
#endif #endif
for (uint8_t i = 0; i < IS31FL3736_DRIVER_COUNT; i++) { for (uint8_t i = 0; i < IS31FL3736_DRIVER_COUNT; i++) {

View File

@ -115,8 +115,8 @@ void is31fl3736_init_drivers(void) {
i2c_init(); i2c_init();
#if defined(IS31FL3736_SDB_PIN) #if defined(IS31FL3736_SDB_PIN)
setPinOutput(IS31FL3736_SDB_PIN); gpio_set_pin_output(IS31FL3736_SDB_PIN);
writePinHigh(IS31FL3736_SDB_PIN); gpio_write_pin_high(IS31FL3736_SDB_PIN);
#endif #endif
for (uint8_t i = 0; i < IS31FL3736_DRIVER_COUNT; i++) { for (uint8_t i = 0; i < IS31FL3736_DRIVER_COUNT; i++) {

View File

@ -117,8 +117,8 @@ void is31fl3737_init_drivers(void) {
i2c_init(); i2c_init();
#if defined(IS31FL3737_SDB_PIN) #if defined(IS31FL3737_SDB_PIN)
setPinOutput(IS31FL3737_SDB_PIN); gpio_set_pin_output(IS31FL3737_SDB_PIN);
writePinHigh(IS31FL3737_SDB_PIN); gpio_write_pin_high(IS31FL3737_SDB_PIN);
#endif #endif
for (uint8_t i = 0; i < IS31FL3737_DRIVER_COUNT; i++) { for (uint8_t i = 0; i < IS31FL3737_DRIVER_COUNT; i++) {

View File

@ -117,8 +117,8 @@ void is31fl3737_init_drivers(void) {
i2c_init(); i2c_init();
#if defined(IS31FL3737_SDB_PIN) #if defined(IS31FL3737_SDB_PIN)
setPinOutput(IS31FL3737_SDB_PIN); gpio_set_pin_output(IS31FL3737_SDB_PIN);
writePinHigh(IS31FL3737_SDB_PIN); gpio_write_pin_high(IS31FL3737_SDB_PIN);
#endif #endif
for (uint8_t i = 0; i < IS31FL3737_DRIVER_COUNT; i++) { for (uint8_t i = 0; i < IS31FL3737_DRIVER_COUNT; i++) {

View File

@ -143,8 +143,8 @@ void is31fl3741_init_drivers(void) {
i2c_init(); i2c_init();
#if defined(IS31FL3741_SDB_PIN) #if defined(IS31FL3741_SDB_PIN)
setPinOutput(IS31FL3741_SDB_PIN); gpio_set_pin_output(IS31FL3741_SDB_PIN);
writePinHigh(IS31FL3741_SDB_PIN); gpio_write_pin_high(IS31FL3741_SDB_PIN);
#endif #endif
for (uint8_t i = 0; i < IS31FL3741_DRIVER_COUNT; i++) { for (uint8_t i = 0; i < IS31FL3741_DRIVER_COUNT; i++) {

View File

@ -143,8 +143,8 @@ void is31fl3741_init_drivers(void) {
i2c_init(); i2c_init();
#if defined(IS31FL3741_SDB_PIN) #if defined(IS31FL3741_SDB_PIN)
setPinOutput(IS31FL3741_SDB_PIN); gpio_set_pin_output(IS31FL3741_SDB_PIN);
writePinHigh(IS31FL3741_SDB_PIN); gpio_write_pin_high(IS31FL3741_SDB_PIN);
#endif #endif
for (uint8_t i = 0; i < IS31FL3741_DRIVER_COUNT; i++) { for (uint8_t i = 0; i < IS31FL3741_DRIVER_COUNT; i++) {

View File

@ -116,8 +116,8 @@ void is31fl3742a_init_drivers(void) {
i2c_init(); i2c_init();
#if defined(IS31FL3742A_SDB_PIN) #if defined(IS31FL3742A_SDB_PIN)
setPinOutput(IS31FL3742A_SDB_PIN); gpio_set_pin_output(IS31FL3742A_SDB_PIN);
writePinHigh(IS31FL3742A_SDB_PIN); gpio_write_pin_high(IS31FL3742A_SDB_PIN);
#endif #endif
for (uint8_t i = 0; i < IS31FL3742A_DRIVER_COUNT; i++) { for (uint8_t i = 0; i < IS31FL3742A_DRIVER_COUNT; i++) {

View File

@ -116,8 +116,8 @@ void is31fl3742a_init_drivers(void) {
i2c_init(); i2c_init();
#if defined(IS31FL3742A_SDB_PIN) #if defined(IS31FL3742A_SDB_PIN)
setPinOutput(IS31FL3742A_SDB_PIN); gpio_set_pin_output(IS31FL3742A_SDB_PIN);
writePinHigh(IS31FL3742A_SDB_PIN); gpio_write_pin_high(IS31FL3742A_SDB_PIN);
#endif #endif
for (uint8_t i = 0; i < IS31FL3742A_DRIVER_COUNT; i++) { for (uint8_t i = 0; i < IS31FL3742A_DRIVER_COUNT; i++) {

View File

@ -138,8 +138,8 @@ void is31fl3743a_init_drivers(void) {
i2c_init(); i2c_init();
#if defined(IS31FL3743A_SDB_PIN) #if defined(IS31FL3743A_SDB_PIN)
setPinOutput(IS31FL3743A_SDB_PIN); gpio_set_pin_output(IS31FL3743A_SDB_PIN);
writePinHigh(IS31FL3743A_SDB_PIN); gpio_write_pin_high(IS31FL3743A_SDB_PIN);
#endif #endif
for (uint8_t i = 0; i < IS31FL3743A_DRIVER_COUNT; i++) { for (uint8_t i = 0; i < IS31FL3743A_DRIVER_COUNT; i++) {

View File

@ -138,8 +138,8 @@ void is31fl3743a_init_drivers(void) {
i2c_init(); i2c_init();
#if defined(IS31FL3743A_SDB_PIN) #if defined(IS31FL3743A_SDB_PIN)
setPinOutput(IS31FL3743A_SDB_PIN); gpio_set_pin_output(IS31FL3743A_SDB_PIN);
writePinHigh(IS31FL3743A_SDB_PIN); gpio_write_pin_high(IS31FL3743A_SDB_PIN);
#endif #endif
for (uint8_t i = 0; i < IS31FL3743A_DRIVER_COUNT; i++) { for (uint8_t i = 0; i < IS31FL3743A_DRIVER_COUNT; i++) {

View File

@ -138,8 +138,8 @@ void is31fl3745_init_drivers(void) {
i2c_init(); i2c_init();
#if defined(IS31FL3745_SDB_PIN) #if defined(IS31FL3745_SDB_PIN)
setPinOutput(IS31FL3745_SDB_PIN); gpio_set_pin_output(IS31FL3745_SDB_PIN);
writePinHigh(IS31FL3745_SDB_PIN); gpio_write_pin_high(IS31FL3745_SDB_PIN);
#endif #endif
for (uint8_t i = 0; i < IS31FL3745_DRIVER_COUNT; i++) { for (uint8_t i = 0; i < IS31FL3745_DRIVER_COUNT; i++) {

View File

@ -138,8 +138,8 @@ void is31fl3745_init_drivers(void) {
i2c_init(); i2c_init();
#if defined(IS31FL3745_SDB_PIN) #if defined(IS31FL3745_SDB_PIN)
setPinOutput(IS31FL3745_SDB_PIN); gpio_set_pin_output(IS31FL3745_SDB_PIN);
writePinHigh(IS31FL3745_SDB_PIN); gpio_write_pin_high(IS31FL3745_SDB_PIN);
#endif #endif
for (uint8_t i = 0; i < IS31FL3745_DRIVER_COUNT; i++) { for (uint8_t i = 0; i < IS31FL3745_DRIVER_COUNT; i++) {

View File

@ -116,8 +116,8 @@ void is31fl3746a_init_drivers(void) {
i2c_init(); i2c_init();
#if defined(IS31FL3746A_SDB_PIN) #if defined(IS31FL3746A_SDB_PIN)
setPinOutput(IS31FL3746A_SDB_PIN); gpio_set_pin_output(IS31FL3746A_SDB_PIN);
writePinHigh(IS31FL3746A_SDB_PIN); gpio_write_pin_high(IS31FL3746A_SDB_PIN);
#endif #endif
for (uint8_t i = 0; i < IS31FL3746A_DRIVER_COUNT; i++) { for (uint8_t i = 0; i < IS31FL3746A_DRIVER_COUNT; i++) {

View File

@ -116,8 +116,8 @@ void is31fl3746a_init_drivers(void) {
i2c_init(); i2c_init();
#if defined(IS31FL3746A_SDB_PIN) #if defined(IS31FL3746A_SDB_PIN)
setPinOutput(IS31FL3746A_SDB_PIN); gpio_set_pin_output(IS31FL3746A_SDB_PIN);
writePinHigh(IS31FL3746A_SDB_PIN); gpio_write_pin_high(IS31FL3746A_SDB_PIN);
#endif #endif
for (uint8_t i = 0; i < IS31FL3746A_DRIVER_COUNT; i++) { for (uint8_t i = 0; i < IS31FL3746A_DRIVER_COUNT; i++) {

View File

@ -105,8 +105,8 @@ void snled27351_init_drivers(void) {
i2c_init(); i2c_init();
#if defined(SNLED27351_SDB_PIN) #if defined(SNLED27351_SDB_PIN)
setPinOutput(SNLED27351_SDB_PIN); gpio_set_pin_output(SNLED27351_SDB_PIN);
writePinHigh(SNLED27351_SDB_PIN); gpio_write_pin_high(SNLED27351_SDB_PIN);
#endif #endif
for (uint8_t i = 0; i < SNLED27351_DRIVER_COUNT; i++) { for (uint8_t i = 0; i < SNLED27351_DRIVER_COUNT; i++) {

View File

@ -105,8 +105,8 @@ void snled27351_init_drivers(void) {
i2c_init(); i2c_init();
#if defined(SNLED27351_SDB_PIN) #if defined(SNLED27351_SDB_PIN)
setPinOutput(SNLED27351_SDB_PIN); gpio_set_pin_output(SNLED27351_SDB_PIN);
writePinHigh(SNLED27351_SDB_PIN); gpio_write_pin_high(SNLED27351_SDB_PIN);
#endif #endif
for (uint8_t i = 0; i < SNLED27351_DRIVER_COUNT; i++) { for (uint8_t i = 0; i < SNLED27351_DRIVER_COUNT; i++) {

View File

@ -192,7 +192,7 @@ __attribute__((weak)) bool oled_send_cmd(const uint8_t *data, uint16_t size) {
return false; return false;
} }
// Command Mode // Command Mode
writePinLow(OLED_DC_PIN); gpio_write_pin_low(OLED_DC_PIN);
// Send the commands // Send the commands
if (spi_transmit(&data[1], size - 1) != SPI_STATUS_SUCCESS) { if (spi_transmit(&data[1], size - 1) != SPI_STATUS_SUCCESS) {
spi_stop(); spi_stop();
@ -215,7 +215,7 @@ __attribute__((weak)) bool oled_send_cmd_P(const uint8_t *data, uint16_t size) {
} }
spi_status_t status = SPI_STATUS_SUCCESS; spi_status_t status = SPI_STATUS_SUCCESS;
// Command Mode // Command Mode
writePinLow(OLED_DC_PIN); gpio_write_pin_low(OLED_DC_PIN);
// Send the commands // Send the commands
for (uint16_t i = 1; i < size && status >= 0; i++) { for (uint16_t i = 1; i < size && status >= 0; i++) {
status = spi_write(pgm_read_byte((const char *)&data[i])); status = spi_write(pgm_read_byte((const char *)&data[i]));
@ -239,7 +239,7 @@ __attribute__((weak)) bool oled_send_data(const uint8_t *data, uint16_t size) {
return false; return false;
} }
// Data Mode // Data Mode
writePinHigh(OLED_DC_PIN); gpio_write_pin_high(OLED_DC_PIN);
// Send the commands // Send the commands
if (spi_transmit(data, size) != SPI_STATUS_SUCCESS) { if (spi_transmit(data, size) != SPI_STATUS_SUCCESS) {
spi_stop(); spi_stop();
@ -256,17 +256,17 @@ __attribute__((weak)) bool oled_send_data(const uint8_t *data, uint16_t size) {
__attribute__((weak)) void oled_driver_init(void) { __attribute__((weak)) void oled_driver_init(void) {
#if defined(OLED_TRANSPORT_SPI) #if defined(OLED_TRANSPORT_SPI)
spi_init(); spi_init();
setPinOutput(OLED_CS_PIN); gpio_set_pin_output(OLED_CS_PIN);
writePinHigh(OLED_CS_PIN); gpio_write_pin_high(OLED_CS_PIN);
setPinOutput(OLED_DC_PIN); gpio_set_pin_output(OLED_DC_PIN);
writePinLow(OLED_DC_PIN); gpio_write_pin_low(OLED_DC_PIN);
# ifdef OLED_RST_PIN # ifdef OLED_RST_PIN
/* Reset device */ /* Reset device */
setPinOutput(OLED_RST_PIN); gpio_set_pin_output(OLED_RST_PIN);
writePinLow(OLED_RST_PIN); gpio_write_pin_low(OLED_RST_PIN);
wait_ms(20); wait_ms(20);
writePinHigh(OLED_RST_PIN); gpio_write_pin_high(OLED_RST_PIN);
wait_ms(20); wait_ms(20);
# endif # endif
#elif defined(OLED_TRANSPORT_I2C) #elif defined(OLED_TRANSPORT_I2C)

View File

@ -17,8 +17,8 @@ bool qp_comms_spi_init(painter_device_t device) {
spi_init(); spi_init();
// Set up CS as output high // Set up CS as output high
setPinOutput(comms_config->chip_select_pin); gpio_set_pin_output(comms_config->chip_select_pin);
writePinHigh(comms_config->chip_select_pin); gpio_write_pin_high(comms_config->chip_select_pin);
return true; return true;
} }
@ -49,7 +49,7 @@ void qp_comms_spi_stop(painter_device_t device) {
painter_driver_t * driver = (painter_driver_t *)device; painter_driver_t * driver = (painter_driver_t *)device;
qp_comms_spi_config_t *comms_config = (qp_comms_spi_config_t *)driver->comms_config; qp_comms_spi_config_t *comms_config = (qp_comms_spi_config_t *)driver->comms_config;
spi_stop(); spi_stop();
writePinHigh(comms_config->chip_select_pin); gpio_write_pin_high(comms_config->chip_select_pin);
} }
const painter_comms_vtable_t spi_comms_vtable = { const painter_comms_vtable_t spi_comms_vtable = {
@ -74,16 +74,16 @@ bool qp_comms_spi_dc_reset_init(painter_device_t device) {
// Set up D/C as output low, if specified // Set up D/C as output low, if specified
if (comms_config->dc_pin != NO_PIN) { if (comms_config->dc_pin != NO_PIN) {
setPinOutput(comms_config->dc_pin); gpio_set_pin_output(comms_config->dc_pin);
writePinLow(comms_config->dc_pin); gpio_write_pin_low(comms_config->dc_pin);
} }
// Set up RST as output, if specified, performing a reset in the process // Set up RST as output, if specified, performing a reset in the process
if (comms_config->reset_pin != NO_PIN) { if (comms_config->reset_pin != NO_PIN) {
setPinOutput(comms_config->reset_pin); gpio_set_pin_output(comms_config->reset_pin);
writePinLow(comms_config->reset_pin); gpio_write_pin_low(comms_config->reset_pin);
wait_ms(20); wait_ms(20);
writePinHigh(comms_config->reset_pin); gpio_write_pin_high(comms_config->reset_pin);
wait_ms(20); wait_ms(20);
} }
@ -93,14 +93,14 @@ bool qp_comms_spi_dc_reset_init(painter_device_t device) {
uint32_t qp_comms_spi_dc_reset_send_data(painter_device_t device, const void *data, uint32_t byte_count) { uint32_t qp_comms_spi_dc_reset_send_data(painter_device_t device, const void *data, uint32_t byte_count) {
painter_driver_t * driver = (painter_driver_t *)device; painter_driver_t * driver = (painter_driver_t *)device;
qp_comms_spi_dc_reset_config_t *comms_config = (qp_comms_spi_dc_reset_config_t *)driver->comms_config; qp_comms_spi_dc_reset_config_t *comms_config = (qp_comms_spi_dc_reset_config_t *)driver->comms_config;
writePinHigh(comms_config->dc_pin); gpio_write_pin_high(comms_config->dc_pin);
return qp_comms_spi_send_data(device, data, byte_count); return qp_comms_spi_send_data(device, data, byte_count);
} }
void qp_comms_spi_dc_reset_send_command(painter_device_t device, uint8_t cmd) { void qp_comms_spi_dc_reset_send_command(painter_device_t device, uint8_t cmd) {
painter_driver_t * driver = (painter_driver_t *)device; painter_driver_t * driver = (painter_driver_t *)device;
qp_comms_spi_dc_reset_config_t *comms_config = (qp_comms_spi_dc_reset_config_t *)driver->comms_config; qp_comms_spi_dc_reset_config_t *comms_config = (qp_comms_spi_dc_reset_config_t *)driver->comms_config;
writePinLow(comms_config->dc_pin); gpio_write_pin_low(comms_config->dc_pin);
spi_write(cmd); spi_write(cmd);
} }

View File

@ -47,9 +47,9 @@
void adns5050_init(void) { void adns5050_init(void) {
// Initialize the ADNS serial pins. // Initialize the ADNS serial pins.
setPinOutput(ADNS5050_SCLK_PIN); gpio_set_pin_output(ADNS5050_SCLK_PIN);
setPinOutput(ADNS5050_SDIO_PIN); gpio_set_pin_output(ADNS5050_SDIO_PIN);
setPinOutput(ADNS5050_CS_PIN); gpio_set_pin_output(ADNS5050_CS_PIN);
// reboot the adns. // reboot the adns.
// if the adns hasn't initialized yet, this is harmless. // if the adns hasn't initialized yet, this is harmless.
@ -69,30 +69,30 @@ void adns5050_init(void) {
// Just as with the serial protocol, this is used by the slave to send a // Just as with the serial protocol, this is used by the slave to send a
// synchronization signal to the master. // synchronization signal to the master.
void adns5050_sync(void) { void adns5050_sync(void) {
writePinLow(ADNS5050_CS_PIN); gpio_write_pin_low(ADNS5050_CS_PIN);
wait_us(1); wait_us(1);
writePinHigh(ADNS5050_CS_PIN); gpio_write_pin_high(ADNS5050_CS_PIN);
} }
void adns5050_cs_select(void) { void adns5050_cs_select(void) {
writePinLow(ADNS5050_CS_PIN); gpio_write_pin_low(ADNS5050_CS_PIN);
} }
void adns5050_cs_deselect(void) { void adns5050_cs_deselect(void) {
writePinHigh(ADNS5050_CS_PIN); gpio_write_pin_high(ADNS5050_CS_PIN);
} }
uint8_t adns5050_serial_read(void) { uint8_t adns5050_serial_read(void) {
setPinInput(ADNS5050_SDIO_PIN); gpio_set_pin_input(ADNS5050_SDIO_PIN);
uint8_t byte = 0; uint8_t byte = 0;
for (uint8_t i = 0; i < 8; ++i) { for (uint8_t i = 0; i < 8; ++i) {
writePinLow(ADNS5050_SCLK_PIN); gpio_write_pin_low(ADNS5050_SCLK_PIN);
wait_us(1); wait_us(1);
byte = (byte << 1) | readPin(ADNS5050_SDIO_PIN); byte = (byte << 1) | gpio_read_pin(ADNS5050_SDIO_PIN);
writePinHigh(ADNS5050_SCLK_PIN); gpio_write_pin_high(ADNS5050_SCLK_PIN);
wait_us(1); wait_us(1);
} }
@ -100,19 +100,19 @@ uint8_t adns5050_serial_read(void) {
} }
void adns5050_serial_write(uint8_t data) { void adns5050_serial_write(uint8_t data) {
setPinOutput(ADNS5050_SDIO_PIN); gpio_set_pin_output(ADNS5050_SDIO_PIN);
for (int8_t b = 7; b >= 0; b--) { for (int8_t b = 7; b >= 0; b--) {
writePinLow(ADNS5050_SCLK_PIN); gpio_write_pin_low(ADNS5050_SCLK_PIN);
if (data & (1 << b)) if (data & (1 << b))
writePinHigh(ADNS5050_SDIO_PIN); gpio_write_pin_high(ADNS5050_SDIO_PIN);
else else
writePinLow(ADNS5050_SDIO_PIN); gpio_write_pin_low(ADNS5050_SDIO_PIN);
wait_us(2); wait_us(2);
writePinHigh(ADNS5050_SCLK_PIN); gpio_write_pin_high(ADNS5050_SCLK_PIN);
} }
// tSWR. See page 15 of the ADNS spec sheet. // tSWR. See page 15 of the ADNS spec sheet.

View File

@ -100,7 +100,7 @@ uint8_t adns9800_read(uint8_t reg_addr) {
} }
void adns9800_init(void) { void adns9800_init(void) {
setPinOutput(ADNS9800_CS_PIN); gpio_set_pin_output(ADNS9800_CS_PIN);
spi_init(); spi_init();

View File

@ -122,17 +122,17 @@ report_analog_joystick_t analog_joystick_read(void) {
report.y = axisToMouseComponent(ANALOG_JOYSTICK_Y_AXIS_PIN, yOrigin, maxCursorSpeed, 1); report.y = axisToMouseComponent(ANALOG_JOYSTICK_Y_AXIS_PIN, yOrigin, maxCursorSpeed, 1);
} }
#ifdef ANALOG_JOYSTICK_CLICK_PIN #ifdef ANALOG_JOYSTICK_CLICK_PIN
report.button = !readPin(ANALOG_JOYSTICK_CLICK_PIN); report.button = !gpio_read_pin(ANALOG_JOYSTICK_CLICK_PIN);
#endif #endif
return report; return report;
} }
void analog_joystick_init(void) { void analog_joystick_init(void) {
setPinInputHigh(ANALOG_JOYSTICK_X_AXIS_PIN); gpio_set_pin_input_high(ANALOG_JOYSTICK_X_AXIS_PIN);
setPinInputHigh(ANALOG_JOYSTICK_Y_AXIS_PIN); gpio_set_pin_input_high(ANALOG_JOYSTICK_Y_AXIS_PIN);
#ifdef ANALOG_JOYSTICK_CLICK_PIN #ifdef ANALOG_JOYSTICK_CLICK_PIN
setPinInputHigh(ANALOG_JOYSTICK_CLICK_PIN); gpio_set_pin_input_high(ANALOG_JOYSTICK_CLICK_PIN);
#endif #endif
// Account for drift // Account for drift
xOrigin = analogReadPin(ANALOG_JOYSTICK_X_AXIS_PIN); xOrigin = analogReadPin(ANALOG_JOYSTICK_X_AXIS_PIN);

View File

@ -51,8 +51,8 @@ uint8_t paw3204_read_reg(uint8_t reg_addr);
void paw3204_write_reg(uint8_t reg_addr, uint8_t data); void paw3204_write_reg(uint8_t reg_addr, uint8_t data);
void paw3204_init(void) { void paw3204_init(void) {
setPinOutput(PAW3204_SCLK_PIN); // setclockpin to output gpio_set_pin_output(PAW3204_SCLK_PIN); // setclockpin to output
setPinInputHigh(PAW3204_SDIO_PIN); // set datapin input high gpio_set_pin_input_high(PAW3204_SDIO_PIN); // set datapin input high
paw3204_write_reg(REG_SETUP, 0x86); // reset sensor and set 1600cpi paw3204_write_reg(REG_SETUP, 0x86); // reset sensor and set 1600cpi
wait_us(5); wait_us(5);
@ -64,16 +64,16 @@ void paw3204_init(void) {
} }
uint8_t paw3204_serial_read(void) { uint8_t paw3204_serial_read(void) {
setPinInput(PAW3204_SDIO_PIN); gpio_set_pin_input(PAW3204_SDIO_PIN);
uint8_t byte = 0; uint8_t byte = 0;
for (uint8_t i = 0; i < 8; ++i) { for (uint8_t i = 0; i < 8; ++i) {
writePinLow(PAW3204_SCLK_PIN); gpio_write_pin_low(PAW3204_SCLK_PIN);
wait_us(1); wait_us(1);
byte = (byte << 1) | readPin(PAW3204_SDIO_PIN); byte = (byte << 1) | gpio_read_pin(PAW3204_SDIO_PIN);
writePinHigh(PAW3204_SCLK_PIN); gpio_write_pin_high(PAW3204_SCLK_PIN);
wait_us(1); wait_us(1);
} }
@ -81,17 +81,17 @@ uint8_t paw3204_serial_read(void) {
} }
void paw3204_serial_write(uint8_t data) { void paw3204_serial_write(uint8_t data) {
writePinLow(PAW3204_SDIO_PIN); gpio_write_pin_low(PAW3204_SDIO_PIN);
setPinOutput(PAW3204_SDIO_PIN); gpio_set_pin_output(PAW3204_SDIO_PIN);
for (int8_t b = 7; b >= 0; b--) { for (int8_t b = 7; b >= 0; b--) {
writePinLow(PAW3204_SCLK_PIN); gpio_write_pin_low(PAW3204_SCLK_PIN);
if (data & (1 << b)) { if (data & (1 << b)) {
writePinHigh(PAW3204_SDIO_PIN); gpio_write_pin_high(PAW3204_SDIO_PIN);
} else { } else {
writePinLow(PAW3204_SDIO_PIN); gpio_write_pin_low(PAW3204_SDIO_PIN);
} }
writePinHigh(PAW3204_SCLK_PIN); gpio_write_pin_high(PAW3204_SCLK_PIN);
} }
wait_us(4); wait_us(4);

View File

@ -24,9 +24,9 @@
void pmw3320_init(void) { void pmw3320_init(void) {
// Initialize sensor serial pins. // Initialize sensor serial pins.
setPinOutput(PMW3320_SCLK_PIN); gpio_set_pin_output(PMW3320_SCLK_PIN);
setPinOutput(PMW3320_SDIO_PIN); gpio_set_pin_output(PMW3320_SDIO_PIN);
setPinOutput(PMW3320_CS_PIN); gpio_set_pin_output(PMW3320_CS_PIN);
// reboot the sensor. // reboot the sensor.
pmw3320_write_reg(REG_Power_Up_Reset, 0x5a); pmw3320_write_reg(REG_Power_Up_Reset, 0x5a);
@ -54,30 +54,30 @@ void pmw3320_init(void) {
// Just as with the serial protocol, this is used by the slave to send a // Just as with the serial protocol, this is used by the slave to send a
// synchronization signal to the master. // synchronization signal to the master.
void pmw3320_sync(void) { void pmw3320_sync(void) {
writePinLow(PMW3320_CS_PIN); gpio_write_pin_low(PMW3320_CS_PIN);
wait_us(1); wait_us(1);
writePinHigh(PMW3320_CS_PIN); gpio_write_pin_high(PMW3320_CS_PIN);
} }
void pmw3320_cs_select(void) { void pmw3320_cs_select(void) {
writePinLow(PMW3320_CS_PIN); gpio_write_pin_low(PMW3320_CS_PIN);
} }
void pmw3320_cs_deselect(void) { void pmw3320_cs_deselect(void) {
writePinHigh(PMW3320_CS_PIN); gpio_write_pin_high(PMW3320_CS_PIN);
} }
uint8_t pmw3320_serial_read(void) { uint8_t pmw3320_serial_read(void) {
setPinInput(PMW3320_SDIO_PIN); gpio_set_pin_input(PMW3320_SDIO_PIN);
uint8_t byte = 0; uint8_t byte = 0;
for (uint8_t i = 0; i < 8; ++i) { for (uint8_t i = 0; i < 8; ++i) {
writePinLow(PMW3320_SCLK_PIN); gpio_write_pin_low(PMW3320_SCLK_PIN);
wait_us(1); wait_us(1);
byte = (byte << 1) | readPin(PMW3320_SDIO_PIN); byte = (byte << 1) | gpio_read_pin(PMW3320_SDIO_PIN);
writePinHigh(PMW3320_SCLK_PIN); gpio_write_pin_high(PMW3320_SCLK_PIN);
wait_us(1); wait_us(1);
} }
@ -85,19 +85,19 @@ uint8_t pmw3320_serial_read(void) {
} }
void pmw3320_serial_write(uint8_t data) { void pmw3320_serial_write(uint8_t data) {
setPinOutput(PMW3320_SDIO_PIN); gpio_set_pin_output(PMW3320_SDIO_PIN);
for (int8_t b = 7; b >= 0; b--) { for (int8_t b = 7; b >= 0; b--) {
writePinLow(PMW3320_SCLK_PIN); gpio_write_pin_low(PMW3320_SCLK_PIN);
if (data & (1 << b)) if (data & (1 << b))
writePinHigh(PMW3320_SDIO_PIN); gpio_write_pin_high(PMW3320_SDIO_PIN);
else else
writePinLow(PMW3320_SDIO_PIN); gpio_write_pin_low(PMW3320_SDIO_PIN);
wait_us(2); wait_us(2);
writePinHigh(PMW3320_SCLK_PIN); gpio_write_pin_high(PMW3320_SCLK_PIN);
} }
// This was taken from ADNS5050 driver. // This was taken from ADNS5050 driver.

View File

@ -346,10 +346,10 @@ static void USB2422_write_block(void) {
void USB2422_init(void) { void USB2422_init(void) {
#ifdef USB2422_RESET_PIN #ifdef USB2422_RESET_PIN
setPinOutput(USB2422_RESET_PIN); gpio_set_pin_output(USB2422_RESET_PIN);
#endif #endif
#ifdef USB2422_ACTIVE_PIN #ifdef USB2422_ACTIVE_PIN
setPinInput(USB2422_ACTIVE_PIN); gpio_set_pin_input(USB2422_ACTIVE_PIN);
#endif #endif
i2c_init(); // IC2 clk must be high at USB2422 reset release time to signal SMB configuration i2c_init(); // IC2 clk must be high at USB2422 reset release time to signal SMB configuration
@ -387,15 +387,15 @@ void USB2422_configure(void) {
void USB2422_reset(void) { void USB2422_reset(void) {
#ifdef USB2422_RESET_PIN #ifdef USB2422_RESET_PIN
writePinLow(USB2422_RESET_PIN); gpio_write_pin_low(USB2422_RESET_PIN);
wait_us(2); wait_us(2);
writePinHigh(USB2422_RESET_PIN); gpio_write_pin_high(USB2422_RESET_PIN);
#endif #endif
} }
bool USB2422_active(void) { bool USB2422_active(void) {
#ifdef USB2422_ACTIVE_PIN #ifdef USB2422_ACTIVE_PIN
return readPin(USB2422_ACTIVE_PIN); return gpio_read_pin(USB2422_ACTIVE_PIN);
#else #else
return 1; return 1;
#endif #endif

View File

@ -13,20 +13,20 @@ static inline void chThdSleepMicroseconds(uint32_t us) {
#endif #endif
void keyboard_post_init_user(void) { void keyboard_post_init_user(void) {
setPinOutput(QMK_WAITING_TEST_BUSY_PIN); gpio_set_pin_output(QMK_WAITING_TEST_BUSY_PIN);
setPinOutput(QMK_WAITING_TEST_YIELD_PIN); gpio_set_pin_output(QMK_WAITING_TEST_YIELD_PIN);
} }
static inline void wait_us_polling_with_strobe(uint32_t us) { static inline void wait_us_polling_with_strobe(uint32_t us) {
writePinHigh(QMK_WAITING_TEST_BUSY_PIN); gpio_write_pin_high(QMK_WAITING_TEST_BUSY_PIN);
wait_us(us); wait_us(us);
writePinLow(QMK_WAITING_TEST_BUSY_PIN); gpio_write_pin_low(QMK_WAITING_TEST_BUSY_PIN);
} }
static inline void wait_us_yield_with_strobe(uint32_t us) { static inline void wait_us_yield_with_strobe(uint32_t us) {
writePinHigh(QMK_WAITING_TEST_YIELD_PIN); gpio_write_pin_high(QMK_WAITING_TEST_YIELD_PIN);
chThdSleepMicroseconds(us); chThdSleepMicroseconds(us);
writePinLow(QMK_WAITING_TEST_YIELD_PIN); gpio_write_pin_low(QMK_WAITING_TEST_YIELD_PIN);
} }
static const uint32_t waiting_values[] = {0, 1, 5, 10, 25, 50, 100, 150, 200, 500, 1000}; static const uint32_t waiting_values[] = {0, 1, 5, 10, 25, 50, 100, 150, 200, 500, 1000};

View File

@ -216,12 +216,12 @@ void channel_2_stop(void) {
void audio_driver_initialize(void) { void audio_driver_initialize(void) {
#ifdef AUDIO1_PIN_SET #ifdef AUDIO1_PIN_SET
channel_1_stop(); channel_1_stop();
setPinOutput(AUDIO1_PIN); gpio_set_pin_output(AUDIO1_PIN);
#endif #endif
#ifdef AUDIO2_PIN_SET #ifdef AUDIO2_PIN_SET
channel_2_stop(); channel_2_stop();
setPinOutput(AUDIO2_PIN); gpio_set_pin_output(AUDIO2_PIN);
#endif #endif
// TCCR3A / TCCR3B: Timer/Counter #3 Control Registers TCCR3A/TCCR3B, TCCR1A/TCCR1B // TCCR3A / TCCR3B: Timer/Counter #3 Control Registers TCCR3A/TCCR3B, TCCR1A/TCCR1B

View File

@ -291,11 +291,11 @@ ISR(TIMERx_OVF_vect) {
#endif // BACKLIGHT_BREATHING #endif // BACKLIGHT_BREATHING
void backlight_init_ports(void) { void backlight_init_ports(void) {
setPinOutput(BACKLIGHT_PIN); gpio_set_pin_output(BACKLIGHT_PIN);
#if BACKLIGHT_ON_STATE == 1 #if BACKLIGHT_ON_STATE == 1
writePinLow(BACKLIGHT_PIN); gpio_write_pin_low(BACKLIGHT_PIN);
#else #else
writePinHigh(BACKLIGHT_PIN); gpio_write_pin_high(BACKLIGHT_PIN);
#endif #endif
// I could write a wall of text here to explain... but TL;DW // I could write a wall of text here to explain... but TL;DW

View File

@ -19,18 +19,18 @@ void clock_init(void) {}
void clock_lo(void) { void clock_lo(void) {
// Transition from input with pull-up to output low via Hi-Z instead of output high // Transition from input with pull-up to output low via Hi-Z instead of output high
writePinLow(PS2_CLOCK_PIN); gpio_write_pin_low(PS2_CLOCK_PIN);
setPinOutput(PS2_CLOCK_PIN); gpio_set_pin_output(PS2_CLOCK_PIN);
} }
void clock_hi(void) { void clock_hi(void) {
setPinInputHigh(PS2_CLOCK_PIN); gpio_set_pin_input_high(PS2_CLOCK_PIN);
} }
bool clock_in(void) { bool clock_in(void) {
setPinInputHigh(PS2_CLOCK_PIN); gpio_set_pin_input_high(PS2_CLOCK_PIN);
wait_us(1); wait_us(1);
return readPin(PS2_CLOCK_PIN); return gpio_read_pin(PS2_CLOCK_PIN);
} }
/* /*
@ -40,16 +40,16 @@ void data_init(void) {}
void data_lo(void) { void data_lo(void) {
// Transition from input with pull-up to output low via Hi-Z instead of output high // Transition from input with pull-up to output low via Hi-Z instead of output high
writePinLow(PS2_DATA_PIN); gpio_write_pin_low(PS2_DATA_PIN);
setPinOutput(PS2_DATA_PIN); gpio_set_pin_output(PS2_DATA_PIN);
} }
void data_hi(void) { void data_hi(void) {
setPinInputHigh(PS2_DATA_PIN); gpio_set_pin_input_high(PS2_DATA_PIN);
} }
bool data_in(void) { bool data_in(void) {
setPinInputHigh(PS2_DATA_PIN); gpio_set_pin_input_high(PS2_DATA_PIN);
wait_us(1); wait_us(1);
return readPin(PS2_DATA_PIN); return gpio_read_pin(PS2_DATA_PIN);
} }

View File

@ -239,28 +239,28 @@ inline static void serial_delay_half2(void) {
inline static void serial_output(void) ALWAYS_INLINE; inline static void serial_output(void) ALWAYS_INLINE;
inline static void serial_output(void) { inline static void serial_output(void) {
setPinOutput(SOFT_SERIAL_PIN); gpio_set_pin_output(SOFT_SERIAL_PIN);
} }
// make the serial pin an input with pull-up resistor // make the serial pin an input with pull-up resistor
inline static void serial_input_with_pullup(void) ALWAYS_INLINE; inline static void serial_input_with_pullup(void) ALWAYS_INLINE;
inline static void serial_input_with_pullup(void) { inline static void serial_input_with_pullup(void) {
setPinInputHigh(SOFT_SERIAL_PIN); gpio_set_pin_input_high(SOFT_SERIAL_PIN);
} }
inline static uint8_t serial_read_pin(void) ALWAYS_INLINE; inline static uint8_t serial_read_pin(void) ALWAYS_INLINE;
inline static uint8_t serial_read_pin(void) { inline static uint8_t serial_read_pin(void) {
return !!readPin(SOFT_SERIAL_PIN); return !!gpio_read_pin(SOFT_SERIAL_PIN);
} }
inline static void serial_low(void) ALWAYS_INLINE; inline static void serial_low(void) ALWAYS_INLINE;
inline static void serial_low(void) { inline static void serial_low(void) {
writePinLow(SOFT_SERIAL_PIN); gpio_write_pin_low(SOFT_SERIAL_PIN);
} }
inline static void serial_high(void) ALWAYS_INLINE; inline static void serial_high(void) ALWAYS_INLINE;
inline static void serial_high(void) { inline static void serial_high(void) {
writePinHigh(SOFT_SERIAL_PIN); gpio_write_pin_high(SOFT_SERIAL_PIN);
} }
void soft_serial_initiator_init(void) { void soft_serial_initiator_init(void) {

View File

@ -41,10 +41,10 @@ static uint8_t currentSlaveConfig = 0;
static bool currentSlave2X = false; static bool currentSlave2X = false;
void spi_init(void) { void spi_init(void) {
writePinHigh(SPI_SS_PIN); gpio_write_pin_high(SPI_SS_PIN);
setPinOutput(SPI_SCK_PIN); gpio_set_pin_output(SPI_SCK_PIN);
setPinOutput(SPI_MOSI_PIN); gpio_set_pin_output(SPI_MOSI_PIN);
setPinInput(SPI_MISO_PIN); gpio_set_pin_input(SPI_MISO_PIN);
SPCR = (_BV(SPE) | _BV(MSTR)); SPCR = (_BV(SPE) | _BV(MSTR));
} }
@ -105,8 +105,8 @@ bool spi_start(pin_t slavePin, bool lsbFirst, uint8_t mode, uint16_t divisor) {
SPSR |= _BV(SPI2X); SPSR |= _BV(SPI2X);
} }
currentSlavePin = slavePin; currentSlavePin = slavePin;
setPinOutput(currentSlavePin); gpio_set_pin_output(currentSlavePin);
writePinLow(currentSlavePin); gpio_write_pin_low(currentSlavePin);
return true; return true;
} }
@ -169,8 +169,8 @@ spi_status_t spi_receive(uint8_t *data, uint16_t length) {
void spi_stop(void) { void spi_stop(void) {
if (currentSlavePin != NO_PIN) { if (currentSlavePin != NO_PIN) {
setPinOutput(currentSlavePin); gpio_set_pin_output(currentSlavePin);
writePinHigh(currentSlavePin); gpio_write_pin_high(currentSlavePin);
currentSlavePin = NO_PIN; currentSlavePin = NO_PIN;
SPSR &= ~(_BV(SPI2X)); SPSR &= ~(_BV(SPI2X));
SPCR &= ~(currentSlaveConfig); SPCR &= ~(currentSlaveConfig);

View File

@ -62,25 +62,25 @@ inline static void serial_delay_blip(void) {
wait_us(1); wait_us(1);
} }
inline static void serial_output(void) { inline static void serial_output(void) {
setPinOutput(SOFT_SERIAL_PIN); gpio_set_pin_output(SOFT_SERIAL_PIN);
} }
inline static void serial_input(void) { inline static void serial_input(void) {
setPinInputHigh(SOFT_SERIAL_PIN); gpio_set_pin_input_high(SOFT_SERIAL_PIN);
} }
inline static bool serial_read_pin(void) { inline static bool serial_read_pin(void) {
return !!readPin(SOFT_SERIAL_PIN); return !!gpio_read_pin(SOFT_SERIAL_PIN);
} }
inline static void serial_low(void) { inline static void serial_low(void) {
writePinLow(SOFT_SERIAL_PIN); gpio_write_pin_low(SOFT_SERIAL_PIN);
} }
inline static void serial_high(void) { inline static void serial_high(void) {
writePinHigh(SOFT_SERIAL_PIN); gpio_write_pin_high(SOFT_SERIAL_PIN);
} }
void interrupt_handler(void *arg); void interrupt_handler(void *arg);
// Use thread + palWaitLineTimeout instead of palSetLineCallback // Use thread + palWaitLineTimeout instead of palSetLineCallback
// - Methods like setPinOutput and palEnableLineEvent/palDisableLineEvent // - Methods like gpio_set_pin_output and palEnableLineEvent/palDisableLineEvent
// cause the interrupt to lock up, which would limit to only receiving data... // cause the interrupt to lock up, which would limit to only receiving data...
static THD_WORKING_AREA(waThread1, 128); static THD_WORKING_AREA(waThread1, 128);
static THD_FUNCTION(Thread1, arg) { static THD_FUNCTION(Thread1, arg) {

View File

@ -32,12 +32,12 @@ __attribute__((weak)) void spi_init(void) {
is_initialised = true; is_initialised = true;
// Try releasing special pins for a short time // Try releasing special pins for a short time
setPinInput(SPI_SCK_PIN); gpio_set_pin_input(SPI_SCK_PIN);
if (SPI_MOSI_PIN != NO_PIN) { if (SPI_MOSI_PIN != NO_PIN) {
setPinInput(SPI_MOSI_PIN); gpio_set_pin_input(SPI_MOSI_PIN);
} }
if (SPI_MISO_PIN != NO_PIN) { if (SPI_MISO_PIN != NO_PIN) {
setPinInput(SPI_MISO_PIN); gpio_set_pin_input(SPI_MISO_PIN);
} }
chThdSleepMilliseconds(10); chThdSleepMilliseconds(10);
@ -271,10 +271,10 @@ bool spi_start(pin_t slavePin, bool lsbFirst, uint8_t mode, uint16_t divisor) {
#if SPI_SELECT_MODE == SPI_SELECT_MODE_PAD #if SPI_SELECT_MODE == SPI_SELECT_MODE_PAD
spiConfig.ssport = PAL_PORT(slavePin); spiConfig.ssport = PAL_PORT(slavePin);
spiConfig.sspad = PAL_PAD(slavePin); spiConfig.sspad = PAL_PAD(slavePin);
setPinOutput(slavePin); gpio_set_pin_output(slavePin);
#elif SPI_SELECT_MODE == SPI_SELECT_MODE_NONE #elif SPI_SELECT_MODE == SPI_SELECT_MODE_NONE
if (slavePin != NO_PIN) { if (slavePin != NO_PIN) {
setPinOutput(slavePin); gpio_set_pin_output(slavePin);
} }
#else #else
# error "Unsupported SPI_SELECT_MODE" # error "Unsupported SPI_SELECT_MODE"
@ -284,7 +284,7 @@ bool spi_start(pin_t slavePin, bool lsbFirst, uint8_t mode, uint16_t divisor) {
spiSelect(&SPI_DRIVER); spiSelect(&SPI_DRIVER);
#if SPI_SELECT_MODE == SPI_SELECT_MODE_NONE #if SPI_SELECT_MODE == SPI_SELECT_MODE_NONE
if (slavePin != NO_PIN) { if (slavePin != NO_PIN) {
writePinLow(slavePin); gpio_write_pin_low(slavePin);
} }
#endif #endif
@ -319,7 +319,7 @@ void spi_stop(void) {
if (spiStarted) { if (spiStarted) {
#if SPI_SELECT_MODE == SPI_SELECT_MODE_NONE #if SPI_SELECT_MODE == SPI_SELECT_MODE_NONE
if (currentSlavePin != NO_PIN) { if (currentSlavePin != NO_PIN) {
writePinHigh(currentSlavePin); gpio_write_pin_high(currentSlavePin);
} }
#endif #endif
spiUnselect(&SPI_DRIVER); spiUnselect(&SPI_DRIVER);

View File

@ -57,15 +57,15 @@ void sendByte(uint8_t byte) {
// using something like wait_ns(is_one ? T1L : T0L) here throws off timings // using something like wait_ns(is_one ? T1L : T0L) here throws off timings
if (is_one) { if (is_one) {
// 1 // 1
writePinHigh(WS2812_DI_PIN); gpio_write_pin_high(WS2812_DI_PIN);
wait_ns(WS2812_T1H); wait_ns(WS2812_T1H);
writePinLow(WS2812_DI_PIN); gpio_write_pin_low(WS2812_DI_PIN);
wait_ns(WS2812_T1L); wait_ns(WS2812_T1L);
} else { } else {
// 0 // 0
writePinHigh(WS2812_DI_PIN); gpio_write_pin_high(WS2812_DI_PIN);
wait_ns(WS2812_T0H); wait_ns(WS2812_T0H);
writePinLow(WS2812_DI_PIN); gpio_write_pin_low(WS2812_DI_PIN);
wait_ns(WS2812_T0L); wait_ns(WS2812_T0L);
} }
} }

View File

@ -26,23 +26,23 @@ static const pin_t backlight_pin = BACKLIGHT_PIN;
static inline void backlight_on(pin_t backlight_pin) { static inline void backlight_on(pin_t backlight_pin) {
#if BACKLIGHT_ON_STATE == 0 #if BACKLIGHT_ON_STATE == 0
writePinLow(backlight_pin); gpio_write_pin_low(backlight_pin);
#else #else
writePinHigh(backlight_pin); gpio_write_pin_high(backlight_pin);
#endif #endif
} }
static inline void backlight_off(pin_t backlight_pin) { static inline void backlight_off(pin_t backlight_pin) {
#if BACKLIGHT_ON_STATE == 0 #if BACKLIGHT_ON_STATE == 0
writePinHigh(backlight_pin); gpio_write_pin_high(backlight_pin);
#else #else
writePinLow(backlight_pin); gpio_write_pin_low(backlight_pin);
#endif #endif
} }
void backlight_pins_init(void) { void backlight_pins_init(void) {
// Setup backlight pin as output and output to off state. // Setup backlight pin as output and output to off state.
FOR_EACH_LED(setPinOutput(backlight_pin); backlight_off(backlight_pin);) FOR_EACH_LED(gpio_set_pin_output(backlight_pin); backlight_off(backlight_pin);)
} }
void backlight_pins_on(void) { void backlight_pins_on(void) {

View File

@ -94,7 +94,7 @@ void dip_switch_init(void) {
} }
# endif # endif
for (uint8_t i = 0; i < NUM_DIP_SWITCHES; i++) { for (uint8_t i = 0; i < NUM_DIP_SWITCHES; i++) {
setPinInputHigh(dip_switch_pad[i]); gpio_set_pin_input_high(dip_switch_pad[i]);
} }
dip_switch_read(true); dip_switch_read(true);
#endif #endif
@ -123,7 +123,7 @@ void dip_switch_read(bool forced) {
for (uint8_t i = 0; i < NUM_DIP_SWITCHES; i++) { for (uint8_t i = 0; i < NUM_DIP_SWITCHES; i++) {
#ifdef DIP_SWITCH_PINS #ifdef DIP_SWITCH_PINS
dip_switch_state[i] = !readPin(dip_switch_pad[i]); dip_switch_state[i] = !gpio_read_pin(dip_switch_pad[i]);
#endif #endif
#ifdef DIP_SWITCH_MATRIX_GRID #ifdef DIP_SWITCH_MATRIX_GRID
dip_switch_state[i] = peek_matrix(dip_switch_pad[i].row, dip_switch_pad[i].col, read_raw); dip_switch_state[i] = peek_matrix(dip_switch_pad[i].row, dip_switch_pad[i].col, read_raw);

View File

@ -162,12 +162,12 @@ void encoder_init(void) {
#endif // defined(SPLIT_KEYBOARD) && defined(ENCODER_RESOLUTIONS) #endif // defined(SPLIT_KEYBOARD) && defined(ENCODER_RESOLUTIONS)
for (uint8_t i = 0; i < thisCount; i++) { for (uint8_t i = 0; i < thisCount; i++) {
setPinInputHigh(encoders_pad_a[i]); gpio_set_pin_input_high(encoders_pad_a[i]);
setPinInputHigh(encoders_pad_b[i]); gpio_set_pin_input_high(encoders_pad_b[i]);
} }
encoder_wait_pullup_charge(); encoder_wait_pullup_charge();
for (uint8_t i = 0; i < thisCount; i++) { for (uint8_t i = 0; i < thisCount; i++) {
encoder_state[i] = (readPin(encoders_pad_a[i]) << 0) | (readPin(encoders_pad_b[i]) << 1); encoder_state[i] = (gpio_read_pin(encoders_pad_a[i]) << 0) | (gpio_read_pin(encoders_pad_b[i]) << 1);
} }
} }
@ -247,7 +247,7 @@ static bool encoder_update(uint8_t index, uint8_t state) {
bool encoder_read(void) { bool encoder_read(void) {
bool changed = false; bool changed = false;
for (uint8_t i = 0; i < thisCount; i++) { for (uint8_t i = 0; i < thisCount; i++) {
uint8_t new_status = (readPin(encoders_pad_a[i]) << 0) | (readPin(encoders_pad_b[i]) << 1); uint8_t new_status = (gpio_read_pin(encoders_pad_a[i]) << 0) | (gpio_read_pin(encoders_pad_b[i]) << 1);
if ((encoder_state[i] & 0x3) != new_status) { if ((encoder_state[i] & 0x3) != new_status) {
encoder_state[i] <<= 2; encoder_state[i] <<= 2;
encoder_state[i] |= new_status; encoder_state[i] |= new_status;

View File

@ -96,10 +96,10 @@ void haptic_init(void) {
#endif #endif
eeconfig_debug_haptic(); eeconfig_debug_haptic();
#ifdef HAPTIC_ENABLE_PIN #ifdef HAPTIC_ENABLE_PIN
setPinOutput(HAPTIC_ENABLE_PIN); gpio_set_pin_output(HAPTIC_ENABLE_PIN);
#endif #endif
#ifdef HAPTIC_ENABLE_STATUS_LED #ifdef HAPTIC_ENABLE_STATUS_LED
setPinOutput(HAPTIC_ENABLE_STATUS_LED); gpio_set_pin_output(HAPTIC_ENABLE_STATUS_LED);
#endif #endif
} }
@ -356,9 +356,9 @@ void haptic_shutdown(void) {
void haptic_notify_usb_device_state_change(void) { void haptic_notify_usb_device_state_change(void) {
update_haptic_enable_gpios(); update_haptic_enable_gpios();
#if defined(HAPTIC_ENABLE_PIN) #if defined(HAPTIC_ENABLE_PIN)
setPinOutput(HAPTIC_ENABLE_PIN); gpio_set_pin_output(HAPTIC_ENABLE_PIN);
#endif #endif
#if defined(HAPTIC_ENABLE_STATUS_LED) #if defined(HAPTIC_ENABLE_STATUS_LED)
setPinOutput(HAPTIC_ENABLE_STATUS_LED); gpio_set_pin_output(HAPTIC_ENABLE_STATUS_LED);
#endif #endif
} }

View File

@ -84,22 +84,22 @@ void haptic_notify_usb_device_state_change(void);
# ifndef HAPTIC_ENABLE_PIN # ifndef HAPTIC_ENABLE_PIN
# error HAPTIC_ENABLE_PIN not defined # error HAPTIC_ENABLE_PIN not defined
# endif # endif
# define HAPTIC_ENABLE_PIN_WRITE_ACTIVE() writePinLow(HAPTIC_ENABLE_PIN) # define HAPTIC_ENABLE_PIN_WRITE_ACTIVE() gpio_write_pin_low(HAPTIC_ENABLE_PIN)
# define HAPTIC_ENABLE_PIN_WRITE_INACTIVE() writePinHigh(HAPTIC_ENABLE_PIN) # define HAPTIC_ENABLE_PIN_WRITE_INACTIVE() gpio_write_pin_high(HAPTIC_ENABLE_PIN)
#else #else
# define HAPTIC_ENABLE_PIN_WRITE_ACTIVE() writePinHigh(HAPTIC_ENABLE_PIN) # define HAPTIC_ENABLE_PIN_WRITE_ACTIVE() gpio_write_pin_high(HAPTIC_ENABLE_PIN)
# define HAPTIC_ENABLE_PIN_WRITE_INACTIVE() writePinLow(HAPTIC_ENABLE_PIN) # define HAPTIC_ENABLE_PIN_WRITE_INACTIVE() gpio_write_pin_low(HAPTIC_ENABLE_PIN)
#endif #endif
#ifdef HAPTIC_ENABLE_STATUS_LED_ACTIVE_LOW #ifdef HAPTIC_ENABLE_STATUS_LED_ACTIVE_LOW
# ifndef HAPTIC_ENABLE_STATUS_LED # ifndef HAPTIC_ENABLE_STATUS_LED
# error HAPTIC_ENABLE_STATUS_LED not defined # error HAPTIC_ENABLE_STATUS_LED not defined
# endif # endif
# define HAPTIC_ENABLE_STATUS_LED_WRITE_ACTIVE() writePinLow(HAPTIC_ENABLE_STATUS_LED) # define HAPTIC_ENABLE_STATUS_LED_WRITE_ACTIVE() gpio_write_pin_low(HAPTIC_ENABLE_STATUS_LED)
# define HAPTIC_ENABLE_STATUS_LED_WRITE_INACTIVE() writePinHigh(HAPTIC_ENABLE_STATUS_LED) # define HAPTIC_ENABLE_STATUS_LED_WRITE_INACTIVE() gpio_write_pin_high(HAPTIC_ENABLE_STATUS_LED)
#else #else
# define HAPTIC_ENABLE_STATUS_LED_WRITE_ACTIVE() writePinHigh(HAPTIC_ENABLE_STATUS_LED) # define HAPTIC_ENABLE_STATUS_LED_WRITE_ACTIVE() gpio_write_pin_high(HAPTIC_ENABLE_STATUS_LED)
# define HAPTIC_ENABLE_STATUS_LED_WRITE_INACTIVE() writePinLow(HAPTIC_ENABLE_STATUS_LED) # define HAPTIC_ENABLE_STATUS_LED_WRITE_INACTIVE() gpio_write_pin_low(HAPTIC_ENABLE_STATUS_LED)
#endif #endif
#ifndef HAPTIC_OFF_IN_LOW_POWER #ifndef HAPTIC_OFF_IN_LOW_POWER

View File

@ -43,7 +43,7 @@ __attribute__((weak)) void joystick_axis_init(uint8_t axis) {
if (axis >= JOYSTICK_AXIS_COUNT) return; if (axis >= JOYSTICK_AXIS_COUNT) return;
#if defined(JOYSTICK_ANALOG) #if defined(JOYSTICK_ANALOG)
setPinInput(joystick_axes[axis].input_pin); gpio_set_pin_input(joystick_axes[axis].input_pin);
#endif #endif
} }

View File

@ -98,19 +98,19 @@ __attribute__((weak)) void led_update_ports(led_t led_state) {
#endif #endif
#ifdef LED_NUM_LOCK_PIN #ifdef LED_NUM_LOCK_PIN
writePin(LED_NUM_LOCK_PIN, led_state.num_lock); gpio_write_pin(LED_NUM_LOCK_PIN, led_state.num_lock);
#endif #endif
#ifdef LED_CAPS_LOCK_PIN #ifdef LED_CAPS_LOCK_PIN
writePin(LED_CAPS_LOCK_PIN, led_state.caps_lock); gpio_write_pin(LED_CAPS_LOCK_PIN, led_state.caps_lock);
#endif #endif
#ifdef LED_SCROLL_LOCK_PIN #ifdef LED_SCROLL_LOCK_PIN
writePin(LED_SCROLL_LOCK_PIN, led_state.scroll_lock); gpio_write_pin(LED_SCROLL_LOCK_PIN, led_state.scroll_lock);
#endif #endif
#ifdef LED_COMPOSE_PIN #ifdef LED_COMPOSE_PIN
writePin(LED_COMPOSE_PIN, led_state.compose); gpio_write_pin(LED_COMPOSE_PIN, led_state.compose);
#endif #endif
#ifdef LED_KANA_PIN #ifdef LED_KANA_PIN
writePin(LED_KANA_PIN, led_state.kana); gpio_write_pin(LED_KANA_PIN, led_state.kana);
#endif #endif
} }
@ -118,24 +118,24 @@ __attribute__((weak)) void led_update_ports(led_t led_state) {
*/ */
__attribute__((weak)) void led_init_ports(void) { __attribute__((weak)) void led_init_ports(void) {
#ifdef LED_NUM_LOCK_PIN #ifdef LED_NUM_LOCK_PIN
setPinOutput(LED_NUM_LOCK_PIN); gpio_set_pin_output(LED_NUM_LOCK_PIN);
writePin(LED_NUM_LOCK_PIN, !LED_PIN_ON_STATE); gpio_write_pin(LED_NUM_LOCK_PIN, !LED_PIN_ON_STATE);
#endif #endif
#ifdef LED_CAPS_LOCK_PIN #ifdef LED_CAPS_LOCK_PIN
setPinOutput(LED_CAPS_LOCK_PIN); gpio_set_pin_output(LED_CAPS_LOCK_PIN);
writePin(LED_CAPS_LOCK_PIN, !LED_PIN_ON_STATE); gpio_write_pin(LED_CAPS_LOCK_PIN, !LED_PIN_ON_STATE);
#endif #endif
#ifdef LED_SCROLL_LOCK_PIN #ifdef LED_SCROLL_LOCK_PIN
setPinOutput(LED_SCROLL_LOCK_PIN); gpio_set_pin_output(LED_SCROLL_LOCK_PIN);
writePin(LED_SCROLL_LOCK_PIN, !LED_PIN_ON_STATE); gpio_write_pin(LED_SCROLL_LOCK_PIN, !LED_PIN_ON_STATE);
#endif #endif
#ifdef LED_COMPOSE_PIN #ifdef LED_COMPOSE_PIN
setPinOutput(LED_COMPOSE_PIN); gpio_set_pin_output(LED_COMPOSE_PIN);
writePin(LED_COMPOSE_PIN, !LED_PIN_ON_STATE); gpio_write_pin(LED_COMPOSE_PIN, !LED_PIN_ON_STATE);
#endif #endif
#ifdef LED_KANA_PIN #ifdef LED_KANA_PIN
setPinOutput(LED_KANA_PIN); gpio_set_pin_output(LED_KANA_PIN);
writePin(LED_KANA_PIN, !LED_PIN_ON_STATE); gpio_write_pin(LED_KANA_PIN, !LED_PIN_ON_STATE);
#endif #endif
} }

View File

@ -78,27 +78,27 @@ __attribute__((weak)) void matrix_read_rows_on_col(matrix_row_t current_matrix[]
static inline void setPinOutput_writeLow(pin_t pin) { static inline void setPinOutput_writeLow(pin_t pin) {
ATOMIC_BLOCK_FORCEON { ATOMIC_BLOCK_FORCEON {
setPinOutput(pin); gpio_set_pin_output(pin);
writePinLow(pin); gpio_write_pin_low(pin);
} }
} }
static inline void setPinOutput_writeHigh(pin_t pin) { static inline void setPinOutput_writeHigh(pin_t pin) {
ATOMIC_BLOCK_FORCEON { ATOMIC_BLOCK_FORCEON {
setPinOutput(pin); gpio_set_pin_output(pin);
writePinHigh(pin); gpio_write_pin_high(pin);
} }
} }
static inline void setPinInputHigh_atomic(pin_t pin) { static inline void setPinInputHigh_atomic(pin_t pin) {
ATOMIC_BLOCK_FORCEON { ATOMIC_BLOCK_FORCEON {
setPinInputHigh(pin); gpio_set_pin_input_high(pin);
} }
} }
static inline uint8_t readMatrixPin(pin_t pin) { static inline uint8_t readMatrixPin(pin_t pin) {
if (pin != NO_PIN) { if (pin != NO_PIN) {
return (readPin(pin) == MATRIX_INPUT_PRESSED_STATE) ? 0 : 1; return (gpio_read_pin(pin) == MATRIX_INPUT_PRESSED_STATE) ? 0 : 1;
} else { } else {
return 1; return 1;
} }
@ -113,7 +113,7 @@ __attribute__((weak)) void matrix_init_pins(void) {
for (int col = 0; col < MATRIX_COLS; col++) { for (int col = 0; col < MATRIX_COLS; col++) {
pin_t pin = direct_pins[row][col]; pin_t pin = direct_pins[row][col];
if (pin != NO_PIN) { if (pin != NO_PIN) {
setPinInputHigh(pin); gpio_set_pin_input_high(pin);
} }
} }
} }

View File

@ -149,9 +149,9 @@ __attribute__((weak)) void pointing_device_init(void) {
pointing_device_driver.init(); pointing_device_driver.init();
#ifdef POINTING_DEVICE_MOTION_PIN #ifdef POINTING_DEVICE_MOTION_PIN
# ifdef POINTING_DEVICE_MOTION_PIN_ACTIVE_LOW # ifdef POINTING_DEVICE_MOTION_PIN_ACTIVE_LOW
setPinInputHigh(POINTING_DEVICE_MOTION_PIN); gpio_set_pin_input_high(POINTING_DEVICE_MOTION_PIN);
# else # else
setPinInput(POINTING_DEVICE_MOTION_PIN); gpio_set_pin_input(POINTING_DEVICE_MOTION_PIN);
# endif # endif
#endif #endif
} }
@ -247,9 +247,9 @@ __attribute__((weak)) bool pointing_device_task(void) {
# error POINTING_DEVICE_MOTION_PIN not supported when sharing the pointing device report between sides. # error POINTING_DEVICE_MOTION_PIN not supported when sharing the pointing device report between sides.
# endif # endif
# ifdef POINTING_DEVICE_MOTION_PIN_ACTIVE_LOW # ifdef POINTING_DEVICE_MOTION_PIN_ACTIVE_LOW
if (!readPin(POINTING_DEVICE_MOTION_PIN)) if (!gpio_read_pin(POINTING_DEVICE_MOTION_PIN))
# else # else
if (readPin(POINTING_DEVICE_MOTION_PIN)) if (gpio_read_pin(POINTING_DEVICE_MOTION_PIN))
# endif # endif
{ {
#endif #endif

View File

@ -123,14 +123,14 @@ void split_watchdog_task(void) {
void matrix_io_delay(void); void matrix_io_delay(void);
static uint8_t peek_matrix_intersection(pin_t out_pin, pin_t in_pin) { static uint8_t peek_matrix_intersection(pin_t out_pin, pin_t in_pin) {
setPinInputHigh(in_pin); gpio_set_pin_input_high(in_pin);
setPinOutput(out_pin); gpio_set_pin_output(out_pin);
writePinLow(out_pin); gpio_write_pin_low(out_pin);
// It's almost unnecessary, but wait until it's down to low, just in case. // It's almost unnecessary, but wait until it's down to low, just in case.
wait_us(1); wait_us(1);
uint8_t pin_state = readPin(in_pin); uint8_t pin_state = gpio_read_pin(in_pin);
// Set out_pin to a setting that is less susceptible to noise. // Set out_pin to a setting that is less susceptible to noise.
setPinInputHigh(out_pin); gpio_set_pin_input_high(out_pin);
matrix_io_delay(); // Wait for the pull-up to go HIGH. matrix_io_delay(); // Wait for the pull-up to go HIGH.
return pin_state; return pin_state;
} }
@ -138,13 +138,13 @@ static uint8_t peek_matrix_intersection(pin_t out_pin, pin_t in_pin) {
__attribute__((weak)) bool is_keyboard_left_impl(void) { __attribute__((weak)) bool is_keyboard_left_impl(void) {
#if defined(SPLIT_HAND_PIN) #if defined(SPLIT_HAND_PIN)
setPinInput(SPLIT_HAND_PIN); gpio_set_pin_input(SPLIT_HAND_PIN);
wait_us(100); wait_us(100);
// Test pin SPLIT_HAND_PIN for High/Low, if low it's right hand // Test pin SPLIT_HAND_PIN for High/Low, if low it's right hand
# ifdef SPLIT_HAND_PIN_LOW_IS_LEFT # ifdef SPLIT_HAND_PIN_LOW_IS_LEFT
return !readPin(SPLIT_HAND_PIN); return !gpio_read_pin(SPLIT_HAND_PIN);
# else # else
return readPin(SPLIT_HAND_PIN); return gpio_read_pin(SPLIT_HAND_PIN);
# endif # endif
#elif defined(SPLIT_HAND_MATRIX_GRID) #elif defined(SPLIT_HAND_MATRIX_GRID)
# ifdef SPLIT_HAND_MATRIX_GRID_LOW_IS_LEFT # ifdef SPLIT_HAND_MATRIX_GRID_LOW_IS_LEFT

View File

@ -28,27 +28,27 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
# define CLOCK_DELAY 10 # define CLOCK_DELAY 10
void shift_init_impl(void) { void shift_init_impl(void) {
setPinOutput(SR_EXP_RCLK_PIN); gpio_set_pin_output(SR_EXP_RCLK_PIN);
setPinOutput(SPI_DATAOUT_PIN); gpio_set_pin_output(SPI_DATAOUT_PIN);
setPinOutput(SPI_SCLK_PIN); gpio_set_pin_output(SPI_SCLK_PIN);
} }
void shift_out_impl(const uint8_t *data, uint16_t length) { void shift_out_impl(const uint8_t *data, uint16_t length) {
writePinLow(SR_EXP_RCLK_PIN); gpio_write_pin_low(SR_EXP_RCLK_PIN);
for (uint16_t i = 0; i < length; i++) { for (uint16_t i = 0; i < length; i++) {
uint8_t val = data[i]; uint8_t val = data[i];
// shift out lsb first // shift out lsb first
for (uint8_t bit = 0; bit < 8; bit++) { for (uint8_t bit = 0; bit < 8; bit++) {
writePin(SPI_DATAOUT_PIN, !!(val & (1 << bit))); gpio_write_pin(SPI_DATAOUT_PIN, !!(val & (1 << bit)));
writePin(SPI_SCLK_PIN, true); gpio_write_pin(SPI_SCLK_PIN, true);
wait_us(CLOCK_DELAY); wait_us(CLOCK_DELAY);
writePin(SPI_SCLK_PIN, false); gpio_write_pin(SPI_SCLK_PIN, false);
wait_us(CLOCK_DELAY); wait_us(CLOCK_DELAY);
} }
} }
writePinHigh(SR_EXP_RCLK_PIN); gpio_write_pin_high(SR_EXP_RCLK_PIN);
return SPI_STATUS_SUCCESS; return SPI_STATUS_SUCCESS;
} }
@ -74,13 +74,13 @@ void shift_out(const uint8_t *data, uint16_t length) {
} }
void shift_enable(void) { void shift_enable(void) {
setPinOutput(SR_EXP_OE_PIN); gpio_set_pin_output(SR_EXP_OE_PIN);
writePinLow(SR_EXP_OE_PIN); gpio_write_pin_low(SR_EXP_OE_PIN);
} }
void shift_disable(void) { void shift_disable(void) {
setPinOutput(SR_EXP_OE_PIN); gpio_set_pin_output(SR_EXP_OE_PIN);
writePinHigh(SR_EXP_OE_PIN); gpio_write_pin_high(SR_EXP_OE_PIN);
} }
void shift_init(void) { void shift_init(void) {

View File

@ -60,8 +60,8 @@ bool spi_start(pin_t csPin, bool lsbFirst, uint8_t mode, uint16_t divisor) {
} }
currentSelectPin = csPin; currentSelectPin = csPin;
setPinOutput(currentSelectPin); gpio_set_pin_output(currentSelectPin);
writePinLow(currentSelectPin); gpio_write_pin_low(currentSelectPin);
SPI_SERCOM->SPI.CTRLA.bit.DORD = lsbFirst; // Data Order - LSB is transferred first SPI_SERCOM->SPI.CTRLA.bit.DORD = lsbFirst; // Data Order - LSB is transferred first
SPI_SERCOM->SPI.CTRLA.bit.CPOL = 1; // Clock Polarity - SCK high when idle. Leading edge of cycle is falling. Trailing rising. SPI_SERCOM->SPI.CTRLA.bit.CPOL = 1; // Clock Polarity - SCK high when idle. Leading edge of cycle is falling. Trailing rising.
@ -94,8 +94,8 @@ spi_status_t spi_transmit(const uint8_t *data, uint16_t length) {
void spi_stop(void) { void spi_stop(void) {
if (currentSelectPin != NO_PIN) { if (currentSelectPin != NO_PIN) {
setPinOutput(currentSelectPin); gpio_set_pin_output(currentSelectPin);
writePinHigh(currentSelectPin); gpio_write_pin_high(currentSelectPin);
currentSelectPin = NO_PIN; currentSelectPin = NO_PIN;
} }
} }

View File

@ -26,9 +26,9 @@ __attribute__((weak)) bool usb_connected_state(void) {
__attribute__((weak)) bool usb_vbus_state(void) { __attribute__((weak)) bool usb_vbus_state(void) {
#ifdef USB_VBUS_PIN #ifdef USB_VBUS_PIN
setPinInput(USB_VBUS_PIN); gpio_set_pin_input(USB_VBUS_PIN);
wait_us(5); wait_us(5);
return readPin(USB_VBUS_PIN); return gpio_read_pin(USB_VBUS_PIN);
#else #else
return true; return true;
#endif #endif