示例#1
0
//-----------------------------------------------------------------
// Main
//-----------------------------------------------------------------
int main(void)
{
    uint8_t uiResult;
    
    pllInit();

    // Turn off analogue inputs
    ANSELB = PORTB_ANSEL;
    ANSELC = 0x0000;
    ANSELD = PORTD_ANSEL;
    ANSELE = 0x0000;
    ANSELG = 0x0000;

    memset(lastestDmxBuffer, 0, NUM_DIMMER_CHANNELS);
    memset(lastOutputBuffer, 0, NUM_DIMMER_CHANNELS);

    // Startup
    ioMuxInit();
    eepromInit();
    eepromLoad();
    lcdInit();
    buttonsInit();
    uiInit();
    ledsInit();
    phaseAngleInit();
    dmxInit(eepromGetDmxAddress());

    // Timer 1 setup - overflow at 100Hz
    TMR1  = 0;
    PR1   = 25000;
    T1CON = 0x8010;     // 1:8 prescale (2.5MHz)
    _T1IF = 0;

    while(1)
    {
        if(_T1IF)
        {   // 100 Hz Timer stuff
            _T1IF = 0;
            buttonsCheck();
            ledsCheck();
            uiResult = uiCheck();
        }
        else
        {
            uiResult = 0;
        }

        if(uiResult || dmxCheck())
        {
            updateDimmers();
        }

        lcdCheck();
    }
}
ErrorCond     getJbus485StatesFromEeprom (void)
{
    return eepromLoad (EEPROM_JBUS_SERIAL, &jbus485States, sizeof(jbus485States));
}