SimAVR
AVR Simulator
avr_timer.c File Reference
#include <stdio.h>
#include "avr_ioport.h"
#include "avr_timer.h"
#include "sim_time.h"
Include dependency graph for avr_timer.c:

Functions

static uint16_t _timer_get_ocr (avr_timer_t *timer, int comparator_index)
 Get Ouput Compare Register (OCR) More...
 
static uint16_t _timer_get_comp_ocr (struct avr_t *avr, avr_timer_comp_p comparator)
 cf. More...
 
static uint16_t _timer_get_tcnt (avr_timer_t *timer)
 Get Timer Counter Register (TCNT) More...
 
static uint16_t _timer_get_icr (avr_timer_t *timer)
 Get Input Capture Register (ICR) More...
 
static avr_cycle_count_t avr_timer_comp (avr_timer_t *p, avr_cycle_count_t when, uint8_t comparator_index)
 
static void avr_timer_comp_on_tov (avr_timer_t *p, avr_cycle_count_t when, uint8_t comparator_index)
 
static avr_cycle_count_t avr_timer_compa (struct avr_t *avr, avr_cycle_count_t when, void *param)
 
static avr_cycle_count_t avr_timer_compb (struct avr_t *avr, avr_cycle_count_t when, void *param)
 
static avr_cycle_count_t avr_timer_compc (struct avr_t *avr, avr_cycle_count_t when, void *param)
 
static avr_cycle_count_t avr_timer_tov (struct avr_t *avr, avr_cycle_count_t when, void *param)
 
static uint16_t _avr_timer_get_current_tcnt (avr_timer_t *p)
 Compute the current value of TCNT. More...
 
static uint8_t avr_timer_tcnt_read (struct avr_t *avr, avr_io_addr_t addr, void *param)
 Read TCNT. More...
 
static void avr_timer_cancel_all_cycle_timers (struct avr_t *avr, avr_timer_t *timer)
 
static void avr_timer_tcnt_write (struct avr_t *avr, avr_io_addr_t addr, uint8_t v, void *param)
 Write TCNT. More...
 
static void _avr_timer_configure (avr_timer_t *p, uint32_t clock, uint32_t top)
 Configure a timer. More...
 
static void avr_timer_reconfigure (avr_timer_t *p)
 
static void avr_timer_write_ocr (struct avr_t *avr, avr_io_addr_t addr, uint8_t v, void *param)
 
static void avr_timer_write (struct avr_t *avr, avr_io_addr_t addr, uint8_t v, void *param)
 
static void avr_timer_write_pending (struct avr_t *avr, avr_io_addr_t addr, uint8_t v, void *param)
 
static void avr_timer_irq_icp (struct avr_irq_t *irq, uint32_t value, void *param)
 
static void avr_timer_reset (avr_io_t *port)
 
void avr_timer_init (avr_t *avr, avr_timer_t *p)
 

Variables

static const char * irq_names [TIMER_IRQ_COUNT]
 
static avr_io_t _io
 

Function Documentation

static void _avr_timer_configure ( avr_timer_t p,
uint32_t  clock,
uint32_t  top 
)
static

Configure a timer.

Here is the call graph for this function:

Here is the caller graph for this function:

static uint16_t _avr_timer_get_current_tcnt ( avr_timer_t p)
static

Compute the current value of TCNT.

Here is the caller graph for this function:

static uint16_t _timer_get_comp_ocr ( struct avr_t avr,
avr_timer_comp_p  comparator 
)
static

cf.

infra, duplicate

Here is the caller graph for this function:

static uint16_t _timer_get_icr ( avr_timer_t timer)
static

Get Input Capture Register (ICR)

Here is the caller graph for this function:

static uint16_t _timer_get_ocr ( avr_timer_t timer,
int  comparator_index 
)
static

Get Ouput Compare Register (OCR)

Here is the caller graph for this function:

static uint16_t _timer_get_tcnt ( avr_timer_t timer)
static

Get Timer Counter Register (TCNT)

Here is the caller graph for this function:

static void avr_timer_cancel_all_cycle_timers ( struct avr_t avr,
avr_timer_t timer 
)
static

Here is the call graph for this function:

Here is the caller graph for this function:

static avr_cycle_count_t avr_timer_comp ( avr_timer_t p,
avr_cycle_count_t  when,
uint8_t  comparator_index 
)
static

Here is the call graph for this function:

Here is the caller graph for this function:

static void avr_timer_comp_on_tov ( avr_timer_t p,
avr_cycle_count_t  when,
uint8_t  comparator_index 
)
static

Check output compare mode and set/clear pins

Here is the call graph for this function:

Here is the caller graph for this function:

static avr_cycle_count_t avr_timer_compa ( struct avr_t avr,
avr_cycle_count_t  when,
void *  param 
)
static

Here is the call graph for this function:

Here is the caller graph for this function:

static avr_cycle_count_t avr_timer_compb ( struct avr_t avr,
avr_cycle_count_t  when,
void *  param 
)
static

Here is the call graph for this function:

Here is the caller graph for this function:

static avr_cycle_count_t avr_timer_compc ( struct avr_t avr,
avr_cycle_count_t  when,
void *  param 
)
static

Here is the call graph for this function:

Here is the caller graph for this function:

static void avr_timer_irq_icp ( struct avr_irq_t irq,
uint32_t  value,
void *  param 
)
static

Here is the call graph for this function:

Here is the caller graph for this function:

static void avr_timer_reconfigure ( avr_timer_t p)
static

Here is the call graph for this function:

Here is the caller graph for this function:

static void avr_timer_reset ( avr_io_t port)
static

Here is the call graph for this function:

static uint8_t avr_timer_tcnt_read ( struct avr_t avr,
avr_io_addr_t  addr,
void *  param 
)
static

Read TCNT.

Here is the call graph for this function:

Here is the caller graph for this function:

static void avr_timer_tcnt_write ( struct avr_t avr,
avr_io_addr_t  addr,
uint8_t  v,
void *  param 
)
static

Write TCNT.

Here is the call graph for this function:

Here is the caller graph for this function:

static avr_cycle_count_t avr_timer_tov ( struct avr_t avr,
avr_cycle_count_t  when,
void *  param 
)
static

Here is the call graph for this function:

Here is the caller graph for this function:

static void avr_timer_write ( struct avr_t avr,
avr_io_addr_t  addr,
uint8_t  v,
void *  param 
)
static

Here is the call graph for this function:

Here is the caller graph for this function:

static void avr_timer_write_ocr ( struct avr_t avr,
avr_io_addr_t  addr,
uint8_t  v,
void *  param 
)
static

Here is the call graph for this function:

Here is the caller graph for this function:

static void avr_timer_write_pending ( struct avr_t avr,
avr_io_addr_t  addr,
uint8_t  v,
void *  param 
)
static

Here is the call graph for this function:

Here is the caller graph for this function:

Variable Documentation

avr_io_t _io
static
Initial value:
= {
.kind = "timer",
.reset = avr_timer_reset,
.irq_names = irq_names,
}
static void avr_timer_reset(avr_io_t *port)
Definition: avr_timer.c:616
static const char * irq_names[TIMER_IRQ_COUNT]
Definition: avr_timer.c:655
const char* irq_names[TIMER_IRQ_COUNT]
static
Initial value:
= {
[TIMER_IRQ_OUT_PWM0] = "8>pwm0",
[TIMER_IRQ_OUT_PWM1] = "8>pwm1",
[TIMER_IRQ_OUT_COMP + 0] = ">compa",
[TIMER_IRQ_OUT_COMP + 1] = ">compb",
[TIMER_IRQ_OUT_COMP + 2] = ">compc",
}
Definition: avr_timer.h:47
Definition: avr_timer.h:46
comparator pins output IRQ
Definition: avr_timer.h:48