コード例 #1
0
ファイル: main.c プロジェクト: Seeed-Studio/Lua_for_RePhone
void lua_setup()
{
    VM_THREAD_HANDLE handle;

    L = lua_open();
    lua_gc(L, LUA_GCSTOP, 0); /* stop collector during initialization */
    luaL_openlibs(L);         /* open libraries */

    luaopen_audio(L);
    luaopen_gsm(L);
    luaopen_timer(L);
    luaopen_gpio(L);
    luaopen_screen(L);
    luaopen_i2c(L);
    luaopen_tcp(L);
    luaopen_https(L);
    luaopen_bluetooth(L);
    luaopen_button(L);

    lua_register(L, "msleep", msleep_c);

    lua_gc(L, LUA_GCRESTART, 0);

    luaL_dofile(L, "init.lua");

    handle = vm_thread_create(shell_thread, L, 0);
    vm_thread_change_priority(handle, 245);
}
コード例 #2
0
ファイル: tcp.c プロジェクト: craigcomstock/RePhone_on_Linux
//------------------------------------------------------------------------------------------------------------------
static void bearer_callback(VM_BEARER_HANDLE handle, VM_BEARER_STATE event, VMUINT data_account_id, void *user_data)
{
    if (VM_BEARER_WOULDBLOCK == g_bearer_hdl)
    {
        g_bearer_hdl = handle;
    }
    if (handle == g_bearer_hdl)
    {
        switch (event)
        {
        case VM_BEARER_DEACTIVATED:
        	printf("[BEARER] deactivated\n");
            break;
        case VM_BEARER_ACTIVATING:
        	printf("[BEARER] activating\n");
            break;
        case VM_BEARER_ACTIVATED:
        	printf("[BEARER] activated\n");
        	g_bearer_id = data_account_id;
            g_thread_handle = vm_thread_create(tcpsvr_thread, NULL, 0);
            break;
        case VM_BEARER_DEACTIVATING:
        	printf("[BEARER] deactivating\n");
            break;
        default:
            break;

        }
    }
}
コード例 #3
0
static void bearer_callback(VM_BEARER_HANDLE handle, VM_BEARER_STATE event, VMUINT data_account_id, void *user_data)
{
    if (VM_BEARER_WOULDBLOCK == g_bearer_hdl)
    {
        g_bearer_hdl = handle;
    }
    if (handle == g_bearer_hdl)
    {
        switch (event)
        {
            case VM_BEARER_DEACTIVATED:
                break;
            case VM_BEARER_ACTIVATING:
                break;
            case VM_BEARER_ACTIVATED:
                g_thread_handle = vm_thread_create(soc_sub_thread, NULL, 0);

                break;
            case VM_BEARER_DEACTIVATING:
                break;
            default:
                break;
        }
    }
}
コード例 #4
0
/*
 * \brief Main entry point of Arduino application
 */
extern "C" void vm_main( void )
{
	VM_THREAD_HANDLE handle;

	/* Alloc DMA memory for SPI read and write, for SPI must be use non-cache memory, so we need use
	   vm_malloc_dma to alloc memory, but in arduino thread we cannot invoke this interface directly,
	   so use here to prepare memory, you can see its usage in SPI.transfer in SPI.cpp */
	spi_w_data = (unsigned char*)vm_malloc_dma(2);
	spi_r_data = (unsigned char*)vm_malloc_dma(2);

	/* Same reason like above, this is used for transferring large of data, like screen buffer, you
	   can see its usage in SPI.write in SPI.cpp  */
	spi_data_memory = (unsigned char*)vm_malloc_dma(64*1024);
	memset(spi_data_memory,0, 64*1024);

	/* only prepare something for rand, please don't delete this , otherwise arduino cannot use these
	   two interface */
	srand(0) ;
	rand();

	/* Register system event callback */
	vm_pmng_register_system_event_callback(__handle_sysevt);

	/* Register voice call event callback */
	vm_gsm_tel_call_reg_listener(__call_listener_func);

	/* Create arduino thread, and change its priority, please don't change the code, or it will effort
	   system stable */
	handle = vm_thread_create(__arduino_thread, NULL, 0);
	vm_thread_change_priority(handle, 245);
}
コード例 #5
0
ファイル: measure.c プロジェクト: lantti/RestessbarKSreporter
ADC_HANDLE open_hx711(int scl_pin, int sda_pin)
{
	ADC_HANDLE handle = 0;
	handle_details* details;
	hx711_task* task;

	while (open_handles[handle] != NULL)
	{
		handle++;
		if (handle > MAX_HANDLE)
		{
			return ADC_HANDLE_INVALID;
		}
	}

	details = vm_calloc(sizeof(handle_details));
	if (details == NULL)
	{
		return ADC_HANDLE_INVALID;
	}

	task = &details->task;
	task->scl_handle = vm_dcl_open(VM_DCL_GPIO, scl_pin);
	if (task->scl_handle == VM_DCL_HANDLE_INVALID)
	{
		vm_free(details);
		return ADC_HANDLE_INVALID;
	}
	vm_dcl_control(task->scl_handle, VM_DCL_GPIO_COMMAND_SET_MODE_0, NULL);
	vm_dcl_control(task->scl_handle, VM_DCL_GPIO_COMMAND_SET_DIRECTION_OUT, NULL);
	vm_dcl_control(task->scl_handle, VM_DCL_GPIO_COMMAND_WRITE_HIGH, NULL);

	task->sda_handle = vm_dcl_open(VM_DCL_GPIO, sda_pin);
	if (task->sda_handle == VM_DCL_HANDLE_INVALID)
	{
		vm_dcl_close(task->scl_handle);
		vm_free(details);
		return ADC_HANDLE_INVALID;
	}
	vm_dcl_control(task->sda_handle, VM_DCL_GPIO_COMMAND_SET_MODE_0, NULL);
	vm_dcl_control(task->sda_handle, VM_DCL_GPIO_COMMAND_SET_DIRECTION_IN, NULL);

	vm_mutex_init(&details->mutex);
	task->op = WAIT;
	task->delay = 100;
	task->callback = dummy_callback;
	task->callback_env = NULL;
	open_handles[handle] = details;
	write_console("open\n");
	vm_thread_create(measurement, (void*) details, (VM_THREAD_PRIORITY) 0);
	return handle;
}
コード例 #6
0
ファイル: main.cpp プロジェクト: vfajardo/LinkIt-ONE-IDE
/*
 * \brief Main entry point of Arduino application
 */
void vm_main( void )
{
    VM_THREAD_HANDLE handle;
    spi_w_data = (unsigned char*)vm_malloc_nc(2);
    spi_r_data = (unsigned char*)vm_malloc_nc(2);
    srand(0);
    rand();
    spi_data_memory = (unsigned char*)vm_malloc_nc(64*1024);
    memset(spi_data_memory,0, 64*1024);
    vm_reg_sysevt_callback(__handle_sysevt);
    vm_call_reg_listener(__call_listener_func);
    handle = vm_thread_create(__arduino_thread, NULL, 0);
    vm_thread_change_priority(handle, 245);
}
コード例 #7
0
mfxStatus mfxSchedulerCore::StartWakeUpThread(void)
{
    // stop the thread before creating it again
    // don't try to check thread status, it might lead to interesting effects.
    if (m_hwWakeUpThread.handle)
        StopWakeUpThread();
    
    m_timer_hw_event = MFX_THREAD_TIME_TO_WAIT; //!!!!!! 
    // wa for case if it will be outside of coming 15.31 Beta
    //m_timer_hw_event = 10; 

#ifdef MFX_VLV_PLATFORM    
    m_timer_hw_event = 10; //temporary fix for VLV
#endif

#if defined(_WIN32) || defined(_WIN64)
    m_hwTaskDone.handle = CreateEventExW(NULL, 
                                        _T("Global\\IGFXKMDNotifyBatchBuffersComplete"), 
                                        CREATE_EVENT_MANUAL_RESET, 
                                        STANDARD_RIGHTS_ALL | EVENT_MODIFY_STATE);
    if (m_hwTaskDone.handle)
    {
        // create 'hardware task done' thread
        Ipp32s iRes = vm_thread_create(&m_hwWakeUpThread,
                                        scheduler_wakeup_thread_proc,
                                        this);
        if (0 == iRes)
        {
            return MFX_ERR_UNKNOWN;
        }
        m_zero_thread_wait = 15; //let wait 15 ms instead of 1 sec (we might miss event in case of GlobalEvents, it affects latency in multi-instance)
    }
    else
        m_zero_thread_wait = 1; // w/o events main thread should poll driver to get status 
#else
#if !defined(SYNCHRONIZATION_BY_NON_ZERO_THREAD)
    m_zero_thread_wait = 1;
#endif
#endif // defined(_WIN32) || defined(_WIN64)

    return MFX_ERR_NONE;

} // mfxStatus mfxSchedulerCore::StartWakeUpThread(void)
コード例 #8
0
ファイル: main.c プロジェクト: WayenWeng/CodeLite_for_RePhone
void lua_setup()
{
    VM_THREAD_HANDLE handle;

    L = lua_open();
    lua_gc(L, LUA_GCSTOP, 0);  /* stop collector during initialization */
    luaL_openlibs(L);  /* open libraries */

    luaopen_audio(L);
    luaopen_gsm(L);
    luaopen_timer(L);
    luaopen_gpio(L);
    luaopen_screen(L);
    luaopen_i2c(L);
    luaopen_tcp(L);
    luaopen_https(L);

    lua_register(L, "msleep", msleep_c);

    lua_gc(L, LUA_GCRESTART, 0);

    luaL_dofile(L, "init.lua");

    if (0)
    {
        const char *script = "audio.play('nokia.mp3')";
        int error;
        error = luaL_loadbuffer(L, script, strlen(script), "line") ||
                lua_pcall(L, 0, 0, 0);
        if (error) {
            fprintf(stderr, "%s", lua_tostring(L, -1));
            lua_pop(L, 1);  /* pop error message from the stack */
        }
    }

    handle = vm_thread_create(shell_thread, L, 0);
	vm_thread_change_priority(handle, 245);

}