Ejemplo n.º 1
0
int main(int argc, char **argv) {

	BT_u32 i = 0;

	while(1) {
		i++;
		BT_ThreadSleep(1000);
	}
	return 0;
}
Ejemplo n.º 2
0
static BT_u32 i2c_master_transfer(BT_HANDLE hI2C, BT_I2C_MESSAGE *msgs, BT_u32 num, BT_ERROR *pError) {

	while(hI2C->pRegs->STATUS & STATUS_BA) {
		BT_ThreadYield();
	}

	if(num > 1) {
		hI2C->bHold = 1;
		hI2C->pRegs->CONTROL |= CONTROL_HOLD;
	} else {
		hI2C->bHold = BT_FALSE;
	}

	BT_u32 count;
	for(count = 0; count < num; count++, msgs++) {
		if(count == (num - 1)) {
			hI2C->bHold = BT_FALSE;
		}

retry:
		hI2C->err_status = 0;
		hI2C->p_msg = msgs;

		if(msgs->flags & BT_I2C_M_TEN) {
			hI2C->pRegs->CONTROL &= ~CONTROL_NEA;
		} else {
			hI2C->pRegs->CONTROL |= CONTROL_NEA;
		}

		if(msgs->flags & BT_I2C_M_RD) {
			mrecv(hI2C);
		} else {
			msend(hI2C);
		}

		// Wait on transfer complete signal.
		BT_kMutexPend(hI2C->pMutex, 0);
		hI2C->pRegs->INT_DISABLE = 0x000002FF;

		if(hI2C->err_status & INT_MASK_ARB_LOST) {
			BT_kPrint("ZYNQ I2C: Lost ownership on bus, trying again...");
			BT_ThreadSleep(2);
			goto retry;
		}
	}

	hI2C->p_msg = NULL;
	hI2C->err_status = 0;

	return num;
}
Ejemplo n.º 3
0
int main(void) {

	BT_ERROR Error;

	BT_HANDLE hUART = BT_DeviceOpen("uart1", &Error);

	uart_config(hUART);

	BT_UartEnable(hUART);
	BT_SetStandardHandle(hUART);

	BT_kPrint("BootThunder started...");

	BT_HANDLE hVolume = BT_DeviceOpen("mmc00", &Error);
	while(!hVolume) {
		BT_ThreadSleep(5);
		hVolume = BT_DeviceOpen("mmc00", &Error);
	}

	BT_Mount(hVolume, "/sd0/");

	signal_booted();

	Error = BT_ShellScript("/sd0/boot.cfg");
	if(Error) {
		BT_kPrint("No kernel shell script found, jumping to terminal shell");
	}

	// If we got here then script wasn't found, or didn't boot! Create a shell.
	sprintf(buffer, "boot --core 0 %08x", jtag_loop);
	BT_ShellCommand(buffer);

	while(1) {
		BT_ThreadSleep(1000);
	}

	return 0;
}
Ejemplo n.º 4
0
int main(void) {

	BT_HANDLE hUart = BT_Open("/dev/serial1", 0, NULL);
	
	BT_UART_CONFIG oConfig;
	BT_SetPowerState(hUart, BT_POWER_STATE_AWAKE);

	oConfig.eMode			= BT_UART_MODE_POLLED;
	oConfig.ucDataBits		= BT_UART_8_DATABITS;
	oConfig.ucStopBits		= BT_UART_ONE_STOP_BIT;
	oConfig.ucParity		= BT_UART_PARITY_NONE;
	oConfig.ulBaudrate		= 115200;

	BT_UartSetConfiguration(hUart, &oConfig);

	BT_UartEnable(hUart);
	BT_SetStdout(hUart);
	BT_SetStdin(hUart);

	BT_HANDLE hKernel = BT_GetKernelProcessHandle();
	BT_SetProcessFileDescriptor(hKernel, 1, hUart);

	BT_kPrint("ThunderCat booted:");
	BT_kPrint("Starting init program");

	BT_THREAD_CONFIG oTConfig;
	oTConfig.ulStackDepth = 1024;
	oTConfig.ulPriority = 0;
	oTConfig.ulFlags = 0;

	//test_case(0, 0);

//	BT_CreateProcess(thread, "pr-0", &oTConfig, NULL);
//	BT_CreateProcess(thread, "pr-1", &oTConfig, NULL);
//	BT_CreateProcess(thread, "pr-2", &oTConfig, NULL);
//	BT_CreateProcess(thread, "pr-3", &oTConfig, NULL);
//	BT_CreateThread(thread, &oTConfig, NULL);
	BT_CreateThread(test_case, &oTConfig, NULL);
	//BT_CreateThread(thread, &oTConfig, NULL);

	BT_HANDLE hShell = BT_ShellCreate(hUart, hUart, "ThunderCat>", 0, NULL);
	BT_Shell(hShell);

	while(1) {
		BT_ThreadSleep(1000);
	}
}
Ejemplo n.º 5
0
static int bt_ps(BT_HANDLE hShell, int argc, char **argv) {

	BT_HANDLE hStdout = BT_ShellGetStdout(hShell);
	BT_u32 i = 0;
	struct bt_process_time oTime;

	BT_u32 total_processes = BT_GetTotalProcesses();

	struct process_time *runtimes = BT_kMalloc(sizeof(struct process_time) * total_processes);
	if(!runtimes) {
		return -1;
	}


	BT_u64 runtime = BT_GetGlobalTimer();
	for(i = 0; i < total_processes; i++) {
		BT_GetProcessTime(&oTime, i);
		runtimes[i].ullRuntimeCounter = oTime.ullRunTimeCounter;
	}

	BT_ThreadSleep(1000);

	runtime = BT_GetGlobalTimer() - runtime;
	for(i = 0; i < total_processes; i++) {
		BT_GetProcessTime(&oTime, i);
		runtimes[i].ullRuntimeCounter = oTime.ullRunTimeCounter - runtimes[i].ullRuntimeCounter;
	}

	for(i = 0; i < total_processes; i++) {
		BT_GetProcessTime(&oTime, i);
		bt_fprintf(hStdout, "%s : %d%%\n", oTime.name, runtimes[i].ullRuntimeCounter / (runtime / 100));
	}

	bt_fprintf(hStdout, "Total runtime %d seconds\n", (BT_u32) (BT_GetGlobalTimer() / (BT_u64)BT_GetGlobalTimerRate()));

	BT_kFree(runtimes);

	return 0;
}
Ejemplo n.º 6
0
void FF_Sleep( uint32_t ulTime_ms )
{
	BT_ThreadSleep(ulTime_ms);
}