Update repo

This commit is contained in:
hangpersonal committed 2026-10-06 20:15:27 -07:00
1 parent 0afe39c8fe
commit d229fd964d
6 files changed
+7 -26

No files matched your search

-1
View File
@@ -41,7 +41,6 @@ static const struct gpio_dt_spec button =
GPIO_DT_SPEC_GET(DT_ALIAS(sw0), gpios);
#endif
int main(void) {
bool led_state = true;
+2 -2
View File
@@ -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;
uint8_t ch;
int rc;
+1 -3
View File
@@ -6,7 +6,6 @@
#include <zephyr/drivers/uart.h>
#include <zephyr/drivers/adc.h>
#define ADC_NODE DT_NODELABEL(adc1)
#if !DT_NODE_HAS_STATUS(ADC_NODE, okay)
@@ -34,9 +33,8 @@ static struct adc_sequence seq = {
.resolution = 12, // 12-bit
};
int main(void) {
int main(void)
{
if(!device_is_ready(adc_dev)) {
return 0;
}
+1 -4
View File
@@ -6,7 +6,6 @@
#include <zephyr/drivers/uart.h>
#include <zephyr/drivers/adc.h>
#define ADC_NODE DT_NODELABEL(adc1)
#if !DT_NODE_HAS_STATUS(ADC_NODE, okay)
@@ -19,7 +18,6 @@ static const struct device *const adc_dev =
static uint16_t sample;
// Channels Configuration: PA1(IN1), PA4(IN4), PB0(IN8)
static struct adc_channel_cfg ch1_cfg = {
.gain = ADC_GAIN_1,
.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)) {
return 0;
}
+1 -7
View File
@@ -6,7 +6,6 @@
#include <zephyr/drivers/uart.h>
#include <zephyr/drivers/adc.h>
#if !DT_NODE_HAS_STATUS(DT_ALIAS(sw0), okay)
#error "Board does not define alias sw0. Add a boad overlay"
#endif
@@ -16,7 +15,6 @@ static const struct gpio_dt_spec button =
static struct gpio_callback button_cb;
static void button_isr(const struct device *port,
struct gpio_callback *cb,
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)) {
return 0;
}
@@ -49,7 +46,6 @@ int main(void)
gpio_init_callback(&button_cb, button_isr, BIT(button.pin));
gpio_add_callback(button.port, &button_cb);
if(gpio_pin_interrupt_configure_dt(&button, GPIO_INT_EDGE_BOTH) != 0) {
return 0;
}
@@ -57,9 +53,7 @@ int main(void)
printk("\r\n[EXTI] Button pin interrupt is ready. Press button\r\n");
while (1) {
k_sleep(K_FOREVER);
}
return 0;
+2 -9
View File
@@ -6,7 +6,6 @@
#include <zephyr/drivers/uart.h>
#include <zephyr/drivers/adc.h>
#define ADC_NODE DT_NODELABEL(adc1)
#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 uint16_t sample;
static struct adc_sequence_options seq_opts = {
.interval_us = 0, // Let driver decide
.extra_samplings = 0, // One-shot, resubmit work continuously
@@ -37,7 +34,6 @@ static struct adc_sequence_options seq_opts = {
};
// Channel Configuration
static struct adc_channel_cfg ch1_cfg = {
.gain = ADC_GAIN_1,
@@ -47,7 +43,7 @@ static struct adc_channel_cfg ch1_cfg = {
.differential = 0,
};
// Sequence Configuration
static struct adc_sequence seq = {
.channels = BIT(1), // Channel bitmap
.buffer = &sample,
@@ -56,7 +52,6 @@ static struct adc_sequence seq = {
.options = &seq_opts
};
static enum adc_action adc_cb(const struct device *dev,
const struct adc_sequence *sequence,
uint16_t sampling_index)
@@ -69,7 +64,6 @@ static enum adc_action adc_cb(const struct device *dev,
return ADC_ACTION_FINISH;
}
static void adc_sample_work_handler(struct k_work *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);
}
int main(void) {
int main(void)
{
if(!device_is_ready(adc_dev)) {
return 0;
}