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.

SPDX-License-Identifier: BSD-3-Clause

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 )

◆ cmd_mdio_read()

void cmd_mdio_read ( struct adin1320_desc * dev,
struct cmd_input * cmd_input )

◆ cmd_mdio_write()

void cmd_mdio_write ( struct adin1320_desc * dev,
struct cmd_input * cmd_input )

◆ cmd_print_list()

void cmd_print_list ( struct cmd_input * cmd_input)

◆ cmd_reset()

void cmd_reset ( struct adin1320_desc * dev_0,
struct adin1320_desc * dev_8,
struct cmd_input * cmd_input,
bool dev_init[2] )

◆ device_init()

int device_init ( struct adin1320_desc ** dev_0,
struct adin1320_desc ** dev_8,
bool dev_init[2] )

◆ 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 execute continuously the 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

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 )

◆ 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 )

◆ 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 )

◆ get_cmd()

void get_cmd ( struct no_os_uart_desc * uart_desc,
struct cmd_input * cmd_input )

◆ process_cmd()

void process_cmd ( struct adin1320_desc * dev_0,
struct adin1320_desc * dev_8,
struct cmd_input * cmd_input,
bool dev_init[2] )

◆ select_cmd()

void select_cmd ( struct cmd_input * cmd_input)