mirror of
https://github.com/SemvdH/OBD2-car-display.git
synced 2025-12-16 04:31:04 +00:00
Add start of TC and design for init image
This commit is contained in:
@@ -1,10 +1,6 @@
|
||||
#include "sam3xa/include/sam3x8e.h"
|
||||
#include "sam3xa/include/component/component_rtt.h"
|
||||
// #include "sam3xa/include/component/component_rtt.h"
|
||||
// #include "sam3xa/include/sam3x8e.h"
|
||||
#include "obd2_timer.h"
|
||||
|
||||
void obd2_timer_init(void)
|
||||
void obd2_RTT_init(void)
|
||||
{
|
||||
/* enable the timer: reset the RTT
|
||||
RTT->RTT_MR = RTT_MR_RTTRST;
|
||||
@@ -12,16 +8,16 @@ void obd2_timer_init(void)
|
||||
RTT->RTT_AR = 0;
|
||||
}
|
||||
|
||||
void obd2_timer_enable()
|
||||
void obd2_RTT_enable()
|
||||
{
|
||||
/* enable the alarm interrupt*/
|
||||
RTT->RTT_MR |= RTT_MR_ALMIEN;
|
||||
/* enable the alarm interrupt and set the prescaler to the processor frequency to generate an interrupt every second*/
|
||||
RTT->RTT_MR |= RTT_MR_ALMIEN | RTT_MR_RTPRES(CLOCK_FREQ);
|
||||
|
||||
/* enable the interrupt*/
|
||||
NVIC_EnableIRQ(RTT_IRQn);
|
||||
}
|
||||
|
||||
void obd2_timer_reset()
|
||||
void obd2_RTT_reset()
|
||||
{
|
||||
/* To prevent several executions of the interrupt handler,
|
||||
the interrupt must be disabled in the interrupt handler
|
||||
@@ -41,8 +37,14 @@ void obd2_timer_reset()
|
||||
RTT->RTT_MR |= RTT_MR_RTTRST;
|
||||
}
|
||||
|
||||
void obd2_timer_set_period(__UINT32_TYPE__ period)
|
||||
void obd2_RTT_set_period(__UINT32_TYPE__ period)
|
||||
{
|
||||
/* set the prescaler value equal to the clock speed divided by how many milliseconds*/
|
||||
RTT->RTT_MR |= RTT_MR_RTPRES(CLOCK_FREQ / (1000/period));
|
||||
}
|
||||
|
||||
void obd2_TC_init()
|
||||
{
|
||||
/* enable the timer/counter 0*/
|
||||
TC0->TC_CHANNEL[0].TC_CCR |= TC_CCR_CLKEN;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user