summaryrefslogtreecommitdiff
path: root/drivers/sensors
diff options
context:
space:
mode:
authorRyan <fauxpark@gmail.com>2024-02-18 17:08:27 +1100
committerGitHub <noreply@github.com>2024-02-18 17:08:27 +1100
commit2d1aed78a67b3d2b002cc739ef087963b05b76b8 (patch)
treeea681d02e547332cffa6b7aec6c16ef37ad70ee3 /drivers/sensors
parent6810aaf0130113e267e20fb506d874cc858f5f67 (diff)
Update GPIO macro usages in core (#23093)
Diffstat (limited to 'drivers/sensors')
-rw-r--r--drivers/sensors/adns5050.c32
-rw-r--r--drivers/sensors/adns9800.c2
-rw-r--r--drivers/sensors/analog_joystick.c8
-rw-r--r--drivers/sensors/paw3204.c24
-rw-r--r--drivers/sensors/pmw3320.c32
5 files changed, 49 insertions, 49 deletions
diff --git a/drivers/sensors/adns5050.c b/drivers/sensors/adns5050.c
index b76268fba2..97daa8db09 100644
--- a/drivers/sensors/adns5050.c
+++ b/drivers/sensors/adns5050.c
@@ -47,9 +47,9 @@
void adns5050_init(void) {
// Initialize the ADNS serial pins.
- setPinOutput(ADNS5050_SCLK_PIN);
- setPinOutput(ADNS5050_SDIO_PIN);
- setPinOutput(ADNS5050_CS_PIN);
+ gpio_set_pin_output(ADNS5050_SCLK_PIN);
+ gpio_set_pin_output(ADNS5050_SDIO_PIN);
+ gpio_set_pin_output(ADNS5050_CS_PIN);
// reboot the adns.
// 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
// synchronization signal to the master.
void adns5050_sync(void) {
- writePinLow(ADNS5050_CS_PIN);
+ gpio_write_pin_low(ADNS5050_CS_PIN);
wait_us(1);
- writePinHigh(ADNS5050_CS_PIN);
+ gpio_write_pin_high(ADNS5050_CS_PIN);
}
void adns5050_cs_select(void) {
- writePinLow(ADNS5050_CS_PIN);
+ gpio_write_pin_low(ADNS5050_CS_PIN);
}
void adns5050_cs_deselect(void) {
- writePinHigh(ADNS5050_CS_PIN);
+ gpio_write_pin_high(ADNS5050_CS_PIN);
}
uint8_t adns5050_serial_read(void) {
- setPinInput(ADNS5050_SDIO_PIN);
+ gpio_set_pin_input(ADNS5050_SDIO_PIN);
uint8_t byte = 0;
for (uint8_t i = 0; i < 8; ++i) {
- writePinLow(ADNS5050_SCLK_PIN);
+ gpio_write_pin_low(ADNS5050_SCLK_PIN);
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);
}
@@ -100,19 +100,19 @@ uint8_t adns5050_serial_read(void) {
}
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--) {
- writePinLow(ADNS5050_SCLK_PIN);
+ gpio_write_pin_low(ADNS5050_SCLK_PIN);
if (data & (1 << b))
- writePinHigh(ADNS5050_SDIO_PIN);
+ gpio_write_pin_high(ADNS5050_SDIO_PIN);
else
- writePinLow(ADNS5050_SDIO_PIN);
+ gpio_write_pin_low(ADNS5050_SDIO_PIN);
wait_us(2);
- writePinHigh(ADNS5050_SCLK_PIN);
+ gpio_write_pin_high(ADNS5050_SCLK_PIN);
}
// tSWR. See page 15 of the ADNS spec sheet.
diff --git a/drivers/sensors/adns9800.c b/drivers/sensors/adns9800.c
index 083ab34d9f..f34529ee90 100644
--- a/drivers/sensors/adns9800.c
+++ b/drivers/sensors/adns9800.c
@@ -100,7 +100,7 @@ uint8_t adns9800_read(uint8_t reg_addr) {
}
void adns9800_init(void) {
- setPinOutput(ADNS9800_CS_PIN);
+ gpio_set_pin_output(ADNS9800_CS_PIN);
spi_init();
diff --git a/drivers/sensors/analog_joystick.c b/drivers/sensors/analog_joystick.c
index 221625075c..15b35a45f2 100644
--- a/drivers/sensors/analog_joystick.c
+++ b/drivers/sensors/analog_joystick.c
@@ -122,17 +122,17 @@ report_analog_joystick_t analog_joystick_read(void) {
report.y = axisToMouseComponent(ANALOG_JOYSTICK_Y_AXIS_PIN, yOrigin, maxCursorSpeed, 1);
}
#ifdef ANALOG_JOYSTICK_CLICK_PIN
- report.button = !readPin(ANALOG_JOYSTICK_CLICK_PIN);
+ report.button = !gpio_read_pin(ANALOG_JOYSTICK_CLICK_PIN);
#endif
return report;
}
void analog_joystick_init(void) {
- setPinInputHigh(ANALOG_JOYSTICK_X_AXIS_PIN);
- setPinInputHigh(ANALOG_JOYSTICK_Y_AXIS_PIN);
+ gpio_set_pin_input_high(ANALOG_JOYSTICK_X_AXIS_PIN);
+ gpio_set_pin_input_high(ANALOG_JOYSTICK_Y_AXIS_PIN);
#ifdef ANALOG_JOYSTICK_CLICK_PIN
- setPinInputHigh(ANALOG_JOYSTICK_CLICK_PIN);
+ gpio_set_pin_input_high(ANALOG_JOYSTICK_CLICK_PIN);
#endif
// Account for drift
xOrigin = analogReadPin(ANALOG_JOYSTICK_X_AXIS_PIN);
diff --git a/drivers/sensors/paw3204.c b/drivers/sensors/paw3204.c
index a13753dd6f..28c47522ed 100644
--- a/drivers/sensors/paw3204.c
+++ b/drivers/sensors/paw3204.c
@@ -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_init(void) {
- setPinOutput(PAW3204_SCLK_PIN); // setclockpin to output
- setPinInputHigh(PAW3204_SDIO_PIN); // set datapin input high
+ gpio_set_pin_output(PAW3204_SCLK_PIN); // setclockpin to output
+ gpio_set_pin_input_high(PAW3204_SDIO_PIN); // set datapin input high
paw3204_write_reg(REG_SETUP, 0x86); // reset sensor and set 1600cpi
wait_us(5);
@@ -64,16 +64,16 @@ void paw3204_init(void) {
}
uint8_t paw3204_serial_read(void) {
- setPinInput(PAW3204_SDIO_PIN);
+ gpio_set_pin_input(PAW3204_SDIO_PIN);
uint8_t byte = 0;
for (uint8_t i = 0; i < 8; ++i) {
- writePinLow(PAW3204_SCLK_PIN);
+ gpio_write_pin_low(PAW3204_SCLK_PIN);
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);
}
@@ -81,17 +81,17 @@ uint8_t paw3204_serial_read(void) {
}
void paw3204_serial_write(uint8_t data) {
- writePinLow(PAW3204_SDIO_PIN);
- setPinOutput(PAW3204_SDIO_PIN);
+ gpio_write_pin_low(PAW3204_SDIO_PIN);
+ gpio_set_pin_output(PAW3204_SDIO_PIN);
for (int8_t b = 7; b >= 0; b--) {
- writePinLow(PAW3204_SCLK_PIN);
+ gpio_write_pin_low(PAW3204_SCLK_PIN);
if (data & (1 << b)) {
- writePinHigh(PAW3204_SDIO_PIN);
+ gpio_write_pin_high(PAW3204_SDIO_PIN);
} 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);
diff --git a/drivers/sensors/pmw3320.c b/drivers/sensors/pmw3320.c
index 69a584f4e1..f19fbfd1ab 100644
--- a/drivers/sensors/pmw3320.c
+++ b/drivers/sensors/pmw3320.c
@@ -24,9 +24,9 @@
void pmw3320_init(void) {
// Initialize sensor serial pins.
- setPinOutput(PMW3320_SCLK_PIN);
- setPinOutput(PMW3320_SDIO_PIN);
- setPinOutput(PMW3320_CS_PIN);
+ gpio_set_pin_output(PMW3320_SCLK_PIN);
+ gpio_set_pin_output(PMW3320_SDIO_PIN);
+ gpio_set_pin_output(PMW3320_CS_PIN);
// reboot the sensor.
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
// synchronization signal to the master.
void pmw3320_sync(void) {
- writePinLow(PMW3320_CS_PIN);
+ gpio_write_pin_low(PMW3320_CS_PIN);
wait_us(1);
- writePinHigh(PMW3320_CS_PIN);
+ gpio_write_pin_high(PMW3320_CS_PIN);
}
void pmw3320_cs_select(void) {
- writePinLow(PMW3320_CS_PIN);
+ gpio_write_pin_low(PMW3320_CS_PIN);
}
void pmw3320_cs_deselect(void) {
- writePinHigh(PMW3320_CS_PIN);
+ gpio_write_pin_high(PMW3320_CS_PIN);
}
uint8_t pmw3320_serial_read(void) {
- setPinInput(PMW3320_SDIO_PIN);
+ gpio_set_pin_input(PMW3320_SDIO_PIN);
uint8_t byte = 0;
for (uint8_t i = 0; i < 8; ++i) {
- writePinLow(PMW3320_SCLK_PIN);
+ gpio_write_pin_low(PMW3320_SCLK_PIN);
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);
}
@@ -85,19 +85,19 @@ uint8_t pmw3320_serial_read(void) {
}
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--) {
- writePinLow(PMW3320_SCLK_PIN);
+ gpio_write_pin_low(PMW3320_SCLK_PIN);
if (data & (1 << b))
- writePinHigh(PMW3320_SDIO_PIN);
+ gpio_write_pin_high(PMW3320_SDIO_PIN);
else
- writePinLow(PMW3320_SDIO_PIN);
+ gpio_write_pin_low(PMW3320_SDIO_PIN);
wait_us(2);
- writePinHigh(PMW3320_SCLK_PIN);
+ gpio_write_pin_high(PMW3320_SCLK_PIN);
}
// This was taken from ADNS5050 driver.