/*----------------------------------------------------------------------------- * program start */ int main(void) { int sioHandle; uint8_t windThreshold1; uint8_t windThreshold2; MCUSR = 0; wdt_disable(); /* get module address from EEPROM */ sMyAddr = eeprom_read_byte((const uint8_t *)MODUL_ADDRESS); windThreshold1 = eeprom_read_byte((const uint8_t *)WIND_THRESHOLD1); windThreshold2 = eeprom_read_byte((const uint8_t *)WIND_THRESHOLD2); GetClientListFromEeprom(); PortInit(); TimerInit(); SioInit(); sioHandle = SioOpen("USART0", eSioBaud9600, eSioDataBits8, eSioParityNo, eSioStopBits1, eSioModeHalfDuplex); SioSetIdleFunc(sioHandle, IdleSio); SioSetTransceiverPowerDownFunc(sioHandle, BusTransceiverPowerDown); BusTransceiverPowerDown(true); BusInit(sioHandle); spRxBusMsg = BusMsgBufGet(); /* enable global interrupts */ ENABLE_INT; SendStartupMsg(); /* wait for controller startup delay for sending first state telegram */ DELAY_S(STARTUP_DELAY); while (1) { Idle(); ProcessSwitch(); ProcessBus(); if (sWind >= windThreshold1) { sWindSwitch |= 0x01; } else { sWindSwitch &= ~0x01; } if (sWind >= windThreshold2) { sWindSwitch |= 0x02; } else { sWindSwitch &= ~0x02; } } return 0; /* never reached */ }
/** * @brief Initializes and controls all other functions (indirectly). * * @param argc Argument counter. * @param argv Array of different function arguments. * @return int Error code. */ int main(int argc, char** argv) { ConfigureOscillator(); /********** User code initialisation **************************************/ IOPorts_init(); Uart1_init(); Buzzer_init(); LedCube_init(); Buzzer_shortBeep(); uint8_t z, u; UNUSED(u); // Infinite loop for user code while (1) { // User code for (z = 0; z < CUBEDATA_MAX_Z_C; z++) { //LedCube_setPixel(1, 1, z, COLOUR_CYAN); //LedCube_updateUsingCopy(); FillLayerWithSingleColour(z, COLOUR_YELLOW); Buzzer_shortBeep(); DELAY_S(1); } DELAY_S(10); LedCube_resetData(); LedCube_update(); LedCube_resetData(); } /********** End. Nothing comes beyond this point! *************************/ while (1); return (0); }
/*----------------------------------------------------------------------------- * program start */ int main(void) { int sioHandle; uint8_t inputState; MCUSR = 0; wdt_disable(); /* get module address from EEPROM */ sMyAddr = eeprom_read_byte((const uint8_t *)MODUL_ADDRESS); sInputType = eeprom_read_byte((const uint8_t *)INPUT_TYPE); if (sInputType > INPUT_TYPE_MOTION_DETECTOR) { sInputType = INPUT_TYPE_DUAL_BUTTON; } PortInit(); TimerInit(); SioInit(); SioRandSeed(sMyAddr); sioHandle = SioOpen("USART0", eSioBaud9600, eSioDataBits8, eSioParityNo, eSioStopBits1, eSioModeHalfDuplex); SioSetIdleFunc(sioHandle, IdleSio); SioSetTransceiverPowerDownFunc(sioHandle, BusTransceiverPowerDown); BusTransceiverPowerDown(true); BusInit(sioHandle); spRxBusMsg = BusMsgBufGet(); /* enable global interrupts */ ENABLE_INT; SendStartupMsg(); if ((sInputType == INPUT_TYPE_DUAL_SWITCH) || (sInputType == INPUT_TYPE_MOTION_DETECTOR)) { /* wait for controller startup delay for sending first state telegram */ DELAY_S(STARTUP_DELAY); } if ((sInputType == INPUT_TYPE_DUAL_SWITCH) || (sInputType == INPUT_TYPE_MOTION_DETECTOR)) { inputState = GetInputState(); sSwitchStateOld = ~inputState; ProcessSwitch(inputState); } while (1) { Idle(); inputState = GetInputState(); if ((sInputType == INPUT_TYPE_DUAL_SWITCH) || (sInputType == INPUT_TYPE_MOTION_DETECTOR)) { ProcessSwitch(inputState); } else if (sInputType == INPUT_TYPE_DUAL_BUTTON) { ProcessButton(inputState); } ProcessBus(); } return 0; /* never reached */ }