Пример #1
0
void
Init_Peripherals(void)
{
    InitCpuTimers();
    Timer_Init();
    SCI_Init();
    EPwmTimerInit();
    I2CA_Init();
    SPI_Init();
    ECAN_Init();
    EQEP_Init();
    ADC_Init();
    USB_Init();
}
Пример #2
0
int main(void) {
    uint16_t i = 0;

    OscInit();
    AnalogInit();
    OutputInit();
    PPSInit();

    Timing_Init();
    UART_DMA_Init();

    UI_LED_Initialize();
    for (i=0; i<UI_LED_Count; i++) {
        UI_LED_SetState(UI_LED_List[i], LED_On);
    }
    UI_LED_Update();

    DBG_printf("\r\n");
    DBG_printf("\2330;36mCalsol Datalogger v%u.%u (alpha)\23337m", VERSION_MAJ, VERSION_MIN);
    DBG_printf("\23336m  Built %s %s with C30 ver %i\23337m", __DATE__, __TIME__, __C30_VERSION__);

    DBG_DATA_printf("\23336mDevice reset:%s%s%s%s%s%s%s%s\23337m",
                    (RCONbits.TRAPR? " Trap" : ""),
                    (RCONbits.IOPUWR? " IllegalOpcode/UninitializedW" : ""),
                    (RCONbits.CM? " ConfigMismatch" : ""),
                    (RCONbits.EXTR? " ExternalReset" : ""),
                    (RCONbits.SWR? " SoftwareReset" : ""),
                    (RCONbits.WDTO? " WatchdogTimeout" : ""),
                    (RCONbits.BOR? " BrownOutReset" : ""),
                    (RCONbits.POR? " PowerOnReset" : "")
                   );

    ECAN_Init();
    ECAN_Config();
    C1FCTRLbits.FSA = 4;	// FIFO starts
    C1FEN1 = 0;
    ECAN_SetStandardFilter(0, 0x00, 0, 15);
    ECAN_SetStandardMask(0, 0x00);
    ECAN_SetMode(ECAN_MODE_OPERATE);
    ECAN_SetupDMA();

    UI_Switch_Update();
    if (UI_Switch_GetTest()) {
        DBG_printf("Entering test mode");
        UI_LED_SetState(&UI_LED_Fault, LED_Blink);
        while (UI_Switch_GetTest()) {
            UI_LED_Update();
            UI_Switch_Update();
        }
        UI_LED_SetState(&UI_LED_Fault, LED_Off);
        UI_LED_Update();
    }

    for (i=0; i<UI_LED_Count; i++) {
        UI_LED_SetState(UI_LED_List[i], LED_Off);
    }

    DBG_printf("Initialization complete");


    Datalogger_Init();

    while(1) {
        Datalogger_Loop();
    }
}