TIMER
Ameba SDK » HAL

timer functions More...

## Ameba Common

typedef struct gtimer_s | gtimer_t
typedef void(* | gtimer_irq_handler) (uint32_t id)
void | gtimer_init (gtimer_t *obj, uint32_t tid)
| Initializes the timer, including clock/function/timer registers. More...
void | gtimer_deinit (gtimer_t *obj)
| Deinitializes the timer, including clock/function/timer registers. More...
uint32_t | gtimer_read_tick (gtimer_t *obj)
| Read current timer tick in Gtimer clock(0~32768). More...
uint64_t | gtimer_read_us (gtimer_t *obj)
| Read current timer tick in microsecond. More...
void | gtimer_reload (gtimer_t *obj, uint32_t duration_us)
| Reload timer. More...
void | gtimer_start (gtimer_t *obj)
| Start the timer. More...
void | gtimer_start_one_shout (gtimer_t *obj, uint32_t duration_us, void *handler, uint32_t hid)
| Set up a shout timer, including clock/function/timer registers. More...
void | gtimer_start_periodical (gtimer_t *obj, uint32_t duration_us, void *handler, uint32_t hid)
| Set up a periodic timer, including clock/function/timer registers. More...
void | gtimer_stop (gtimer_t *obj)
| Stop the timer, including clock/function/timer registers. More...

## Ameba Only

enum | { TIMER0 = 2, TIMER1 = 3, TIMER2 = 4, TIMER3 = 5, TIMER4 = 0, GTIMER_MAX = 5 }

## AmebaZ Only

enum | { TIMER0 = 2, TIMER1 = 3, TIMER2 = 4, TIMER3 = 5, GTIMER_MAX = 5 }

## Detailed Description

timer functions

## Function Documentation

void gtimer_deinit | ( | gtimer_t * | obj | ) |

Deinitializes the timer, including clock/function/timer registers.

Parameters

  obj | gtimer object defined in application software.

Return values

  none |

void gtimer_init | ( | gtimer_t * | obj,
|  | uint32_t | tid
| ) |  |

Initializes the timer, including clock/function/timer registers.

Parameters

  obj | gtimer object defined in application software.
  tid | the timer struct ID defined in gtimer structure.

Return values

  none |

uint32_t gtimer_read_tick | ( | gtimer_t * | obj | ) |

Read current timer tick in Gtimer clock(0~32768).

Parameters

  obj | gtimer object defined in application software.

Return values

  32 | bit tick time

uint64_t gtimer_read_us | ( | gtimer_t * | obj | ) |

Read current timer tick in microsecond.

Parameters

  obj | gtimer object defined in application software.

Return values

  64 | bit tick time

void gtimer_reload | ( | gtimer_t * | obj,
|  | uint32_t | duration_us
| ) |  |

Reload timer.

Parameters

  obj | gtimer object defined in application software.
  duration_us | the time in microsecond of gtimer to reload.

Return values

  none |

void gtimer_start | ( | gtimer_t * | obj | ) |

Start the timer.

Parameters

  obj | gtimer object defined in application software.

Return values

  none |

void gtimer_start_one_shout | ( | gtimer_t * | obj,
|  | uint32_t | duration_us,
|  | void * | handler,
|  | uint32_t | hid
| ) |  |

Set up a shout timer, including clock/function/timer registers.

Parameters

  obj | gtimer object defined in application software.
  duration_us | the period in microsecond of gtimer.
  handler | The Pointer to the function that program runs into when timer is up.
  hid | the timer struct ID defined in gtimer structure.

Return values

  none |

void gtimer_start_periodical | ( | gtimer_t * | obj,
|  | uint32_t | duration_us,
|  | void * | handler,
|  | uint32_t | hid
| ) |  |

Set up a periodic timer, including clock/function/timer registers.

Parameters

  obj | gtimer object defined in application software.
  duration_us | the period in microsecond of gtimer.
  handler | The Pointer to function that program runs into when timer is up.
  hid | the timer struct ID defined in gtimer structure.

Return values

  none |

void gtimer_stop | ( | gtimer_t * | obj | ) |

Stop the timer, including clock/function/timer registers.

Parameters

  obj | gtimer object defined in application software.

Return values

  none |