diff options
-rw-r--r-- | src/fsm/i2c.c | 19 | ||||
-rw-r--r-- | src/fsm/main.c | 2 |
2 files changed, 11 insertions, 10 deletions
diff --git a/src/fsm/i2c.c b/src/fsm/i2c.c index 8398b58..133d740 100644 --- a/src/fsm/i2c.c +++ b/src/fsm/i2c.c @@ -32,6 +32,10 @@ #include "task.h" #include "semphr.h" +const uint16_t GPIOB_PIN_SDA = GPIO_Pin_9; +const uint16_t GPIOB_PIN_SCL = GPIO_Pin_6; + + static int i2c_init_done = 0; static int i2c_error = 0; @@ -60,27 +64,24 @@ static void i2c_recover_from_lockup(void) // Configure I2C SCL and SDA pins. GPIO_InitTypeDef GPIO_InitStructure; - GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6 | GPIO_Pin_9; + GPIO_InitStructure.GPIO_Pin = GPIOB_PIN_SCL | GPIOB_PIN_SDA; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT; GPIO_InitStructure.GPIO_OType = GPIO_OType_OD; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP; GPIO_Init(GPIOB, &GPIO_InitStructure); - const uint16_t pin_sda = GPIO_Pin_9; - const uint16_t pin_scl = GPIO_Pin_6; - const TickType_t delay = 5 / portTICK_PERIOD_MS; - GPIO_SetBits(GPIOB, pin_sda | pin_scl); + GPIO_SetBits(GPIOB, GPIOB_PIN_SDA | GPIOB_PIN_SCL); vTaskDelay(delay); I2C_SoftwareResetCmd(I2Cx, ENABLE); for (int i = 0; i < 10; i++) { - GPIO_ResetBits(GPIOB, pin_scl); + GPIO_ResetBits(GPIOB, GPIOB_PIN_SCL); vTaskDelay(delay); - GPIO_SetBits(GPIOB, pin_scl); + GPIO_SetBits(GPIOB, GPIOB_PIN_SCL); vTaskDelay(delay); } @@ -91,11 +92,11 @@ static void i2c_device_init(void) { // Configure I2C SCL and SDA pins. GPIO_InitTypeDef GPIO_InitStructure; - GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6 | GPIO_Pin_9; + GPIO_InitStructure.GPIO_Pin = GPIOB_PIN_SCL | GPIOB_PIN_SDA; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; GPIO_InitStructure.GPIO_OType = GPIO_OType_OD; - GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; + GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP; GPIO_Init(GPIOB, &GPIO_InitStructure); GPIO_PinAFConfig(GPIOB, GPIO_PinSource6, GPIO_AF_I2C1); diff --git a/src/fsm/main.c b/src/fsm/main.c index 786e2ad..040899e 100644 --- a/src/fsm/main.c +++ b/src/fsm/main.c @@ -224,7 +224,7 @@ static void gps_monit_task(void *pvParameters) gps_utctime(&gps_time); - if (gps_time.sec % 10 > 5) { + if (gps_time.sec % 4 >= 2) { GPIO_SetBits(GPIOD, GPIOD_BOARD_LED_BLUE); } else { |