Exemplo n.º 1
0
static VMINT32 measurement(VM_THREAD_HANDLE thread_handle, void* user_data)
{
	VMINT measured_result;
	handle_details* details;
	hx711_task current_task;


	write_console("thread enter\n");
	details = (handle_details*) user_data;
	get_task(details, &current_task);
	enter_standby(&current_task);

	while (1)
	{
		get_task(details, &current_task);

		if (current_task.op == TERMINATE)
		{
			break;
		}

		if (current_task.op == WAIT)
		{
			enter_standby(&current_task);
			continue;
		}

		if (current_task.op != A128)
		{
			wait_result(&current_task);
			read_result(&current_task);
			clock_setup_pulses(&current_task);
		}
		wait_result(&current_task);
		measured_result = read_result(&current_task);
		current_task.callback(current_task.callback_env, measured_result);
		enter_standby(&current_task);
	}

	write_console("thread exit\n");
	enter_standby(&current_task);
	vm_mutex_lock(&details->mutex);
	vm_dcl_close(current_task.sda_handle);
	vm_dcl_close(current_task.scl_handle);
	current_task.callback(current_task.callback_env, 0);
	vm_free(details);
	return 0;
}
Exemplo n.º 2
0
/**
 * @brief Bootloader "C" entry point
 *
 * @param none
 *
 * @returns Nothing. Will launch/restart image if successful, halt if not.
 */
void bootrom_main(void) {

    chip_init();

    dbginit();

    dbgprint("Hello world from s3fw\n");

#ifdef _SIMULATION
    /* Handshake with the controller, indicating trying to enter standby */
    chip_handshake_boot_status(0);
    enter_standby();
#endif
    /* Our work is done */
    while(1);
}