Beispiel #1
0
bool fifo_get(fifo_struct *bs, uint8_t* c)
{
	mcu_disable_interrupt();
	if(bs->entries>0)
	{
		memcpy(c, bs->data+bs->read_pos, bs->element_size);
		bs->read_pos = (bs->read_pos+bs->element_size)%bs->max_len;
		(bs->entries)--;
		mcu_enable_interrupt();
		return true;
	}
	mcu_enable_interrupt();
	return false;
}
Beispiel #2
0
bool fifo_put(fifo_struct *bs, uint8_t* c)
{
	mcu_disable_interrupt();
	if(bs->entries<bs->max_elements)
	{
		memcpy(bs->data+bs->write_pos, c, bs->element_size);
		bs->write_pos = (bs->write_pos+bs->element_size)%bs->max_len;
		(bs->entries)++;
		mcu_enable_interrupt();
		return true;
	}
	mcu_enable_interrupt();
	return false;
}
Beispiel #3
0
/***********************************************************************
*  Name        : Reset_Handler
*  Description :
*  Parameter   : None
*  Returns     : None
***********************************************************************/
void Reset_Handler( void )
{
    WATCHDOG_Disable();
    /********************************************************/
    /*	PLL setting											*/
    /********************************************************/
    /*the high clock is enable in bootloader,so we don't need*/
    /*to enable again in here!*/
    //mcu_setup_high_clock();

    mcu_disable_interrupt();
    /********************************************************/
    /* setup Interrupt table address   							*/
    /********************************************************/
#ifdef CHERY_M16_MP5
    mcu_set_irq_table_address(0x00008100);
#else
    mcu_set_irq_table_address(0x00004000);
#endif

    mcu_enable_interrupt();
    /********************************************************/
    /*	All Interrupt setup  							*/
    /********************************************************/
    IRQ_Init_Setup();

    /********************************************************/
    /*	All IO config									   */
    /********************************************************/
    mcu_io_init_reset();

    __main();
}
Beispiel #4
0
int main(void) {
	xplained_init();
	fprintf(COMM_LCD, G_NAME);
	setDate(2013, 1, 15, 11, 32, 50);
// 250 ms Timer siehe app3b.c ~ 0,09% Fehler

// Top Wert
	TCC0.PER = 32031;
// Prescaler
	TCC0.CTRLA = TC_CLKSEL_DIV256_gc;

	mcu_enable_interrupt();

	while (1) {
		if (update) {
			clearRow(LCD_ROW1);
			fprintf(COMM_LCD, "%.2i:%.2i:%.2i", hour, min, s);

			//Ganz komischer Fehler mit clearRow(LCD_ROW2), irgendwie wird LCD_ROW0 zum teil überschrieben, deshalb so:
			st7036_goto(LCD_ROW2, 0);
			fprintf(COMM_LCD, "             ");
			st7036_goto(LCD_ROW2, 0);
			fprintf(COMM_LCD, "%i.%i.%i", day, month, year);
			update = false;
		}
	}
	return 0;
}