Esta es la tercera parte del demo del sistema operativo de tiempo real Zephyr para la plataforma Microchip PIC32CM PL10-CNANO evaluación
Por favor refierase a la Parte 1 y la Parte 2 de esta serie antes de continuar con este demo del sistema operativo Zephyr.
El primer demo de Zephyr RTOS es el blinky demo y que usa la siguiente fuente de código,
/*
* Copyright (c) 2016 Intel Corporation
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <stdio.h>
#include <zephyr/kernel.h>
#include <zephyr/drivers/gpio.h>
/* 1000 msec = 1 sec */
#define SLEEP_TIME_MS 1000
/* The devicetree node identifier for the "led0" alias. */
#define LED0_NODE DT_ALIAS(led0)
/*
* A build error on this line means your board is unsupported.
* See the sample documentation for information on how to fix this.
*/
static const struct gpio_dt_spec led = GPIO_DT_SPEC_GET(LED0_NODE, gpios);
int main(void)
{
int ret;
bool led_state = true;
if (!gpio_is_ready_dt(&led)) {
return 0;
}
ret = gpio_pin_configure_dt(&led, GPIO_OUTPUT_ACTIVE);
if (ret < 0) {
return 0;
}
while (1) {
ret = gpio_pin_toggle_dt(&led);
if (ret < 0) {
return 0;
}
led_state = !led_state;
printf("LED state: %s\n", led_state ? "ON" : "OFF");
k_msleep(SLEEP_TIME_MS);
}
return 0;
}
Este programa de Zephyr RTOS parpadea el LED de la plataforma una vez por cada segundo. Para completar este demo por favor proceda como se ilustra a continuación,
zephyrproject/zephyr$ west build -p always -b pic32cm_pl10_cnano samples/basic/blinky
...
...
[137/137] Linking C executable zephyr/zephyr.elf
Memory region Used Size Region Size %age Used
FLASH: 12068 B 60 KB 19.64%
RAM: 3864 B 8 KB 47.17%
IDT_LIST: 0 B 32 KB 0.00%
En este momento hemos construido la aplicación de blinky para el sistema operativo Zephyr que está listo para programarlo en la plataforma de evaluación. En nuestro próximo artículo vamos a programar este demo en la plataforma Microchip PIC32CM PL10-CNANO evaluation board. La plataforma Microchip PIC32CM PL10-CNANOde evaluación es de bajo costo, poderosa y está disponible en DigiKey.
Que tenga un buen día.
Este artículo está disponible en inglés aquí.
This article is available in english here.
