резисторами к + питания ?
Так правильно?:
настройка:
Код: Выделить всё
GPIO_InitTypeDef GPIO_InitStructure;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE); //включаем тактирование
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1; //светодиоды D1 b D2
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; //обычный выход
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOB, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6 | GPIO_Pin_7; //софтварная I2C
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_OD; //?
GPIO_Init(GPIOB, &GPIO_InitStructure);Код: Выделить всё
GPIO_SetBits(GPIOB, GPIO_Pin_6); //высокий уровень
GPIO_ResetBits(GPIOB, GPIO_Pin_6);//низкий уровень
Код: Выделить всё
bool r_bit = (GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_7));


