int main(void){ #if PROTOCOL==PROTO_JUMPER uint8_t autoproto; #endif MCUSR = 0; wdt_disable(); CLKPR = 0x80; CLKPR = 0x00; initUart(); spiInitMaster(SPI_CLOCKRATE); #if PROTOCOL==PROTO_SEDU_BUGGY buggySeduLoop(); #elif PROTOCOL==PROTO_SEDU seduLoop(); #elif PROTOCOL==PROTO_TPM2 tpm2Loop(); #elif PROTOCOL==PROTO_JUMPER autoproto = getProtoJumper(); if( autoproto == PROTO_SEDU_BUGGY ) buggySeduLoop(); else if( autoproto == PROTO_SEDU ) seduLoop(); else if( autoproto == PROTO_TPM2 ) tpm2Loop(); #endif return 0; }
int main(void) { // PORT config DDRC = 0xFF; PORTC = 0x00; //1111 1111 : 0000 0000 //DDRB = 0xFF; PORTB = 0x00; //1111 1111 : 0000 0000 DDRB = 0x03; PORTB = 0x00; DDRA = 0xFD; PORTA = 0x02; //1111 1101 : 0000 0010 DDRD = 0x0a; PORTD = 0x05; //scheduler setup static task motionSensorPoll, lcdDisplay, uoutTask, RT_Task, M_Task, hvacTask, sensorTimeoutTask; task *tasks[] = { &lcdDisplay, &motionSensorPoll, &uoutTask, &RT_Task, &M_Task, &hvacTask, &sensorTimeoutTask }; unsigned short numTasks = sizeof(tasks)/sizeof(task*); //USART task uoutTask.period = 50; uoutTask.TickFn = &uoutTick; //Remote timeout task RT_Task.period = 1000; RT_Task.TickFn = &remoteTimeoutTask; //Menu task M_Task.period = 100; M_Task.TickFn = &menuTask; //LCD display task lcdDisplay.period = 100; lcdDisplay.TickFn = &lcdDisplayTick; //Motion sensor polling task motionSensorPoll.period = 100; motionSensorPoll.TickFn = &motionSensorTick; //HVAC hvacTask.period = 500; hvacTask.TickFn = &hvacTick; // sensor timeout sensorTimeoutTask.period = 500; sensorTimeoutTask.TickFn = &sensorTimeoutTick; // Init radio spiInitMaster(); nrfMaster(); enableINT0(); // Init USART uoutInit(0); delay_ms(20); uoutSend("\n\r\n\r\n\r"); uoutSend(" Welcome to thermostat!\n\r"); uoutSend("==========================\n\r"); unsigned short gcd = tasksInit(tasks, numTasks); // Timer TimerSet(gcd); TimerOn(); //custom character for lcd unsigned char personPattern[8] = {0x04, 0x0A, 0x04, 0x1f, 0x04, 0x04, 0x0A, 0x11}; unsigned char fanOnPattern[8] = {0x00,0x06,0x1A,0x15,0x0B,0x0C,0x00,0x1F}; unsigned char fanAutoPattern[8] = {0x00,0x06,0x1A,0x15,0x0B,0x0C,0x00,0x00}; unsigned char onPattern[8] = {0x10, 0x12, 0x16, 0x1C, 0x18, 0x10, 0x10, 0x10}; unsigned char offPattern[8] = {0x10, 0x10, 0x10, 0x18, 0x1C, 0x16, 0x12, 0x10}; LCD_build(0,personPattern); LCD_build(1,fanOnPattern); LCD_build(2,fanAutoPattern); LCD_build(3,onPattern); LCD_build(4,offPattern); while(1) { sensor = GetBit(PINA,1); tasksTick(tasks, numTasks); while(!TimerFlag); // Wait for a GCD period TimerFlag = 0; } return 0; }