Update repo
This commit is contained in:
1 parent
0afe39c8fe
commit
d229fd964d
6 files changed
+9
-28
No files matched your search
@@ -41,7 +41,6 @@ static const struct gpio_dt_spec button =
|
|||||||
GPIO_DT_SPEC_GET(DT_ALIAS(sw0), gpios);
|
GPIO_DT_SPEC_GET(DT_ALIAS(sw0), gpios);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
int main(void) {
|
int main(void) {
|
||||||
|
|
||||||
bool led_state = true;
|
bool led_state = true;
|
||||||
|
|||||||
@@ -45,8 +45,8 @@ static void uart_rx_isr(const struct device *dev, void *user_data) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(void)
|
int main(void) {
|
||||||
{
|
|
||||||
uint32_t cnt = 0;
|
uint32_t cnt = 0;
|
||||||
uint8_t ch;
|
uint8_t ch;
|
||||||
int rc;
|
int rc;
|
||||||
|
|||||||
@@ -6,7 +6,6 @@
|
|||||||
#include <zephyr/drivers/uart.h>
|
#include <zephyr/drivers/uart.h>
|
||||||
#include <zephyr/drivers/adc.h>
|
#include <zephyr/drivers/adc.h>
|
||||||
|
|
||||||
|
|
||||||
#define ADC_NODE DT_NODELABEL(adc1)
|
#define ADC_NODE DT_NODELABEL(adc1)
|
||||||
|
|
||||||
#if !DT_NODE_HAS_STATUS(ADC_NODE, okay)
|
#if !DT_NODE_HAS_STATUS(ADC_NODE, okay)
|
||||||
@@ -34,9 +33,8 @@ static struct adc_sequence seq = {
|
|||||||
.resolution = 12, // 12-bit
|
.resolution = 12, // 12-bit
|
||||||
};
|
};
|
||||||
|
|
||||||
|
int main(void) {
|
||||||
int main(void)
|
|
||||||
{
|
|
||||||
if(!device_is_ready(adc_dev)) {
|
if(!device_is_ready(adc_dev)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,6 @@
|
|||||||
#include <zephyr/drivers/uart.h>
|
#include <zephyr/drivers/uart.h>
|
||||||
#include <zephyr/drivers/adc.h>
|
#include <zephyr/drivers/adc.h>
|
||||||
|
|
||||||
|
|
||||||
#define ADC_NODE DT_NODELABEL(adc1)
|
#define ADC_NODE DT_NODELABEL(adc1)
|
||||||
|
|
||||||
#if !DT_NODE_HAS_STATUS(ADC_NODE, okay)
|
#if !DT_NODE_HAS_STATUS(ADC_NODE, okay)
|
||||||
@@ -19,7 +18,6 @@ static const struct device *const adc_dev =
|
|||||||
static uint16_t sample;
|
static uint16_t sample;
|
||||||
|
|
||||||
// Channels Configuration: PA1(IN1), PA4(IN4), PB0(IN8)
|
// Channels Configuration: PA1(IN1), PA4(IN4), PB0(IN8)
|
||||||
|
|
||||||
static struct adc_channel_cfg ch1_cfg = {
|
static struct adc_channel_cfg ch1_cfg = {
|
||||||
.gain = ADC_GAIN_1,
|
.gain = ADC_GAIN_1,
|
||||||
.reference = ADC_REF_INTERNAL,
|
.reference = ADC_REF_INTERNAL,
|
||||||
@@ -69,9 +67,8 @@ static int read_one(uint8_t ch, uint16_t *out) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int main(void) {
|
||||||
int main(void)
|
|
||||||
{
|
|
||||||
if(!device_is_ready(adc_dev)) {
|
if(!device_is_ready(adc_dev)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,6 @@
|
|||||||
#include <zephyr/drivers/uart.h>
|
#include <zephyr/drivers/uart.h>
|
||||||
#include <zephyr/drivers/adc.h>
|
#include <zephyr/drivers/adc.h>
|
||||||
|
|
||||||
|
|
||||||
#if !DT_NODE_HAS_STATUS(DT_ALIAS(sw0), okay)
|
#if !DT_NODE_HAS_STATUS(DT_ALIAS(sw0), okay)
|
||||||
#error "Board does not define alias sw0. Add a boad overlay"
|
#error "Board does not define alias sw0. Add a boad overlay"
|
||||||
#endif
|
#endif
|
||||||
@@ -16,7 +15,6 @@ static const struct gpio_dt_spec button =
|
|||||||
|
|
||||||
static struct gpio_callback button_cb;
|
static struct gpio_callback button_cb;
|
||||||
|
|
||||||
|
|
||||||
static void button_isr(const struct device *port,
|
static void button_isr(const struct device *port,
|
||||||
struct gpio_callback *cb,
|
struct gpio_callback *cb,
|
||||||
gpio_port_pins_t pins)
|
gpio_port_pins_t pins)
|
||||||
@@ -34,9 +32,8 @@ static void button_isr(const struct device *port,
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int main(void) {
|
||||||
|
|
||||||
int main(void)
|
|
||||||
{
|
|
||||||
if(!device_is_ready(button.port)) {
|
if(!device_is_ready(button.port)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -49,7 +46,6 @@ int main(void)
|
|||||||
gpio_init_callback(&button_cb, button_isr, BIT(button.pin));
|
gpio_init_callback(&button_cb, button_isr, BIT(button.pin));
|
||||||
gpio_add_callback(button.port, &button_cb);
|
gpio_add_callback(button.port, &button_cb);
|
||||||
|
|
||||||
|
|
||||||
if(gpio_pin_interrupt_configure_dt(&button, GPIO_INT_EDGE_BOTH) != 0) {
|
if(gpio_pin_interrupt_configure_dt(&button, GPIO_INT_EDGE_BOTH) != 0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -57,9 +53,7 @@ int main(void)
|
|||||||
printk("\r\n[EXTI] Button pin interrupt is ready. Press button\r\n");
|
printk("\r\n[EXTI] Button pin interrupt is ready. Press button\r\n");
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
|
|
||||||
k_sleep(K_FOREVER);
|
k_sleep(K_FOREVER);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -6,7 +6,6 @@
|
|||||||
#include <zephyr/drivers/uart.h>
|
#include <zephyr/drivers/uart.h>
|
||||||
#include <zephyr/drivers/adc.h>
|
#include <zephyr/drivers/adc.h>
|
||||||
|
|
||||||
|
|
||||||
#define ADC_NODE DT_NODELABEL(adc1)
|
#define ADC_NODE DT_NODELABEL(adc1)
|
||||||
#define ADC_SAMPLE_PERIOD K_MSEC(50)
|
#define ADC_SAMPLE_PERIOD K_MSEC(50)
|
||||||
|
|
||||||
@@ -25,10 +24,8 @@ static enum adc_action adc_cb(const struct device *dev,
|
|||||||
|
|
||||||
static K_WORK_DELAYABLE_DEFINE(adc_sample_work, adc_sample_work_handler);
|
static K_WORK_DELAYABLE_DEFINE(adc_sample_work, adc_sample_work_handler);
|
||||||
|
|
||||||
|
|
||||||
static uint16_t sample;
|
static uint16_t sample;
|
||||||
|
|
||||||
|
|
||||||
static struct adc_sequence_options seq_opts = {
|
static struct adc_sequence_options seq_opts = {
|
||||||
.interval_us = 0, // Let driver decide
|
.interval_us = 0, // Let driver decide
|
||||||
.extra_samplings = 0, // One-shot, resubmit work continuously
|
.extra_samplings = 0, // One-shot, resubmit work continuously
|
||||||
@@ -37,7 +34,6 @@ static struct adc_sequence_options seq_opts = {
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// Channel Configuration
|
// Channel Configuration
|
||||||
static struct adc_channel_cfg ch1_cfg = {
|
static struct adc_channel_cfg ch1_cfg = {
|
||||||
.gain = ADC_GAIN_1,
|
.gain = ADC_GAIN_1,
|
||||||
@@ -47,7 +43,7 @@ static struct adc_channel_cfg ch1_cfg = {
|
|||||||
.differential = 0,
|
.differential = 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Sequence Configuration
|
||||||
static struct adc_sequence seq = {
|
static struct adc_sequence seq = {
|
||||||
.channels = BIT(1), // Channel bitmap
|
.channels = BIT(1), // Channel bitmap
|
||||||
.buffer = &sample,
|
.buffer = &sample,
|
||||||
@@ -56,7 +52,6 @@ static struct adc_sequence seq = {
|
|||||||
.options = &seq_opts
|
.options = &seq_opts
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
static enum adc_action adc_cb(const struct device *dev,
|
static enum adc_action adc_cb(const struct device *dev,
|
||||||
const struct adc_sequence *sequence,
|
const struct adc_sequence *sequence,
|
||||||
uint16_t sampling_index)
|
uint16_t sampling_index)
|
||||||
@@ -69,7 +64,6 @@ static enum adc_action adc_cb(const struct device *dev,
|
|||||||
return ADC_ACTION_FINISH;
|
return ADC_ACTION_FINISH;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void adc_sample_work_handler(struct k_work *work)
|
static void adc_sample_work_handler(struct k_work *work)
|
||||||
{
|
{
|
||||||
ARG_UNUSED(work);
|
ARG_UNUSED(work);
|
||||||
@@ -86,9 +80,8 @@ static void adc_sample_work_handler(struct k_work *work)
|
|||||||
(void)k_work_reschedule(&adc_sample_work, ADC_SAMPLE_PERIOD);
|
(void)k_work_reschedule(&adc_sample_work, ADC_SAMPLE_PERIOD);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int main(void) {
|
||||||
|
|
||||||
int main(void)
|
|
||||||
{
|
|
||||||
if(!device_is_ready(adc_dev)) {
|
if(!device_is_ready(adc_dev)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user