/*
 * configuration.h
 *
 *  Created on: Aug 1, 2012
 *      Author: naraharid
 */



#ifndef CONFIGURATION_H_
#define CONFIGURATION_H_
/* Configuration registers */


#include <stdio.h>
#include "drivers/mss_uart/mss_uart.h"
//#include "mss_timer.h"


 /************* Base address of System Registers in Memory map ********/

#define BASE_ADDRESS 0x40038000

/************** Addresses of AHB Bus Matrxi config registers *********/

#define	ESRAM_MAX_LAT  (BASE_ADDRESS+0x04)
#define	MASTER_WEIGHT0_CR   (BASE_ADDRESS+0x3C)
#define MASTER_WEIGHT1_CR   (BASE_ADDRESS+0x40)
#define MSS_EXTERNAL_SR     (BASE_ADDRESS+0x198)


/**************************************************
 * Initialises the AHB Bus Matrix config registers
 * with the default values.
 *************************************************/
void AHBBus_init();

/******************************************************************
 * master_select() function is used to calculate the  weight values
 * to be assigned based on the master and weight values selcted.
 *
 * @ param master
 * master parameter is a buffer that holds the master numbers selected
 * through UART.
 *
 * @param weight
 * weight parameter is a buffer that holds the weight values selected
 * through UART for the corresponding masters selected.
 *
 * @param mast_no
 * mast_no parameter holds the count of total number of masters selected
 ********************************************************************/
void master_select
(
    uint32_t *master,
    uint32_t *weight,
    int mast_no
);

/******************************************************************
 * set_weight() function is used to assign the  weight values
 * to the corresponding configuration registers.
 *
 * @ param weight
 * weight parameter is the weight value calculated by master_select()
 * This is assigned to the configuraton register
 *
 * @param config_reg
 * config_reg parameter that selects the configuration register
 * to be used.
 ********************************************************************/

void set_weight
(
    uint32_t weight,
    int config_reg
);

/******************************************************************
 * set_latency() function is used to assign the latency values (given
 * for processor related masters) to the corresponding configuration
 * registers.
 *
 * @ param latency
 * weight parameter is the latency value selected through UART
 *
 * @param slave
 * Selects the slave if eSRAM0 or eSRAM1
 ********************************************************************/
void set_latency
(
    uint32_t latency,
    int slave
);



#endif /* CONFIGURATION_H_ */
