示例#1
0
/* Hardware initialization */
static void hwInit(void)
{
	extFunc = eeprom_read_byte((uint8_t*)EEPROM_EXT_FUNC);
	#if 0
	loadTempParams();
	if (extFunc == USE_DS18B20) {
		ds18x20SearchDevices();
		tempInit();							/* Init temperature control */
	}
	#endif
	I2CInit();								/* I2C bus */
	displayInit();							/* Load params and text labels before fb scan started */
	rcInit();								/* IR Remote control */
	inputInit();							/* Buttons/encoder polling */
	adcInit();								/* Analog-to-digital converter */

	sei();									/* Gloabl interrupt enable */

	//tunerInit(extFunc);						/* Tuner */

	DDR(STMU_STBY) |= STMU_STBY_LINE;		/* Standby port */
	DDR(STMU_MUTE) |= STMU_MUTE_LINE;		/* Mute port */
	sndInit(extFunc);						/* Load labels/icons/etc */

	setStbyTimer(0);

	return;
}
void setup() {
  Serial.begin(9600);
  Serial.println();
  Serial.print(SELF_NAME);
  Serial.println(F(" started..."));

  #ifdef ETHERNET_FEATURE
    ethernetInit();
  #endif

  sdCardInit();

  #ifdef RTC_FEATURE
    rtcInit();
  #endif

  #ifdef SERVER_FEATURE
    serverInit();
  #endif

  timersInit();

  #ifdef MAJORDOMO_FEATURE
    majordomoInit();
    majordomoMegaLive();
  #endif

  #ifdef LAURENT_FEATURE
    laurentInit();
  #endif

  #ifdef SD_INFO_FEATURE
    sdInfoInit();
  #endif

  #ifdef SD_FILES_FEATURE
    sdFilesInit();
  #endif

  #ifdef PING_FEATURE
    pingInit();
  #endif

  #ifdef UPLOAD_FEATURE
    uploadInit();
  #endif

  #ifdef PIRS_FEATURE
    pirsInit();
  #endif

  #ifdef CONTACTS_FEATURE
    contactsInit();
  #endif

  #ifdef TEMP_FEATURE
    tempInit();
  #endif

  #ifdef ELECTRO_FEATURE
    electroInit();
  #endif

  #ifdef KEYS_FEATURE
    keysInit();
  #endif

  #ifdef LEDS_FEATURE
    ledsInit();
  #endif

  #ifdef NOO_FEATURE
    nooInit();
  #endif

  timeStamp();
  Serialprint("GLOBAL Init DONE\n");
  Serial.println();
  timeStamp();
  Serialprint("AMS WORK\n");
} // setup
示例#3
0
文件: main.c 项目: jkramarz/kdhome
void main()
{
	SCB->VTOR = 0x08000000;
	
	// set clock source as HSI / 2 * (PLL) 4
	RCC->CFGR |= RCC_CFGR_PLLMULL8 | RCC_CFGR_PLLXTPRE_HSE_Div2 /*| RCC_CFGR_PLLSRC*/;
	RCC->CR |= RCC_CR_PLLON;
	while (!(RCC->CR & RCC_CR_PLLRDY));
	RCC->CFGR |= RCC_CFGR_SW_PLL;
	while (!(RCC->CFGR & RCC_CFGR_SWS_PLL));

	// enable peripherals
	RCC->APB1ENR = RCC_APB1ENR_TIM2EN;
	RCC->APB2ENR = RCC_APB2ENR_IOPAEN | RCC_APB2ENR_IOPBEN | RCC_APB2ENR_IOPCEN | RCC_APB2ENR_ADC1EN | RCC_APB2ENR_USART1EN | RCC_APB2ENR_AFIOEN;

	AFIO->MAPR = AFIO_MAPR_SWJ_CFG_JTAGDISABLE; 
	
	// configure USART
	IO_ALT_PUSH_PULL(UART_TX);
	USART1->BRR = USART_BRR(230400);
	USART1->CR1 = USART_CR1_UE | USART_CR1_TE | USART_CR1_RE | USART_CR1_RXNEIE;
	ENABLE_INTERRUPT(USART1_IRQn);

	// enable systick
	SysTick->LOAD = SysTick->VAL = (F_CPU / 1000) / 8;
	SysTick->CTRL = /*SysTick_CTRL_CLKSOURCE |*/ SysTick_CTRL_ENABLE | SysTick_CTRL_TICKINT;

	_delay_init();
	
	IO_PUSH_PULL(LED);
	IO_HIGH(LED);

#ifndef ETHERNET_MODULE
	OW_UART_init();
	tempInit();
	ioInit();
	irInit();
#endif
#ifdef ETHERNET
	ethInit();
#endif


	uint8_t b;
	uint32_t lastCheck = 0;
	for (;;)
	{
		// if (IO_IS_LOW(IN1)) dodump = 1;
		// else dodump = 0;
		// dodump=1;
		
#ifndef ETHERNET_MODULE
		ioProcess();
	
		tempProcess();

		irProcess();
#endif
		provTmr();
#ifdef ETHERNET
		ethProcess();
#endif
	}
}