Prusa MINI Firmware overview
wiring_time.c File Reference
#include "Arduino.h"
#include "cmsis_os.h"

Functions

uint32_t GetCurrentMicro (void)
 
uint32_t millis (void)
 
uint32_t micros (void)
 
static int is_interrupt (void)
 
void delay (uint32_t ms)
 
void delayMicroseconds (uint32_t usec)
 

Function Documentation

◆ GetCurrentMicro()

uint32_t GetCurrentMicro ( void  )
6  {
7  // copy-paste from original arduino_stm32/clock.c
8  /* Ensure COUNTFLAG is reset by reading SysTick control and status register */
9  /*((SysTick->CTRL & SysTick_CTRL_COUNTFLAG_Msk) == (SysTick_CTRL_COUNTFLAG_Msk));
10  uint32_t m = HAL_GetTick();
11  uint32_t u = SysTick->LOAD - SysTick->VAL;
12  if (((SysTick->CTRL & SysTick_CTRL_COUNTFLAG_Msk) == (SysTick_CTRL_COUNTFLAG_Msk)))
13  {
14  m = HAL_GetTick();
15  u = SysTick->LOAD - SysTick->VAL;
16  }
17  return (m * 1000 + (u * 1000) / SysTick->LOAD);*/
18  // new impl for RTOS with system timer6
19  int irq = __get_PRIMASK() & 1;
20  if (irq)
21  __disable_irq();
22  uint32_t u = TIM6->CNT;
23  uint32_t m = HAL_GetTick();
24  if (irq)
25  __enable_irq();
26  return (m * 1000 + u);
27 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ millis()

uint32_t millis ( void  )
29  {
30  //return osKernelSysTick();
31  return HAL_GetTick();
32 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ micros()

uint32_t micros ( void  )
34  {
35  return GetCurrentMicro();
36 }
Here is the call graph for this function:

◆ is_interrupt()

static int is_interrupt ( void  )
static
38  {
39  return (SCB->ICSR & SCB_ICSR_VECTACTIVE_Msk) != 0;
40 }
Here is the caller graph for this function:

◆ delay()

void delay ( uint32_t  ms)
42  {
43  if (!is_interrupt())
44  osDelay(ms);
45  //HAL_Delay(ms);
46 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ delayMicroseconds()

void delayMicroseconds ( uint32_t  usec)
48  {
49  if (!is_interrupt()) {
50  uint32_t start = GetCurrentMicro();
51  while ((start + usec) > GetCurrentMicro())
52  ;
53  }
54 }
Here is the call graph for this function:
is_interrupt
static int is_interrupt(void)
Definition: wiring_time.c:38
g29_auto.start
start
Definition: g29_auto.py:150
osDelay
osStatus osDelay(uint32_t millisec)
Wait for Timeout (Time Delay)
Definition: cmsis_os.c:365
HAL_GetTick
uint32_t HAL_GetTick(void)
Provides a tick value in millisecond.
Definition: stm32f4xx_hal.c:339
GetCurrentMicro
uint32_t GetCurrentMicro(void)
Definition: wiring_time.c:6