Hello,
I have been working to manipulate GPIO.
I succeeded to turn on and off P0.02 ~ P0.05 (LED 1~4). However, I cannot get P0.00 and P0.01 to get work.
GPIO IN seems to work because I looped back the 5V and I get 1 as a result but GPIO OUT doesn't work at all.
I measured with a multimeter but it mesaures no voltage.
I referenced to following examples and Q&A:
https://devzone.nordicsemi.com/f/nordic-q-a/43774/simple-gpio-example---nrf9160-dk
https://devzone.nordicsemi.com/f/nordic-q-a/44940/simple-gpio-example---nrf9160-dk-2
I added my project to the git, please take a look at it if you need more reference to help me.
https://github.com/CerfVert94/nRF9160-GPIO
I added the following lines to KConfig.deconfig :
config GPIO
bool
default y
depends on SPI && SOC_FAMILY_NRF
I commented out uart1 that uses pin P0.00 and P0.01 in nrf9160_pca10090_common.dts; just in case.
/*
&uart1 {
status = "ok";
current-speed = <115200>;
tx-pin = <1>;
rx-pin = <0>;
rts-pin = <14>;
cts-pin = <15>;
};
*/
I use the non-secure boot, so added nrf9160_pca10090ns.overlay file, which contains the following lines :
&spi3 {
status = "ok";
sck-pin = <10>;
mosi-pin = <11>;
miso-pin = <12>;
ss-pin = <13>;
spi-max-frequency = <4000000>;
};
All these config / overlay files are in path/ncs/nrf/applications/MY_PROJECT/ , where CMakeLists.txt is located.
The following is my code :
static void gpio_init(void)
{
const char* const gpioName = "GPIO_0";
gpio_dev = device_get_binding(gpioName);
if (gpio_dev == NULL) {
printk("Could not get %s device\n", gpioName);
return;
}
printk("Successfully initialised %s device\n", gpioName);
if(gpio_pin_configure(gpio_dev, PIN1, GPIO_DIR_OUT) < 0)
printk("Could not configure pin P0.%02d\n", PIN1);
if(gpio_pin_configure(gpio_dev, PIN2, GPIO_DIR_OUT ) < 0)
printk("Could not configure pin P0.%02d\n", PIN2);
}
static void spi_init(void)
{
const char* const spiName = "SPI_3";
spi_dev = device_get_binding(spiName);
if (spi_dev == NULL) {
printk("Could not get %s device\n", spiName);
return;
}
printk("Successfully initialised %s device\n", spiName);
}
void main(void)
{
printk("Application started\n");
gpio_init();
spi_init();
if (!gpio_pin_write(gpio_dev, PIN1, 1))
printf("1. P0.%02d : write 1\n", PIN1);
if (!gpio_pin_write(gpio_dev, PIN2, 1))
printf("2. P0.%02d : write 1\n", PIN2);
while(1);
}
I want to manipulate Chip Select signal during SPI communication but I can't manipulate GPIO ... could you help me, please?