اطلاعیه

Collapse
No announcement yet.

مشکل با تابع set_PinFunc در برنامه نویسی cmsis

Collapse
X
 
  • فیلتر
  • زمان
  • Show
Clear All
new posts

    مشکل با تابع set_PinFunc در برنامه نویسی cmsis

    سلام.
    من دارم با توابع cmsis برای lpc1768 کد می زنم . میخواستم پین سل رو کنترل کنم و نمیخواستم که از تابع درختیی که تو کتابخانه هست استفاده کنم واسه همین با اومدم که از این کد استفاده کنم
    کد:
     set_PinFunc ( 0, 2, PINSEL_FUNC_1);
    اما این کد اجرا نمی شده . وقتی دکمه rebuild رو می زنم با این ارو مواجه می شم که میگه undefined symbol .....
    و میزنه که target not created
    وقتی هم که دکمه translate رو می زنم این وارنینگ رو میده که function set_pinfunc declare implicitly
    حالا نمی دونم مشکل دقیقا کجاست .
    البته وقتی از تابع درختی استفاده می کنم مشکلی نیست

    #2
    پاسخ : مشکل با تابع set_PinFunc در برنامه نویسی cmsis

    سلام،
    به خاطر این هست که این تابع static تعریف شده. شما برای این که بتونی از این تابع بیرون از فایل خودش استفاده کنی باید از این حالت خارجش کنی.
    هر انسانی که احساس بی نیازی کند سرکش و طغیان گر می شود...

    دیدگاه


      #3
      پاسخ : مشکل با تابع set_PinFunc در برنامه نویسی cmsis

      حقیقتش من تازه دارم با keil و به زبون c کد می زنم . وخیلی درست متوجه منظورت نشدم.
      این تابع توی کتابخونه cmsis نوشته شده و من ننوشتم و فقط ازش استفاده کردم. این کتابخونه هم برای این نوشته شده که بتونیم ازش تو کدمون استفاده کنیم. اگه درست متوجه شده باشم این تابع دینامیکه و اصلا دلیلی نداره کسی که کتابخونه cmsis رو می نویسه یه تابع استاتیک توش بگذاره که فقط از تو خود کتابخونه قابل فراخوانی باشه . کد های کتابخونه هم به این شرحه
      کد:
      /**********************************************************************
      * $Id$		lpc17xx_pinsel.h				2010-05-21
      *//**
      * @file		lpc17xx_pinsel.h
      * @brief	Contains all macro definitions and function prototypes
      * 			support for Pin connect block firmware library on LPC17xx
      * @version	2.0
      * @date		21. May. 2010
      * @author	NXP MCU SW Application Team
      *
      * Copyright(C) 2010, NXP Semiconductor
      * All rights reserved.
      *
      ***********************************************************************
      * Software that is described herein is for illustrative purposes only
      * which provides customers with programming information regarding the
      * products. This software is supplied "AS IS" without any warranties.
      * NXP Semiconductors assumes no responsibility or liability for the
      * use of the software, conveys no license or title under any patent,
      * copyright, or mask work right to the product. NXP Semiconductors
      * reserves the right to make changes in the software without
      * notification. NXP Semiconductors also make no representation or
      * warranty that such application will be suitable for the specified
      * use without further testing or modification.
      **********************************************************************/
      
      /* Peripheral group ----------------------------------------------------------- */
      /** @defgroup PINSEL PINSEL (Pin Selection)
       * @ingroup LPC1700CMSIS_FwLib_Drivers
       * @{
       */
      
      #ifndef LPC17XX_PINSEL_H_
      #define LPC17XX_PINSEL_H_
      
      /* Includes ------------------------------------------------------------------- */
      #include "lpc17xx.h"
      #include "lpc_types.h"
      
      #ifdef __cplusplus
      extern "C"
      {
      #endif
      
      /* Public Macros -------------------------------------------------------------- */
      /** @defgroup PINSEL_Public_Macros PINSEL Public Macros
       * @{
       */
      
      /*********************************************************************//**
       *!< Macros define for PORT Selection
       ***********************************************************************/
      #define PINSEL_PORT_0 	((0))	/**< PORT 0*/
      #define PINSEL_PORT_1 	((1))	/**< PORT 1*/
      #define PINSEL_PORT_2 	((2))	/**< PORT 2*/
      #define PINSEL_PORT_3 	((3))	/**< PORT 3*/
      #define PINSEL_PORT_4 	((4))	/**< PORT 4*/
      
      /***********************************************************************
       * Macros define for Pin Function selection
       **********************************************************************/
      #define PINSEL_FUNC_0	((0))	/**< default function*/
      #define PINSEL_FUNC_1	((1))	/**< first alternate function*/
      #define PINSEL_FUNC_2	((2))	/**< second alternate function*/
      #define PINSEL_FUNC_3	((3))	/**< third or reserved alternate function*/
      
      /***********************************************************************
       * Macros define for Pin Number of Port
       **********************************************************************/
      #define PINSEL_PIN_0 	((0)) 	/**< Pin 0 */
      #define PINSEL_PIN_1 	((1)) 	/**< Pin 1 */
      #define PINSEL_PIN_2 	((2)) 	/**< Pin 2 */
      #define PINSEL_PIN_3 	((3)) 	/**< Pin 3 */
      #define PINSEL_PIN_4 	((4)) 	/**< Pin 4 */
      #define PINSEL_PIN_5 	((5)) 	/**< Pin 5 */
      #define PINSEL_PIN_6 	((6)) 	/**< Pin 6 */
      #define PINSEL_PIN_7 	((7)) 	/**< Pin 7 */
      #define PINSEL_PIN_8 	((8)) 	/**< Pin 8 */
      #define PINSEL_PIN_9 	((9)) 	/**< Pin 9 */
      #define PINSEL_PIN_10 	((10)) 	/**< Pin 10 */
      #define PINSEL_PIN_11 	((11)) 	/**< Pin 11 */
      #define PINSEL_PIN_12 	((12)) 	/**< Pin 12 */
      #define PINSEL_PIN_13 	((13)) 	/**< Pin 13 */
      #define PINSEL_PIN_14 	((14)) 	/**< Pin 14 */
      #define PINSEL_PIN_15 	((15)) 	/**< Pin 15 */
      #define PINSEL_PIN_16 	((16)) 	/**< Pin 16 */
      #define PINSEL_PIN_17 	((17)) 	/**< Pin 17 */
      #define PINSEL_PIN_18 	((18)) 	/**< Pin 18 */
      #define PINSEL_PIN_19 	((19)) 	/**< Pin 19 */
      #define PINSEL_PIN_20 	((20)) 	/**< Pin 20 */
      #define PINSEL_PIN_21 	((21)) 	/**< Pin 21 */
      #define PINSEL_PIN_22 	((22)) 	/**< Pin 22 */
      #define PINSEL_PIN_23 	((23)) 	/**< Pin 23 */
      #define PINSEL_PIN_24 	((24)) 	/**< Pin 24 */
      #define PINSEL_PIN_25 	((25)) 	/**< Pin 25 */
      #define PINSEL_PIN_26 	((26)) 	/**< Pin 26 */
      #define PINSEL_PIN_27 	((27)) 	/**< Pin 27 */
      #define PINSEL_PIN_28 	((28)) 	/**< Pin 28 */
      #define PINSEL_PIN_29 	((29)) 	/**< Pin 29 */
      #define PINSEL_PIN_30 	((30)) 	/**< Pin 30 */
      #define PINSEL_PIN_31 	((31)) 	/**< Pin 31 */
      
      /***********************************************************************
       * Macros define for Pin mode
       **********************************************************************/
      #define PINSEL_PINMODE_PULLUP		((0))	/**< Internal pull-up resistor*/
      #define PINSEL_PINMODE_TRISTATE 	((2))	/**< Tri-state */
      #define PINSEL_PINMODE_PULLDOWN 	((3)) 	/**< Internal pull-down resistor */
      
      /***********************************************************************
       * Macros define for Pin mode (normal/open drain)
       **********************************************************************/
      #define	PINSEL_PINMODE_NORMAL		((0))	/**< Pin is in the normal (not open drain) mode.*/
      #define	PINSEL_PINMODE_OPENDRAIN	((1)) 	/**< Pin is in the open drain mode */
      
      /***********************************************************************
       * Macros define for I2C mode
       ***********************************************************************/
      #define	PINSEL_I2C_Normal_Mode		((0))	/**< The standard drive mode */
      #define	PINSEL_I2C_Fast_Mode		((1)) 	/**< Fast Mode Plus drive mode */
      
      /**
       * @}
       */
      
      /* Private Macros ------------------------------------------------------------- */
      /** @defgroup PINSEL_Private_Macros PINSEL Private Macros
       * @{
       */
      
      /* Pin selection define */
      /* I2C Pin Configuration register bit description */
      #define PINSEL_I2CPADCFG_SDADRV0 	_BIT(0) /**< Drive mode control for the SDA0 pin, P0.27 */
      #define PINSEL_I2CPADCFG_SDAI2C0	_BIT(1) /**< I2C mode control for the SDA0 pin, P0.27 */
      #define PINSEL_I2CPADCFG_SCLDRV0	_BIT(2) /**< Drive mode control for the SCL0 pin, P0.28 */
      #define PINSEL_I2CPADCFG_SCLI2C0	_BIT(3) /**< I2C mode control for the SCL0 pin, P0.28 */
      
      /**
       * @}
       */
      
      
      /* Public Types --------------------------------------------------------------- */
      /** @defgroup PINSEL_Public_Types PINSEL Public Types
       * @{
       */
      
      /** @brief Pin configuration structure */
      typedef struct
      {
      	uint8_t Portnum;	/**< Port Number, should be PINSEL_PORT_x,
      						where x should be in range from 0 to 4 */
      	uint8_t Pinnum;		/**< Pin Number, should be PINSEL_PIN_x,
      						where x should be in range from 0 to 31 */
      	uint8_t Funcnum;	/**< Function Number, should be PINSEL_FUNC_x,
      						where x should be in range from 0 to 3 */
      	uint8_t Pinmode;	/**< Pin Mode, should be:
      						- PINSEL_PINMODE_PULLUP: Internal pull-up resistor
      						- PINSEL_PINMODE_TRISTATE: Tri-state
      						- PINSEL_PINMODE_PULLDOWN: Internal pull-down resistor */
      	uint8_t OpenDrain;	/**< OpenDrain mode, should be:
      						- PINSEL_PINMODE_NORMAL: Pin is in the normal (not open drain) mode
      						- PINSEL_PINMODE_OPENDRAIN: Pin is in the open drain mode */
      } PINSEL_CFG_Type;
      
      /**
       * @}
       */
      
      
      /* Public Functions ----------------------------------------------------------- */
      /** @defgroup PINSEL_Public_Functions PINSEL Public Functions
       * @{
       */
      
      void PINSEL_ConfigPin(PINSEL_CFG_Type *PinCfg);
      void PINSEL_ConfigTraceFunc (FunctionalState NewState);
      void PINSEL_SetI2C0Pins(uint8_t i2cPinMode, FunctionalState filterSlewRateEnable);
      
      
      /**
       * @}
       */
      
      
      #ifdef __cplusplus
      }
      #endif
      
      #endif /* LPC17XX_PINSEL_H_ */
      
      /**
       * @}
       */
      
      /* --------------------------------- End Of File ------------------------------ */
      این فایل .h بود
      و این پایینی هم فایل .c هست که تو هر دوش این تابع ذکر شده

      کد:
      /**********************************************************************
      * $Id$		lpc17xx_pinsel.c				2010-05-21
      *//**
      * @file		lpc17xx_pinsel.c
      * @brief	Contains all functions support for Pin connect block firmware
      * 			library on LPC17xx
      * @version	2.0
      * @date		21. May. 2010
      * @author	NXP MCU SW Application Team
      *
      * Copyright(C) 2010, NXP Semiconductor
      * All rights reserved.
      *
      ***********************************************************************
      * Software that is described herein is for illustrative purposes only
      * which provides customers with programming information regarding the
      * products. This software is supplied "AS IS" without any warranties.
      * NXP Semiconductors assumes no responsibility or liability for the
      * use of the software, conveys no license or title under any patent,
      * copyright, or mask work right to the product. NXP Semiconductors
      * reserves the right to make changes in the software without
      * notification. NXP Semiconductors also make no representation or
      * warranty that such application will be suitable for the specified
      * use without further testing or modification.
      **********************************************************************/
      
      /* Peripheral group ----------------------------------------------------------- */
      /** @addtogroup PINSEL
       * @{
       */
      
      /* Includes ------------------------------------------------------------------- */
      #include "lpc17xx_pinsel.h"
      
      /* Public Functions ----------------------------------------------------------- */
      
      static void set_PinFunc ( uint8_t portnum, uint8_t pinnum, uint8_t funcnum);
      static void set_ResistorMode ( uint8_t portnum, uint8_t pinnum, uint8_t modenum);
      static void set_OpenDrainMode( uint8_t portnum, uint8_t pinnum, uint8_t modenum);
      
      /*********************************************************************//**
       * @brief 		Setup the pin selection function
       * @param[in]	portnum PORT number,
       * 				should be one of the following:
       * 				- PINSEL_PORT_0	: Port 0
       * 				- PINSEL_PORT_1	: Port 1
       * 				- PINSEL_PORT_2	: Port 2
       * 				- PINSEL_PORT_3	: Port 3
       *
       * @param[in]	pinnum	Pin number,
       * 				should be one of the following:
      				- PINSEL_PIN_0 : Pin 0
      				- PINSEL_PIN_1 : Pin 1
      				- PINSEL_PIN_2 : Pin 2
      				- PINSEL_PIN_3 : Pin 3
      				- PINSEL_PIN_4 : Pin 4
      				- PINSEL_PIN_5 : Pin 5
      				- PINSEL_PIN_6 : Pin 6
      				- PINSEL_PIN_7 : Pin 7
      				- PINSEL_PIN_8 : Pin 8
      				- PINSEL_PIN_9 : Pin 9
      				- PINSEL_PIN_10 : Pin 10
      				- PINSEL_PIN_11 : Pin 11
      				- PINSEL_PIN_12 : Pin 12
      				- PINSEL_PIN_13 : Pin 13
      				- PINSEL_PIN_14 : Pin 14
      				- PINSEL_PIN_15 : Pin 15
      				- PINSEL_PIN_16 : Pin 16
      				- PINSEL_PIN_17 : Pin 17
      				- PINSEL_PIN_18 : Pin 18
      				- PINSEL_PIN_19 : Pin 19
      				- PINSEL_PIN_20 : Pin 20
      				- PINSEL_PIN_21 : Pin 21
      				- PINSEL_PIN_22 : Pin 22
      				- PINSEL_PIN_23 : Pin 23
      				- PINSEL_PIN_24 : Pin 24
      				- PINSEL_PIN_25 : Pin 25
      				- PINSEL_PIN_26 : Pin 26
      				- PINSEL_PIN_27 : Pin 27
      				- PINSEL_PIN_28 : Pin 28
      				- PINSEL_PIN_29 : Pin 29
      				- PINSEL_PIN_30 : Pin 30
      				- PINSEL_PIN_31 : Pin 31
      
       * @param[in] 	funcnum Function number,
       * 				should be one of the following:
       *				- PINSEL_FUNC_0 : default function
       *				- PINSEL_FUNC_1 : first alternate function
       *				- PINSEL_FUNC_2 : second alternate function
       *				- PINSEL_FUNC_3 : third alternate function
       *
       * @return 		None
       **********************************************************************/
      static void set_PinFunc ( uint8_t portnum, uint8_t pinnum, uint8_t funcnum)
      {
      	uint32_t pinnum_t = pinnum;
      	uint32_t pinselreg_idx = 2 * portnum;
      	uint32_t *pPinCon = (uint32_t *)&LPC_PINCON->PINSEL0;
      
      	if (pinnum_t >= 16) {
      		pinnum_t -= 16;
      		pinselreg_idx++;
      	}
      	*(uint32_t *)(pPinCon + pinselreg_idx) &= ~(0x03UL << (pinnum_t * 2));
      	*(uint32_t *)(pPinCon + pinselreg_idx) |= ((uint32_t)funcnum) << (pinnum_t * 2);
      }
      
      /*********************************************************************//**
       * @brief 		Setup resistor mode for each pin
       * @param[in]	portnum PORT number,
       * 				should be one of the following:
       * 				- PINSEL_PORT_0	: Port 0
       * 				- PINSEL_PORT_1	: Port 1
       * 				- PINSEL_PORT_2	: Port 2
       * 				- PINSEL_PORT_3	: Port 3
       * @param[in]	pinnum	Pin number,
       * 				should be one of the following:
      				- PINSEL_PIN_0 : Pin 0
      				- PINSEL_PIN_1 : Pin 1
      				- PINSEL_PIN_2 : Pin 2
      				- PINSEL_PIN_3 : Pin 3
      				- PINSEL_PIN_4 : Pin 4
      				- PINSEL_PIN_5 : Pin 5
      				- PINSEL_PIN_6 : Pin 6
      				- PINSEL_PIN_7 : Pin 7
      				- PINSEL_PIN_8 : Pin 8
      				- PINSEL_PIN_9 : Pin 9
      				- PINSEL_PIN_10 : Pin 10
      				- PINSEL_PIN_11 : Pin 11
      				- PINSEL_PIN_12 : Pin 12
      				- PINSEL_PIN_13 : Pin 13
      				- PINSEL_PIN_14 : Pin 14
      				- PINSEL_PIN_15 : Pin 15
      				- PINSEL_PIN_16 : Pin 16
      				- PINSEL_PIN_17 : Pin 17
      				- PINSEL_PIN_18 : Pin 18
      				- PINSEL_PIN_19 : Pin 19
      				- PINSEL_PIN_20 : Pin 20
      				- PINSEL_PIN_21 : Pin 21
      				- PINSEL_PIN_22 : Pin 22
      				- PINSEL_PIN_23 : Pin 23
      				- PINSEL_PIN_24 : Pin 24
      				- PINSEL_PIN_25 : Pin 25
      				- PINSEL_PIN_26 : Pin 26
      				- PINSEL_PIN_27 : Pin 27
      				- PINSEL_PIN_28 : Pin 28
      				- PINSEL_PIN_29 : Pin 29
      				- PINSEL_PIN_30 : Pin 30
      				- PINSEL_PIN_31 : Pin 31
      
       * @param[in] 	modenum: Mode number,
       * 				should be one of the following:
      				- PINSEL_PINMODE_PULLUP	: Internal pull-up resistor
      				- PINSEL_PINMODE_TRISTATE : Tri-state
      				- PINSEL_PINMODE_PULLDOWN : Internal pull-down resistor
      
       * @return 		None
       **********************************************************************/
      void set_ResistorMode ( uint8_t portnum, uint8_t pinnum, uint8_t modenum)
      {
      	uint32_t pinnum_t = pinnum;
      	uint32_t pinmodereg_idx = 2 * portnum;
      	uint32_t *pPinCon = (uint32_t *)&LPC_PINCON->PINMODE0;
      
      	if (pinnum_t >= 16) {
      		pinnum_t -= 16;
      		pinmodereg_idx++ ;
      	}
      
      	*(uint32_t *)(pPinCon + pinmodereg_idx) &= ~(0x03UL << (pinnum_t * 2));
      	*(uint32_t *)(pPinCon + pinmodereg_idx) |= ((uint32_t)modenum) << (pinnum_t * 2);
      }
      
      /*********************************************************************//**
       * @brief 		Setup Open drain mode for each pin
       * @param[in]	portnum PORT number,
       * 				should be one of the following:
       * 				- PINSEL_PORT_0	: Port 0
       * 				- PINSEL_PORT_1	: Port 1
       * 				- PINSEL_PORT_2	: Port 2
       * 				- PINSEL_PORT_3	: Port 3
       *
       * @param[in]	pinnum	Pin number,
       * 				should be one of the following:
      				- PINSEL_PIN_0 : Pin 0
      				- PINSEL_PIN_1 : Pin 1
      				- PINSEL_PIN_2 : Pin 2
      				- PINSEL_PIN_3 : Pin 3
      				- PINSEL_PIN_4 : Pin 4
      				- PINSEL_PIN_5 : Pin 5
      				- PINSEL_PIN_6 : Pin 6
      				- PINSEL_PIN_7 : Pin 7
      				- PINSEL_PIN_8 : Pin 8
      				- PINSEL_PIN_9 : Pin 9
      				- PINSEL_PIN_10 : Pin 10
      				- PINSEL_PIN_11 : Pin 11
      				- PINSEL_PIN_12 : Pin 12
      				- PINSEL_PIN_13 : Pin 13
      				- PINSEL_PIN_14 : Pin 14
      				- PINSEL_PIN_15 : Pin 15
      				- PINSEL_PIN_16 : Pin 16
      				- PINSEL_PIN_17 : Pin 17
      				- PINSEL_PIN_18 : Pin 18
      				- PINSEL_PIN_19 : Pin 19
      				- PINSEL_PIN_20 : Pin 20
      				- PINSEL_PIN_21 : Pin 21
      				- PINSEL_PIN_22 : Pin 22
      				- PINSEL_PIN_23 : Pin 23
      				- PINSEL_PIN_24 : Pin 24
      				- PINSEL_PIN_25 : Pin 25
      				- PINSEL_PIN_26 : Pin 26
      				- PINSEL_PIN_27 : Pin 27
      				- PINSEL_PIN_28 : Pin 28
      				- PINSEL_PIN_29 : Pin 29
      				- PINSEL_PIN_30 : Pin 30
      				- PINSEL_PIN_31 : Pin 31
      
       * @param[in]	modenum Open drain mode number,
       * 				should be one of the following:
       * 				- PINSEL_PINMODE_NORMAL : Pin is in the normal (not open drain) mode
       * 				- PINSEL_PINMODE_OPENDRAIN : Pin is in the open drain mode
       *
       * @return 		None
       **********************************************************************/
      void set_OpenDrainMode( uint8_t portnum, uint8_t pinnum, uint8_t modenum)
      {
      	uint32_t *pPinCon = (uint32_t *)&LPC_PINCON->PINMODE_OD0;
      
      	if (modenum == PINSEL_PINMODE_OPENDRAIN){
      		*(uint32_t *)(pPinCon + portnum) |= (0x01UL << pinnum);
      	} else {
      		*(uint32_t *)(pPinCon + portnum) &= ~(0x01UL << pinnum);
      	}
      }
      
      /* End of Public Functions ---------------------------------------------------- */
      
      /* Public Functions ----------------------------------------------------------- */
      /** @addtogroup PINSEL_Public_Functions
       * @{
       */
      /*********************************************************************//**
       * @brief 		Configure trace function
       * @param[in] 	NewState State of the Trace function configuration,
       * 				should be one of the following:
       * 				- ENABLE : Enable Trace Function
       * 				- DISABLE : Disable Trace Function
       *
       * @return 		None
       **********************************************************************/
      void PINSEL_ConfigTraceFunc(FunctionalState NewState)
      {
      	if (NewState == ENABLE) {
      		LPC_PINCON->PINSEL10 |= (0x01UL << 3);
      	} else if (NewState == DISABLE) {
      		LPC_PINCON->PINSEL10 &= ~(0x01UL << 3);
      	}
      }
      
      /*********************************************************************//**
       * @brief 		Setup I2C0 pins
       * @param[in]	i2cPinMode I2C pin mode,
       * 				should be one of the following:
       * 				- PINSEL_I2C_Normal_Mode : The standard drive mode
       * 				- PINSEL_I2C_Fast_Mode : Fast Mode Plus drive mode
       *
       * @param[in]	filterSlewRateEnable should be:
       * 				- ENABLE: Enable filter and slew rate.
       * 				- DISABLE: Disable filter and slew rate.
       *
       * @return 		None
       **********************************************************************/
      void PINSEL_SetI2C0Pins(uint8_t i2cPinMode, FunctionalState filterSlewRateEnable)
      {
      	uint32_t regVal;
      
      	if (i2cPinMode == PINSEL_I2C_Fast_Mode){
      		regVal = PINSEL_I2CPADCFG_SCLDRV0 | PINSEL_I2CPADCFG_SDADRV0;
      	}
      
      	if (filterSlewRateEnable == DISABLE){
      		regVal = PINSEL_I2CPADCFG_SCLI2C0 | PINSEL_I2CPADCFG_SDAI2C0;
      	}
      	LPC_PINCON->I2CPADCFG = regVal;
      }
      
      
      /*********************************************************************//**
       * @brief 		Configure Pin corresponding to specified parameters passed
       * 				in the PinCfg
       * @param[in]	PinCfg	Pointer to a PINSEL_CFG_Type structure
       *          that contains the configuration information for the
       *          specified pin.
       * @return 		None
       **********************************************************************/
      void PINSEL_ConfigPin(PINSEL_CFG_Type *PinCfg)
      {
      	set_PinFunc(PinCfg->Portnum, PinCfg->Pinnum, PinCfg->Funcnum);
      	set_ResistorMode(PinCfg->Portnum, PinCfg->Pinnum, PinCfg->Pinmode);
      	set_OpenDrainMode(PinCfg->Portnum, PinCfg->Pinnum, PinCfg->OpenDrain);
      }
      
      
      /**
       * @}
       */
      
      /**
       * @}
       */
      
      /* --------------------------------- End Of File ------------------------------ */

      دیدگاه


        #4
        پاسخ : مشکل با تابع set_PinFunc در برنامه نویسی cmsis

        در فایل .h نگاه کنید، تابع مورد نظر شما وجود نداره، این به چه معنی؟ یعنی اون تابع برای دسترسی داخلی کتابخونه هست نه برای همه...
        خب حالا شما می خوای ازش استفاده کنی، باید چه کار کنی؟ باید اون رو هم برای دسترسی عمومی تعریف کنید.
        برای این کار اگر در کتابخونه .c نگاه کنید می بینید که این جوری این تابع تعریف شده:
        کد:
        static void set_PinFunc ( uint8_t portnum, uint8_t pinnum, uint8_t funcnum)
        شما static رو از اول تعریفش بردارید.
        هر انسانی که احساس بی نیازی کند سرکش و طغیان گر می شود...

        دیدگاه


          #5
          پاسخ : مشکل با تابع set_PinFunc در برنامه نویسی cmsis

          ممنون دوست عزیز . با پاک کردن کلمه static مشکل ارور حل شد .
          فقط چند تا سوال تو ان زمینه
          آیا دیگه نیازی نیست تو فایل .h اون رو تعریف کنم ؟
          2-موقع کامپایل کردن یه وارنینگ میده با این مضمون (البته از بعضی توابع دیگه هم که استفاده می کنم همین وارنینگ رو میده) function set_pinfunc declare implicitly
          این وارنینگ برای چیه و مشکلی ایجاد نمی کنه؟

          دیدگاه


            #6
            پاسخ : مشکل با تابع set_PinFunc در برنامه نویسی cmsis

            اگر در فایل .h تعریفش نکنی یه وارنینگ به بقیه وارنینگ ها اضافه میشه.
            این وارنینگی هم که می گیرید مربوط به ورودی های توابع هست. معمولا مشکل ساز نمیشه اگر ورودی ها درست باشند.
            هر انسانی که احساس بی نیازی کند سرکش و طغیان گر می شود...

            دیدگاه

            لطفا صبر کنید...
            X