Newer
Older
uwuboot / source / arm11 / pxi.c
@profi200 profi200 on 15 Nov 2016 818 bytes Changed back file names to not force Thumb.
#include "types.h"
#include "pxi.h"
//#include "interrupt.h"



void PXI_init(void)
{
	REG_PXI_SYNC11 = 0;
	REG_PXI_CNT11 = PXI_FLUSH_SEND_FIFO | PXI_EMPTY_FULL_ERROR | PXI_ENABLE_SEND_RECV_FIFO;

	while((REG_PXI_SYNC11 & 0xFFu) != 9u);
	REG_PXI_SYNC11 |= 11u<<8;
}

void PXI_sendWord(u32 val)
{
	while(REG_PXI_CNT11 & PXI_SEND_FIFO_FULL);
	REG_PXI_SEND11 = val;
	REG_PXI_SYNC11 |= PXI_NOTIFY_9;
}

bool PXI_trySendWord(u32 val)
{
	if(REG_PXI_CNT11 & PXI_SEND_FIFO_FULL)
		return false;
	REG_PXI_SEND11 = val;
	REG_PXI_SYNC11 |= PXI_NOTIFY_9;
	return true;
}

u32 PXI_recvWord(void)
{
	while(REG_PXI_CNT11 & PXI_RECV_FIFO_EMPTY);
	return REG_PXI_RECV11;
}

u32 PXI_tryRecvWord(bool *success)
{
	if(REG_PXI_CNT11 & PXI_RECV_FIFO_EMPTY)
	{
		*success = false;
		return 0;
	}

	*success = true;
	return REG_PXI_RECV11;
}