AnsweredAssumed Answered

STM32f103x read deep switch problem

Question asked by nowrozi.daniel on Apr 20, 2015
Latest reply on Apr 20, 2015 by Clive One
Hello everybody, i m a newbe to stm32 programming i wrote below function for read first 7 pins of GPIOA but its value only return 0x4444444 for GPIOA->CRL , it doesent matter if i change deep config whats wrong in my configuration?

// this functions read deepswitch (8)
uint8_t readBoardAddressEnd()
{
        RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);
       
        GPIO_InitTypeDef gpioStruct;
        GPIO_StructInit(&gpioStruct);
         
        gpioStruct.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3 | GPIO_Pin_4;
        gpioStruct.GPIO_Mode = GPIO_Mode_IN_FLOATING;
        GPIO_Init(GPIOA , &gpioStruct);
     
        assert_param(IS_GPIO_ALL_PERIPH(GPIOA));
        assert_param(IS_GET_GPIO_PIN(GPIO_Pin_4) |
                                IS_GET_GPIO_PIN(GPIO_Pin_3) |
                                IS_GET_GPIO_PIN(GPIO_Pin_2) |
                                IS_GET_GPIO_PIN(GPIO_Pin_1) |
                                IS_GET_GPIO_PIN(GPIO_Pin_0));
                 
        board_address = GPIOA->CRL & ((uint8_t)0x00011111);
     
        GPIO_StructInit(&gpioStruct);
         
        gpioStruct.GPIO_Pin = GPIO_Pin_2 | GPIO_Pin_3;
        gpioStruct.GPIO_Mode = GPIO_Mode_IPD;
        GPIO_Init(GPIOC , &gpioStruct);
         
        board_address = board_address << 1;
        board_address |= GPIO_ReadInputDataBit(GPIOC, GPIO_Pin_3);
        board_address = board_address << 1;
        board_address |= GPIO_ReadInputDataBit(GPIOC, GPIO_Pin_2);
         
                 
        return board_address;
}
 

Outcomes