view src/cs/system/main/abb_init.c @ 18:80c8857ce1c7

ABB init hooked in
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 15 May 2020 05:23:20 +0000
parents
children
line wrap: on
line source

/*
 * This module is a small extract from TI's l1_init.c,
 * containing the function that initializes access to the ABB.
 */

#include <string.h>
#include "l1_types.h"
#include "sys_types.h"
#include "spi_drv.h"
#include "abb.h"

#include "mem.h"
#include "inth.h"
#include "dma.h"
#include "iq.h"

#include "clkm.h"
#include "rhea_arm.h"
#include "ulpd.h"

/*-------------------------------------------------------*/
/* l1_abb_power_on()                                     */
/*-------------------------------------------------------*/
/* Parameters :                                          */
/* Return     :                                          */
/* Functionality :                                       */
/* Initialize the global structure for spi communication */
/* with ABB.                                             */
/* Set up ABB connection (CLK 13M free)                  */
/* Aknowledge the ABB status register                    */
/* Configure ABB modules                                 */
/* Program the ramp parameters into the NDB              */
/* Load in the NDB registers' value to be programmed in  */
/* ABB at first communication it                         */
/*-------------------------------------------------------*/

void l1_abb_power_on(void)
{
    T_SPI_DEV *Abb;
    T_SPI_DEV init_spi_device;
    UWORD16 Abb_Status;

    Abb               = &init_spi_device;   /* Pointer initialization to device communication structure */
    Abb->PrescVal     = SPI_CLOCK_DIV_1;    /* ABB transmission parameters initialization */
    Abb->DataTrLength = SPI_WNB_15;
    Abb->DevAddLength = 5;
    Abb->DevId        = ABB;
    Abb->ClkEdge      = SPI_CLK_EDG_RISE;
    Abb->TspEnLevel   = SPI_NTSPEN_NEG_LEV;
    Abb->TspEnForm    = SPI_NTSPEN_LEV_TRIG;

    SPI_InitDev(Abb);                   /* Initialize the spi to work with ABB */

    ABB_free_13M();                     /* Set up Abb connection (CLK 13M free).*/
    Abb_Status = ABB_Read_Status();     /* Aknowledge the Abb status register.  */

    /*------------------------------------------------------------------*/
    /* Add here SW to manage Abb VRPCSTS status register informations   */
    /*------------------------------------------------------------------*/

    ABB_Read_Register_on_page(PAGE0,ITSTATREG);  /* Aknowledge the interrupt status register */
                                        /* to clear any pending interrupt */

    /* FC FFS editor: different arguments from full L1 */
    ABB_on(0, 0);
}