Exemplo n.º 1
0
int main(void) {
    // Set the system clock to the full 120MHz
    uint32_t sysClkFreq = SysCtlClockFreqSet(SYSCTL_XTAL_25MHZ | SYSCTL_OSC_MAIN | SYSCTL_USE_PLL | SYSCTL_CFG_VCO_480, 120000000);


    debug_init(sysClkFreq);
    status_led_init();
    network_driver_init(sysClkFreq);
    networking_init();
    telemetry_init();
    transducer_init();
    thermocouple_init();
    solenoid_init();

    debug_print("Initialization complete. starting main loop.\r\n");

    // Set up the SysTick timer and its interrupts
    SysTickPeriodSet(6000); // 40 kHz
    SysTickIntRegister(sys_tick);
    SysTickIntEnable();
    SysTickEnable();

    uint32_t loopIterations = 0;
    uint32_t frame_start = systick_clock;



    while(1) {
        status_led_periodic();
        network_driver_periodic();
        telemetry_periodic();
        solenoid_periodic();

        //	debug_print_u32(systick_clock);

        //count loop iterations per second
        loopIterations++;
        if(systick_clock - frame_start >= 1000) {
            loops_per_second = loopIterations;
            loopIterations = 0;
            frame_start = systick_clock;
        }

    }
}
Exemplo n.º 2
0
/**
 * This API checks the new GNI against the system view to decide what really
 * needs to be done.
 * For MIDONET VPC mode, all is done in this driver API.
 * @param pConfig [in] a pointer to eucanetd system-wide configuration
 * @param pGni [in] a pointer to the Global Network Information structure
 * @param pGniApplied [in] a pointer to the previously successfully implemented GNI
 * @return A bitmask indicating what needs to be done. The following bits are
 *         the ones to look for: EUCANETD_RUN_NETWORK_API, EUCANETD_RUN_SECURITY_GROUP_API
 *         and EUCANETD_RUN_ADDRESSING_API.
 */
static u32 network_driver_system_scrub(eucanetdConfig *pConfig, globalNetworkInfo *pGni, globalNetworkInfo *pGniApplied) {
    int rc = 0;
    u32 ret = EUCANETD_RUN_NO_API;
    struct timeval tv;

    eucanetd_timer(&tv);
    // Make sure midoname buffer is available
    midonet_api_cache_midos_init();

    // Need a valid global network view
    if (!pConfig || !pGni) {
        LOGERROR("Failed to scrub the system for '%s' network driver. Invalid parameters provided.\n", DRIVER_NAME());
        return (ret);
    }

    int config_changed = cmp_gni_config(pGni, pGniApplied);
    if (!IS_INITIALIZED() || (pGni && config_changed)) {
        LOGINFO("(re)initializing %s driver.\n", DRIVER_NAME());
        if (pMidoConfig) {
            free_mido_config(pMidoConfig);
            gInitialized = FALSE;
        } else {
            LOGERROR("failed to (re)initialize config options: VPCMIDO driver not initialized\n");
            return (EUCANETD_RUN_ERROR_API);
        }
        rc = network_driver_init(pConfig, pGni);
        if (rc) {
            LOGERROR("failed to (re)initialize config options\n");
            return (EUCANETD_RUN_ERROR_API);
        }
        pGniApplied = NULL;
    }

    if (config_changed & GNI_CONFIG_DIFF_MIDONODES) {
        pMidoConfig->midotz_ok = FALSE;
    }

    LOGTRACE("euca VPCMIDO system state: %s\n", midonet_api_system_changed == 0 ? "CLEAN" : "DIRTY");
    rc = do_midonet_update(pGni, pGniApplied, pMidoConfig);

    if (rc != 0) {
        LOGERROR("failed to update midonet: check log for details\n");
        switch (rc) {
            case -2:
                // Accept errors in instances/interface implementation.
                ret = EUCANETD_VPCMIDO_IFERROR;
                break;
            case -1:
                // Accept errors in gateway(s) implementation.
                ret = EUCANETD_VPCMIDO_GWERROR;
                break;
            default:
                ret = EUCANETD_RUN_ERROR_API;                
        }
    } else {
        LOGTRACE("Networking state sync: updated successfully in %.2f ms\n", eucanetd_timer_usec(&tv) / 1000.0);
        pMidoConfig->config->mido_arptable_config_changed = FALSE;
    }

    return (ret);
}