From: Martin Mares Date: Fri, 29 Jun 2018 21:22:11 +0000 (+0200) Subject: More I2C debugging X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;ds=sidebyside;h=abb212223d07a11a335151a64e111d8a670e93f5;p=home-hw.git More I2C debugging --- diff --git a/Inc/usb.h b/Inc/usb.h index 6d5eaf4..2aea056 100644 --- a/Inc/usb.h +++ b/Inc/usb.h @@ -2,7 +2,7 @@ #define USB_SELF_POWERED #define USB_NUM_CONFIGURATIONS 1 -#define USB_DEBUG +#undef USB_DEBUG /*** USB state structure ***/ diff --git a/Inc/util.h b/Inc/util.h index 6772a50..827cc9c 100644 --- a/Inc/util.h +++ b/Inc/util.h @@ -24,7 +24,7 @@ static inline void put_u16_le(byte *p, u16 x) // debug.c -#undef DEBUG_SEMIHOSTING +#define DEBUG_SEMIHOSTING void debug_printf(const char *fmt, ...); void debug_puts(const char *s); diff --git a/Src/bmp085.c b/Src/bmp085.c index 76f548f..76c6481 100644 --- a/Src/bmp085.c +++ b/Src/bmp085.c @@ -23,7 +23,7 @@ static uint bmp_read(uint reg, uint bytes) LL_I2C_GenerateStartCondition(I2C1); while (!LL_I2C_IsActiveFlag_SB(I2C1)) ; - LL_I2C_AcknowledgeNextData(I2C1, LL_I2C_ACK); + LL_I2C_DisableBitPOS(I2C1); LL_I2C_TransmitData8(I2C1, 0xef); while (!LL_I2C_IsActiveFlag_ADDR(I2C1)) ; @@ -41,6 +41,7 @@ static uint bmp_read(uint reg, uint bytes) } else if (bytes == 2) { + LL_I2C_EnableBitPOS(I2C1); LL_I2C_ClearFlag_ADDR(I2C1); LL_I2C_AcknowledgeNextData(I2C1, LL_I2C_NACK); while (!LL_I2C_IsActiveFlag_BTF(I2C1)) @@ -51,24 +52,31 @@ static uint bmp_read(uint reg, uint bytes) } else { + LL_I2C_AcknowledgeNextData(I2C1, LL_I2C_ACK); LL_I2C_ClearFlag_ADDR(I2C2); uint d = 0; for (uint i=0; i> 8; tx_packet[1] = adjusted_temp & 0xff; @@ -160,13 +169,6 @@ int main(void) // debug_printf("Counter = %d\n", cnt); // display_counter(cnt); - static byte led_state; - if (led_state) - LL_GPIO_SetOutputPin(LED_GPIO_Port, LED_Pin); - else - LL_GPIO_ResetOutputPin(LED_GPIO_Port, LED_Pin); - led_state ^= 1; - __WFI(); /* USER CODE END WHILE */