mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
drivers: adapted gpio_init(_x)() calls
This commit is contained in:
parent
03efb5be99
commit
e51d634aeb
@ -153,7 +153,7 @@ int adt7310_init(adt7310_t *dev, spi_t spi, gpio_t cs)
|
||||
dev->high_res = false;
|
||||
|
||||
/* CS */
|
||||
gpio_init(dev->cs, GPIO_DIR_OUT, GPIO_NOPULL);
|
||||
gpio_init(dev->cs, GPIO_OUT);
|
||||
gpio_set(dev->cs);
|
||||
|
||||
#if ENABLE_DEBUG
|
||||
|
@ -63,13 +63,13 @@ int at86rf2xx_init(at86rf2xx_t *dev, spi_t spi, spi_speed_t spi_speed,
|
||||
/* initialise SPI */
|
||||
spi_init_master(dev->spi, SPI_CONF_FIRST_RISING, spi_speed);
|
||||
/* initialise GPIOs */
|
||||
gpio_init(dev->cs_pin, GPIO_DIR_OUT, GPIO_NOPULL);
|
||||
gpio_init(dev->cs_pin, GPIO_OUT);
|
||||
gpio_set(dev->cs_pin);
|
||||
gpio_init(dev->sleep_pin, GPIO_DIR_OUT, GPIO_NOPULL);
|
||||
gpio_init(dev->sleep_pin, GPIO_OUT);
|
||||
gpio_clear(dev->sleep_pin);
|
||||
gpio_init(dev->reset_pin, GPIO_DIR_OUT, GPIO_NOPULL);
|
||||
gpio_init(dev->reset_pin, GPIO_OUT);
|
||||
gpio_set(dev->reset_pin);
|
||||
gpio_init_int(dev->int_pin, GPIO_NOPULL, GPIO_RISING, _irq_handler, dev);
|
||||
gpio_init_int(dev->int_pin, GPIO_IN, GPIO_RISING, _irq_handler, dev);
|
||||
|
||||
/* make sure device is not sleeping, so we can query part number */
|
||||
at86rf2xx_assert_awake(dev);
|
||||
|
@ -199,7 +199,7 @@ static int _init(netdev2_t *dev)
|
||||
|
||||
cc110x_t *cc110x = &((netdev2_cc110x_t*) dev)->cc110x;
|
||||
|
||||
gpio_init_int(cc110x->params.gdo2, GPIO_NOPULL, GPIO_BOTH,
|
||||
gpio_init_int(cc110x->params.gdo2, GPIO_IN, GPIO_BOTH,
|
||||
&_netdev2_cc110x_isr, (void*)dev);
|
||||
|
||||
gpio_set(cc110x->params.gdo2);
|
||||
|
@ -44,7 +44,7 @@ void cc110x_cs(cc110x_t *dev)
|
||||
volatile int retry_count = 0;
|
||||
/* Switch MISO/GDO1 to GPIO input mode */
|
||||
#ifndef GPIO_READS_SPI_PINS
|
||||
gpio_init(dev->params.gdo1, GPIO_DIR_IN, GPIO_NOPULL);
|
||||
gpio_init(dev->params.gdo1, GPIO_IN);
|
||||
#endif
|
||||
/* CS to low */
|
||||
gpio_clear(dev->params.cs);
|
||||
|
@ -55,11 +55,11 @@ int cc110x_setup(cc110x_t *dev, const cc110x_params_t *params)
|
||||
dev->params = *params;
|
||||
|
||||
/* Configure chip-select */
|
||||
gpio_init(dev->params.cs, GPIO_DIR_OUT, GPIO_NOPULL);
|
||||
gpio_init(dev->params.cs, GPIO_OUT);
|
||||
gpio_set(dev->params.cs);
|
||||
|
||||
/* Configure GDO1 */
|
||||
gpio_init(dev->params.gdo1, GPIO_DIR_IN, GPIO_NOPULL);
|
||||
gpio_init(dev->params.gdo1, GPIO_IN);
|
||||
|
||||
/* Configure SPI */
|
||||
spi_acquire(dev->params.spi);
|
||||
|
@ -80,7 +80,7 @@ int dht_init(dht_t *dev, const dht_params_t *params)
|
||||
|
||||
memcpy(dev, params, sizeof(dht_t));
|
||||
|
||||
if (gpio_init(dev->pin, GPIO_DIR_OUT, dev->pull) == -1) {
|
||||
if (gpio_init(dev->pin, GPIO_OUT) == -1) {
|
||||
return -1;
|
||||
}
|
||||
gpio_set(dev->pin);
|
||||
@ -103,9 +103,9 @@ int dht_read(dht_t *dev, int16_t *temp, int16_t *hum)
|
||||
xtimer_usleep(40);
|
||||
|
||||
/* sync on device */
|
||||
gpio_init(dev->pin, GPIO_DIR_IN, dev->pull);
|
||||
while (!gpio_read(dev->pin)) ;
|
||||
while (gpio_read(dev->pin)) ;
|
||||
gpio_init(dev, dev->in_mode);
|
||||
while (!gpio_read(dev)) ;
|
||||
while (gpio_read(dev)) ;
|
||||
|
||||
/*
|
||||
* data is read in sequentially, highest bit first:
|
||||
@ -120,7 +120,7 @@ int dht_read(dht_t *dev, int16_t *temp, int16_t *hum)
|
||||
|
||||
/* set pin high again - so we can trigger the next reading by pulling it low
|
||||
* again */
|
||||
gpio_init(dev->pin, GPIO_DIR_OUT, dev->pull);
|
||||
gpio_init(dev->pin, GPIO_OUT);
|
||||
gpio_set(dev->pin);
|
||||
|
||||
/* validate the checksum */
|
||||
|
@ -288,11 +288,11 @@ static int nd_init(netdev2_t *netdev)
|
||||
mutex_lock(&dev->devlock);
|
||||
|
||||
/* setup the low-level interfaces */
|
||||
gpio_init(dev->reset_pin, GPIO_DIR_OUT, GPIO_NOPULL);
|
||||
gpio_init(dev->reset_pin, GPIO_OUT);
|
||||
gpio_clear(dev->reset_pin); /* this puts the device into reset state */
|
||||
gpio_init(dev->cs_pin, GPIO_DIR_OUT, GPIO_NOPULL);
|
||||
gpio_init(dev->cs_pin, GPIO_OUT);
|
||||
gpio_set(dev->cs_pin);
|
||||
gpio_init_int(dev->int_pin, GPIO_NOPULL, GPIO_FALLING, on_int, (void *)dev);
|
||||
gpio_init_int(dev->int_pin, GPIO_IN, GPIO_FALLING, on_int, (void *)dev);
|
||||
res = spi_init_master(dev->spi, SPI_CONF_FIRST_RISING, SPI_SPEED);
|
||||
if (res < 0) {
|
||||
DEBUG("[enc28j60] init: error initializing SPI bus [%i]\n", res);
|
||||
|
@ -250,9 +250,9 @@ static int _init(netdev2_t *encdev)
|
||||
DEBUG("encx24j600: starting initialization...\n");
|
||||
|
||||
/* setup IO */
|
||||
gpio_init(dev->cs, GPIO_DIR_OUT, GPIO_PULLUP);
|
||||
gpio_init(dev->cs, GPIO_OUT);
|
||||
gpio_set(dev->cs);
|
||||
gpio_init_int(dev->int_pin, GPIO_PULLUP, GPIO_FALLING, encx24j600_isr, (void*)dev);
|
||||
gpio_init_int(dev->int_pin, GPIO_IN_PU, GPIO_FALLING, encx24j600_isr, (void*)dev);
|
||||
|
||||
if (spi_init_master(dev->spi, SPI_CONF_FIRST_RISING, ENCX24J600_SPI_SPEED) < 0) {
|
||||
return -1;
|
||||
|
@ -59,7 +59,7 @@ typedef enum {
|
||||
typedef struct {
|
||||
gpio_t pin; /**< GPIO pin of the device's data pin */
|
||||
dht_type_t type; /**< type of the DHT device */
|
||||
gpio_pp_t pull; /**< internal pull resistor configuration, set to
|
||||
gpio_mode_t in_mode; /**< internal pull resistor configuration, set to
|
||||
* GPIO_NOPULL when using an external pull-up */
|
||||
} dht_t;
|
||||
|
||||
|
@ -304,7 +304,7 @@ void kw2xrf_init_interrupts(kw2xrf_t *dev, gpio_t int_pin)
|
||||
kw2xrf_write_dreg(MKW2XDM_PHY_CTRL3, reg);
|
||||
|
||||
/* set up GPIO-pin used for IRQ */
|
||||
gpio_init_int(int_pin, GPIO_NOPULL, GPIO_FALLING, &kw2xrf_irq_handler, dev);
|
||||
gpio_init_int(int_pin, GPIO_IN, GPIO_FALLING, &kw2xrf_irq_handler, dev);
|
||||
}
|
||||
|
||||
int kw2xrf_set_pan(kw2xrf_t *dev, uint16_t pan)
|
||||
|
@ -64,7 +64,7 @@ int kw2xrf_spi_init(spi_t spi, spi_speed_t spi_speed,
|
||||
res = spi_init_master(kw2xrf_spi, SPI_CONF_FIRST_RISING, spi_speed);
|
||||
#if KW2XRF_SHARED_SPI
|
||||
spi_release(kw2xrf_spi);
|
||||
gpio_init(kw2xrf_cs_pin, GPIO_DIR_OUT, GPIO_NOPULL);
|
||||
gpio_init(kw2xrf_cs_pin, GPIO_OUT);
|
||||
gpio_set(kw2xrf_cs_pin);
|
||||
#endif
|
||||
|
||||
|
@ -39,7 +39,7 @@ int lis3dh_init(lis3dh_t *dev, spi_t spi, gpio_t cs_pin, uint8_t scale)
|
||||
dev->scale = 0;
|
||||
|
||||
/* CS */
|
||||
gpio_init(dev->cs, GPIO_DIR_OUT, GPIO_NOPULL);
|
||||
gpio_init(dev->cs, GPIO_OUT);
|
||||
gpio_set(dev->cs);
|
||||
|
||||
if (lis3dh_read_regs(dev, LIS3DH_REG_WHO_AM_I, 1, &in) < 0) {
|
||||
|
@ -72,7 +72,7 @@ int lsm303dlhc_init(lsm303dlhc_t *dev, i2c_t i2c, gpio_t acc_pin, gpio_t mag_pin
|
||||
res += i2c_write_reg(dev->i2c, dev->acc_address,
|
||||
LSM303DLHC_REG_CTRL3_A, LSM303DLHC_CTRL3_A_I1_NONE);
|
||||
/* configure acc data ready pin */
|
||||
gpio_init(acc_pin, GPIO_DIR_IN, GPIO_NOPULL);
|
||||
gpio_init(acc_pin, GPIO_IN);
|
||||
|
||||
/* configure magnetometer and temperature */
|
||||
/* enable temperature output and set sample rate */
|
||||
@ -87,7 +87,7 @@ int lsm303dlhc_init(lsm303dlhc_t *dev, i2c_t i2c, gpio_t acc_pin, gpio_t mag_pin
|
||||
LSM303DLHC_REG_MR_M, LSM303DLHC_MAG_MODE_CONTINUOUS);
|
||||
i2c_release(dev->i2c);
|
||||
/* configure mag data ready pin */
|
||||
gpio_init(mag_pin, GPIO_DIR_IN, GPIO_NOPULL);
|
||||
gpio_init(mag_pin, GPIO_IN);
|
||||
|
||||
return (res < 7) ? -1 : 0;
|
||||
}
|
||||
@ -217,7 +217,7 @@ int lsm303dlhc_enable(lsm303dlhc_t *dev)
|
||||
tmp = (LSM303DLHC_CTRL4_A_BDU| LSM303DLHC_CTRL4_A_SCALE_2G | LSM303DLHC_CTRL4_A_HR);
|
||||
res += i2c_write_reg(dev->i2c, dev->acc_address, LSM303DLHC_REG_CTRL4_A, tmp);
|
||||
res += i2c_write_reg(dev->i2c, dev->acc_address, LSM303DLHC_REG_CTRL3_A, LSM303DLHC_CTRL3_A_I1_DRDY1);
|
||||
gpio_init(dev->acc_pin, GPIO_DIR_IN, GPIO_NOPULL);
|
||||
gpio_init(dev->acc_pin, GPIO_IN);
|
||||
|
||||
tmp = LSM303DLHC_TEMP_EN | LSM303DLHC_TEMP_SAMPLE_75HZ;
|
||||
res += i2c_write_reg(dev->i2c, dev->mag_address, LSM303DLHC_REG_CRA_M, tmp);
|
||||
@ -229,7 +229,7 @@ int lsm303dlhc_enable(lsm303dlhc_t *dev)
|
||||
LSM303DLHC_REG_MR_M, LSM303DLHC_MAG_MODE_CONTINUOUS);
|
||||
i2c_release(dev->i2c);
|
||||
|
||||
gpio_init(dev->mag_pin, GPIO_DIR_IN, GPIO_NOPULL);
|
||||
gpio_init(dev->mag_pin, GPIO_IN);
|
||||
|
||||
return (res < 6) ? -1 : 0;
|
||||
}
|
||||
|
@ -81,14 +81,14 @@ int nrf24l01p_init(nrf24l01p_t *dev, spi_t spi, gpio_t ce, gpio_t cs, gpio_t irq
|
||||
dev->listener = KERNEL_PID_UNDEF;
|
||||
|
||||
/* Init CE pin */
|
||||
gpio_init(dev->ce, GPIO_DIR_OUT, GPIO_NOPULL);
|
||||
gpio_init(dev->ce, GPIO_OUT);
|
||||
|
||||
/* Init CS pin */
|
||||
gpio_init(dev->cs, GPIO_DIR_OUT, GPIO_NOPULL);
|
||||
gpio_init(dev->cs, GPIO_OUT);
|
||||
gpio_set(dev->cs);
|
||||
|
||||
/* Init IRQ pin */
|
||||
gpio_init_int(dev->irq, GPIO_PULLUP, GPIO_FALLING, nrf24l01p_rx_cb, dev);
|
||||
gpio_init_int(dev->irq, GPIO_IN_PU, GPIO_FALLING, nrf24l01p_rx_cb, dev);
|
||||
|
||||
|
||||
/* Init SPI */
|
||||
|
@ -114,7 +114,7 @@ int nvram_spi_init(nvram_t *dev, nvram_spi_params_t *spi_params, size_t size)
|
||||
}
|
||||
dev->extra = spi_params;
|
||||
|
||||
gpio_init(spi_params->cs, GPIO_DIR_OUT, GPIO_NOPULL);
|
||||
gpio_init(spi_params->cs, GPIO_OUT);
|
||||
gpio_set(spi_params->cs);
|
||||
|
||||
return 0;
|
||||
|
@ -231,9 +231,9 @@ int pcd8544_init(pcd8544_t *dev, spi_t spi, gpio_t cs, gpio_t reset, gpio_t mode
|
||||
DEBUG("done setting dev members\n");
|
||||
|
||||
/* initialze pins */
|
||||
gpio_init(cs, GPIO_DIR_OUT, GPIO_NOPULL);
|
||||
gpio_init(reset, GPIO_DIR_OUT, GPIO_NOPULL);
|
||||
gpio_init(mode, GPIO_DIR_OUT, GPIO_NOPULL);
|
||||
gpio_init(cs, GPIO_OUT);
|
||||
gpio_init(reset, GPIO_OUT);
|
||||
gpio_init(mode, GPIO_OUT);
|
||||
DEBUG("done with gpios\n");
|
||||
/* clear CS line */
|
||||
gpio_set(cs);
|
||||
|
@ -41,7 +41,7 @@ int pir_init(pir_t *dev, gpio_t gpio)
|
||||
{
|
||||
dev->gpio_dev = gpio;
|
||||
dev->msg_thread_pid = KERNEL_PID_UNDEF;
|
||||
return gpio_init(dev->gpio_dev, GPIO_DIR_IN, GPIO_NOPULL);
|
||||
return gpio_init(dev->gpio_dev, GPIO_IN);
|
||||
}
|
||||
|
||||
pir_event_t pir_get_status(pir_t *dev)
|
||||
@ -106,5 +106,5 @@ static void pir_callback(void *arg)
|
||||
|
||||
static int pir_activate_int(pir_t *dev)
|
||||
{
|
||||
return gpio_init_int(dev->gpio_dev, GPIO_NOPULL, GPIO_BOTH, pir_callback, dev);
|
||||
return gpio_init_int(dev->gpio_dev, GPIO_IN, GPIO_BOTH, pir_callback, dev);
|
||||
}
|
||||
|
@ -428,14 +428,14 @@ int xbee_init(xbee_t *dev, uart_t uart, uint32_t baudrate,
|
||||
return -ENXIO;
|
||||
}
|
||||
if (reset_pin != GPIO_UNDEF) {
|
||||
if (gpio_init(reset_pin, GPIO_DIR_OUT, GPIO_NOPULL) < 0) {
|
||||
if (gpio_init(reset_pin, GPIO_OUT) < 0) {
|
||||
DEBUG("xbee: Error initializing RESET pin\n");
|
||||
return -ENXIO;
|
||||
}
|
||||
gpio_set(reset_pin);
|
||||
}
|
||||
if (sleep_pin != GPIO_UNDEF) {
|
||||
if (gpio_init(sleep_pin, GPIO_DIR_OUT, GPIO_NOPULL) < 0) {
|
||||
if (gpio_init(sleep_pin, GPIO_OUT) < 0) {
|
||||
DEBUG("xbee: Error initializing SLEEP pin\n");
|
||||
return -ENXIO;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user