2015-07-24 07:31 PM
I am just getting started with the Cortex (and C.)
I would like to access an entire GPIO port but cannot find a way to address the port(GPIOF.) I see the HAL functions for addressing the bits but not the entire port.Here is the code and error message: const uint16_t MotorDriveStateTable[8]={0x0040,0x0060,0x0020,0x00A0,0x0080,0x0090,0x0010,0x0050}; uint16_t MotorDriveStateCount; /* Infinite loop */ while (1) { /*EXPERIMENTAL CODE */ HAL_GPIO_TogglePin(GPIOF, GPIO_PIN_4);(error) *GPIOF &= 0x0ff0f;(error) *GPIOF |= MotorDriveStateTable[MotorDriveStateCount]; MotorDriveStateCount++; }/*end while (1) */-Error[Pe031]: expression must have integral type Would any one be willing to help?2015-07-25 10:29 AM
GPIOF->ODR &= 0x0ff0f;
GPIOF->ODR |= MotorDriveStateTable[MotorDriveStateCount];2015-07-25 01:44 PM
Thank you for the lesson Clive.
I, finally, found the port definitions in stm32f051x8.h./** * @brief General Purpose I/O */typedef struct{ __IO uint32_t MODER; /*!< GPIO port mode register, Address offset: 0x00 */ __IO uint16_t OTYPER; /*!< GPIO port output type register, Address offset: 0x04 */ uint16_t RESERVED0; /*!< Reserved, 0x06 */ __IO uint32_t OSPEEDR; /*!< GPIO port output speed register, Address offset: 0x08 */ __IO uint32_t PUPDR; /*!< GPIO port pull-up/pull-down register, Address offset: 0x0C */ __IO uint16_t IDR; /*!< GPIO port input data register, Address offset: 0x10 */ uint16_t RESERVED1; /*!< Reserved, 0x12 */ __IO uint16_t ODR; /*!< GPIO port output data register, Address offset: 0x14 */ uint16_t RESERVED2; /*!< Reserved, 0x16 */ __IO uint16_t BSRRL; /*!< GPIO port bit set/reset low register, Address offset: 0x18 */ __IO uint16_t BSRRH; /*!< GPIO port bit set/reset high register, Address offset: 0x1A */ __IO uint32_t LCKR; /*!< GPIO port configuration lock register, Address offset: 0x1C */ __IO uint32_t AFR[2]; /*!< GPIO alternate function low register, Address offset: 0x20-0x24 */ __IO uint16_t BRR; /*!< GPIO bit reset register, Address offset: 0x28 */ uint16_t RESERVED3; /*!< Reserved, 0x2A */}GPIO_TypeDef;and then:#define GPIOF ((GPIO_TypeDef *) GPIOF_BASE)