Untitled

mail@pastecode.io avatar
unknown
c_cpp
2 months ago
935 B
3
Indexable
Never
#include <zephyr/kernel.h>
#include <zephyr/device.h>
#include <zephyr/devicetree.h>
#include <zephyr/sys/printk.h>
#include <zephyr/drivers/gpio.h>
#include <zephyr/logging/log.h>
#include <zephyr/drivers/spi.h>

LOG_MODULE_REGISTER(test_SPIM,LOG_LEVEL_DBG);


#define LED0_NODE DT_ALIAS(led3)

static const struct gpio_dt_spec led = GPIO_DT_SPEC_GET(LED0_NODE, gpios);

static struct gpio_callback button_cb_data;

#define SPIOP	SPI_WORD_SET(16) | SPI_TRANSFER_MSB | SPI_WORD_SIZE_GET(8)

struct spi_dt_spec spispec = SPI_DT_SPEC_GET(DT_NODELABEL(pressurboi), SPIOP, 0);



int main(void)
{
	LOG_INF("%i",spispec.config.cs.gpio.port);
    

    if (!device_is_ready(led.port)) {
		return -1;
	}

	int ret = gpio_pin_configure_dt(&led, GPIO_OUTPUT_ACTIVE);
	if (ret < 0) {
		return -1;
	}

	//Just to show that we have flashed it correctly
    gpio_pin_set_dt(&led,1);

    

    return 1;
}
Leave a Comment