Microchip® Advanced Software Framework

phy_tx_test_console.c File Reference

ATMEL PLC PHY TX Test Console Application.

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

#include <string.h>
#include "FreeRTOS.h"
#include "task.h"
#include "board.h"
#include "asf.h"
#include "math.h"
#include "atpl230.h"
#include "atpl230_version.h"
#include "conf_atpl230.h"
#include "phy_embedded_app.h"
#include "conf_example.h"

Macros

#define mainMONITOR_BLOCK_TIME   (1000 / portTICK_RATE_MS)
 
#define mainMONITOR_TIMER_RATE   (500 / portTICK_RATE_MS)
 
#define MENU_CONSOLE   "\n\rPHY-Console>"
 
#define MENU_COUPLING
 
#define MENU_DATA_MODE
 
#define MENU_HEADER
 
#define MENU_IMPEDANCE
 
#define MENU_MODE
 
#define MENU_SCHEME
 
#define STRING_EOL   "\r"
 
#define STRING_HEADER
 
#define WATCHDOG_1s   1000000
 
#define WATCHDOG_5s   5000000
 

Functions

static void auto_impedance_mode (void)
 Auto impedance mode. More...
 
static void configure_dbg_console (void)
 Configure UART console. More...
 
static void display_config (void)
 Display current information. More...
 
static void execute_tx_test (void)
 Execute TX test. More...
 
static void fill_msg_fixed (void)
 Fill data message in fixed mode. More...
 
static void fill_msg_manual (void)
 Fill data message in manual mode. More...
 
static void fix_impedance_mode (uint8_t uc_impedance)
 Fix impedance mode. More...
 
static void get_data_len (void)
 Get Length of data to transmit. More...
 
static void get_impedance_mode (void)
 Get Autodetect Impedance mode. More...
 
static void get_transmission_att_level (void)
 Get ID of attenuation level. More...
 
static void get_transmission_buffer_id (void)
 Get ID of transmission buffer. More...
 
static void get_transmission_channel (void)
 Get ID of channel in transmission. More...
 
static void get_transmission_coupling (void)
 Get ID of coupling board. More...
 
static void get_transmission_data (void)
 Get Transmission Data. More...
 
static void get_transmission_disable_rx (void)
 Get disable RX configuration. More...
 
static void get_transmission_mode (void)
 Get Transmission Mode. More...
 
static void get_transmission_period (void)
 Get Period of transmission. More...
 
static void get_transmission_scheme (void)
 Get scheme of modulation. More...
 
static uint8_t load_config (void)
 Get configuration parameters from GPBR. More...
 
int main (void)
 Main code entry point.0. More...
 
static void prvProcessMonitorTasks (xTimerHandle pxTimer)
 Display scheduler activity led. More...
 
static void prvSetupHardware (void)
 Configure the hardware. More...
 
static void save_config (uint8_t cmd_start_mode)
 Set configuration parameters in GPBR. More...
 
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

uint8_t ucv_tx_data_buffer [512]
 
static txPhyEmbeddedConfig_t xAppPhyCfgTx
 

#define mainMONITOR_BLOCK_TIME   (1000 / portTICK_RATE_MS)

Referenced by main().

#define mainMONITOR_TIMER_RATE   (500 / portTICK_RATE_MS)

Referenced by main().

#define MENU_COUPLING
Value:
"\n\r-- Coupling Board --------------\r\n" \
"0: ATPLCOUP000_v1\n\r" \
"1: ATPLCOUP000_v2\n\r" \
"2: ATPLCOUP001_v1\n\r" \
"3: ATPLCOUP002_v1\n\r" \
"4: ATPLCOUP002_v2\n\r" \
"5: ATPLCOUP003_v1\n\r" \
"6: ATPLCOUP004_v1\n\r" \
"7: ATPLCOUP005_v1\n\r" \
"8: ATPLCOUP006_v1\n\r"

Referenced by get_transmission_coupling().

#define MENU_DATA_MODE
Value:
"\n\r-- Select Data Mode --------------\r\n" \
"1: Fixed Data\n\r" \
"2: Manual Data\n\r"

Referenced by get_transmission_data().

#define MENU_HEADER
Value:
"\n\r-- Menu Configuration --------------\n\r" \
"0: Select buffer to transmit\n\r" \
"1: Select attenuation level\n\r" \
"2: Select scheme to transmit\n\r" \
"3: Disable Rx in transmission\n\r" \
"4: Select mode to transmit\n\r" \
"5: Select time period between messages to transmit(ms.)\n\r" \
"6: Enter data to transmit\n\r" \
"7: Select channel to transmit\n\r" \
"8: Select coupling board in use\n\r" \
"9: Config Auto-Detect impedance \n\r" \
"v: View TX configuration values\n\r" \
"e: Execute transmission application\n\r" \
"otherwise: Display this main menu\n\n\r"

Referenced by main().

#define MENU_IMPEDANCE
Value:
"\n\r-- Autodetect Impedance Mode --------------\r\n" \
"0: Autodetect mode\n\r" \
"1: Fixed Mode. High Impedance\n\r" \
"2: Fixed Mode. Low Impedance\n\r" \
"3: Fixed Mode. Vlow Impedance\n\r"

Referenced by get_impedance_mode().

#define MENU_MODE
Value:
"\n\r-- PRIME Mode --------------\r\n" \
"0: MODE_TYPE_A\n\r" \
"2: MODE_TYPE_B\n\r" \
"3: MODE_TYPE_BC\n\r"

Referenced by get_transmission_mode().

#define MENU_SCHEME
Value:
"\n\r-- Modulation Scheme --------------\r\n" \
"0: PROTOCOL_DBPSK\n\r" \
"1: PROTOCOL_DQPSK\n\r" \
"2: PROTOCOL_D8PSK\n\r" \
"3: PROTOCOL_DBPSK_VTB\n\r" \
"4: PROTOCOL_DQPSK_VTB\n\r" \
"5: PROTOCOL_D8PSK_VTB\n\r" \
"6: PROTOCOL_DBPSK_ROBO\n\r" \
"7: PROTOCOL_DQPSK_ROBO\n\r"

Referenced by get_transmission_scheme().

#define STRING_EOL   "\r"
#define STRING_HEADER
Value:
"-- ATMEL PLC Getting Started Application --\r\n" \
"-- "BOARD_NAME " --\r\n" \
"-- Compiled: "__DATE__ " "__TIME__ " --\r\n" \
"-- PHY version: "ATPL230_VERSION_STR " --\r\n"
#define BOARD_NAME
Definition: inc/app_init.h:140
#define ATPL230_VERSION_STR
Definition: atpl230_version.h:47

Referenced by main().

#define WATCHDOG_1s   1000000
#define WATCHDOG_5s   5000000

Referenced by main().

static void auto_impedance_mode ( void  )
static
static void configure_dbg_console ( void  )
static
static void execute_tx_test ( void  )
static

Execute TX test.

References vPhyEmbeddedAppTask(), and vTaskStartScheduler().

Referenced by main().

static void fill_msg_fixed ( void  )
static
static void fill_msg_manual ( void  )
static
static void fix_impedance_mode ( uint8_t  uc_impedance)
static
static void get_data_len ( void  )
static

Get Length of data to transmit.

References xPhyMsgTx_t::data_len, uart_read(), wdt_restart(), and txPhyEmbeddedConfig_t::xPhyMsg.

Referenced by get_transmission_data().

static void get_impedance_mode ( void  )
static
static void get_transmission_att_level ( void  )
static

Get ID of attenuation level.

References xPhyMsgTx_t::att_level, MENU_CONSOLE, uart_read(), wdt_restart(), and txPhyEmbeddedConfig_t::xPhyMsg.

Referenced by main().

static void get_transmission_buffer_id ( void  )
static

Get ID of transmission buffer.

References MENU_CONSOLE, uart_read(), xPhyMsgTx_t::uc_buff_id, wdt_restart(), and txPhyEmbeddedConfig_t::xPhyMsg.

Referenced by main().

static void get_transmission_channel ( void  )
static

Get ID of channel in transmission.

References MENU_CONSOLE, uart_read(), txPhyEmbeddedConfig_t::uc_channel, and wdt_restart().

Referenced by main().

static void get_transmission_data ( void  )
static

Get Transmission Data.

References fill_msg_fixed(), fill_msg_manual(), get_data_len(), MENU_DATA_MODE, uart_read(), and wdt_restart().

Referenced by main().

static void get_transmission_disable_rx ( void  )
static

Get disable RX configuration.

References xPhyMsgTx_t::disable_rx, MENU_CONSOLE, uart_read(), wdt_restart(), and txPhyEmbeddedConfig_t::xPhyMsg.

Referenced by main().

static void get_transmission_mode ( void  )
static
static void get_transmission_period ( void  )
static

Get Period of transmission.

References MENU_CONSOLE, uart_read(), txPhyEmbeddedConfig_t::ul_tx_period, and wdt_restart().

Referenced by main().

static void get_transmission_scheme ( void  )
static

Get scheme of modulation.

References MENU_CONSOLE, MENU_SCHEME, xPhyMsgTx_t::scheme, uart_read(), wdt_restart(), and txPhyEmbeddedConfig_t::xPhyMsg.

Referenced by main().

static void prvProcessMonitorTasks ( xTimerHandle  pxTimer)
static

Display scheduler activity led.

References UNUSED.

Referenced by main().

static void prvSetupHardware ( void  )
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()).

uint8_t ucv_tx_data_buffer[512]
txPhyEmbeddedConfig_t xAppPhyCfgTx
static