📄 lib_st.c
字号:
//*--------------------------------------------------------------------------------------
//* ATMEL Microcontroller Software Support - ROUSSET -
//*--------------------------------------------------------------------------------------
//* The software is delivered "AS IS" without warranty or condition of any
//* kind, either express, implied or statutory. This includes without
//* limitation any warranty or condition with respect to merchantability or
//* fitness for any particular purpose, or against the infringements of
//* intellectual property rights of others.
//*--------------------------------------------------------------------------------------
//* File Name : lib_st.c
//* Object : System Timer Library.
//*
//* 1.0 23/05/00 PFi : Creation
//* 1.1 14/02/02 PFi : New function has been added. See /* New */
//*--------------------------------------------------------------------------------------
#include "periph/system_timer/lib_st.h"
#include "periph/aic/lib_aic.h"
#include "periph/stdc/lib_err.h"
//*--------------------------------------------------------------------------------------
//* Function Name : at91_no_handler_st
//* Object : Default System Timer Interrupt Handler
//* Input Parameters : none
//* Output Parameters : none
//* Functions called : at91_error
//*--------------------------------------------------------------------------------------
static void at91_no_handler_st ( void )
//* Begin
{
at91_error ( __FILE__, __LINE__ ) ;
//* End
}
//*---------------------------------- New 18/02/02 -------------------------------------
//*--------------------------------------------------------------------------------------
//* Function Name : at91_st_enable_interrupt
//* Object : Initialization of ST's Interrupts
//* Input Parameters : <*st_pt> : Pointer to the Sytem Timer Descriptor
//* : <irq> : IRQ bit(s) to enable in ST_IER
//* : <*AsmSTHandler> : Pointer to the C or ASM Interrupt Handler
//* Output Parameters : none
//* Functions called : at91_irq_open
//*--------------------------------------------------------------------------------------
void at91_st_enable_interrupt ( const STDesc *st_pt, u_int irq, TypeAICHandler *AsmSTHandler)
{//Begin
//* Init IRQ at System Timer Level
st_pt->st_base->ST_IER |= irq ;
//* Initialize the Interrupt Controller
at91_irq_open ( st_pt->PeriphId, 7, AIC_SRCTYPE_INT_LEVEL_SENSITIVE, AsmSTHandler ) ;
}
//*---------------------------------- New 18/02/02 -------------------------------------
//*--------------------------------------------------------------------------------------
//* Function Name : at91_st_disable_interrupt
//* Object : Close one or more ST's Interrupts
//* Input Parameters : <*st_pt> : Pointer to the Sytem Timer Descriptor
//* : <irq> : IRQ bit(s) to disable in ST_IDR
//* Output Parameters : none
//* Functions called : at91_irq_close
//*--------------------------------------------------------------------------------------
void at91_st_disable_interrupt ( const STDesc *st_pt, u_int irq )
//* Begin
{
//* Disable IRQs at System Timer level
st_pt->st_base->ST_IDR = irq ;
//* End
}
//*--------------------------------------------------------------------------------------
//* Function Name : at91_st_wd_mode
//* Object : Initialize the WatchDog mode of the System Timer.
//* Input Parameters : <wd_mode> = mode of watchdog
//* Output Parameters : none
//* Functions called : none
//*--------------------------------------------------------------------------------------
void at91_st_wd_mode ( const STDesc *st_pt, u_int wd_mode )
//* Begin
{
//* Set EXTEN and RSTEN Bit in WatchDog Mode Register
st_pt->st_base->ST_WDMR |= wd_mode ;
//* End
}
//*--------------------------------------------------------------------------------------
//* Function Name : at91_st_wd_rearm
//* Object : Restart the WatchDog counter.
//* Input Parameters : none
//* Output Parameters : none
//* Functions called : none
//*--------------------------------------------------------------------------------------
void at91_st_wd_rearm ( const STDesc *st_pt )
//* Begin
{
//* Restart the Watch Dog
st_pt->st_base->ST_CR = ST_WDRST ;
//* End
}
//*---------------------------------- New 14/02/02 -------------------------------------
//*--------------------------------------------------------------------------------------
//* Function Name : at91_st_get_status
//* Object : Read the Status Register of the Sytem Timer
//* Input Parameters : ST Descriptor
//* Output Parameters : Status Register (ST_SR)
//* Functions called : none
//*--------------------------------------------------------------------------------------
u_int at91_st_get_status ( const STDesc *st_pt )
//* Begin
{
//* Return the System Timer status Register
return ( st_pt->st_base->ST_SR ) ;
//* End
}
//*---------------------------------- New 14/02/02 -------------------------------------
//*--------------------------------------------------------------------------------------
//* Function Name : at91_st_set_prescaler
//* Object : Set the value of the Real-time Prescaler Value
//* Input Parameters : <st_pt> : Pointer to the ST Descriptor
//* : <pres> : Value of the prescaler
//* Output Parameters : none
//* Functions called : none
//*--------------------------------------------------------------------------------------
void at91_st_set_prescaler ( const STDesc *st_pt, u_short pres )
//* Begin
{
//* Set the value of the Real-time Prescaler Value
st_pt->st_base->ST_RTMR = pres ;
//* End
}
//*---------------------------------- New 14/02/02 -------------------------------------
//*--------------------------------------------------------------------------------------
//* Function Name : at91_st_get_prescaler
//* Object : Read the Real-time Prescaler Value
//* Input Parameters : ST Descriptor
//* Output Parameters : Value of the prescaler (RTPRES)
//* Functions called : none
//*--------------------------------------------------------------------------------------
u_int at91_st_get_prescaler ( const STDesc *st_pt )
//* Begin
{
//* Return the Real-time Prescaler Value
return ( st_pt->st_base->ST_RTMR ) ;
//* End
}
//*---------------------------------- New 14/02/02 -------------------------------------
//*--------------------------------------------------------------------------------------
//* Function Name : at91_st_set_almv
//* Object : Set the value of the ALMV
//* Input Parameters : <st_pt> : Pointer to the ST Descriptor
//* : <almv> : Value of the almv
//* Output Parameters : none
//* Functions called : none
//*--------------------------------------------------------------------------------------
void at91_st_set_almv ( const STDesc *st_pt, u_short almv )
//* Begin
{
//* Set the ALMS value
st_pt->st_base->ST_RTAR = almv ;
//* End
}
//*---------------------------------- New 14/02/02 -------------------------------------
//*--------------------------------------------------------------------------------------
//* Function Name : at91_st_get_almv
//* Object : Get the ALARM Value ALMV
//* Input Parameters : ST Descriptor
//* Output Parameters : Register (ST_RTAR)
//* Functions called : none
//*--------------------------------------------------------------------------------------
u_int at91_st_get_almv ( const STDesc *st_pt )
//* Begin
{
//* Return the Real-time ALMV Value
return ( st_pt->st_base->ST_RTAR ) ;
//* End
}
//*---------------------------------- New 14/02/02 -------------------------------------
//*--------------------------------------------------------------------------------------
//* Function Name : at91_st_set_piv
//* Object : Set the Period Interval Value
//* Input Parameters : ST Descriptor
//* : <piv> : Period Interval Value
//* Output Parameters : none
//* Functions called : none
//*--------------------------------------------------------------------------------------
void at91_st_set_piv ( const STDesc *st_pt, u_short piv )
//* Begin
{
//* Set the Period Interval Value
st_pt->st_base->ST_PIMR = piv ;
//* End
}
//*---------------------------------- New 18/02/02 -------------------------------------
//*--------------------------------------------------------------------------------------
//* Function Name : at91_st_get_piv
//* Object : Read the Period Interval Value
//* Input Parameters : ST Descriptor
//* Output Parameters : PIV value (ST_PIMR)
//* Functions called : none
//*--------------------------------------------------------------------------------------
u_int at91_st_get_piv ( const STDesc *st_pt )
//* Begin
{
//* Return the Period Interval Value
return (st_pt->st_base->ST_PIMR ) ;
//* End
}
//*---------------------------------- New 18/02/02 -------------------------------------
//*--------------------------------------------------------------------------------------
//* Function Name : at91_st_get_rtt_value
//* Object : Read the Current value of the Real-Time Timer
//* Input Parameters : ST Descriptor
//* Output Parameters : Current Real-Time Value (ST_CRTR)
//* Functions called : none
//*--------------------------------------------------------------------------------------
u_int at91_st_get_rtt_value ( const STDesc *st_pt )
//* Begin
{
//* Return the Current value of the Real-Time Timer
return ( st_pt->st_base->ST_CRTR ) ;
//* End
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -