void
init_lowlevel(void)
{
	/* button init */
	/* set up kbi */
	enable_irq_kbi(4);
	kbi_edge(4);
	enable_ext_wu(4);
//	kbi_pol_neg(7);
//	kbi_pol_pos(7);
//	gpio_sel0_pullup(29);
//	gpio_pu0_disable(29);

	trim_xtal();
	
	/* uart init */
	uart_init(BRINC, BRMOD, SAMP);
	
	default_vreg_init();

	maca_init();

	set_channel(RF_CHANNEL - 11); /* channel 11 */
	set_power(0x12); /* 0x12 is the highest, not documented */

	enable_irq(CRM);

#if USE_32KHZ_XTAL
	enable_32khz_xtal();
#else
	cal_ring_osc();
#endif

#if USE_32KHZ_XTAL
	*CRM_RTC_TIMEOUT = 32768 * 10; 
#else 
	*CRM_RTC_TIMEOUT = cal_rtc_secs * 10;
#endif

#if (USE_WDT == 1)
	/* set the watchdog timer timeout to 1 sec */
	cop_timeout_ms(WDT_TIMEOUT);
	/* enable the watchdog timer */
	CRM->COP_CNTLbits.COP_EN = 1;
#endif

	/* XXX debug */
	/* trigger periodic rtc int */
//	clear_rtc_wu_evt();
//	enable_rtc_wu();
//	enable_rtc_wu_irq();
}
Ejemplo n.º 2
0
int main(void)
{
	char byte;
	uint32_t i;

	rtc_init_osc(1);

	default_vreg_init();
	uart_init(INC, MOD, SAMP);

	for (i = 0; i < 0x14000; i++) {
		memcpy(&byte, (void *)i, 1);
		uart1_putc(byte);
		//rtc_delay_ms(1);
	}
	while (1) ;
}