/*********************************************************************** * 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(); }
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; }
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; }