12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- #include "stm32l0xx_hal.h"
- #include "xa_shield.h"
- #include "x-nucleo-6180xa1.h"
- #include <stdio.h>
- #include <stdio.h>
- I2C_HandleTypeDef i2_handle;
- volatile uint32_t tick_cnt;
- static void wait_ms(int ms);
- // PB8, PB9 - I2C_1
- // Inputs GPIO_MODE_IT_RISING : PA4 = INTB , PA5 = INTL, PA10 = INTR, PB0 = INT
- void xa_shield(void)
- {
- XNUCLEO6180XA1_GPIO_Init();
- XNUCLEO6180XA1_I2C1_Init(&i2_handle);
-
- }
- //
- extern "C" {
- void HAL_SYSTICK_Callback(void)
- {
- tick_cnt++;
- }
- }
- //
- void wait_ms(int ms)
- {
- uint32_t start, now;
- int dif;
- start = tick_cnt;
-
- do {
- now = tick_cnt;
- dif = now - start;
- }
- while (dif < ms);
- }
- // Нужно определить функцию задержки из x-nucleo-6180xa1
- void XNUCLEO6180XA1_WaitMilliSec(int SegDelayMs)
- {
- //wait_ms(SegDelayMs);
- HAL_Delay(SegDelayMs);
- }
- //
- void xa_shield_test(void)
- {
- char str[6] = {"Err_"};
- //static uint8_t cnt = 0;
-
- //
- //int ret = XNUCLEO6180XA1_GetSwitch();
- //printf("Switch state: %u\r\n", ret);
-
- //sprintf(str, "%u", cnt);
-
- XNUCLEO6180XA1_DisplayString(str, 1);
-
-
-
- //HAL_Delay(1000);
- }
|