mirror of
https://github.com/mytechnotalent/Embedded-Hacking.git
synced 2026-08-15 23:50:23 +02:00
Updated Drivers
This commit is contained in:
@@ -43,15 +43,24 @@
|
||||
#define LED_PIN 25
|
||||
#define BLINK_DELAY_MS 500
|
||||
|
||||
|
||||
/**
|
||||
* @brief Application entry point for the LED blink demo
|
||||
*
|
||||
* Initializes the onboard LED and enters an infinite loop that
|
||||
* toggles the LED state every BLINK_DELAY_MS milliseconds.
|
||||
*
|
||||
* @return int Does not return
|
||||
*/
|
||||
int main(void) {
|
||||
stdio_init_all();
|
||||
blink_init(LED_PIN);
|
||||
|
||||
printf("Blink driver initialized on GPIO %d\r\n", LED_PIN);
|
||||
|
||||
while (true) {
|
||||
blink_toggle(LED_PIN);
|
||||
printf("LED: %s\r\n", blink_get_state(LED_PIN) ? "ON" : "OFF");
|
||||
sleep_ms(BLINK_DELAY_MS);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,24 +31,29 @@
|
||||
#include "pico/stdlib.h"
|
||||
#include "hardware/gpio.h"
|
||||
|
||||
|
||||
void blink_init(uint32_t pin) {
|
||||
gpio_init(pin);
|
||||
gpio_set_dir(pin, GPIO_OUT);
|
||||
gpio_put(pin, false);
|
||||
}
|
||||
|
||||
|
||||
void blink_on(uint32_t pin) {
|
||||
gpio_put(pin, true);
|
||||
}
|
||||
|
||||
|
||||
void blink_off(uint32_t pin) {
|
||||
gpio_put(pin, false);
|
||||
}
|
||||
|
||||
|
||||
void blink_toggle(uint32_t pin) {
|
||||
gpio_put(pin, !gpio_get(pin));
|
||||
}
|
||||
|
||||
|
||||
bool blink_get_state(uint32_t pin) {
|
||||
return (bool)gpio_get(pin);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user