Microchip® Advanced Software Framework

usart_unit_tests.c File Reference

Unit tests for FreeRTOS USART Interface Layer.

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

#include <stdint.h>
#include <stdbool.h>
#include <board.h>
#include <sysclk.h>
#include <string.h>
#include <unit_test/suite.h>
#include <stdio_serial.h>
#include <usart.h>
#include <conf_test.h>
#include <conf_board.h>
#include <conf_example.h>
#include "FreeRTOS.h"
#include "task.h"
#include "freertos_usart_serial.h"

Macros

#define RX_BUFFER_SIZE   (78)
 
#define USART_BAUD_RATE   (115200)
 

Functions

static void create_usart_tasks (Usart *usart_base, uint16_t stack_depth_words, unsigned portBASE_TYPE task_priority)
 
int main (void)
 Run USART unit tests. More...
 
static void prvSetupHardware (void)
 
static void run_usart_test (const struct test_case *test)
 
static void usart_echo_tx_task (void *pvParameters)
 
static void usart_task (void *pvParameters)
 
void vApplicationIdleHook (void)
 
void vApplicationMallocFailedHook (void)
 
void vApplicationStackOverflowHook (xTaskHandle pxTask, signed char *pcTaskName)
 
void vApplicationTickHook (void)
 This function is called by FreeRTOS each tick. More...
 

Variables

const uint8_t * echo_strings []
 
static freertos_usart_if freertos_usart
 
static uint8_t receive_buffer [RX_BUFFER_SIZE] = {0}
 

#define RX_BUFFER_SIZE   (78)
#define USART_BAUD_RATE   (115200)

Referenced by create_usart_tasks().

static void create_usart_tasks ( Usart *  usart_base,
uint16_t  stack_depth_words,
unsigned portBASE_TYPE  task_priority 
)
static
int main ( void  )
static void prvSetupHardware ( void  )
static
static void run_usart_test ( const struct test_case test)
static
static void usart_task ( void *  pvParameters)
static
void vApplicationIdleHook ( void  )
void vApplicationMallocFailedHook ( void  )

vApplicationMallocFailedHook() will only be called if configUSE_MALLOC_FAILED_HOOK is set to 1 in FreeRTOSConfig.h. It is a hook function that will get called if a call to pvPortMalloc() fails. pvPortMalloc() is called internally by the kernel whenever a task, queue, timer or semaphore is created. It is also called by various parts of the demo application. If heap_1.c or heap_2.c are used, then the size of the heap available to pvPortMalloc() is defined by configTOTAL_HEAP_SIZE in FreeRTOSConfig.h, and the xPortGetFreeHeapSize() API function can be used to query the size of free heap space that remains (although it does not provide information on how the remaining heap might be fragmented).

void vApplicationStackOverflowHook ( xTaskHandle  pxTask,
signed char *  pcTaskName 
)

Run time stack overflow checking is performed if configCHECK_FOR_STACK_OVERFLOW is defined to 1 or 2. This hook function is called if a stack overflow is detected.

void vApplicationTickHook ( void  )

This function is called by FreeRTOS each tick.

This function will be called by each tick interrupt if configUSE_TICK_HOOK is set to 1 in FreeRTOSConfig.h. User code can be added here, but the tick hook is called from an interrupt context, so code must not attempt to block, and only the interrupt safe FreeRTOS API functions can be used (those that end in FromISR()).

const uint8_t* echo_strings[]
uint8_t receive_buffer[RX_BUFFER_SIZE] = {0}
static

Referenced by create_usart_tasks().