/* MIPS I system
* Copyright 2011-2012 Stefan Schuermans <stefan@schuermans.info>
* Copyleft GNU public license V2 or later
* http://www.gnu.org/copyleft/gpl.html
*/
#include "cyc_cnt.h"
static volatile unsigned int *const cyc_cnt_ptr =
(volatile unsigned int *)0x80001000;
/**
* @brief read cycle counter
* @return cycle counter value
*/
unsigned int cyc_cnt_read(void)
{
return *cyc_cnt_ptr;
}
/**
* @brief delay for a number of cycles
* @param[in] cyc number of cycles
*/
void cyc_cnt_delay(unsigned int cyc)
{
unsigned int start = cyc_cnt_read();
while (cyc_cnt_read() - start < cyc)
/* wait */;
}