Skip to content
Snippets Groups Projects
main.c 1.67 KiB
/**
 * \file
 *
 * \brief Empty user application template
 *
 */

/**
 * \mainpage User Application template doxygen documentation
 *
 * \par Empty user application template
 *
 * Bare minimum empty user application template
 *
 * \par Content
 *
 * -# Include the ASF header files (through asf.h)
 * -# "Insert system clock initialization code here" comment
 * -# Minimal main function that starts with a call to board_init()
 * -# "Insert application code here" comment
 *
 */

/*
 * Include header files for all drivers that have been imported from
 * Atmel Software Framework (ASF).
 */
#include <asf.h>
#include <util/delay.h>
#include <stdio.h>
#include "usart_lib.h"
#include "timer_lib.h"
#include "bootloader.h"
#include "version.h"
#include <ccp.h>
int main (void)
{
	// Insert system clock initialization code here (sysclk_init()).

	board_init();
	sysclk_init();
		
	/* Set interrupt vector location to boot section of flash */
	uint8_t temp = 0x00;
	temp = PMIC.CTRL | PMIC_IVSEL_bm;
	CCP = CCP_IOREG_gc;
	PMIC.CTRL = temp;
	
	timer_init();
	
	pmic_init();
	pmic_set_scheduling(PMIC_SCH_FIXED_PRIORITY);//PMIC_SCH_ROUND_ROBIN);
	cpu_irq_enable();
	usart_init();
    ioport_toggle_pin(MMC_LED);
    char message[] = "Bootloader V00.00\r\n";
    message[12] += SVN_REVISION_MAJOR / 10;
    message[13] += SVN_REVISION_MAJOR % 10;
    message[15] += SVN_REVISION_MINOR / 10;
    message[16] += SVN_REVISION_MINOR % 10;
    printString(message);
    start_bootloader();
	//reset processor
	//ccp_write_io((void *)&RST.CTRL, RST_SWRST_bm);
	// Insert application code here, after the board has been initialized.
	start_firmware();
}