⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lib_pdc2.c

📁 ARM9200开发板的ROM boot程序源码1.0
💻 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_usart2.c
//* Object              : PDC Peripheral data Controller functions Library.
//*
//* 1.0 11/12/00 JPP    : Creation
//*----------------------------------------------------------------------------

//* --------------------------- include file ----------------------------------

#include    "periph/pdc2/lib_pdc2.h"


//*----------------------------------------------------------------------------
//* Function Name       : at91_pdc2_open
//* Object              : Initialize SSC.
//* Input Parameters    : <pdc2_pt> = PDC2 Descriptor pointer
//*                     : <mode>    = the Mode Register to be programmed
//* Output Parameters   : None
//* Functions called    : None
//*----------------------------------------------------------------------------
void at91_pdc2_open ( AT91PS_PDC2 pPDC2)
//* Begin
{
int ess;
	//* Stop PDC
	ess = pPDC2->PDC2_PTCR  ;

	//* Reset all Counter register
	pPDC2->PDC2_RCR  = 0 ;
	pPDC2->PDC2_RNCR = 0 ;
	pPDC2->PDC2_TCR  = 0 ;
	pPDC2->PDC2_TNCR = 0 ;

	//* Reset all Pointer register
	pPDC2->PDC2_RPR  = 0 ;
	pPDC2->PDC2_RNPR = 0 ;
	pPDC2->PDC2_TPR  = 0 ;
	pPDC2->PDC2_TNPR = 0 ;

    //* Enables the RX and TX PDC transfer requests
    pPDC2->PDC2_PTCR = ( PDC_TXTEN | PDC_RXTEN) ;

//* End
}

//*----------------------------------------------------------------------------
//* Function Name       : at91_pdc2_close
//* Object              : Disable an PDC.
//* Input Parameters    : <pdc2_pt> = PDC2 Descriptor pointer
//* Output Parameters   : none
//* Functions called    : none
//*----------------------------------------------------------------------------
void at91_pdc2_close ( AT91PS_PDC2 pPDC2)
//* Begin
{

	//* Stop PDC
	pPDC2->PDC2_PTCR = ( PDC_RXTDIS | PDC_TXTDIS );

	//* Reset all Counter register
	pPDC2->PDC2_RCR  = 0 ;
	pPDC2->PDC2_RNCR = 0 ;
	pPDC2->PDC2_TCR  = 0 ;
	pPDC2->PDC2_TNCR = 0 ;

	//* Reset all Pointer register
	pPDC2->PDC2_RPR  = 0 ;
	pPDC2->PDC2_RNPR = 0 ;
	pPDC2->PDC2_TPR  = 0 ;
	pPDC2->PDC2_TNPR = 0 ;

//* End
}

//*----------------------------------------------------------------------------
//* Function Name       : at91_pdc2_get_status
//* Object              : Read the Status Register of an PDC2.
//* Input Parameters    : <pdc2_pt> = PDC Descriptor pointer
//* Output Parameters   : PDC2_PTSR Status Register
//* Functions called    : none
//*----------------------------------------------------------------------------
u_int at91_pdc2_get_status ( AT91PS_PDC2 pPDC2  )
//* Begin
{
    //* Return the Control Status Register Value
    return (pPDC2->PDC2_PTSR ) ;

//* End
}

//*----------------------------------------------------------------------------
//* Function Name       : at91_pdc2_trig_cmd
//* Object              : Set the Control register bit
//* Input Parameters    : <pdc2_pt> = PDC Descriptor pointer
//*                     : <cmd>      = command mask
//* Output Parameters   : none
//* Functions called    : none
//*----------------------------------------------------------------------------
void at91_pdc2_trig_cmd ( AT91PS_PDC2 pPDC2, u_int cmd )
//* Begin
{
    //* Write the command in the Control Register
    pPDC2->PDC2_PTCR = cmd ;

//* End
}

//*----------------------------------------------------------------------------
//* Function Name       : at91_pdc2_send
//* Object              : Set pointers and counters for send frame
//* Input Parameters    : <pdc2_pt> = PDC Descriptor pointer
//*                     : <data_pt> = Data descriptor
//* Output Parameters   : none
//* Functions called    : none
//*----------------------------------------------------------------------------
void at91_pdc2_send ( AT91PS_PDC2 pPDC2, PdcDataDesc *data_pt )
//* Begin
{
	//* Set Pointers register
	pPDC2->PDC2_TPR  = (at91_reg) data_pt->transmit_pt ;
	pPDC2->PDC2_TNPR = (at91_reg) data_pt->transmit_next_pt;

	//* Set Counters register
	pPDC2->PDC2_TCR  = data_pt->transmit_count;
	pPDC2->PDC2_TNCR = data_pt->transmit_next_count ;

//* End
}

//*----------------------------------------------------------------------------
//* Function Name       : at91_pdc2_receive
//* Object              : Set pointers and counters for receive frame
//* Input Parameters    : <pdc2_pt> = PDC Descriptor pointer
//*                     : <data_pt> = Data descriptor
//* Output Parameters   : none
//* Functions called    : none
//*----------------------------------------------------------------------------
void at91_pdc2_receive ( AT91PS_PDC2 pPDC2, PdcDataDesc *data_pt )
//* Begin
{
	//* Set Pointers register
	pPDC2->PDC2_RPR  = (at91_reg) data_pt->receiver_pt ;
	pPDC2->PDC2_RNPR = (at91_reg) data_pt->receiver_next_pt ;

	//* Set Counters register
	pPDC2->PDC2_RCR  =  data_pt->receiver_count ;
	pPDC2->PDC2_RNCR =  data_pt->receiver_next_count ;

//* End
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -