Exemplo n.º 1
0
int main(void)
{
  Config32MHzClock(); // configure sysclk=32MHz RC oscillator, turn on 32KHz osc
  Config32KHzRTC();   // configure with 1 tick per second

  CLK.PSCTRL = 0x00;  // no division on peripheral clock

  // make clkout on PORTE:7
  PORTCFG.CLKEVOUT = PORTCFG_CLKOUT_PE7_gc;
  PORTE.DIR = (1<<7); // clkout

  // configure timer/counter0
  TCC0.CTRLA = 0x7;   // clk/1024

  // configure PORTF:0 as output to LED
  PORTF.DIR=(1<<0);

  // setup RTC counter params
  RTC.PER = 0;         // overflow after 1 second
  RTC.INTCTRL |= 0x3;  // set high level interrupt on RTC overflow
  RTC.CNT = 0;         // clear initial count

  PMIC.CTRL = PMIC_HILVLEN_bm; // enable high level interrupts
  sei(); // enable interrupts

  while(1); // forever

return 0;
};
Exemplo n.º 2
0
int main (void)
{
	double batteryLevel;
	heaterOn = 0;
	
	//Power on device, check internal battery
	powerManagerInit(); // initialise power manager + turn power on
	powerOffHeater();
	
	clock_init();
			
	initializeADC();
	
	initializeLedHandler();
	RGBOff();
	RGBShowColor(Blue);
	
	batteryLevel = readInternalBattery();

	
	//if(batteryLevel < 3.3)
	//{
		//RGBShowColor(Red);
		//_delay_ms(500);
		//RGBOff();
		//_delay_ms(500);
		//RGBShowColor(Red);
		//_delay_ms(500);
		//
		////powerOff();
		//
		//return 0;
	//}
	
	Config32KHzRTC(); //Todo:  RTC ook echt om de 1ms en niet wat die nu doet...
	
	initializeRTC();
	InitializeDebug();
	initializeBluetooth();
	
	/* DHT11 enable */
	PORTB.DIRSET = SEN1_EN;
	PORTB.OUTSET = SEN1_EN;
	
	/* Sen 2 */
	PORTB.DIRSET = SEN2_EN;
	PORTB.OUTSET = SEN2_EN;
	
	/* USB status */
	PORTC.DIRCLR = USB_STAT;
	
	
	//initializePWM();
	
	stdout = &mystdout;																	/* onze eigen stdout gebruiken (usart) */
	
	sei();																				/* Interrupts enablen */
	
	PMIC.CTRL |= (PMIC_HILVLEN_bm | PMIC_LOLVLEN_bm);										/* Hi en Lo lvl interrupts */
	
	/* BT config */
	PORTC.DIRCLR = BT_STAT;
	
	PORTC.DIRSET = BT_KEY;
	PORTC.OUTCLR = BT_KEY;
	
	PORTC.DIRSET = BT_EN;
	PORTC.OUTSET = BT_EN;
	
	PORTB.DIRSET = HY_EN;
	//PORTB.OUTSET = HY_EN;
	
	bluetoothRename("snuffelneusWit");
	
	//usartE0_sendstring("AT+NAMEsnuffelneus6.0");
	
	_delay_ms(2000);

	while(1) {
	}
}