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

📄 lib_at91sam7x256.h

📁 CANopen 协议栈源码 ,实现基本的CANopen 协议
💻 H
📖 第 1 页 / 共 5 页
字号:
//* \brief Test if the next transfer descriptor has been moved to the current td//*----------------------------------------------------------------------------__inline int AT91F_PDC_IsNextRxEmpty ( // \return return 1 if transfer is complete	AT91PS_PDC pPDC )       // \arg pointer to a PDC controller{	return !(pPDC->PDC_RNCR);}//*----------------------------------------------------------------------------//* \fn    AT91F_PDC_Open//* \brief Open PDC: disable TX and RX reset transfer descriptors, re-enable RX and TX//*----------------------------------------------------------------------------__inline void AT91F_PDC_Open (	AT91PS_PDC pPDC)       // \arg pointer to a PDC controller{    //* Disable the RX and TX PDC transfer requests	AT91F_PDC_DisableRx(pPDC);	AT91F_PDC_DisableTx(pPDC);	//* Reset all Counter register Next buffer first	AT91F_PDC_SetNextTx(pPDC, (char *) 0, 0);	AT91F_PDC_SetNextRx(pPDC, (char *) 0, 0);	AT91F_PDC_SetTx(pPDC, (char *) 0, 0);	AT91F_PDC_SetRx(pPDC, (char *) 0, 0);    //* Enable the RX and TX PDC transfer requests	AT91F_PDC_EnableRx(pPDC);	AT91F_PDC_EnableTx(pPDC);}//*----------------------------------------------------------------------------//* \fn    AT91F_PDC_Close//* \brief Close PDC: disable TX and RX reset transfer descriptors//*----------------------------------------------------------------------------__inline void AT91F_PDC_Close (	AT91PS_PDC pPDC)       // \arg pointer to a PDC controller{    //* Disable the RX and TX PDC transfer requests	AT91F_PDC_DisableRx(pPDC);	AT91F_PDC_DisableTx(pPDC);	//* Reset all Counter register Next buffer first	AT91F_PDC_SetNextTx(pPDC, (char *) 0, 0);	AT91F_PDC_SetNextRx(pPDC, (char *) 0, 0);	AT91F_PDC_SetTx(pPDC, (char *) 0, 0);	AT91F_PDC_SetRx(pPDC, (char *) 0, 0);}//*----------------------------------------------------------------------------//* \fn    AT91F_PDC_SendFrame//* \brief Close PDC: disable TX and RX reset transfer descriptors//*----------------------------------------------------------------------------__inline unsigned int AT91F_PDC_SendFrame(	AT91PS_PDC pPDC,	char *pBuffer,	unsigned int szBuffer,	char *pNextBuffer,	unsigned int szNextBuffer ){	if (AT91F_PDC_IsTxEmpty(pPDC)) {		//* Buffer and next buffer can be initialized		AT91F_PDC_SetTx(pPDC, pBuffer, szBuffer);		AT91F_PDC_SetNextTx(pPDC, pNextBuffer, szNextBuffer);		return 2;	}	else if (AT91F_PDC_IsNextTxEmpty(pPDC)) {		//* Only one buffer can be initialized		AT91F_PDC_SetNextTx(pPDC, pBuffer, szBuffer);		return 1;	}	else {		//* All buffer are in use...		return 0;	}}//*----------------------------------------------------------------------------//* \fn    AT91F_PDC_ReceiveFrame//* \brief Close PDC: disable TX and RX reset transfer descriptors//*----------------------------------------------------------------------------__inline unsigned int AT91F_PDC_ReceiveFrame (	AT91PS_PDC pPDC,	char *pBuffer,	unsigned int szBuffer,	char *pNextBuffer,	unsigned int szNextBuffer ){	if (AT91F_PDC_IsRxEmpty(pPDC)) {		//* Buffer and next buffer can be initialized		AT91F_PDC_SetRx(pPDC, pBuffer, szBuffer);		AT91F_PDC_SetNextRx(pPDC, pNextBuffer, szNextBuffer);		return 2;	}	else if (AT91F_PDC_IsNextRxEmpty(pPDC)) {		//* Only one buffer can be initialized		AT91F_PDC_SetNextRx(pPDC, pBuffer, szBuffer);		return 1;	}	else {		//* All buffer are in use...		return 0;	}}/* *****************************************************************************                SOFTWARE API FOR DBGU   ***************************************************************************** *///*----------------------------------------------------------------------------//* \fn    AT91F_DBGU_InterruptEnable//* \brief Enable DBGU Interrupt//*----------------------------------------------------------------------------__inline void AT91F_DBGU_InterruptEnable(        AT91PS_DBGU pDbgu,   // \arg  pointer to a DBGU controller        unsigned int flag) // \arg  dbgu interrupt to be enabled{        pDbgu->DBGU_IER = flag;}//*----------------------------------------------------------------------------//* \fn    AT91F_DBGU_InterruptDisable//* \brief Disable DBGU Interrupt//*----------------------------------------------------------------------------__inline void AT91F_DBGU_InterruptDisable(        AT91PS_DBGU pDbgu,   // \arg  pointer to a DBGU controller        unsigned int flag) // \arg  dbgu interrupt to be disabled{        pDbgu->DBGU_IDR = flag;}//*----------------------------------------------------------------------------//* \fn    AT91F_DBGU_GetInterruptMaskStatus//* \brief Return DBGU Interrupt Mask Status//*----------------------------------------------------------------------------__inline unsigned int AT91F_DBGU_GetInterruptMaskStatus( // \return DBGU Interrupt Mask Status        AT91PS_DBGU pDbgu) // \arg  pointer to a DBGU controller{        return pDbgu->DBGU_IMR;}//*----------------------------------------------------------------------------//* \fn    AT91F_DBGU_IsInterruptMasked//* \brief Test if DBGU Interrupt is Masked//*----------------------------------------------------------------------------__inline int AT91F_DBGU_IsInterruptMasked(        AT91PS_DBGU pDbgu,   // \arg  pointer to a DBGU controller        unsigned int flag) // \arg  flag to be tested{        return (AT91F_DBGU_GetInterruptMaskStatus(pDbgu) & flag);}/* *****************************************************************************                SOFTWARE API FOR PIO   ***************************************************************************** *///*----------------------------------------------------------------------------//* \fn    AT91F_PIO_CfgPeriph//* \brief Enable pins to be drived by peripheral//*----------------------------------------------------------------------------__inline void AT91F_PIO_CfgPeriph(	AT91PS_PIO pPio,             // \arg pointer to a PIO controller	unsigned int periphAEnable,  // \arg PERIPH A to enable	unsigned int periphBEnable)  // \arg PERIPH B to enable{	pPio->PIO_ASR = periphAEnable;	pPio->PIO_BSR = periphBEnable;	pPio->PIO_PDR = (periphAEnable | periphBEnable); // Set in Periph mode}//*----------------------------------------------------------------------------//* \fn    AT91F_PIO_CfgOutput//* \brief Enable PIO in output mode//*----------------------------------------------------------------------------__inline void AT91F_PIO_CfgOutput(	AT91PS_PIO pPio,             // \arg pointer to a PIO controller	unsigned int pioEnable)      // \arg PIO to be enabled{	pPio->PIO_PER = pioEnable; // Set in PIO mode	pPio->PIO_OER = pioEnable; // Configure in Output}//*----------------------------------------------------------------------------//* \fn    AT91F_PIO_CfgInput//* \brief Enable PIO in input mode//*----------------------------------------------------------------------------__inline void AT91F_PIO_CfgInput(	AT91PS_PIO pPio,             // \arg pointer to a PIO controller	unsigned int inputEnable)      // \arg PIO to be enabled{	// Disable output	pPio->PIO_ODR  = inputEnable;	pPio->PIO_PER  = inputEnable;}//*----------------------------------------------------------------------------//* \fn    AT91F_PIO_CfgOpendrain//* \brief Configure PIO in open drain//*----------------------------------------------------------------------------__inline void AT91F_PIO_CfgOpendrain(	AT91PS_PIO pPio,             // \arg pointer to a PIO controller	unsigned int multiDrvEnable) // \arg pio to be configured in open drain{	// Configure the multi-drive option	pPio->PIO_MDDR = ~multiDrvEnable;	pPio->PIO_MDER = multiDrvEnable;}//*----------------------------------------------------------------------------//* \fn    AT91F_PIO_CfgPullup//* \brief Enable pullup on PIO//*----------------------------------------------------------------------------__inline void AT91F_PIO_CfgPullup(	AT91PS_PIO pPio,             // \arg pointer to a PIO controller	unsigned int pullupEnable)   // \arg enable pullup on PIO{		// Connect or not Pullup	pPio->PIO_PPUDR = ~pullupEnable;	pPio->PIO_PPUER = pullupEnable;}//*----------------------------------------------------------------------------//* \fn    AT91F_PIO_CfgDirectDrive//* \brief Enable direct drive on PIO//*----------------------------------------------------------------------------__inline void AT91F_PIO_CfgDirectDrive(	AT91PS_PIO pPio,             // \arg pointer to a PIO controller	unsigned int directDrive)    // \arg PIO to be configured with direct drive{	// Configure the Direct Drive	pPio->PIO_OWDR  = ~directDrive;	pPio->PIO_OWER  = directDrive;}//*----------------------------------------------------------------------------//* \fn    AT91F_PIO_CfgInputFilter//* \brief Enable input filter on input PIO//*----------------------------------------------------------------------------__inline void AT91F_PIO_CfgInputFilter(	AT91PS_PIO pPio,             // \arg pointer to a PIO controller	unsigned int inputFilter)    // \arg PIO to be configured with input filter{	// Configure the Direct Drive	pPio->PIO_IFDR  = ~inputFilter;	pPio->PIO_IFER  = inputFilter;}//*----------------------------------------------------------------------------//* \fn    AT91F_PIO_GetInput//* \brief Return PIO input value//*----------------------------------------------------------------------------__inline unsigned int AT91F_PIO_GetInput( // \return PIO input	AT91PS_PIO pPio) // \arg  pointer to a PIO controller{	return pPio->PIO_PDSR;}//*----------------------------------------------------------------------------//* \fn    AT91F_PIO_IsInputSet//* \brief Test if PIO is input flag is active//*----------------------------------------------------------------------------__inline int AT91F_PIO_IsInputSet(	AT91PS_PIO pPio,   // \arg  pointer to a PIO controller	unsigned int flag) // \arg  flag to be tested{	return (AT91F_PIO_GetInput(pPio) & flag);}//*----------------------------------------------------------------------------//* \fn    AT91F_PIO_SetOutput//* \brief Set to 1 output PIO//*----------------------------------------------------------------------------__inline void AT91F_PIO_SetOutput(	AT91PS_PIO pPio,   // \arg  pointer to a PIO controller	unsigned int flag) // \arg  output to be set{	pPio->PIO_SODR = flag;}//*----------------------------------------------------------------------------//* \fn    AT91F_PIO_ClearOutput//* \brief Set to 0 output PIO//*----------------------------------------------------------------------------__inline void AT91F_PIO_ClearOutput(	AT91PS_PIO pPio,   // \arg  pointer to a PIO controller	unsigned int flag) // \arg  output to be cleared{	pPio->PIO_CODR = flag;}//*----------------------------------------------------------------------------//* \fn    AT91F_PIO_ForceOutput//* \brief Force output when Direct drive option is enabled//*----------------------------------------------------------------------------__inline void AT91F_PIO_ForceOutput(	AT91PS_PIO pPio,   // \arg  pointer to a PIO controller	unsigned int flag) // \arg  output to be forced{	pPio->PIO_ODSR = flag;}//*----------------------------------------------------------------------------//* \fn    AT91F_PIO_Enable//* \brief Enable PIO//*----------------------------------------------------------------------------__inline void AT91F_PIO_Enable(        AT91PS_PIO pPio,   // \arg  pointer to a PIO controller        unsigned int flag) // \arg  pio to be enabled{        pPio->PIO_PER = flag;}//*----------------------------------------------------------------------------//* \fn    AT91F_PIO_Disable//* \brief Disable PIO//*----------------------------------------------------------------------------__inline void AT91F_PIO_Disable(        AT91PS_PIO pPio,   // \arg  pointer to a PIO controller        unsigned int flag) // \arg  pio to be disabled{        pPio->PIO_PDR = flag;}//*----------------------------------------------------------------------------//* \fn    AT91F_PIO_GetStatus//* \brief Return PIO Status//*----------------------------------------------------------------------------__inline unsigned int AT91F_PIO_GetStatus( // \return PIO Status        AT91PS_PIO pPio) // \arg  pointer to a PIO controller{        return pPio->PIO_PSR;

⌨️ 快捷键说明

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