📄 lib_tc.h
字号:
//*----------------------------------------------------------------------------
//* 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_tc.h
//* Object : Timer Counter Library Function Prototyping File.
//*
//* 1.0 01/04/00 JCZ : Creation
//*----------------------------------------------------------------------------
#ifndef lib_tc_h
#define lib_tc_h
#include "periph/timer_counter/tc.h"
#include "periph/pio/lib_pio.h"
//* Define Register coding for <reg_id>
#define RA 0
#define RB 1
#define RC 2
#define CV 3
__inline void AT91F_TCSetMode(
AT91PS_TCOUNTER pTC,
unsigned int bitSet)
{
//* Set the Mode of the Timer Counter
pTC->TC_CMR |= bitSet ;
}
__inline void AT91F_TCClearMode(
AT91PS_TCOUNTER pTC,
unsigned int bitClear)
{
//* Clear bits in the Mode register
pTC->TC_CMR &= ~bitClear ;
}
__inline void AT91F_TCDisableClock(
AT91PS_TCOUNTER pTC)
{
//* Disable the clock and interrupts
pTC->TC_CCR = TC_CLKDIS ;
}
__inline int AT91F_TCDisableClock(
AT91PS_TCOUNTER pTC)
{
//* Return the value of the Status Register
return ( pTC->TC_SR ) ;
}
__inline int AT91F_TCReadRA(
AT91PS_TCOUNTER pTC)
{
return(pTC->TC_RA);
}
__inline int AT91F_TCReadRB(
AT91PS_TCOUNTER pTC)
{
return(pTC->TC_RB);
}
__inline int AT91F_TCReadRC(
AT91PS_TCOUNTER pTC)
{
return(pTC->TC_RC);
}
__inline int AT91F_TCReadCV(
AT91PS_TCOUNTER pTC)
{
return(pTC->TC_CV);
}
__inline int AT91F_TCWriteRA(
AT91PS_TCOUNTER pTC,
int val)
{
pTC->TC_RA = val ;
}
__inline int AT91F_TCWriteRB(
AT91PS_TCOUNTER pTC,
int val)
{
pTC->TC_RB = val ;
}
__inline int AT91F_TCWriteRC(
AT91PS_TCOUNTER pTC,
int val)
{
pTC->TC_RC = val ;
}
/*------------------------------------*/
/* Timer Counter Descriptor Structure */
/*------------------------------------*/
typedef struct
{
AT91S_TCOUNTER *tc_base ;
const PioCtrlDesc *pio_ctrl ;
u_char periph_id ;
u_char pin_tioa ;
u_char pin_tiob ;
u_char pin_tclk ;
} TCDesc ;
/*------------------------------------------*/
/* Timer Counter Block Descriptor Structure */
/*------------------------------------------*/
typedef struct
{
const TCDesc *tc0_desc ;
const TCDesc *tc1_desc ;
const TCDesc *tc2_desc ;
} TCBlockDesc ;
extern void at91_tc_open ( const TCDesc *tc_pt, u_int mode, u_int tioa, u_int tiob );
extern void at91_tc_close ( const TCDesc *tc_pt );
extern u_int at91_tc_get_status ( const TCDesc *tc_pt );
extern void at91_tc_trig_cmd ( const TCDesc *tc_pt, u_int cmd );
extern void at91_tc_set_mode ( const TCDesc *tc_pt, u_int mask, u_int data );
extern void at91_tc_read ( const TCDesc *tc_pt, u_int reg[] );
extern void at91_tc_write ( const TCDesc *tc_pt, u_int reg[] );
extern void at91_tc_compute_microsec ( u_int *rc, u_int *clk, u_int mcki_khz ) ;
#endif /* lib_tc_h */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -