Dependencies:   ADBMS2950

program/src/application.cpp

Committer:
dpandit1988
Date:
2020-07-24
Revision:
1:94a3e8fe5e25
Child:
4:0e99350684aa

File content as of revision 1:94a3e8fe5e25:

/**
********************************************************************************
*
* @file:    application.c
*
* @brief:   This file contains the application test cases.
*
* @details:
*
*******************************************************************************
Copyright(c) 2020 Analog Devices, Inc. All Rights Reserved. This software is
proprietary & confidential to Analog Devices, Inc. and its licensors. By using
this software you agree to the terms of the associated Analog Devices License
Agreement.
*******************************************************************************
*/
/*! \addtogroup Main
*  @{
*/

/*! \addtogroup Application
*  @{
*/
/*============= I N C L U D E S =============*/
/*============== D E F I N E S ===============*/
/*============= E X T E R N A L S ============*/
/*============= E N U M E R A T O R S ============*/

#include "application.h"
#ifdef MBED
extern Serial pc;
#endif /* MBED */
/**
*******************************************************************************
* @brief Setup Variables
* The following variables can be modified to configure the software.
*******************************************************************************
*/

#define TOTAL_IC 1
cell_asic IC[TOTAL_IC];

void app_main()
{
  printMenu();
  while(1)
  {
    int user_command;
#ifdef MBED
    pc.scanf("%d", &user_command);
    pc.printf("Enter cmd:%d\n", user_command);
#else /* IAR */
    scanf("%d", &user_command);
    printf("Enter cmd:%d\n", user_command);
#endif /* MBED */
    adi2950_init_config(TOTAL_IC, &IC[0]);
    run_command(user_command); /*!< Run test case */
  }
}

void run_command(int cmd)
{
  switch(cmd)
  {
  case 1:
    adi2950_write_read_config(TOTAL_IC, &IC[0]);
    break;

  case 2:
    adi2950_read_config(TOTAL_IC, &IC[0]);
    break;

  case 3:
    adi2950_start_adi1_measurment(TOTAL_IC);
    break;

  case 4:
    adi2950_start_adi2_measurment(TOTAL_IC);
    break;

  case 5:
    adi2950_read_current_register(TOTAL_IC, &IC[0]);
    break;

  case 6:
    adi2950_read_vbat_register(TOTAL_IC, &IC[0]);
    break;

  case 7:
    adi2950_read_ivbat_register(TOTAL_IC, &IC[0]);
    break;

  case 8:
    adi2950_read_ocr_register(TOTAL_IC, &IC[0]);
    break;

  case 9:
    adi2950_read_avgcr_register(TOTAL_IC, &IC[0]);
    break;

  case 10:
    adi2950_read_avgvbat_register(TOTAL_IC, &IC[0]);
    break;

  case 11:
    adi2950_read_avgivbat_register(TOTAL_IC, &IC[0]);
    break;

  case 12:
    adi2950_start_adv_measurment(TOTAL_IC);
    break;

  case 13:
    adi2950_read_vr_registers(TOTAL_IC, &IC[0]);
    break;

  case 14:
    adi2950_read_vrx_registers(TOTAL_IC, &IC[0]);
    break;

  case 15:
    adi2950_read_rvr_registers(TOTAL_IC, &IC[0]);
    break;

  case 16:
    adi2950_start_adaux_measurment(TOTAL_IC);
    break;

  case 17:
    adi2950_read_adaux_measurment(TOTAL_IC, &IC[0]);
    break;

  case 18:
    adi2950_read_all_status_registers(TOTAL_IC, &IC[0]);
    break;

  case 19:
    adi2950_read_device_sid(TOTAL_IC, &IC[0]);
    break;

  case 20:
    adi2950_soft_reset(TOTAL_IC);
    break;

  case 21:
    adi2950_reset_cmd_count(TOTAL_IC);
    break;

  case 22:
    adi2950_snap(TOTAL_IC);
    break;

  case 23:
    adi2950_unsnap(TOTAL_IC);
    break;

  case 24:
    adi2950_gpio_spi_communication(TOTAL_IC, &IC[0]);
    break;

  case 25:
    adi2950_gpio_i2c_write_to_slave(TOTAL_IC, &IC[0]);
    break;

  case 26:
    adi2950_gpio_i2c_read_from_slave(TOTAL_IC, &IC[0]);
    break;

  case 27:
    adi2950_set_reset_gpo_pins(TOTAL_IC, &IC[0]);
    break;

  case 0:
    printMenu();
    break;

  default:
    printMsg("Incorrect Option");
    break;
  }
}
/** @}*/
/** @}*/