示例#1
0
文件: vsfsm.c 项目: kevin988/vsf
vsf_err_t vsfsm_set_active(struct vsfsm_t *sm, bool active)
{
	vsf_enter_critical();
	sm->active = active;
	vsf_leave_critical();
	return VSFERR_NONE;
}
示例#2
0
文件: main.c 项目: hank-fan/vsf
void main(void)
{
	struct vsf_module_t *module;
	struct vsf_module_info_t *minfo =
						(struct vsf_module_info_t *)APPCFG_MODULES_ADDR;
	int32_t pagesize;

	vsf_enter_critical();
	vsfhal_core_init(NULL);
	vsfhal_flash_capacity(0, (uint32_t*)&pagesize, NULL);
	pagesize = msb(pagesize);
	vsf_bufmgr_init(app.bufmgr_buffer, sizeof(app.bufmgr_buffer));

	// register modules
	while (minfo->entry != 0xFFFFFFFF)
	{
		module = vsf_bufmgr_malloc(sizeof(struct vsf_module_t));
		if (NULL == module)
		{
			break;
		}

		module->flash = minfo;
		minfo = (struct vsf_module_info_t *)((uint8_t *)minfo +\
			((minfo->size + (1 << pagesize) - 1) & ~((1 << pagesize) - 1)));
		vsf_module_register(module);
	}

	vsf_module_load("vsf.os", true);
	// vsfos module SHALL never return;
}
示例#3
0
文件: main.c 项目: kevin988/vsf
int main(void)
{
	uint32_t app_main_ptr;
	
	vsf_leave_critical();
	
	// system initialize
	vsf_bufmgr_init(app.bufmgr_buffer, sizeof(app.bufmgr_buffer));
	core_interfaces.core.init(NULL);
	core_interfaces.tickclk.init();
	core_interfaces.tickclk.start();
	vsftimer_init();
	core_interfaces.tickclk.set_callback(app_tickclk_callback_int, NULL);
	
	if (app.hwcfg.key.port != IFS_DUMMY_PORT)
	{
		core_interfaces.gpio.init(app.hwcfg.key.port);
		core_interfaces.gpio.config_pin(app.hwcfg.key.port, app.hwcfg.key.port,
										GPIO_INPU);
	}
	if ((IFS_DUMMY_PORT == app.hwcfg.key.port) ||
		core_interfaces.gpio.get(app.hwcfg.key.port, 1 << app.hwcfg.key.pin))
	{
		// key release
		// load and call application
		app_main_ptr = *(uint32_t *)APP_MAIN_ADDR;
		if (app_main_ptr < 128 * 1024)
		{
			app_main_ptr += APP_MAIN_ADDR;
			((int (*)(struct app_hwcfg_t *hwcfg))app_main_ptr)(&app.hwcfg);
		}
		else
		{
			goto bootlaoder_init;
		}
	}
	else
	{
		// run bootloader
	bootlaoder_init:
		
	}
	
	while (1)
	{
		vsfsm_poll();
		
		vsf_enter_critical();
		if (!vsfsm_get_event_pending())
		{
			// sleep, will also enable interrupt
			core_interfaces.core.sleep(SLEEP_WFI);
		}
		else
		{
			vsf_leave_critical();
		}
	}
}
示例#4
0
文件: vsfsm.c 项目: kevin988/vsf
vsf_err_t vsfsm_poll(void)
{
	struct vsfsm_evtqueue_t tmp;
	
	while (vsfsm_evt_count)
	{
		tmp = *vsfsm_evtq_head;
		(vsfsm_evtq_head == &vsfsm_evtq[VSFSM_CFG_EVTQ_SIZE - 1]) ?
			vsfsm_evtq_head = &vsfsm_evtq[0] : vsfsm_evtq_head++;
		vsf_enter_critical();
		tmp.sm->evt_count--;
		vsfsm_evt_count--;
		vsf_leave_critical();
		vsfsm_dispatch_evt(tmp.sm, tmp.evt);
	}
	return VSFERR_NONE;
}
示例#5
0
vsf_err_t nuc505_sdio_stop(uint8_t index)
{
	SD->CTL |= SDH_CTL_CTLRST_Msk;
	while (SD->CTL & SDH_CTL_CTLRST_Msk);
	SD->DMACTL |= SDH_DMACTL_DMARST_Msk;
	vsf_enter_critical();
	if (sdio_busy)
	{
		if (sdio_info)
			sdio_info->manual_stop = 1;

		sdio_busy = 0;
		sdio_callback(sdio_callback_param);
	}
	vsf_leave_critical();

	return VSFERR_NONE;
}
示例#6
0
文件: vsfsm.c 项目: kevin988/vsf
static vsf_err_t vsfsm_evtq_post(struct vsfsm_t *sm, vsfsm_evt_t evt)
{
	vsf_enter_critical();
	
	if (vsfsm_evt_count >= VSFSM_CFG_EVTQ_SIZE)
	{
		vsf_leave_critical();
		return VSFERR_NOT_ENOUGH_RESOURCES;
	}
	
	vsfsm_evtq_tail->sm = sm;
	vsfsm_evtq_tail->evt = evt;
	(vsfsm_evtq_tail == &vsfsm_evtq[VSFSM_CFG_EVTQ_SIZE - 1]) ?
		vsfsm_evtq_tail = &vsfsm_evtq[0] : vsfsm_evtq_tail++;
	sm->evt_count++;
	vsfsm_evt_count++;
	
	vsf_leave_critical();
	
	return VSFERR_NONE;
}
示例#7
0
文件: vsf.c 项目: ymwcoding/vsf
static void vsfsm_enter_critical_internal(void)
{
    vsf_enter_critical();
}