File nut/os/timer.c


Included Files


Preprocessor definitions

#define NUT_TICK_FREQ 1000UL

#define MAX_AVR_FREQ 20000000

#define LOOP_OFFSET_16 31

#define LOOP_OFFSET_32 56


Global Variable nutTimerList

NUTTIMERINFO* nutTimerList
Visible in:   nut/os/timer.c
Used in: NutTimerInsert() nut/os/timer.c
  NutTimerProcessElapsed() nut/os/timer.c
  NutTimerStop() nut/os/timer.c

Global Variable nut_ticks

volatile uint32_t nut_ticks
Visible in:   nut/os/timer.c
Used in: NutGetTickCount() nut/os/timer.c
  NutTimerIntr() nut/os/timer.c

Global Variable system_time

volatile struct timeval system_time
Visible in:   nut/os/timer.c
Used in: NutGetMillis() nut/os/timer.c
  NutGetSeconds() nut/os/timer.c
  NutTimerIntr() nut/os/timer.c

Global Variable systick_us

uint32_t systick_us
Visible in:   nut/os/timer.c
Used in: NutTimerInit() nut/os/timer.c
  NutTimerIntr() nut/os/timer.c

Global Variable _delay_loop_2_mult

uint16_t _delay_loop_2_mult
Visible in:   nut/os/timer.c
Used in: NutMicroDelay() nut/os/timer.c
  NutTimerInit() nut/os/timer.c

Local Variables

nut_ticks_resume
static uint32_t nut_ticks_resume
Used in: NutTimerCreate()  
  NutTimerProcessElapsed()  

clock_cache
static uint32_t clock_cache[0+1]

Used in: NutClockSet()  

Global Function NutClockSet()

int NutClockSet ( int idx, uint32_t freq )
Prototyped in: nut/include/sys/timer.h
Calls: memset() nut/c/string/memset.c
References Variables: clock_cache nut/os/timer.c

Global Function NutDelay()

void NutDelay ( uint8_t ms )
Prototyped in: nut/include/sys/timer.h
Calls: NutMicroDelay() nut/os/timer.c
Called by: AceDisable() nut/arch/avr/dev/tlc16c550.c
  AhdlcAt91Disable() nut/arch/arm/dev/atmel/at91_ahdlc.c
  AhdlcAvrDisable() nut/arch/avr/dev/ahdlcavr.c
  AvrUsartDisable() nut/arch/avr/dev/usartavr.c
  CSNicInit() nut/arch/avr/dev/cs8900.c
  CSSoftwareWakeup() nut/arch/avr/dev/cs8900.c
  LcdDelay() nut/arch/avr/dev/hd44780.c
  LcdInit() nut/arch/avr/dev/hd44780_bus.c
  Lpc177x_8x_MciInit() nut/arch/cm3/dev/nxp/lpc177x_8x_mci.c
  NicMmuWait() nut/dev/lan91.c
  NicReset() nut/dev/lan91.c
  NicStart() nut/dev/dm9000.c
  NutChatSendString() nut/dev/chat.c
  NutPhyCtl() nut/dev/phy.c
  SpiFlashErase() nut/hwtest/avr/isp2/isp2.c
  SpiFlashWriteByte() nut/hwtest/avr/isp2/isp2.c
  UartAvrDisable() nut/arch/avr/dev/uartavr.c
  VsBeep() nut/dev/vscodec.c
  VsMemoryTest() nut/dev/vs10xx.c
  VsPlayerInit() nut/dev/vs10xx.c
  VsPlayerReset() nut/dev/vs10xx.c
  phy_inw() nut/dev/dm9000.c
  phy_outw() nut/dev/dm9000.c

Global Function NutGetCpuClock()

uint32_t NutGetCpuClock ( void )
Prototyped in: nut/include/sys/timer.h
Called by: AhdlcAt91IOCtl() nut/arch/arm/dev/atmel/at91_ahdlc.c
  AhdlcAt91Init() nut/arch/arm/dev/atmel/at91_ahdlc.c
  AhdlcAvrIOCtl() nut/arch/avr/dev/ahdlcavr.c
  At91BaudRateDiv() nut/arch/arm/dev/atmel/debug_at91.c
  At91SpiSetRate() nut/arch/arm/dev/atmel/at91_spi.c
  At91SpiSetup() nut/arch/arm/dev/atmel/spibus_at91.c
  At91UsartGetSpeed() nut/arch/arm/dev/atmel/usartDat91.c
  At91UsartSetSpeed() nut/arch/arm/dev/atmel/usartDat91.c
  AvrSpiSetup() nut/arch/avr/dev/spibus_avr.c
  AvrTwiBusConf() nut/arch/avr/dev/i2cbus_avr.c
  AvrUsartGetSpeed() nut/arch/avr/dev/usartavr.c
  AvrUsartSetSpeed() nut/arch/avr/dev/usartavr.c
  DebugSetSpeed() nut/arch/avr/dev/debug0.c
  IrblastFreq2Ocr() nut/arch/avr/dev/irblast.c
  IrblastPeriod2Ocr() nut/arch/avr/dev/irblast.c
  Mcf5225xWatchDogStart() nut/arch/m68k/coldfire/dev/mcf5225x/mcf5225x_cwd.c
  NutAppMain() nut/app/timers/timers.c
  NutTimerInit() nut/os/timer.c
  Sbbi0SetSpeed() nut/dev/sbbif0.c
  ShowTimer() nut/hwtest/avr/basemon/webdemo.c
  SpiDigitalInit() nut/arch/avr/dev/spidigio.c
  Sppi0SetSpeed() nut/arch/avr/dev/sppif0.c
  SscSpiSetup() nut/arch/arm/dev/atmel/spibus_at91ssc.c
  Stm32UsartGetSpeed() nut/arch/cm3/dev/stm/stm32_usart.c
  Stm32UsartSetSpeed() nut/arch/cm3/dev/stm/stm32_usart.c
  TwiBusConf() nut/arch/arm/dev/atmel/i2cbus_at91.c
  TwiGetSpeed() nut/arch/m68k/coldfire/dev/common/mcf5_i2c.c
  TwiSetSpeed() nut/arch/m68k/coldfire/dev/common/mcf5_i2c.c
  UartAvrIOCtl() nut/arch/avr/dev/uartavr.c
  UsartGetSpeed() nut/arch/avr/dev/usart_cb_avr.c
  UsartHwGetSpeed() nut/arch/arm/dev/atmel/usart_at91ctl.c
  UsartHwSetSpeed() nut/arch/arm/dev/atmel/usart_at91ctl.c
  UsartSetSpeed() nut/arch/avr/dev/usart_cb_avr.c

Global Function NutGetMillis()

uint32_t NutGetMillis ( void )
Prototyped in: nut/include/sys/timer.h
Called by: DelayDemo() nut/app/timers/timers.c
  NutConditionTimedWait() nut/os/condition.c
  NutGetKeyTime() nut/dev/keys.c
  NutTcpCalcRtt() nut/net/tcputil.c
  NutTcpConnect() nut/net/tcpsock.c
  NutTcpOutput() nut/net/tcpout.c
  NutTcpProcessAck() nut/net/tcpsm.c
  NutTcpSm() nut/net/tcpsm.c
  NutTcpStateRetranTimeout() nut/net/tcpsm.c
  NutUdpCreateSocket() nut/net/udpsock.c
  PeriodicDemo() nut/app/timers/timers.c
  SleepDemo() nut/app/timers/timers.c
  sys_key() nut/dev/keys.c
  sys_led() nut/dev/led.c
References Variables: system_time nut/os/timer.c

Global Function NutGetSeconds()

uint32_t NutGetSeconds ( void )
Prototyped in: nut/include/sys/timer.h
Called by: ArpCacheAging() nut/net/arpcache.c
  DisplayUpTime() nut/app/caltime/caltime.c
  stime() nut/crt/time.c
  time() nut/crt/time.c
References Variables: system_time nut/os/timer.c

Global Function NutGetTickCount()

uint32_t NutGetTickCount ( void )
Prototyped in: nut/include/sys/timer.h
Called by: NutAppMain() nut/app/inetq/inetq.c
  NutTcpCreateSocket() nut/net/tcpsock.c
  NutTimerCreate() nut/os/timer.c
  NutTimerProcessElapsed() nut/os/timer.c
  WaitDRQ() nut/arch/avr/dev/ide.c
  WaitNotBusy() nut/arch/avr/dev/ide.c
References Variables: nut_ticks nut/os/timer.c

Global Function NutMicroDelay()

void NutMicroDelay ( uint32_t us )
Prototyped in: nut/include/sys/timer.h
Calls: _delay_loop_2() nut/os/timer.c
Called by: DelayDemo() nut/app/timers/timers.c
  Gpio_OwiTransaction() nut/dev/owibus0gpio.c
  LcdInit() nut/arch/arm/dev/atmel/hd44780_at91.c
  LcdWriteByte() nut/arch/arm/dev/atmel/hd44780_at91.c
  Lpc177x_8x_MciAcmd_SendBusWidth() nut/arch/cm3/dev/nxp/lpc177x_8x_mci.c
  Lpc177x_8x_MciAcmd_SendOpCond() nut/arch/cm3/dev/nxp/lpc177x_8x_mci.c
  Lpc177x_8x_MciCardInit() nut/arch/cm3/dev/nxp/lpc177x_8x_mci.c
  Lpc177x_8x_MciCmd_ReadBlock() nut/arch/cm3/dev/nxp/lpc177x_8x_mci.c
  Lpc177x_8x_MciCmd_SelectCard() nut/arch/cm3/dev/nxp/lpc177x_8x_mci.c
  Lpc177x_8x_MciCmd_SendACMD() nut/arch/cm3/dev/nxp/lpc177x_8x_mci.c
  Lpc177x_8x_MciCmd_SendIfCond() nut/arch/cm3/dev/nxp/lpc177x_8x_mci.c
  Lpc177x_8x_MciCmd_SendOpCond() nut/arch/cm3/dev/nxp/lpc177x_8x_mci.c
  Lpc177x_8x_MciCmd_StopTransmission() nut/arch/cm3/dev/nxp/lpc177x_8x_mci.c
  Lpc177x_8x_MciCmd_WriteBlock() nut/arch/cm3/dev/nxp/lpc177x_8x_mci.c
  Lpc177x_8x_MciGetCID() nut/arch/cm3/dev/nxp/lpc177x_8x_mci.c
  Lpc177x_8x_MciGetCSD() nut/arch/cm3/dev/nxp/lpc177x_8x_mci.c
  Lpc177x_8x_MciGetCardStatus() nut/arch/cm3/dev/nxp/lpc177x_8x_mci.c
  Lpc177x_8x_MciInit() nut/arch/cm3/dev/nxp/lpc177x_8x_mci.c
  Lpc177x_8x_MciPowerOff() nut/arch/cm3/dev/nxp/lpc177x_8x_mci.c
  Lpc177x_8x_MciReadBlock() nut/arch/cm3/dev/nxp/lpc177x_8x_mci.c
  Lpc177x_8x_MciSendCmd() nut/arch/cm3/dev/nxp/lpc177x_8x_mci.c
  Lpc177x_8x_MciSetBlockLen() nut/arch/cm3/dev/nxp/lpc177x_8x_mci.c
  Lpc177x_8x_MciSetBusWidth() nut/arch/cm3/dev/nxp/lpc177x_8x_mci.c
  Lpc177x_8x_MciSetCardAddress() nut/arch/cm3/dev/nxp/lpc177x_8x_mci.c
  Lpc177x_8x_MciSetClock() nut/arch/cm3/dev/nxp/lpc177x_8x_mci.c
  Lpc177x_8x_MciWriteBlock() nut/arch/cm3/dev/nxp/lpc177x_8x_mci.c
  NutDelay() nut/os/timer.c
  Sc16is752UsartTxReady() nut/dev/usartsc16is752.c
  St7565rReset() nut/dev/spi_lcd_st7565r.c
  TapTargetReset() nut/dev/jtag_tap.c
  TwDelay() nut/dev/twibus_gpio.c
  TwGet() nut/dev/i2cbus0gpio.c
  TwPut() nut/dev/i2cbus0gpio.c
  TwStart() nut/dev/i2cbus0gpio.c
  TwStop() nut/dev/i2cbus0gpio.c
References Variables: _delay_loop_2_mult nut/os/timer.c

Global Function NutSleep()

void NutSleep ( uint32_t ms )
Prototyped in: nut/include/sys/timer.h
Calls: NutThreadRemoveQueue() nut/os/thread.c
  NutThreadResume() nut/os/thread.c
  NutThreadYield() nut/os/thread.c
  NutTimerStart() nut/os/timer.c
Called by: ATAPIGetTotalSectors() nut/arch/avr/dev/ide.c
  AhdlcRx() nut/arch/avr/dev/ahdlcavr.c
  At25dWaitReady() nut/dev/at25df.c
  At45dNodeWaitReady() nut/dev/spi_node_at45d.c
  At45dWaitReady() nut/dev/spi_at45d.c
  At45dbWaitReady() nut/dev/at45db.c
  At49bvWaitReady() nut/dev/at49bv.c
  At91MciDiscover() nut/arch/arm/dev/atmel/at91_mci.c
  AvrTwiBusWait() nut/arch/avr/dev/i2cbus_avr.c
  CFChange() nut/arch/avr/dev/ide.c
  CSEthPutPacket() nut/arch/avr/dev/cs8900.c
  CSNICrx() nut/arch/avr/dev/cs8900.c
  CardAllocate() nut/dev/spi_mmc.c
  CardInit() nut/dev/spi_mmc.c
  CardRxTkn() nut/dev/spi_mmc.c
  CardWaitRdy() nut/dev/spi_mmc.c
  DELAY() nut/arch/avr/dev/wlandrv.c
  DisplayLocalTime() nut/app/caltime/caltime.c
  DisplaySeconds() nut/app/caltime/caltime.c
  DisplayUpTime() nut/app/caltime/caltime.c
  DisplayZuluTime() nut/app/caltime/caltime.c
  FeederThread() nut/dev/vscodec.c
  Gpio_OwiTransaction() nut/dev/owibus0gpio.c
  HardwareReset() nut/arch/avr/dev/ide.c
  HelixOpen() nut/dev/hxcodec.c
  High() nut/app/events/events.c
  LcdClear() nut/arch/arm/dev/atmel/hd44780_at91.c
  LcdCursorHome() nut/arch/arm/dev/atmel/hd44780_at91.c
  LcdDelay() nut/arch/avr/dev/hd44780.c
  LcdInit() nut/arch/arm/dev/atmel/st7036_at91.c
  Low() nut/app/events/events.c
  MmCardInit() nut/dev/mmcard.c
  MmCardTxCmd() nut/dev/mmcard.c
  MmCardWrite() nut/dev/mmcard.c
  NicInit() nut/arch/avr/dev/nicrtl.c
  NicPhyConfig() nut/dev/lan91.c
  NicRx() nut/arch/avr/dev/nicrtl.c
  NicRxLanc() nut/dev/lan91.c
  NicStart() nut/dev/dm9000.c
  NotifyTask() nut/app/httpd_upnp/upnp.c
  NutAppMain() nut/hwtest/cm3/nxp/mbed_ssp_lcd/lcd_test.c
  NutChatSendString() nut/dev/chat.c
  NutInit() nut/hwtest/avr/basemon/basemon.c
  NutPppSm() nut/net/pppsm.c
  OwiInit() nut/dev/owibus.c
  PhatSectorLoad() nut/fs/phatio.c
  Player() nut/hwtest/audio/nutpiper/player.c
  ProcessRequests() nut/app/tcps/tcps.c
  QueryDateAndTime() nut/app/pppc/pppc.c
  SSDPTask() nut/app/httpd_upnp/upnp.c
  Scanner() nut/hwtest/audio/nutpiper/scanner.c
  SendNotifyAlive() nut/app/httpd_upnp/upnp.c
  SendNotifyAliveChunk() nut/app/httpd_upnp/upnp.c
  Service() nut/app/httpd_upnp/httpserv.c
  ShtCommand() nut/dev/sht21.c
  SleepDemo() nut/app/timers/timers.c
  Thread1() nut/hwtest/cm3/nxp/mbed_ssp_lcd/lcd_test.c
  Thread2() nut/app/threads/threads.c
  TwiBusProbe() nut/arch/arm/dev/atmel/i2cbus_at91.c
  TwiInitTransfer() nut/arch/m68k/coldfire/dev/common/mcf5_i2c.c
  UserInterface() nut/hwtest/audio/nutpiper/nutpiper.c
  VsCodecLoadPlugIn() nut/dev/spi_vscodec.c
  VsCodecWriteWRam() nut/dev/spi_vscodec.c
  VsInit() nut/dev/vscodec.c
  VsOpen() nut/dev/vscodec.c
  VsPlayerFlush() nut/dev/vscodec.c
  WebDemo() nut/hwtest/avr/basemon/webdemo.c
  X12Init() nut/dev/x12rtc.c
  XsvfDelay() nut/app/xsvfexec/host.c
  XsvfExit() nut/app/xsvfexec/host.c
  XsvfGetCmd() nut/app/xsvfexec/host.c
  XsvfInit() nut/app/xsvfexec/host.c
  boot() nut/boot/at91sam7x_bootloader/demo/demo-app.c
  lld_at24_read() nut/dev/at24c.c
  lld_at24_write() nut/dev/at24c.c
  loader() nut/boot/at91sam7x_bootloader/loader.c
  service_thread() nut/app/cantest/cantest.c
  wlandrv_ProbeDevice() nut/arch/avr/dev/wlandrv.c
References Functions: NutThreadWake() nut/os/thread.c

Global Function NutTimerCreate()

NUTTIMERINFO* NutTimerCreate ( uint32_t ticks, void (*callback)(HANDLE,void*), void* arg, uint8_t flags )
Prototyped in: nut/include/sys/timer.h
Calls: NutGetTickCount() nut/os/timer.c
  NutHeapRootAlloc() nut/os/heap.c
Called by: NutTimerStartTicks() nut/os/timer.c
References Variables: nut_ticks_resume nut/os/timer.c

Global Function NutTimerInit()

void NutTimerInit ( void )
Prototyped in: nut/include/sys/timer.h
Calls: NutGetCpuClock() nut/os/timer.c
  NutGetTickClock() nut/arch/m68k/coldfire/dev/mcf51cn/mcf51cn_ostimer.c
  NutRegisterTimer() nut/arch/m68k/coldfire/dev/mcf51cn/mcf51cn_ostimer.c
Called by: NutIdle() nut/os/nutinit.c
  THREAD() nut/arch/h8300h/os/nutinit.c
  idle() nut/hwtest/avr/basemon/basemon.c
References Functions: NutTimerIntr() nut/os/timer.c
References Variables: _delay_loop_2_mult nut/os/timer.c
  systick_us nut/os/timer.c

Global Function NutTimerInsert()

void NutTimerInsert ( NUTTIMERINFO* tn )
Prototyped in: nut/include/sys/timer.h
Called by: NutTimerProcessElapsed() nut/os/timer.c
  NutTimerStartTicks() nut/os/timer.c
  NutTimerStop() nut/os/timer.c
References Variables: nutTimerList nut/os/timer.c

Global Function NutTimerIntr()

void NutTimerIntr ( void* arg )
Prototyped in: nut/include/sys/timer.h
Used in: NutTimerInit() nut/os/timer.c
References Variables: nut_ticks nut/os/timer.c
  system_time nut/os/timer.c
  systick_us nut/os/timer.c

Global Function NutTimerProcessElapsed()

void NutTimerProcessElapsed ( void )
Prototyped in: nut/include/sys/timer.h
Calls: NutGetTickCount() nut/os/timer.c
  NutHeapRootFree() nut/os/heap.c
  NutTimerInsert() nut/os/timer.c
Called by: NutThreadResume() nut/os/thread.c
References Variables: nutTimerList nut/os/timer.c
  nut_ticks_resume nut/os/timer.c

Global Function NutTimerStart()

HANDLE NutTimerStart ( uint32_t ms, void (*callback)(HANDLE,void*), void* arg, uint8_t flags )
Prototyped in: nut/include/sys/timer.h
Calls: NutTimerMillisToTicks() nut/arch/m68k/coldfire/dev/mcf51cn/mcf51cn_ostimer.c
  NutTimerStartTicks() nut/os/timer.c
Called by: NutEventWait() nut/os/event.c
  NutMsgQStartTimer() nut/os/msg.c
  NutRegisterKey() nut/dev/keys.c
  NutRegisterLed() nut/dev/led.c
  NutSleep() nut/os/timer.c
  OneShotDemo() nut/app/timers/timers.c
  PeriodicDemo() nut/app/timers/timers.c

Global Function NutTimerStartTicks()

HANDLE NutTimerStartTicks ( uint32_t ticks, void (*callback)(HANDLE,void*), void* arg, uint8_t flags )
Prototyped in: nut/include/sys/timer.h
Calls: NutTimerCreate() nut/os/timer.c
  NutTimerInsert() nut/os/timer.c
Called by: NutMsgQTimerCb() nut/os/msg.c
  NutTimerStart() nut/os/timer.c

Global Function NutTimerStop()

void NutTimerStop ( HANDLE handle )
Prototyped in: nut/include/sys/timer.h
Calls: NutTimerInsert() nut/os/timer.c
Called by: NutEventPostAsync() nut/os/event.c
  NutMsgQStopTimer() nut/os/msg.c
  PeriodicDemo() nut/app/timers/timers.c
References Variables: nutTimerList nut/os/timer.c

Global Function _delay_loop_1()

\ingroup util_delay_basic

void _delay_loop_1 ( uint8_t __count )
Delay loop using an 8-bit counter \c __count, so up to 256 iterations are possible. (The value 256 would have to be passed as 0.) The loop executes three CPU cycles per iteration, not including the overhead the compiler needs to setup the counter register.
Thus, at a CPU speed of 1 MHz, delays of up to 768 microseconds can be achieved.

Prototyped in: nut/include/include2/util/delay_basic.h
Included from: nut/include/include2/util/delay_basic.h

Global Function _delay_loop_2()

\ingroup util_delay_basic

void _delay_loop_2 ( uint16_t __count )
Delay loop using a 16-bit counter \c __count, so up to 65536 iterations are possible. (The value 65536 would have to be passed as 0.) The loop executes four CPU cycles per iteration, not including the overhead the compiler requires to setup the counter register pair.
Thus, at a CPU speed of 1 MHz, delays of up to about 262.1 milliseconds can be achieved.

Prototyped in: nut/include/include2/util/delay_basic.h
Included from: nut/include/include2/util/delay_basic.h
Called by: NutMicroDelay() nut/os/timer.c