/*******************************************************************************
 * (c) Copyright 2011 Microsemi Corporation.  All rights reserved.
 *
 * File:main.c
 * File history:
 *      Revision: 1.0 Date: August 2nd, 2011
 *
 * Description:
 * This application code corresponds to the application note:
 *"SmartFusion: Enhancing Analog Front-End Performance using Oversampling and
 * Fourth-Order Sigma-Delta Modulator - Simple Wire implementation"
 * This application configures the SmartFusion ACE peripheral and enables the MSS_UART
 * interface for user interface.
 *
 * Author: Corporate Applications Engineering
 *
 */

/**************************************************************************/
/* Standard Includes */
/**************************************************************************/
#include <stdio.h>
#include <string.h>

/**************************************************************************/
/* Firmware Includes */
/**************************************************************************/
#include "mss_uart.h"
#include "mss_ace.h"


/**************************************************************************/
/* Main Function */
/**************************************************************************/

int main(void)
{
	const uint8_t welcome[] = "\n\r ***SmartFusion: Enhancing Analog Front-End performance using Oversampling***"
							  "\n\r ****and Fourth-Order Sigma-Delta Modulator - Simple Wire Implementation.****";
	const uint8_t connection[] = "\n\r Apply analog input to the ADC0 at pin-4 of JP4 header and probe DAC0"
								 "\n\r output at pin-3 of JP4 on A2F500-DEV-KIT\n\r";


	/* UART Initialization and Configuration */
	MSS_UART_init
	(
			&g_mss_uart0,
			MSS_UART_57600_BAUD,
			MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY | MSS_UART_ONE_STOP_BIT
	);

	MSS_UART_polled_tx( &g_mss_uart0, welcome, sizeof(welcome));
	MSS_UART_polled_tx( &g_mss_uart0, connection, sizeof(connection));



	/* ACE Initialization */
	ACE_init();

	/* Defining DAC0 Configuration */
	ACE_configure_sdd
	(
			SDD0_OUT,
			SDD_16_BITS,
			SDD_VOLTAGE_MODE | SDD_NON_RTZ,
			INDIVIDUAL_UPDATE
	);

	/* Enable SDD_0 */
	ACE_enable_sdd(SDD0_OUT);

	while (1)
	{

	}

	return 0;
}




