LightSensor.c 463 B

1234567891011121314151617181920
  1. #include "stm32f10x.h" // Device header
  2. void LightSensor_Init(void)
  3. {
  4. RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE);
  5. GPIO_InitTypeDef GPIO_InitStructure;
  6. GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;
  7. GPIO_InitStructure.GPIO_Pin = GPIO_Pin_13;
  8. GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  9. GPIO_Init(GPIOB, &GPIO_InitStructure);
  10. }
  11. uint8_t GetLightSensor_Status(void)
  12. {
  13. return GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_13);
  14. }