Example program for EVAL-AD568x and EVAL-AD569x.

Dependencies:   adi_console_menu platform_drivers

EVAL-AD568x-AD569x

User Guide

This nanoDAC+ Mbed support software can be used as a starting point for developing your own firmware that targets Analog Devices nanoDAC+ products in your own environment. The software is configurable for your exact product within the nanoDAC+ family. See the user-guide for full instructions.

Revision:
9:cce35eca2ab0
Parent:
8:f38c1afe205b
--- a/app/nanodac_console_app.c	Mon Aug 03 10:39:17 2020 +0000
+++ b/app/nanodac_console_app.c	Wed Jul 21 12:09:31 2021 +0100
@@ -9,7 +9,7 @@
             The functions defined in this file performs the action
             based on user selected console menu.
  -----------------------------------------------------------------------------
- Copyright (c) 2020 Analog Devices, Inc.
+ Copyright (c) 2020-2021 Analog Devices, Inc.
  All rights reserved.
 
  This software is proprietary to Analog Devices, Inc. and its licensors.
@@ -29,7 +29,11 @@
 
 #include "ad5686.h"
 #include "platform_support.h"
-#include "platform_drivers.h"
+#include "delay.h"
+#include "error.h"
+#include "i2c.h"
+#include "spi.h"
+#include "gpio_extra.h"
 #include "i2c_extra.h"
 #include "spi_extra.h"
 
@@ -108,7 +112,7 @@
 /************************ Functions Declarations ******************************/
 /******************************************************************************/
 
-static void gpio_power_up_configuration(void);
+static int32_t gpio_power_up_configuration(void);
 
 /******************************************************************************/
 /************************ Functions Definitions *******************************/
@@ -139,33 +143,54 @@
 	struct ad5686_init_param nanodac_init_params = {
 		// i2c_init_param
 		{
-			100000,				// I2C max speed (Hz)
-			I2C_SLAVE_ADDRESS,	// I2C slave address
-			&i2c_init_extra_params	// I2C extra init parameters
+            .max_speed_hz = 100000,             // I2C max speed (Hz)
+            .slave_address = I2C_SLAVE_ADDRESS, // I2C slave address
+            .extra = &i2c_init_extra_params     // I2C extra init parameters
 		},
 
 		// spi_init_param
 		{
-			2000000, 			// SPI max speed (Hz)
-			SPI_SS, 			// Chip select
-			SPI_MODE_2,			// SPI Mode
-			&spi_init_extra_params	// SPI extra init parameters
+            .max_speed_hz = 2000000,        // SPI max speed (Hz)
+            .chip_select = SPI_SS,          // Chip select
+            .mode = SPI_MODE_2,             // SPI Mode
+            .extra = &spi_init_extra_params // SPI extra init parameters
 		},
 
 		// gpio_init_param
-		{ RESET_PIN, NULL }, 	// gpio_reset
-		{ LDAC_PIN, NULL },   	// gpio_ldac
-		{ GAIN_PIN, NULL },  	// gpio_gain
+        { 
+            .number = RESET_PIN,            // Reset GPIO Pin
+            .platform_ops = NULL, 
+            .extra =  NULL                  
+        },  
+        { 
+            .number = LDAC_PIN,             // LDAC GPIO Pin
+            .platform_ops = NULL, 
+            .extra =  NULL
+        },      
+        { 
+            .number = GAIN_PIN,             // Gain GPIO Pin
+            .platform_ops = NULL, 
+            .extra =  NULL
+        },
 
-		ACTIVE_DEVICE			// Active device
+        .act_device  = ACTIVE_DEVICE       // Active device
 	};
 
 	// Initialize the device
-	device_init_status = ad5686_init(&nanodac_dev, nanodac_init_params);
-
-	// Configure the GPIOs specific to application upon power-up
-	gpio_power_up_configuration();
-
+	do
+    {   
+        // Initialize the device
+        if((device_init_status = ad5686_init(&nanodac_dev, 
+            nanodac_init_params)) != SUCCESS)
+            break;
+        // Configure the GPIOs specific to application upon power-up
+        if((device_init_status = gpio_power_up_configuration()) != SUCCESS)
+            break;
+            
+        return device_init_status;
+    } while (0);
+    
+    ad5686_remove(&nanodac_dev);
 	return device_init_status;
 }
 
@@ -174,17 +199,16 @@
  * @brief      Set the power-up GPIO configurations
  * @return     None
  */
-static void gpio_power_up_configuration(void)
+static int32_t gpio_power_up_configuration(void)
 {
-	// Set the directions for GPIO pins
-	(void)gpio_direction_output(nanodac_dev->gpio_gain, GPIO_OUT);
-	(void)gpio_direction_output(nanodac_dev->gpio_ldac, GPIO_OUT);
-	(void)gpio_direction_output(nanodac_dev->gpio_reset, GPIO_OUT);
+	int32_t gpio_power_up_status = 0;   
 
 	// Set the GPIO values
-	gpio_set_value(nanodac_dev->gpio_reset, GPIO_HIGH);
-	gpio_set_value(nanodac_dev->gpio_gain, GPIO_LOW);
-	gpio_set_value(nanodac_dev->gpio_ldac, GPIO_HIGH);
+    gpio_power_up_status |= gpio_set_value(nanodac_dev->gpio_reset, GPIO_HIGH);
+    gpio_power_up_status |= gpio_set_value(nanodac_dev->gpio_gain, GPIO_LOW);
+    gpio_power_up_status |= gpio_set_value(nanodac_dev->gpio_ldac, GPIO_HIGH);
+    
+    return gpio_power_up_status;
 }