void LatticeSim::init(){
  lattice->setAA(fn_aa);
  setInitialConfig();
  setTemperature(0.2);
  lattice->stats.getLatticeStats(lattice);
  lattice->setNative();
  lattice->stats.getLatticeStats(lattice);
}
Example #2
0
/*
 * State Machine Processing
 */
void ImplBMS(void)
{
    //------------------------------------
    // Gestion du fonctionnement de la machine a État
    switch (m_state) {
        case InitPeripheral:
        {
            statusCmp = 0;
            bufferMoy = 0;
            initializePeripheral();
            setState(InitBQ);
            break;
        }
        case InitBQ:
        {
            initBranchData(&branch0, 0); // Met les valeurs à zéro
            assignAddress(&branch0); // Assigne les address au device
            status(&branch0); // Mise à jour des registres de status des devices
            setInitialConfig(&branch0); // Assigne la configuration initiale
            resetBranchFault(&branch0); // Reset des fautes
            resetBranchAlert(&branch0); // Reset des alertes
            status(&branch0); // Mise à jour des status

            /*LP_PARAMS newLongPolling;
            HDW_MAPPING *gVUE32_Ress;

            gVUE32_Ress = gHardwareMapBMS[INDEX_BMS];

            newLongPolling.ucSizeData = gVUE32_Ress[i].ucDataSize
            newLongPolling.hasLifeTime = LONG_POLLING_WITHOUT_LIFE_TIME;
            newLongPolling.ucDestinataire = 0;
            newLongPolling.ucResourceId = E_ID_BMS_BOARD_TEMP;
            newLongPolling.unDelay = 100;
            newLongPolling.ucMsgType = VUE32_TYPE_SETVALUE;*/
            
            setState(Monitor);
            
            //Enables the core to handle any pending interrupt requests
            asm volatile ("ei");

            // Everything is ok so light the yellow LEDS for 1 sec
            unsigned char io_ctrl;
            readRegister(branch0.id,branch0.deviceTable[0].address,IO_CONTROL,1,&io_ctrl);
            io_ctrl = (io_ctrl | 0x40);
            writeRegister(branch0.id,BROADCAST_ADDRESS,IO_CONTROL,io_ctrl);

            unsigned int unSmallDelay = uiTimeStamp + 1000;
            while ( unSmallDelay > uiTimeStamp);
            io_ctrl = (io_ctrl & 0xBF);
            writeRegister(branch0.id,BROADCAST_ADDRESS,IO_CONTROL,io_ctrl);

            break;
        }
        case Monitor:
        {
            EVERY_X_MS(2000)
                    LED1 ^= 1;
                    monitor();
            END_OF_EVERY
            break;
        }
        case Balance:
        {
            EVERY_X_MS(500)
                LED1 ^= 1;
                balance();
            END_OF_EVERY
            break;
        }
        case InitSleep:
        {
            sleepBranch(&branch0); //Met les BQ dans le mode sleep
            setState(Sleep);
            break;
        }
        case Sleep:
        {
            break;
        }
        case WakeUp:
        {
            wakeUpBranch(&branch0); //Réinitialise les BQ après le mode sleep
            setState(InitBQ);
            break;
        }
        case Sieste:
        {
            break;
        }
        case WaitStabiliseTension:
        {
            if (waitStabiliseTension() == 1)
                setState(Balance);
            break;
        }
        case ProblemDetected:
        {
            if (problemDetected() == 1)
                setState(Monitor);
            break;
        }
        case WaitStabiliseTemp:
        {
            if (waitStabiliseTemp() == 1)
                setState(Balance);
            break;
        }
        case Test:
        {
            openCloseAllIO();
            break;
        }
        default:
            break;
    }

    if ( m_state == ProblemDetected)
    {
    EVERY_X_MS(2000)
        unsigned char io_ctrl;
        readRegister(branch0.id,branch0.deviceTable[0].address,IO_CONTROL,1,&io_ctrl);
        if ( io_ctrl & 0x40 )
            io_ctrl = (io_ctrl & 0xBF);
        else
            io_ctrl = (io_ctrl | 0x40);
        writeRegister(branch0.id,BROADCAST_ADDRESS,IO_CONTROL,io_ctrl);
    END_OF_EVERY
    }