no-OS
Loading...
Searching...
No Matches
cmd.c File Reference

Implementation of terminal command control for ADIN1320. More...

#include <errno.h>
#include <stdbool.h>
#include <stdint.h>
#include <string.h>
#include "adin1320.h"
#include "common_data.h"
#include "mdio_spi.h"
#include "no_os_alloc.h"
#include "no_os_delay.h"
#include "no_os_gpio.h"
#include "no_os_mdio.h"
#include "no_os_print_log.h"
#include "no_os_util.h"
Include dependency graph for cmd.c:

Classes

struct  cmd_config
 
struct  cmd_input
 
struct  cmd_gpio
 

Macros

#define FW_VERSION_MAJOR   1
 
#define FW_VERSION_MINOR   0
 
#define FW_VERSION_PATCH   0
 
#define EVAL_BOARD_NAME   "EVAL-ADIN1320FMCZ"
 
#define CMD_PARAM_EMPTY   -1
 
#define CMD_BUFFER_SIZE   100
 
#define CMD_PARAM_SIZE   10
 

Enumerations

enum  cmd_type {
  CMD_TYPE_NONE = 0 ,
  CMD_TYPE_MDIO_READ ,
  CMD_TYPE_MDIO_WRITE ,
  CMD_TYPE_HELP ,
  CMD_TYPE_RESET ,
  CMD_TYPE_MAX
}
 

Functions

void cmd_print_list (struct cmd_input *cmd_input)
 
void cmd_mdio_read (struct adin1320_desc *dev, struct cmd_input *cmd_input)
 
void cmd_mdio_write (struct adin1320_desc *dev, struct cmd_input *cmd_input)
 
void cmd_reset (struct adin1320_desc *dev_0, struct adin1320_desc *dev_8, struct cmd_input *cmd_input, bool dev_init[2])
 
int device_init (struct adin1320_desc **dev_0, struct adin1320_desc **dev_8, bool dev_init[2])
 
int fw_mode_sgmii_path_test (struct cmd_gpio *cmd_gpio, struct adin1320_desc *dev_0, struct adin1320_desc *dev_8)
 
int fw_mode_mdi_path_test (struct cmd_gpio *cmd_gpio, struct adin1320_desc *dev_0, struct adin1320_desc *dev_8)
 
void get_cmd (struct no_os_uart_desc *uart_desc, struct cmd_input *cmd_input)
 
void select_cmd (struct cmd_input *cmd_input)
 
void process_cmd (struct adin1320_desc *dev_0, struct adin1320_desc *dev_8, struct cmd_input *cmd_input, bool dev_init[2])
 
int board_init (struct no_os_uart_desc **uart_desc, struct cmd_config *cmd_cfg, struct cmd_gpio **cmd_gpio)
 
int fw_mode_init (struct cmd_config cmd_cfg, struct cmd_gpio *cmd_gpio, struct adin1320_desc **dev_0, struct adin1320_desc **dev_8, bool *dev_init)
 
int example_main (void)
 Basic example main executiont.
 

Detailed Description

Implementation of terminal command control for ADIN1320.

Author
Johnson Ralph Perez (Johns.nosp@m.onra.nosp@m.lph.P.nosp@m.erez.nosp@m.@anal.nosp@m.og.c.nosp@m.om)

Copyright 2026(c) Analog Devices, Inc.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  3. Neither the name of Analog Devices, Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES, INC. “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANALOG DEVICES, INC. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Macro Definition Documentation

◆ CMD_BUFFER_SIZE

#define CMD_BUFFER_SIZE   100

◆ CMD_PARAM_EMPTY

#define CMD_PARAM_EMPTY   -1

◆ CMD_PARAM_SIZE

#define CMD_PARAM_SIZE   10

◆ EVAL_BOARD_NAME

#define EVAL_BOARD_NAME   "EVAL-ADIN1320FMCZ"

◆ FW_VERSION_MAJOR

#define FW_VERSION_MAJOR   1

◆ FW_VERSION_MINOR

#define FW_VERSION_MINOR   0

◆ FW_VERSION_PATCH

#define FW_VERSION_PATCH   0

Enumeration Type Documentation

◆ cmd_type

enum cmd_type
Enumerator
CMD_TYPE_NONE 
CMD_TYPE_MDIO_READ 
CMD_TYPE_MDIO_WRITE 
CMD_TYPE_HELP 
CMD_TYPE_RESET 
CMD_TYPE_MAX 

Function Documentation

◆ board_init()

int board_init ( struct no_os_uart_desc ** uart_desc,
struct cmd_config * cmd_cfg,
struct cmd_gpio ** cmd_gpio )
Here is the caller graph for this function:

◆ cmd_mdio_read()

void cmd_mdio_read ( struct adin1320_desc * dev,
struct cmd_input * cmd_input )
Here is the caller graph for this function:

◆ cmd_mdio_write()

void cmd_mdio_write ( struct adin1320_desc * dev,
struct cmd_input * cmd_input )
Here is the caller graph for this function:

◆ cmd_print_list()

void cmd_print_list ( struct cmd_input * cmd_input)
Here is the caller graph for this function:

◆ cmd_reset()

void cmd_reset ( struct adin1320_desc * dev_0,
struct adin1320_desc * dev_8,
struct cmd_input * cmd_input,
bool dev_init[2] )
Here is the caller graph for this function:

◆ device_init()

int device_init ( struct adin1320_desc ** dev_0,
struct adin1320_desc ** dev_8,
bool dev_init[2] )
Here is the caller graph for this function:

◆ example_main()

int example_main ( void )

Basic example main executiont.

Basic example main execution.

Returns
ret - Result of the example execution. If working correctly, will execute continuously the while(1) loop and will not return.

Basic example main executiont.

  • 50 ADC readings with delay.
  • Threshold event (non-blocking).
    Returns
    ret - Result of the example execution. If working correctly, will execute continuously the while(1) loop and will not return.
    Basic example main executiont.
Returns
ret - Result of the example execution. If working correctly, will execute print the sample data.

Basic example main executiont.

Returns
ret - Result of the example execution. If working correctly, will execute continuously the while(1) loop and will not return.

Basic example main executiont.

Returns
ret - 0 on success.

Basic example main executiont.

Returns
ret - Result of the example execution. If working correctly, will execute continuously function iio_app_run and will not return.

Basic example main executiont.

Returns
ret - Result of the example execution. If working correctly, will measure active and reactive energy and RMS for channel A and for voltage stopping whenever an interrupt occurs and resulting in a stoppage of the measurement.

Basic example main executiont.

Returns
ret - Result of the example execution.

IIO descriptor and initialization parameter.

IIO app.

Declaring iio_devices structure

Initializing IIO app init param.

Initializing IIO app.

Running the IIO app (use iio_info or osc in terminal).

Set the threshold voltage to 5V

The comparator output will be available on the GPO_A pin

Set the DAC output on channel C to 5V

Measure input current on channel D

Initialize the ADC_RDY GPIO and associated IRQ event

Returns
0 if success, negative error code otherwise

GPIO Pin Interrupt Controller

◆ fw_mode_init()

int fw_mode_init ( struct cmd_config cmd_cfg,
struct cmd_gpio * cmd_gpio,
struct adin1320_desc ** dev_0,
struct adin1320_desc ** dev_8,
bool * dev_init )
Here is the caller graph for this function:

◆ fw_mode_mdi_path_test()

int fw_mode_mdi_path_test ( struct cmd_gpio * cmd_gpio,
struct adin1320_desc * dev_0,
struct adin1320_desc * dev_8 )
Here is the caller graph for this function:

◆ fw_mode_sgmii_path_test()

int fw_mode_sgmii_path_test ( struct cmd_gpio * cmd_gpio,
struct adin1320_desc * dev_0,
struct adin1320_desc * dev_8 )
Here is the caller graph for this function:

◆ get_cmd()

void get_cmd ( struct no_os_uart_desc * uart_desc,
struct cmd_input * cmd_input )
Here is the caller graph for this function:

◆ process_cmd()

void process_cmd ( struct adin1320_desc * dev_0,
struct adin1320_desc * dev_8,
struct cmd_input * cmd_input,
bool dev_init[2] )
Here is the caller graph for this function:

◆ select_cmd()

void select_cmd ( struct cmd_input * cmd_input)
Here is the caller graph for this function: