mirror of
https://gitea.osmocom.org/sim-card/simtrace2.git
synced 2026-03-17 05:38:33 +03:00
Add 'mdelay()' function to busy-wait for given number of milli-seconds
This commit is contained in:
@@ -24,6 +24,7 @@
|
||||
#include "stdlib.h"
|
||||
#include "string.h"
|
||||
#include "inttypes.h"
|
||||
#include "syscalls.h"
|
||||
|
||||
#define MIN(a, b) ((a < b) ? a : b)
|
||||
|
||||
|
||||
@@ -50,8 +50,6 @@
|
||||
|
||||
extern caddr_t _sbrk ( int incr ) ;
|
||||
|
||||
extern int link( char *old, char *new ) ;
|
||||
|
||||
extern int _close( int file ) ;
|
||||
|
||||
extern int _fstat( int file, struct stat *st ) ;
|
||||
@@ -63,3 +61,5 @@ extern int _lseek( int file, int ptr, int dir ) ;
|
||||
extern int _read(int file, char *ptr, int len) ;
|
||||
|
||||
extern int _write( int file, char *ptr, int len ) ;
|
||||
|
||||
extern void mdelay(unsigned int msecs);
|
||||
|
||||
@@ -162,4 +162,24 @@ extern WEAK void LowLevelInit( void )
|
||||
PMC->PMC_MCKR = BOARD_MCKR ;
|
||||
/* wait for master clock to be ready */
|
||||
for ( timeout = 0; !(PMC->PMC_SR & PMC_SR_MCKRDY) && (timeout++ < CLOCK_TIMEOUT) ; );
|
||||
|
||||
/* Configure SysTick for 1ms */
|
||||
SysTick_Config(BOARD_MCK/1000);
|
||||
}
|
||||
|
||||
/* SysTick based delay function */
|
||||
|
||||
volatile uint32_t jiffies;
|
||||
|
||||
/* Interrupt handler for SysTick interrupt */
|
||||
void SysTick_Handler(void)
|
||||
{
|
||||
jiffies++;
|
||||
}
|
||||
|
||||
void mdelay(unsigned int msecs)
|
||||
{
|
||||
uint32_t jiffies_start = jiffies;
|
||||
do {
|
||||
} while ((jiffies - jiffies_start) < msecs);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user