99 * @brief GPIO driver for the ADS1X4S0X AFE.
1010 */
1111
12- #define DT_DRV_COMPAT ti_ads114s0x_gpio
12+ #define DT_DRV_COMPAT ti_ads1x4s0x_gpio
1313
1414#include <zephyr/drivers/gpio.h>
1515#include <zephyr/kernel.h>
1616
1717#define LOG_LEVEL CONFIG_GPIO_LOG_LEVEL
1818#include <zephyr/logging/log.h>
19- LOG_MODULE_REGISTER (gpio_ads114s0x );
19+ LOG_MODULE_REGISTER (gpio_ads1x4s0x );
2020
2121#include <zephyr/drivers/adc/ads1x4s0x.h>
2222
2323#include <zephyr/drivers/gpio/gpio_utils.h>
2424
25- struct gpio_ads114s0x_config {
25+ struct gpio_ads1x4s0x_config {
2626 /* gpio_driver_config needs to be first */
2727 struct gpio_driver_config common ;
2828 const struct device * parent ;
2929};
3030
31- struct gpio_ads114s0x_data {
31+ struct gpio_ads1x4s0x_data {
3232 /* gpio_driver_data needs to be first */
3333 struct gpio_driver_data common ;
3434};
3535
36- static int gpio_ads114s0x_config (const struct device * dev , gpio_pin_t pin , gpio_flags_t flags )
36+ static int gpio_ads1x4s0x_config (const struct device * dev , gpio_pin_t pin , gpio_flags_t flags )
3737{
38- const struct gpio_ads114s0x_config * config = dev -> config ;
38+ const struct gpio_ads1x4s0x_config * config = dev -> config ;
3939 int err = 0 ;
4040
4141 if ((flags & (GPIO_INPUT | GPIO_OUTPUT )) == GPIO_DISCONNECTED ) {
42- return ads114s0x_gpio_deconfigure (config -> parent , pin );
42+ return ads1x4s0x_gpio_deconfigure (config -> parent , pin );
4343 }
4444
4545 if ((flags & GPIO_SINGLE_ENDED ) != 0 ) {
@@ -51,16 +51,16 @@ static int gpio_ads114s0x_config(const struct device *dev, gpio_pin_t pin, gpio_
5151 }
5252
5353 if (flags & GPIO_INT_ENABLE ) {
54- /* ads114s0x GPIOs do not support interrupts */
54+ /* ads1x4s0x GPIOs do not support interrupts */
5555 return - ENOTSUP ;
5656 }
5757
5858 switch (flags & GPIO_DIR_MASK ) {
5959 case GPIO_INPUT :
60- err = ads114s0x_gpio_set_input (config -> parent , pin );
60+ err = ads1x4s0x_gpio_set_input (config -> parent , pin );
6161 break ;
6262 case GPIO_OUTPUT :
63- err = ads114s0x_gpio_set_output (config -> parent , pin ,
63+ err = ads1x4s0x_gpio_set_output (config -> parent , pin ,
6464 (flags & GPIO_OUTPUT_INIT_HIGH ) != 0 );
6565 break ;
6666 default :
@@ -70,76 +70,76 @@ static int gpio_ads114s0x_config(const struct device *dev, gpio_pin_t pin, gpio_
7070 return err ;
7171}
7272
73- static int gpio_ads114s0x_port_get_raw (const struct device * dev , gpio_port_value_t * value )
73+ static int gpio_ads1x4s0x_port_get_raw (const struct device * dev , gpio_port_value_t * value )
7474{
75- const struct gpio_ads114s0x_config * config = dev -> config ;
75+ const struct gpio_ads1x4s0x_config * config = dev -> config ;
7676
77- return ads114s0x_gpio_port_get_raw (config -> parent , value );
77+ return ads1x4s0x_gpio_port_get_raw (config -> parent , value );
7878}
7979
80- static int gpio_ads114s0x_port_set_masked_raw (const struct device * dev , gpio_port_pins_t mask ,
80+ static int gpio_ads1x4s0x_port_set_masked_raw (const struct device * dev , gpio_port_pins_t mask ,
8181 gpio_port_value_t value )
8282{
83- const struct gpio_ads114s0x_config * config = dev -> config ;
83+ const struct gpio_ads1x4s0x_config * config = dev -> config ;
8484
85- return ads114s0x_gpio_port_set_masked_raw (config -> parent , mask , value );
85+ return ads1x4s0x_gpio_port_set_masked_raw (config -> parent , mask , value );
8686}
8787
88- static int gpio_ads114s0x_port_set_bits_raw (const struct device * dev , gpio_port_pins_t pins )
88+ static int gpio_ads1x4s0x_port_set_bits_raw (const struct device * dev , gpio_port_pins_t pins )
8989{
90- const struct gpio_ads114s0x_config * config = dev -> config ;
90+ const struct gpio_ads1x4s0x_config * config = dev -> config ;
9191
92- return ads114s0x_gpio_port_set_masked_raw (config -> parent , pins , pins );
92+ return ads1x4s0x_gpio_port_set_masked_raw (config -> parent , pins , pins );
9393}
9494
95- static int gpio_ads114s0x_port_clear_bits_raw (const struct device * dev , gpio_port_pins_t pins )
95+ static int gpio_ads1x4s0x_port_clear_bits_raw (const struct device * dev , gpio_port_pins_t pins )
9696{
97- const struct gpio_ads114s0x_config * config = dev -> config ;
97+ const struct gpio_ads1x4s0x_config * config = dev -> config ;
9898
99- return ads114s0x_gpio_port_set_masked_raw (config -> parent , pins , 0 );
99+ return ads1x4s0x_gpio_port_set_masked_raw (config -> parent , pins , 0 );
100100}
101101
102- static int gpio_ads114s0x_port_toggle_bits (const struct device * dev , gpio_port_pins_t pins )
102+ static int gpio_ads1x4s0x_port_toggle_bits (const struct device * dev , gpio_port_pins_t pins )
103103{
104- const struct gpio_ads114s0x_config * config = dev -> config ;
104+ const struct gpio_ads1x4s0x_config * config = dev -> config ;
105105
106- return ads114s0x_gpio_port_toggle_bits (config -> parent , pins );
106+ return ads1x4s0x_gpio_port_toggle_bits (config -> parent , pins );
107107}
108108
109- static int gpio_ads114s0x_init (const struct device * dev )
109+ static int gpio_ads1x4s0x_init (const struct device * dev )
110110{
111- const struct gpio_ads114s0x_config * config = dev -> config ;
111+ const struct gpio_ads1x4s0x_config * config = dev -> config ;
112112
113113 if (!device_is_ready (config -> parent )) {
114- LOG_ERR ("parent ads114s0x device '%s' not ready" , config -> parent -> name );
114+ LOG_ERR ("parent ads1x4s0x device '%s' not ready" , config -> parent -> name );
115115 return - EINVAL ;
116116 }
117117
118118 return 0 ;
119119}
120120
121- static const struct gpio_driver_api gpio_ads114s0x_api = {
122- .pin_configure = gpio_ads114s0x_config ,
123- .port_set_masked_raw = gpio_ads114s0x_port_set_masked_raw ,
124- .port_set_bits_raw = gpio_ads114s0x_port_set_bits_raw ,
125- .port_clear_bits_raw = gpio_ads114s0x_port_clear_bits_raw ,
126- .port_toggle_bits = gpio_ads114s0x_port_toggle_bits ,
127- .port_get_raw = gpio_ads114s0x_port_get_raw ,
121+ static DEVICE_API ( gpio , gpio_ads1x4s0x_api ) = {
122+ .pin_configure = gpio_ads1x4s0x_config ,
123+ .port_set_masked_raw = gpio_ads1x4s0x_port_set_masked_raw ,
124+ .port_set_bits_raw = gpio_ads1x4s0x_port_set_bits_raw ,
125+ .port_clear_bits_raw = gpio_ads1x4s0x_port_clear_bits_raw ,
126+ .port_toggle_bits = gpio_ads1x4s0x_port_toggle_bits ,
127+ .port_get_raw = gpio_ads1x4s0x_port_get_raw ,
128128};
129129
130- BUILD_ASSERT (CONFIG_GPIO_ADS114S0X_INIT_PRIORITY > CONFIG_ADC_INIT_PRIORITY ,
131- "ADS114S0X GPIO driver must be initialized after ADS114S0X ADC driver" );
130+ BUILD_ASSERT (CONFIG_GPIO_ADS1X4S0X_INIT_PRIORITY > CONFIG_ADC_INIT_PRIORITY ,
131+ "ADS1X4S0X GPIO driver must be initialized after ADS1X4S0X ADC driver" );
132132
133- #define GPIO_ADS114S0X_DEVICE (id ) \
134- static const struct gpio_ads114s0x_config gpio_ads114s0x_ ##id##_cfg = { \
133+ #define GPIO_ADS1X4S0X_DEVICE (id ) \
134+ static const struct gpio_ads1x4s0x_config gpio_ads1x4s0x_ ##id##_cfg = { \
135135 .common = {.port_pin_mask = GPIO_PORT_PIN_MASK_FROM_DT_INST(id)}, \
136136 .parent = DEVICE_DT_GET(DT_INST_BUS(id)), \
137137 }; \
138138 \
139- static struct gpio_ads114s0x_data gpio_ads114s0x_ ##id##_data; \
139+ static struct gpio_ads1x4s0x_data gpio_ads1x4s0x_ ##id##_data; \
140140 \
141- DEVICE_DT_INST_DEFINE(id, gpio_ads114s0x_init , NULL, &gpio_ads114s0x_ ##id##_data, \
142- &gpio_ads114s0x_ ##id##_cfg, POST_KERNEL, \
143- CONFIG_GPIO_ADS114S0X_INIT_PRIORITY , &gpio_ads114s0x_api );
141+ DEVICE_DT_INST_DEFINE(id, gpio_ads1x4s0x_init , NULL, &gpio_ads1x4s0x_ ##id##_data, \
142+ &gpio_ads1x4s0x_ ##id##_cfg, POST_KERNEL, \
143+ CONFIG_GPIO_ADS1X4S0X_INIT_PRIORITY , &gpio_ads1x4s0x_api );
144144
145- DT_INST_FOREACH_STATUS_OKAY (GPIO_ADS114S0X_DEVICE )
145+ DT_INST_FOREACH_STATUS_OKAY (GPIO_ADS1X4S0X_DEVICE )
0 commit comments