mirror of
https://gitea.osmocom.org/sim-card/simtrace2.git
synced 2026-03-25 17:58:32 +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 "stdlib.h"
|
||||||
#include "string.h"
|
#include "string.h"
|
||||||
#include "inttypes.h"
|
#include "inttypes.h"
|
||||||
|
#include "syscalls.h"
|
||||||
|
|
||||||
#define MIN(a, b) ((a < b) ? a : b)
|
#define MIN(a, b) ((a < b) ? a : b)
|
||||||
|
|
||||||
|
|||||||
@@ -50,8 +50,6 @@
|
|||||||
|
|
||||||
extern caddr_t _sbrk ( int incr ) ;
|
extern caddr_t _sbrk ( int incr ) ;
|
||||||
|
|
||||||
extern int link( char *old, char *new ) ;
|
|
||||||
|
|
||||||
extern int _close( int file ) ;
|
extern int _close( int file ) ;
|
||||||
|
|
||||||
extern int _fstat( int file, struct stat *st ) ;
|
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 _read(int file, char *ptr, int len) ;
|
||||||
|
|
||||||
extern int _write( 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 ;
|
PMC->PMC_MCKR = BOARD_MCKR ;
|
||||||
/* wait for master clock to be ready */
|
/* wait for master clock to be ready */
|
||||||
for ( timeout = 0; !(PMC->PMC_SR & PMC_SR_MCKRDY) && (timeout++ < CLOCK_TIMEOUT) ; );
|
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