precision-converters-firmware
Macros | Functions
ad717x_console_app.c File Reference

: Implementation of the menu functions which handles the functionality of AD717x and AD411x family of devices. More...

#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <ctype.h>
#include "app_config.h"
#include "ad717x.h"
#include "mbed_platform_support.h"
#include "no_os_spi.h"
#include "mbed_spi.h"
#include "ad717x_console_app.h"
#include "ad717x_menu_defines.h"
#include "ad717x_support.h"
#include <ad411x_regs.h>
Include dependency graph for ad717x_console_app.c:

Macros

#define SHOW_ALL_CHANNELS   false
 
#define SHOW_ENABLED_CHANNELS   true
 
#define DISPLAY_DATA_TABULAR   0
 
#define DISPLAY_DATA_STREAM   1
 
#define OPEN_WIRE_DETECT_THRESHOLD   100000
 

Functions

int32_t ad717x_app_initialize (void)
 Initialize the AD717x device and associated low level peripherals. More...
 
void display_main_menu_header (void)
 Display the header info for main menu. More...
 
int32_t menu_read_id (uint32_t menu_id)
 Handle the menu to read device ID. More...
 
int32_t menu_read_status (uint32_t menu_id)
 Handle the menu to read device status register. More...
 
int32_t menu_continuous_conversion_tabular (uint32_t channel_id)
 Samples all enabled channels and displays in tabular form. More...
 
int32_t menu_continuous_conversion_stream (uint32_t channel_id)
 Samples all enabled channels and displays on the console. More...
 
int32_t menu_single_conversion (uint32_t channel_id)
 Samples all enabled channels once in Single Conversion mode. More...
 
int32_t menu_sample_channels (uint32_t menu_id)
 Handle the menu to sample the channels. More...
 
int32_t menu_channels_enable_disable (uint32_t action)
 
int32_t menu_chn_enable_disable_display (uint32_t menu_id)
 Display the menu to enable/disable channel selection. More...
 
int32_t menu_analog_input_connect (uint32_t user_analog_input)
 Handle the menu to connect input to channel. More...
 
int32_t menu_input_chn_connect_display (uint32_t menu_id)
 Display the menu selections to connect analog input pins to a channel. More...
 
int32_t menu_filter_select (uint32_t user_input_filter_type)
 Handle the menu to select the filter type. More...
 
int32_t menu_postfiler_enable_disable (uint32_t user_action)
 Handle the menu to enable/disable the post filter. More...
 
int32_t menu_postfiler_select (uint32_t user_input_post_filter_type)
 Handle the menu to select the post filter. More...
 
int32_t menu_odr_select (uint32_t user_input_odr_val)
 Handle the menu to select the ODR value. More...
 
int32_t menu_polarity_select (uint32_t user_input_polarity)
 Handle the menu to select the polarity. More...
 
int32_t menu_reference_source_select (uint32_t user_input_reference)
 Handle the menu to select the reference source. More...
 
int32_t menu_ref_buffer_enable_disable (uint32_t user_action)
 Handle the menu to enable/disable the reference buffers. More...
 
int32_t menu_input_buffer_enable_disable (uint32_t user_action)
 Handle the menu to enable/disable the input buffers. More...
 
int32_t menu_config_and_assign_setup (uint32_t menu_id)
 Handle the menu to configure and assign the device setup. More...
 
int32_t menu_display_setup (uint32_t menu_id)
 Handle the menu to display device setup. More...
 
int32_t menu_read_temperature (uint32_t menu_id)
 Handle the menu to read die temperature of device. More...
 
int32_t menu_calibrate_adc (uint32_t menu_id)
 Handle the menu to calibrate the device. More...
 
int32_t menu_input_type_selection (uint32_t user_input_type)
 Handle the menu to select input type for open wire detection. More...
 
int32_t menu_select_chn_pair (uint32_t user_channel_pair)
 Handle the menu to select channel pair for open wire detection. More...
 
int32_t menu_select_input_pair (uint32_t user_analog_input)
 Handle the menu to select input pair for open wire detection. More...
 
int32_t menu_open_wire_detection (uint32_t menu_id)
 Handle the menu to perform open wire detection. More...
 
int32_t menu_rw_ad717x_register (uint32_t rw_id)
 
int32_t menu_read_write_device_regs (uint32_t menu_id)
 Handle the menu to read/write device registers. More...
 

Detailed Description

: Implementation of the menu functions which handles the functionality of AD717x and AD411x family of devices.

: This file is specific to AD717x/AD411x console menu application handle. The functions defined in this file performs the action

based on user selected console menu.

Copyright (c) 2020-2022 Analog Devices, Inc. All rights reserved.

This software is proprietary to Analog Devices, Inc. and its licensors. By using this software you agree to the terms of the associated Analog Devices Software License Agreement.

Macro Definition Documentation

◆ DISPLAY_DATA_STREAM

#define DISPLAY_DATA_STREAM   1

◆ DISPLAY_DATA_TABULAR

#define DISPLAY_DATA_TABULAR   0

◆ OPEN_WIRE_DETECT_THRESHOLD

#define OPEN_WIRE_DETECT_THRESHOLD   100000

◆ SHOW_ALL_CHANNELS

#define SHOW_ALL_CHANNELS   false

◆ SHOW_ENABLED_CHANNELS

#define SHOW_ENABLED_CHANNELS   true

Function Documentation

◆ ad717x_app_initialize()

int32_t ad717x_app_initialize ( void  )

Initialize the AD717x device and associated low level peripherals.

Returns
0 in case of success, negative error code otherwise
Here is the caller graph for this function:

◆ display_main_menu_header()

void display_main_menu_header ( void  )

Display the header info for main menu.

Returns
None

◆ menu_analog_input_connect()

int32_t menu_analog_input_connect ( uint32_t  user_analog_input)

Handle the menu to connect input to channel.

Parameters
analoginput to be connected
Returns
MENU_CONTINUE

◆ menu_calibrate_adc()

int32_t menu_calibrate_adc ( uint32_t  menu_id)

Handle the menu to calibrate the device.

Parameters
menu_id-(Optional parameter)
Returns
MENU_CONTINUE

◆ menu_channels_enable_disable()

int32_t menu_channels_enable_disable ( uint32_t  action)

◆ menu_chn_enable_disable_display()

int32_t menu_chn_enable_disable_display ( uint32_t  menu_id)

Display the menu to enable/disable channel selection.

Parameters
menu_id-(Optional parameter)
Returns
MENU_CONTINUE

◆ menu_config_and_assign_setup()

int32_t menu_config_and_assign_setup ( uint32_t  menu_id)

Handle the menu to configure and assign the device setup.

Parameters
menu_id-(Optional parameter)
Returns
MENU_CONTINUE

◆ menu_continuous_conversion_stream()

int32_t menu_continuous_conversion_stream ( uint32_t  channel_id)

Samples all enabled channels and displays on the console.

◆ menu_continuous_conversion_tabular()

int32_t menu_continuous_conversion_tabular ( uint32_t  channel_id)

Samples all enabled channels and displays in tabular form.

◆ menu_display_setup()

int32_t menu_display_setup ( uint32_t  menu_id)

Handle the menu to display device setup.

Parameters
menu_id-(Optional parameter)
Returns
MENU_CONTINUE

◆ menu_filter_select()

int32_t menu_filter_select ( uint32_t  user_input_filter_type)

Handle the menu to select the filter type.

Parameters
userselected filter type
Returns
MENU_DONE

◆ menu_input_buffer_enable_disable()

int32_t menu_input_buffer_enable_disable ( uint32_t  user_action)

Handle the menu to enable/disable the input buffers.

Parameters
userselected action
Returns
MENU_DONE

◆ menu_input_chn_connect_display()

int32_t menu_input_chn_connect_display ( uint32_t  menu_id)

Display the menu selections to connect analog input pins to a channel.

Parameters
menu_id-(Optional parameter)
Returns
MENU_CONTINUE

◆ menu_input_type_selection()

int32_t menu_input_type_selection ( uint32_t  user_input_type)

Handle the menu to select input type for open wire detection.

Parameters
Userselected analog input type
Returns
MENU_DONE

◆ menu_odr_select()

int32_t menu_odr_select ( uint32_t  user_input_odr_val)

Handle the menu to select the ODR value.

Parameters
userselected ODR
Returns
MENU_DONE

◆ menu_open_wire_detection()

int32_t menu_open_wire_detection ( uint32_t  menu_id)

Handle the menu to perform open wire detection.

Parameters
menu_id-(Optional parameter)
Returns
MENU_CONTINUE

◆ menu_polarity_select()

int32_t menu_polarity_select ( uint32_t  user_input_polarity)

Handle the menu to select the polarity.

Parameters
userselected polarity
Returns
MENU_DONE

◆ menu_postfiler_enable_disable()

int32_t menu_postfiler_enable_disable ( uint32_t  user_action)

Handle the menu to enable/disable the post filter.

Parameters
userselected action
Returns
MENU_DONE

◆ menu_postfiler_select()

int32_t menu_postfiler_select ( uint32_t  user_input_post_filter_type)

Handle the menu to select the post filter.

Parameters
userselected post filter type
Returns
MENU_DONE

◆ menu_read_id()

int32_t menu_read_id ( uint32_t  menu_id)

Handle the menu to read device ID.

Parameters
menu_id-(Optional parameter)
Returns
MENU_CONTINUE

◆ menu_read_status()

int32_t menu_read_status ( uint32_t  menu_id)

Handle the menu to read device status register.

Parameters
menu_id-(Optional parameter)
Returns
MENU_CONTINUE

◆ menu_read_temperature()

int32_t menu_read_temperature ( uint32_t  menu_id)

Handle the menu to read die temperature of device.

Parameters
menu_id-(Optional parameter)
Returns
MENU_CONTINUE

◆ menu_read_write_device_regs()

int32_t menu_read_write_device_regs ( uint32_t  menu_id)

Handle the menu to read/write device registers.

Parameters
menu_id-(Optional parameter)
Returns
MENU_CONTINUE

◆ menu_ref_buffer_enable_disable()

int32_t menu_ref_buffer_enable_disable ( uint32_t  user_action)

Handle the menu to enable/disable the reference buffers.

Parameters
userselected action
Returns
MENU_DONE

◆ menu_reference_source_select()

int32_t menu_reference_source_select ( uint32_t  user_input_reference)

Handle the menu to select the reference source.

Parameters
userselected reference source
Returns
MENU_DONE

◆ menu_rw_ad717x_register()

int32_t menu_rw_ad717x_register ( uint32_t  rw_id)

◆ menu_sample_channels()

int32_t menu_sample_channels ( uint32_t  menu_id)

Handle the menu to sample the channels.

Parameters
menu_id-(Optional parameter)
Returns
MENU_CONTINUE

◆ menu_select_chn_pair()

int32_t menu_select_chn_pair ( uint32_t  user_channel_pair)

Handle the menu to select channel pair for open wire detection.

Parameters
Userselected channel pair
Returns
MENU_DONE

◆ menu_select_input_pair()

int32_t menu_select_input_pair ( uint32_t  user_analog_input)

Handle the menu to select input pair for open wire detection.

Parameters
Userselected analog input
Returns
MENU_DONE

◆ menu_single_conversion()

int32_t menu_single_conversion ( uint32_t  channel_id)

Samples all enabled channels once in Single Conversion mode.

This stores all channels that are enabled in a bitmask, and then runs the ADC in single conversion mode, which acquires one channel of data at a time. After capture, that channel is disabled, and single conversion run again, until no channels are enabled. The original enable state of each channel is then restored.