RTEMS  5.1
Functions | Variables
timer.c File Reference

Timer controller for the mbed lpc1768 board. More...

#include <stdio.h>
#include <rtems/status-checks.h>
#include <bsp.h>
#include <bsp/irq.h>
#include <bsp/io.h>
#include <bsp/timer.h>

Functions

rtems_status_code lpc176x_timer_reset (const lpc176x_timer_number tnumber)
 resets timer counter and stops it. More...
 
rtems_status_code lpc176x_timer_set_mode (const lpc176x_timer_number tnumber, const lpc176x_timer_mode mode)
 Sets mode of the timer (timer, counter rising, counter falling or counter both edges) More...
 
rtems_status_code lpc176x_timer_start (const lpc176x_timer_number tnumber)
 Starts the timer counter. More...
 
rtems_status_code lpc176x_timer_is_started (const lpc176x_timer_number tnumber, bool *is_started)
 true if timer is started. More...
 
rtems_status_code lpc176x_timer_set_resolution (const lpc176x_timer_number tnumber, const lpc176x_microseconds resolution)
 sets the resolution in microseconds of the timer More...
 
rtems_status_code lpc176x_timer_match_config (const lpc176x_timer_number tnumber, const lpc176x_match_port match_port, const lpc176x_match_function function, const uint32_t match_value)
 Configures the timer match. More...
 
rtems_status_code lpc176x_timer_capture_config (const lpc176x_timer_number tnumber, const lpc176x_capture_port capture_port, const lpc176x_capture_function function)
 Configures the capture ports. More...
 
rtems_status_code lpc176x_timer_external_match_config (const lpc176x_timer_number number, const lpc176x_match_port match_port, const lpc176x_ext_match_function function)
 Configures the external match ports. More...
 
uint32_t lpc176x_timer_get_capvalue (const lpc176x_timer_number number, const lpc176x_capture_port capture_port)
 Gets the captured value. More...
 
uint32_t lpc176x_timer_get_timer_value (const lpc176x_timer_number tnumber)
 Gets the timer value. More...
 
rtems_status_code lpc176x_timer_set_timer_value (const lpc176x_timer_number tnumber, const uint32_t timer_value)
 Sets the timer value. More...
 
void lpc176x_timer_isr (void *arg)
 Timer generic isroutine. More...
 
rtems_status_code lpc176x_timer_init (const lpc176x_timer_number tnumber)
 Initializes timer in timer mode and resets counter but without starting it, and without any capture or match function. More...
 
rtems_status_code lpc176x_timer_init_with_interrupt (const lpc176x_timer_number tnumber, const lpc176x_isr_funct_vector *const vector)
 Initializes timer in timer mode and resets counter but without starting it, and without any capture or match function. More...
 

Variables

const lpc176x_timer timers [LPC176X_TIMER_COUNT]
 Represents all the timers. More...
 
lpc176x_timer_functions functions_vector [LPC176X_TIMER_COUNT]
 Represents all the functions according to the timers. More...
 

Detailed Description

Timer controller for the mbed lpc1768 board.

Function Documentation

◆ lpc176x_timer_capture_config()

rtems_status_code lpc176x_timer_capture_config ( lpc176x_timer_number  tnumber,
lpc176x_capture_port  capture_port,
lpc176x_capture_function  function 
)
inline

Configures the capture ports.

Parameters
tnumberthe device to be modified
capture_portwhich port of this timer will be setted
functionAt which edge/s will the capture work, and if it will interrupt

◆ lpc176x_timer_external_match_config()

rtems_status_code lpc176x_timer_external_match_config ( lpc176x_timer_number  tnumber,
lpc176x_match_port  match_port,
lpc176x_ext_match_function  function 
)
inline

Configures the external match ports.

Parameters
tnumberthe device to be modified
match_portwhich match for this timer
functionwhat should do when match: set, clear toggle or nothing

◆ lpc176x_timer_get_capvalue()

uint32_t lpc176x_timer_get_capvalue ( lpc176x_timer_number  tnumber,
lpc176x_capture_port  capnumber 
)
inline

Gets the captured value.

Parameters
tnumberthe device to be modified
capnumberwhich capture port for this timer
Returns
the captured value

◆ lpc176x_timer_get_timer_value()

uint32_t lpc176x_timer_get_timer_value ( lpc176x_timer_number  tnumber)
inline

Gets the timer value.

Parameters
tnumberthe device
Returns
the timer value

◆ lpc176x_timer_init()

rtems_status_code lpc176x_timer_init ( lpc176x_timer_number  tnumber)

Initializes timer in timer mode and resets counter but without starting it, and without any capture or match function.

Parameters
tnumberwhich timer
Returns
RTEMS_SUCCESSFUL when everything ok.

◆ lpc176x_timer_init_with_interrupt()

rtems_status_code lpc176x_timer_init_with_interrupt ( lpc176x_timer_number  tnumber,
const lpc176x_isr_funct_vector vector 
)

Initializes timer in timer mode and resets counter but without starting it, and without any capture or match function.

Parameters
tnumberwhich timer to init
vectorthe functions to be used by the isr.
Returns
RTEMS_SUCCESSFUL when everything ok.

◆ lpc176x_timer_is_started()

rtems_status_code lpc176x_timer_is_started ( lpc176x_timer_number  tnumber,
bool *  is_started 
)
inline

true if timer is started.

Parameters
tnumberthe timer number to check.
is_startedTRUE if the timer is running.
Returns
RTEMS_SUCCESSFUL if the started timer check was successfuly.

◆ lpc176x_timer_isr()

void lpc176x_timer_isr ( void *  lpc176x_timer_number)

Timer generic isroutine.

Parameters
timernumberthe number of timer.

◆ lpc176x_timer_match_config()

rtems_status_code lpc176x_timer_match_config ( lpc176x_timer_number  tnumber,
lpc176x_match_port  match_port,
lpc176x_match_function  function,
uint32_t  match_value 
)

Configures the timer match.

Parameters
tnumberthe device to be modified
match_portwhich port of this timer will be setted
functionwhat the timer should do when match: stop timer, clear, and/or interrupt
match_valuethe value that the timer should match.
Returns
RTEMS_SUCCESSFUL if the timer was configured successfuly.

◆ lpc176x_timer_reset()

rtems_status_code lpc176x_timer_reset ( lpc176x_timer_number  tnumber)
inline

resets timer counter and stops it.

Parameters
tnumberthe device to be reseted
Returns
RTEMS_SUCCESSFUL if the timer was reseted successfuly.

◆ lpc176x_timer_set_mode()

rtems_status_code lpc176x_timer_set_mode ( lpc176x_timer_number  tnumber,
lpc176x_timer_mode  mode 
)
inline

Sets mode of the timer (timer, counter rising, counter falling or counter both edges)

Parameters
tnumberthe device to be setted
modethe desired mode
Returns
RTEMS_SUCCESSFUL if the timer's mode was setted successfuly.

◆ lpc176x_timer_set_resolution()

rtems_status_code lpc176x_timer_set_resolution ( lpc176x_timer_number  tnumber,
lpc176x_microseconds  resolution 
)
inline

sets the resolution in microseconds of the timer

Parameters
tnumberthe device to be modified.
resolutionhow many microseconds will mean each timer counter unit.
Returns
RTEMS_SUCCESSFUL if the timer resolution was setted successfuly.

◆ lpc176x_timer_set_timer_value()

rtems_status_code lpc176x_timer_set_timer_value ( lpc176x_timer_number  tnumber,
uint32_t  lpc176x_timer_value 
)
inline

Sets the timer value.

Parameters
tnumberthe timer to modify.
timer_valuethe value to set.

◆ lpc176x_timer_start()

rtems_status_code lpc176x_timer_start ( lpc176x_timer_number  tnumber)
inline

Starts the timer counter.

Parameters
tnumberthe device to be started
Returns
RTEMS_SUCCESSFUL if the timer's was started successfuly.

Variable Documentation

◆ functions_vector

lpc176x_timer_functions functions_vector[LPC176X_TIMER_COUNT]
Initial value:
=
{
{
.funct_vector = NULL
},
{
.funct_vector = NULL
},
{
.funct_vector = NULL
},
{
.funct_vector = NULL
}
}
#define NULL
Requests a GPIO pin group configuration.
Definition: bestcomm_api.h:77

Represents all the functions according to the timers.

◆ timers

const lpc176x_timer timers[LPC176X_TIMER_COUNT]
Initial value:
=
{
{
.device = (lpc176x_timer_device *) LPC176X_TMR0_BASE_ADDR,
.module = LPC176X_MODULE_TIMER_0,
.pinselcap = LPC176X_TIMER0_CAPTURE_PORTS,
.pinselemat = LPC176X_TIMER0_EMATCH_PORTS,
},
{
.device = (lpc176x_timer_device *) LPC176X_TMR1_BASE_ADDR,
.module = LPC176X_MODULE_TIMER_1,
.pinselcap = LPC176X_TIMER1_CAPTURE_PORTS,
.pinselemat = LPC176X_TIMER1_EMATCH_PORTS,
},
{
.device = (lpc176x_timer_device *) LPC176X_TMR2_BASE_ADDR,
.module = LPC176X_MODULE_TIMER_2,
.pinselcap = LPC176X_TIMER2_CAPTURE_PORTS,
.pinselemat = LPC176X_TIMER2_EMATCH_PORTS,
},
{
.device = (lpc176x_timer_device *) LPC176X_TMR3_BASE_ADDR,
.module = LPC176X_MODULE_TIMER_3,
.pinselcap = LPC176X_TIMER3_CAPTURE_PORTS,
.pinselemat = LPC176X_TIMER3_EMATCH_PORTS,
}
}
Represents the timer device registers.
Definition: timer-defs.h:186

Represents all the timers.