Initial commit
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
#include <stdio.h>
|
||||
#include <FreeRTOS.h>
|
||||
#include <task.h>
|
||||
#include <queue.h>
|
||||
#include "pico/stdlib.h"
|
||||
#include "pico/binary_info.h"
|
||||
#include "boards/pico.h"
|
||||
|
||||
volatile QueueHandle_t queue = NULL;
|
||||
const TickType_t ms_delay = 500 / portTICK_PERIOD_MS;
|
||||
TaskHandle_t pico_task_handle = NULL;
|
||||
|
||||
void led_task_pico(void *unused_arg)
|
||||
{
|
||||
|
||||
// Store the Pico LED state
|
||||
uint8_t pico_led_state = 0;
|
||||
|
||||
// Configure the Pico's on-board LED
|
||||
gpio_init(PICO_DEFAULT_LED_PIN);
|
||||
gpio_set_dir(PICO_DEFAULT_LED_PIN, GPIO_OUT);
|
||||
|
||||
while (true)
|
||||
{
|
||||
pico_led_state = 1;
|
||||
gpio_put(PICO_DEFAULT_LED_PIN, pico_led_state);
|
||||
xQueueSendToBack(queue, &pico_led_state, 0);
|
||||
vTaskDelay(ms_delay);
|
||||
|
||||
pico_led_state = 0;
|
||||
gpio_put(PICO_DEFAULT_LED_PIN, pico_led_state);
|
||||
xQueueSendToBack(queue, &pico_led_state, 0);
|
||||
vTaskDelay(ms_delay);
|
||||
}
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
stdio_init_all();
|
||||
|
||||
BaseType_t pico_status = xTaskCreate(led_task_pico,
|
||||
"PICO_LED_TASK",
|
||||
128,
|
||||
NULL,
|
||||
1,
|
||||
&pico_task_handle);
|
||||
queue = xQueueCreate(4, sizeof(uint8_t));
|
||||
if (pico_status == pdPASS)
|
||||
{
|
||||
vTaskStartScheduler();
|
||||
}
|
||||
|
||||
while (true)
|
||||
{
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user