diff --git a/apps/01_blinky_button/src/main.c b/apps/01_blinky_button/src/main.c index 2a21f46..afd069d 100644 --- a/apps/01_blinky_button/src/main.c +++ b/apps/01_blinky_button/src/main.c @@ -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; diff --git a/apps/02_uart/src/main.c b/apps/02_uart/src/main.c index 479ce11..6139050 100644 --- a/apps/02_uart/src/main.c +++ b/apps/02_uart/src/main.c @@ -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; diff --git a/apps/03_adc_pa1_poll/src/main.c b/apps/03_adc_pa1_poll/src/main.c index 0cd18f0..d41b613 100644 --- a/apps/03_adc_pa1_poll/src/main.c +++ b/apps/03_adc_pa1_poll/src/main.c @@ -6,7 +6,6 @@ #include #include - #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; } diff --git a/apps/04_adc_pa1_pa4_pb0_poll/src/main.c b/apps/04_adc_pa1_pa4_pb0_poll/src/main.c index 7c5d322..aabc12e 100644 --- a/apps/04_adc_pa1_pa4_pb0_poll/src/main.c +++ b/apps/04_adc_pa1_pa4_pb0_poll/src/main.c @@ -6,7 +6,6 @@ #include #include - #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; } diff --git a/apps/05_button_exti_irq/src/main.c b/apps/05_button_exti_irq/src/main.c index 9cda78a..92628e6 100644 --- a/apps/05_button_exti_irq/src/main.c +++ b/apps/05_button_exti_irq/src/main.c @@ -6,7 +6,6 @@ #include #include - #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; diff --git a/apps/06_adc_pa1_irq/src/main.c b/apps/06_adc_pa1_irq/src/main.c index 3eb1576..fb67c99 100644 --- a/apps/06_adc_pa1_irq/src/main.c +++ b/apps/06_adc_pa1_irq/src/main.c @@ -6,7 +6,6 @@ #include #include - #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; }