Microchip® Advanced Software Framework

demo_co_routines.c File Reference

FreeRTOS demo Co-routines implementations.

Copyright (c) 2014-2018 Microchip Technology Inc. and its subsidiaries.

#include <asf.h>
#include <conf_demo.h>
#include "demo_co_routines.h"

Macros

Co-routines configuration
#define UART_CO_ROUTINE_PRIORITY   (configMAX_CO_ROUTINE_PRIORITIES - 1)
 
#define MAIN_CO_ROUTINE_PRIORITY   (configMAX_CO_ROUTINE_PRIORITIES - 2)
 
#define MAIN_CO_ROUTINE_DELAY   (100 / portTICK_RATE_MS)
 
#define GRAPH_CO_ROUTINE_PRIORITY   (configMAX_CO_ROUTINE_PRIORITIES - 3)
 
#define GRAPH_CO_ROUTINE_DELAY   (50 / portTICK_RATE_MS)
 
#define TERMINAL_CO_ROUTINE_PRIORITY   (configMAX_CO_ROUTINE_PRIORITIES - 3)
 
#define ABOUT_CO_ROUTINE_PRIORITY   (configMAX_CO_ROUTINE_PRIORITIES - 3)
 

Functions

static void cdc_rx_handler (uint8_t instance)
 Interrupt handler for reception from EDBG Virtual COM Port. More...
 
void demo_co_routines_init (void)
 Initialize Co-routines and resources for demo. More...
 
void vApplicationIdleHook (void)
 This idle task hook will schedule a co-routine each time it is called. More...
 
Co-routines for demo
static void main_co_routine (CoRoutineHandle_t xHandle, UBaseType_t uxIndex)
 Main demo Co-routine. More...
 
static void graph_co_routine (CoRoutineHandle_t xHandle, UBaseType_t uxIndex)
 Graph Co-routine. More...
 
static void terminal_co_routine (CoRoutineHandle_t xHandle, UBaseType_t uxIndex)
 Terminal Co-routine. More...
 
static void about_co_routine (CoRoutineHandle_t xHandle, UBaseType_t uxIndex)
 About Co-routine. More...
 
static void uart_co_routine (CoRoutineHandle_t xHandle, UBaseType_t uxIndex)
 UART Co-routine. More...
 

Menu and display configuration

#define MENU_HEIGHT   8
 Height of menu bar. More...
 
#define MENU_ITEM_WIDTH   (((GFX_MONO_LCD_WIDTH - (MENU_NUM_ITEMS - 1))) / MENU_NUM_ITEMS)
 Width per menu item. More...
 
#define CANVAS_HEIGHT   ((GFX_MONO_LCD_HEIGHT) - (MENU_HEIGHT + 1))
 Height of area in which to draw content. More...
 
#define CANVAS_WIDTH   (GFX_MONO_LCD_WIDTH)
 Width of area in which to draw content. More...
 
#define TERMINAL_LINES   (1 + ((CANVAS_HEIGHT - SYSFONT_HEIGHT) / (SYSFONT_HEIGHT + 1)))
 Character lines on display. More...
 
#define TERMINAL_COLUMNS   (CANVAS_WIDTH / SYSFONT_WIDTH)
 Character columns on display. More...
 
#define TERMINAL_BUFFER_LINES   (1 + TERMINAL_LINES)
 Character lines in terminal buffer. More...
 
#define TERMINAL_BUFFER_COLUMNS   (1 + TERMINAL_COLUMNS)
 Character columns in terminal buffer. More...
 
enum  menu_items {
  MENU_ITEM_GRAPH,
  MENU_ITEM_TERMINAL,
  MENU_ITEM_ABOUT,
  MENU_NUM_ITEMS
}
 Available selections in menu. More...
 

Global constants and variables

static const char menu_items_text [MENU_NUM_ITEMS][6]
 Labels for menu items. More...
 
static const char about_text []
 Text to display on about screen. More...
 
static struct usart_module cdc_usart
 Instance for Embedded Debugger (EDBG) Virtual COM Port driver. More...
 
static uint8_t graph_noise = 128
 Pseudo-random noise for graph Co-routine. More...
 
static gfx_coord_t x1 = 0
 x coord for graph Co-routine More...
 
static uint8_t terminal_buffer [TERMINAL_BUFFER_LINES][TERMINAL_BUFFER_COLUMNS]
 Buffer for terminal text. More...
 
static uint8_t terminal_line_offset
 Index of latest terminal line (first to be printed) More...
 
static QueueHandle_t terminal_in_queue
 Queue for incoming terminal characters. More...
 
static QueueHandle_t graph_co_routine_queue
 Queue for sync graph Co-routine. More...
 
static QueueHandle_t terminal_co_routine_queue
 Queue for sync terminal Co-routine. More...
 
static QueueHandle_t about_co_routine_queue
 Queue for sync about Co-routine. More...
 
static OLED1_CREATE_INSTANCE (oled1, OLED1_EXT_HEADER)
 Instance for OLED1 Xplained Pro LED and button driver. More...