diff --git a/.cproject b/.cproject
index f9ebd03..7b75a00 100644
--- a/.cproject
+++ b/.cproject
@@ -90,7 +90,7 @@
-
+
@@ -112,11 +112,11 @@
-
+
+
-
@@ -209,11 +209,11 @@
-
+
+
-
diff --git a/.settings/language.settings.xml b/.settings/language.settings.xml
index c2a6735..f0a485f 100644
--- a/.settings/language.settings.xml
+++ b/.settings/language.settings.xml
@@ -5,7 +5,7 @@
-
+
@@ -16,7 +16,7 @@
-
+
diff --git a/Core/Inc/can.h b/Core/Inc/can.h
deleted file mode 100644
index c38bb03..0000000
--- a/Core/Inc/can.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/* USER CODE BEGIN Header */
-/**
- ******************************************************************************
- * @file can.h
- * @brief This file contains all the function prototypes for
- * the can.c file
- ******************************************************************************
- * @attention
- *
- * Copyright (c) 2023 STMicroelectronics.
- * All rights reserved.
- *
- * This software is licensed under terms that can be found in the LICENSE file
- * in the root directory of this software component.
- * If no LICENSE file comes with this software, it is provided AS-IS.
- *
- ******************************************************************************
- */
-/* USER CODE END Header */
-/* Define to prevent recursive inclusion -------------------------------------*/
-#ifndef __CAN_H__
-#define __CAN_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* Includes ------------------------------------------------------------------*/
-#include "main.h"
-
-/* USER CODE BEGIN Includes */
-
-/* USER CODE END Includes */
-
-extern CAN_HandleTypeDef hcan1;
-
-/* USER CODE BEGIN Private defines */
-
-/* USER CODE END Private defines */
-
-void MX_CAN1_Init(void);
-
-/* USER CODE BEGIN Prototypes */
-
-/* USER CODE END Prototypes */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __CAN_H__ */
-
diff --git a/Core/Inc/i2c.h b/Core/Inc/i2c.h
deleted file mode 100644
index a91bf62..0000000
--- a/Core/Inc/i2c.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/* USER CODE BEGIN Header */
-/**
- ******************************************************************************
- * @file i2c.h
- * @brief This file contains all the function prototypes for
- * the i2c.c file
- ******************************************************************************
- * @attention
- *
- * Copyright (c) 2023 STMicroelectronics.
- * All rights reserved.
- *
- * This software is licensed under terms that can be found in the LICENSE file
- * in the root directory of this software component.
- * If no LICENSE file comes with this software, it is provided AS-IS.
- *
- ******************************************************************************
- */
-/* USER CODE END Header */
-/* Define to prevent recursive inclusion -------------------------------------*/
-#ifndef __I2C_H__
-#define __I2C_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* Includes ------------------------------------------------------------------*/
-#include "main.h"
-
-/* USER CODE BEGIN Includes */
-
-/* USER CODE END Includes */
-
-extern I2C_HandleTypeDef hi2c1;
-
-/* USER CODE BEGIN Private defines */
-
-/* USER CODE END Private defines */
-
-void MX_I2C1_Init(void);
-
-/* USER CODE BEGIN Prototypes */
-
-/* USER CODE END Prototypes */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __I2C_H__ */
-
diff --git a/Core/Inc/spi.h b/Core/Inc/spi.h
deleted file mode 100644
index f40913c..0000000
--- a/Core/Inc/spi.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/* USER CODE BEGIN Header */
-/**
- ******************************************************************************
- * @file spi.h
- * @brief This file contains all the function prototypes for
- * the spi.c file
- ******************************************************************************
- * @attention
- *
- * Copyright (c) 2023 STMicroelectronics.
- * All rights reserved.
- *
- * This software is licensed under terms that can be found in the LICENSE file
- * in the root directory of this software component.
- * If no LICENSE file comes with this software, it is provided AS-IS.
- *
- ******************************************************************************
- */
-/* USER CODE END Header */
-/* Define to prevent recursive inclusion -------------------------------------*/
-#ifndef __SPI_H__
-#define __SPI_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* Includes ------------------------------------------------------------------*/
-#include "main.h"
-
-/* USER CODE BEGIN Includes */
-
-/* USER CODE END Includes */
-
-extern SPI_HandleTypeDef hspi1;
-
-/* USER CODE BEGIN Private defines */
-
-/* USER CODE END Private defines */
-
-void MX_SPI1_Init(void);
-
-/* USER CODE BEGIN Prototypes */
-
-/* USER CODE END Prototypes */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __SPI_H__ */
-
diff --git a/Core/Src/can.c b/Core/Src/can.c
deleted file mode 100644
index d58ac66..0000000
--- a/Core/Src/can.c
+++ /dev/null
@@ -1,131 +0,0 @@
-/* USER CODE BEGIN Header */
-/**
- ******************************************************************************
- * @file can.c
- * @brief This file provides code for the configuration
- * of the CAN instances.
- ******************************************************************************
- * @attention
- *
- * Copyright (c) 2023 STMicroelectronics.
- * All rights reserved.
- *
- * This software is licensed under terms that can be found in the LICENSE file
- * in the root directory of this software component.
- * If no LICENSE file comes with this software, it is provided AS-IS.
- *
- ******************************************************************************
- */
-/* USER CODE END Header */
-/* Includes ------------------------------------------------------------------*/
-#include "can.h"
-
-/* USER CODE BEGIN 0 */
-
-/* USER CODE END 0 */
-
-CAN_HandleTypeDef hcan1;
-
-/* CAN1 init function */
-void MX_CAN1_Init(void)
-{
-
- /* USER CODE BEGIN CAN1_Init 0 */
-
- /* USER CODE END CAN1_Init 0 */
-
- /* USER CODE BEGIN CAN1_Init 1 */
-
- /* USER CODE END CAN1_Init 1 */
- hcan1.Instance = CAN1;
- hcan1.Init.Prescaler = 4;
- hcan1.Init.Mode = CAN_MODE_NORMAL;
- hcan1.Init.SyncJumpWidth = CAN_SJW_3TQ;
- hcan1.Init.TimeSeg1 = CAN_BS1_14TQ;
- hcan1.Init.TimeSeg2 = CAN_BS2_3TQ;
- hcan1.Init.TimeTriggeredMode = ENABLE;
- hcan1.Init.AutoBusOff = ENABLE;
- hcan1.Init.AutoWakeUp = DISABLE;
- hcan1.Init.AutoRetransmission = ENABLE;
- hcan1.Init.ReceiveFifoLocked = ENABLE;
- hcan1.Init.TransmitFifoPriority = DISABLE;
- if (HAL_CAN_Init(&hcan1) != HAL_OK)
- {
- Error_Handler();
- }
- /* USER CODE BEGIN CAN1_Init 2 */
-
- /* USER CODE END CAN1_Init 2 */
-
-}
-
-void HAL_CAN_MspInit(CAN_HandleTypeDef* canHandle)
-{
-
- GPIO_InitTypeDef GPIO_InitStruct = {0};
- if(canHandle->Instance==CAN1)
- {
- /* USER CODE BEGIN CAN1_MspInit 0 */
-
- /* USER CODE END CAN1_MspInit 0 */
- /* CAN1 clock enable */
- __HAL_RCC_CAN1_CLK_ENABLE();
-
- __HAL_RCC_GPIOA_CLK_ENABLE();
- /**CAN1 GPIO Configuration
- PA11 ------> CAN1_RX
- PA12 ------> CAN1_TX
- */
- GPIO_InitStruct.Pin = GPIO_PIN_11|GPIO_PIN_12;
- GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
- GPIO_InitStruct.Pull = GPIO_NOPULL;
- GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
- GPIO_InitStruct.Alternate = GPIO_AF9_CAN1;
- HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
-
- /* CAN1 interrupt Init */
- HAL_NVIC_SetPriority(CAN1_TX_IRQn, 5, 0);
- HAL_NVIC_EnableIRQ(CAN1_TX_IRQn);
- HAL_NVIC_SetPriority(CAN1_RX0_IRQn, 5, 0);
- HAL_NVIC_EnableIRQ(CAN1_RX0_IRQn);
- HAL_NVIC_SetPriority(CAN1_RX1_IRQn, 5, 0);
- HAL_NVIC_EnableIRQ(CAN1_RX1_IRQn);
- HAL_NVIC_SetPriority(CAN1_SCE_IRQn, 5, 0);
- HAL_NVIC_EnableIRQ(CAN1_SCE_IRQn);
- /* USER CODE BEGIN CAN1_MspInit 1 */
-
- /* USER CODE END CAN1_MspInit 1 */
- }
-}
-
-void HAL_CAN_MspDeInit(CAN_HandleTypeDef* canHandle)
-{
-
- if(canHandle->Instance==CAN1)
- {
- /* USER CODE BEGIN CAN1_MspDeInit 0 */
-
- /* USER CODE END CAN1_MspDeInit 0 */
- /* Peripheral clock disable */
- __HAL_RCC_CAN1_CLK_DISABLE();
-
- /**CAN1 GPIO Configuration
- PA11 ------> CAN1_RX
- PA12 ------> CAN1_TX
- */
- HAL_GPIO_DeInit(GPIOA, GPIO_PIN_11|GPIO_PIN_12);
-
- /* CAN1 interrupt Deinit */
- HAL_NVIC_DisableIRQ(CAN1_TX_IRQn);
- HAL_NVIC_DisableIRQ(CAN1_RX0_IRQn);
- HAL_NVIC_DisableIRQ(CAN1_RX1_IRQn);
- HAL_NVIC_DisableIRQ(CAN1_SCE_IRQn);
- /* USER CODE BEGIN CAN1_MspDeInit 1 */
-
- /* USER CODE END CAN1_MspDeInit 1 */
- }
-}
-
-/* USER CODE BEGIN 1 */
-
-/* USER CODE END 1 */
diff --git a/Core/Src/i2c.c b/Core/Src/i2c.c
deleted file mode 100644
index d71aa64..0000000
--- a/Core/Src/i2c.c
+++ /dev/null
@@ -1,116 +0,0 @@
-/* USER CODE BEGIN Header */
-/**
- ******************************************************************************
- * @file i2c.c
- * @brief This file provides code for the configuration
- * of the I2C instances.
- ******************************************************************************
- * @attention
- *
- * Copyright (c) 2023 STMicroelectronics.
- * All rights reserved.
- *
- * This software is licensed under terms that can be found in the LICENSE file
- * in the root directory of this software component.
- * If no LICENSE file comes with this software, it is provided AS-IS.
- *
- ******************************************************************************
- */
-/* USER CODE END Header */
-/* Includes ------------------------------------------------------------------*/
-#include "i2c.h"
-
-/* USER CODE BEGIN 0 */
-
-/* USER CODE END 0 */
-
-I2C_HandleTypeDef hi2c1;
-
-/* I2C1 init function */
-void MX_I2C1_Init(void)
-{
-
- /* USER CODE BEGIN I2C1_Init 0 */
-
- /* USER CODE END I2C1_Init 0 */
-
- /* USER CODE BEGIN I2C1_Init 1 */
-
- /* USER CODE END I2C1_Init 1 */
- hi2c1.Instance = I2C1;
- hi2c1.Init.ClockSpeed = 100000;
- hi2c1.Init.DutyCycle = I2C_DUTYCYCLE_2;
- hi2c1.Init.OwnAddress1 = 0;
- hi2c1.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT;
- hi2c1.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE;
- hi2c1.Init.OwnAddress2 = 0;
- hi2c1.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE;
- hi2c1.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE;
- if (HAL_I2C_Init(&hi2c1) != HAL_OK)
- {
- Error_Handler();
- }
- /* USER CODE BEGIN I2C1_Init 2 */
-
- /* USER CODE END I2C1_Init 2 */
-
-}
-
-void HAL_I2C_MspInit(I2C_HandleTypeDef* i2cHandle)
-{
-
- GPIO_InitTypeDef GPIO_InitStruct = {0};
- if(i2cHandle->Instance==I2C1)
- {
- /* USER CODE BEGIN I2C1_MspInit 0 */
-
- /* USER CODE END I2C1_MspInit 0 */
-
- __HAL_RCC_GPIOB_CLK_ENABLE();
- /**I2C1 GPIO Configuration
- PB6 ------> I2C1_SCL
- PB7 ------> I2C1_SDA
- */
- GPIO_InitStruct.Pin = GPIO_PIN_6|GPIO_PIN_7;
- GPIO_InitStruct.Mode = GPIO_MODE_AF_OD;
- GPIO_InitStruct.Pull = GPIO_NOPULL;
- GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
- GPIO_InitStruct.Alternate = GPIO_AF4_I2C1;
- HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
-
- /* I2C1 clock enable */
- __HAL_RCC_I2C1_CLK_ENABLE();
- /* USER CODE BEGIN I2C1_MspInit 1 */
-
- /* USER CODE END I2C1_MspInit 1 */
- }
-}
-
-void HAL_I2C_MspDeInit(I2C_HandleTypeDef* i2cHandle)
-{
-
- if(i2cHandle->Instance==I2C1)
- {
- /* USER CODE BEGIN I2C1_MspDeInit 0 */
-
- /* USER CODE END I2C1_MspDeInit 0 */
- /* Peripheral clock disable */
- __HAL_RCC_I2C1_CLK_DISABLE();
-
- /**I2C1 GPIO Configuration
- PB6 ------> I2C1_SCL
- PB7 ------> I2C1_SDA
- */
- HAL_GPIO_DeInit(GPIOB, GPIO_PIN_6);
-
- HAL_GPIO_DeInit(GPIOB, GPIO_PIN_7);
-
- /* USER CODE BEGIN I2C1_MspDeInit 1 */
-
- /* USER CODE END I2C1_MspDeInit 1 */
- }
-}
-
-/* USER CODE BEGIN 1 */
-
-/* USER CODE END 1 */
diff --git a/Core/Src/spi.c b/Core/Src/spi.c
deleted file mode 100644
index 6c5281b..0000000
--- a/Core/Src/spi.c
+++ /dev/null
@@ -1,119 +0,0 @@
-/* USER CODE BEGIN Header */
-/**
- ******************************************************************************
- * @file spi.c
- * @brief This file provides code for the configuration
- * of the SPI instances.
- ******************************************************************************
- * @attention
- *
- * Copyright (c) 2023 STMicroelectronics.
- * All rights reserved.
- *
- * This software is licensed under terms that can be found in the LICENSE file
- * in the root directory of this software component.
- * If no LICENSE file comes with this software, it is provided AS-IS.
- *
- ******************************************************************************
- */
-/* USER CODE END Header */
-/* Includes ------------------------------------------------------------------*/
-#include "spi.h"
-
-/* USER CODE BEGIN 0 */
-
-/* USER CODE END 0 */
-
-SPI_HandleTypeDef hspi1;
-
-/* SPI1 init function */
-void MX_SPI1_Init(void)
-{
-
- /* USER CODE BEGIN SPI1_Init 0 */
-
- /* USER CODE END SPI1_Init 0 */
-
- /* USER CODE BEGIN SPI1_Init 1 */
-
- /* USER CODE END SPI1_Init 1 */
- hspi1.Instance = SPI1;
- hspi1.Init.Mode = SPI_MODE_MASTER;
- hspi1.Init.Direction = SPI_DIRECTION_2LINES;
- hspi1.Init.DataSize = SPI_DATASIZE_8BIT;
- hspi1.Init.CLKPolarity = SPI_POLARITY_LOW;
- hspi1.Init.CLKPhase = SPI_PHASE_1EDGE;
- hspi1.Init.NSS = SPI_NSS_SOFT;
- hspi1.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_128;
- hspi1.Init.FirstBit = SPI_FIRSTBIT_MSB;
- hspi1.Init.TIMode = SPI_TIMODE_DISABLE;
- hspi1.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;
- hspi1.Init.CRCPolynomial = 10;
- if (HAL_SPI_Init(&hspi1) != HAL_OK)
- {
- Error_Handler();
- }
- /* USER CODE BEGIN SPI1_Init 2 */
-
- /* USER CODE END SPI1_Init 2 */
-
-}
-
-void HAL_SPI_MspInit(SPI_HandleTypeDef* spiHandle)
-{
-
- GPIO_InitTypeDef GPIO_InitStruct = {0};
- if(spiHandle->Instance==SPI1)
- {
- /* USER CODE BEGIN SPI1_MspInit 0 */
-
- /* USER CODE END SPI1_MspInit 0 */
- /* SPI1 clock enable */
- __HAL_RCC_SPI1_CLK_ENABLE();
-
- __HAL_RCC_GPIOA_CLK_ENABLE();
- /**SPI1 GPIO Configuration
- PA5 ------> SPI1_SCK
- PA6 ------> SPI1_MISO
- PA7 ------> SPI1_MOSI
- */
- GPIO_InitStruct.Pin = GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7;
- GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
- GPIO_InitStruct.Pull = GPIO_NOPULL;
- GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
- GPIO_InitStruct.Alternate = GPIO_AF5_SPI1;
- HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
-
- /* USER CODE BEGIN SPI1_MspInit 1 */
-
- /* USER CODE END SPI1_MspInit 1 */
- }
-}
-
-void HAL_SPI_MspDeInit(SPI_HandleTypeDef* spiHandle)
-{
-
- if(spiHandle->Instance==SPI1)
- {
- /* USER CODE BEGIN SPI1_MspDeInit 0 */
-
- /* USER CODE END SPI1_MspDeInit 0 */
- /* Peripheral clock disable */
- __HAL_RCC_SPI1_CLK_DISABLE();
-
- /**SPI1 GPIO Configuration
- PA5 ------> SPI1_SCK
- PA6 ------> SPI1_MISO
- PA7 ------> SPI1_MOSI
- */
- HAL_GPIO_DeInit(GPIOA, GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7);
-
- /* USER CODE BEGIN SPI1_MspDeInit 1 */
-
- /* USER CODE END SPI1_MspDeInit 1 */
- }
-}
-
-/* USER CODE BEGIN 1 */
-
-/* USER CODE END 1 */
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..5e71c0d
--- /dev/null
+++ b/README.md
@@ -0,0 +1,22 @@
+```
+基础组件
+-------------------------
+1. 微秒定时器
+2. 网络端口
+3. 日志接口
+5. GPIO初始化中断处理
+6. 网络消息解析处理
+7. SPI读写
+8. 线程
+9. 按键检测
+-------------------------
+
+-------------------------
+凌云光项目之间共享基础组件
+-------------------------
+
+线程划分
+1. UDP接收消息和消息解析。
+2. 主线程循环点亮LED。
+3. 按键监听线程,按住回复出厂设置按键,重启设备,设备恢复出厂设置。
+```
\ No newline at end of file
diff --git a/iflytop_xsync/README.md b/iflytop_xsync/README.md
new file mode 100644
index 0000000..d5a256b
--- /dev/null
+++ b/iflytop_xsync/README.md
@@ -0,0 +1,8 @@
+```
+1. 微秒定时器 OK
+3. 日志接口 OK
+5. GPIO初始化中断处理 OK
+7. SPI读写
+8. 线程
+9. 按键检测
+```
\ No newline at end of file
diff --git a/iflytop_xsync/iflytop_xsync.h b/iflytop_xsync/iflytop_xsync.h
new file mode 100644
index 0000000..510e8db
--- /dev/null
+++ b/iflytop_xsync/iflytop_xsync.h
@@ -0,0 +1,14 @@
+#pragma once
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "iflytop_xsync/xs_basic.h"
+#include "iflytop_xsync/xs_delay.h"
+#include "iflytop_xsync/xs_gpio.h"
+#include "iflytop_xsync/xs_log.h"
+
+#ifdef __cplusplus
+}
+#endif
\ No newline at end of file
diff --git a/iflytop_xsync/pin.c b/iflytop_xsync/pin.c
new file mode 100644
index 0000000..34984c6
--- /dev/null
+++ b/iflytop_xsync/pin.c
@@ -0,0 +1,234 @@
+#include "pin.h"
+const char* pinname(Pin_t pin) {
+ switch (pin) {
+ case PinNull:
+ return "PinNull";
+ case PA0:
+ return "PA0";
+ case PA1:
+ return "PA1";
+ case PA2:
+ return "PA2";
+ case PA3:
+ return "PA3";
+ case PA4:
+ return "PA4";
+ case PA5:
+ return "PA5";
+ case PA6:
+ return "PA6";
+ case PA7:
+ return "PA7";
+ case PA8:
+ return "PA8";
+ case PA9:
+ return "PA9";
+ case PA10:
+ return "PA10";
+ case PA11:
+ return "PA11";
+ case PA12:
+ return "PA12";
+ case PA13:
+ return "PA13";
+ case PA14:
+ return "PA14";
+ case PA15:
+ return "PA15";
+ case PB0:
+ return "PB0";
+ case PB1:
+ return "PB1";
+ case PB2:
+ return "PB2";
+ case PB3:
+ return "PB3";
+ case PB4:
+ return "PB4";
+ case PB5:
+ return "PB5";
+ case PB6:
+ return "PB6";
+ case PB7:
+ return "PB7";
+ case PB8:
+ return "PB8";
+ case PB9:
+ return "PB9";
+ case PB10:
+ return "PB10";
+ case PB11:
+ return "PB11";
+ case PB12:
+ return "PB12";
+ case PB13:
+ return "PB13";
+ case PB14:
+ return "PB14";
+ case PB15:
+ return "PB15";
+ case PC0:
+ return "PC0";
+ case PC1:
+ return "PC1";
+ case PC2:
+ return "PC2";
+ case PC3:
+ return "PC3";
+ case PC4:
+ return "PC4";
+ case PC5:
+ return "PC5";
+ case PC6:
+ return "PC6";
+ case PC7:
+ return "PC7";
+ case PC8:
+ return "PC8";
+ case PC9:
+ return "PC9";
+ case PC10:
+ return "PC10";
+ case PC11:
+ return "PC11";
+ case PC12:
+ return "PC12";
+ case PC13:
+ return "PC13";
+ case PC14:
+ return "PC14";
+ case PC15:
+ return "PC15";
+ case PD0:
+ return "PD0";
+ case PD1:
+ return "PD1";
+ case PD2:
+ return "PD2";
+ case PD3:
+ return "PD3";
+ case PD4:
+ return "PD4";
+ case PD5:
+ return "PD5";
+ case PD6:
+ return "PD6";
+ case PD7:
+ return "PD7";
+ case PD8:
+ return "PD8";
+ case PD9:
+ return "PD9";
+ case PD10:
+ return "PD10";
+ case PD11:
+ return "PD11";
+ case PD12:
+ return "PD12";
+ case PD13:
+ return "PD13";
+ case PD14:
+ return "PD14";
+ case PD15:
+ return "PD15";
+ case PE0:
+ return "PE0";
+ case PE1:
+ return "PE1";
+ case PE2:
+ return "PE2";
+ case PE3:
+ return "PE3";
+ case PE4:
+ return "PE4";
+ case PE5:
+ return "PE5";
+ case PE6:
+ return "PE6";
+ case PE7:
+ return "PE7";
+ case PE8:
+ return "PE8";
+ case PE9:
+ return "PE9";
+ case PE10:
+ return "PE10";
+ case PE11:
+ return "PE11";
+ case PE12:
+ return "PE12";
+ case PE13:
+ return "PE13";
+ case PE14:
+ return "PE14";
+ case PE15:
+ return "PE15";
+ case PF0:
+ return "PF0";
+ case PF1:
+ return "PF1";
+ case PF2:
+ return "PF2";
+ case PF3:
+ return "PF3";
+ case PF4:
+ return "PF4";
+ case PF5:
+ return "PF5";
+ case PF6:
+ return "PF6";
+ case PF7:
+ return "PF7";
+ case PF8:
+ return "PF8";
+ case PF9:
+ return "PF9";
+ case PF10:
+ return "PF10";
+ case PF11:
+ return "PF11";
+ case PF12:
+ return "PF12";
+ case PF13:
+ return "PF13";
+ case PF14:
+ return "PF14";
+ case PF15:
+ return "PF15";
+ case PG0:
+ return "PG0";
+ case PG1:
+ return "PG1";
+ case PG2:
+ return "PG2";
+ case PG3:
+ return "PG3";
+ case PG4:
+ return "PG4";
+ case PG5:
+ return "PG5";
+ case PG6:
+ return "PG6";
+ case PG7:
+ return "PG7";
+ case PG8:
+ return "PG8";
+ case PG9:
+ return "PG9";
+ case PG10:
+ return "PG10";
+ case PG11:
+ return "PG11";
+ case PG12:
+ return "PG12";
+ case PG13:
+ return "PG13";
+ case PG14:
+ return "PG14";
+ case PG15:
+ return "PG15";
+ default:
+ break;
+ }
+ return "UNKNOWN_PIN";
+};
diff --git a/iflytop_xsync/pin.h b/iflytop_xsync/pin.h
new file mode 100644
index 0000000..1b44440
--- /dev/null
+++ b/iflytop_xsync/pin.h
@@ -0,0 +1,119 @@
+#pragma once
+
+typedef enum {
+ PinNull = 0,
+ PA0 = 0x10,
+ PA1,
+ PA2,
+ PA3,
+ PA4,
+ PA5,
+ PA6,
+ PA7,
+ PA8,
+ PA9,
+ PA10,
+ PA11,
+ PA12,
+ PA13,
+ PA14,
+ PA15,
+ PB0 = 0x20,
+ PB1,
+ PB2,
+ PB3,
+ PB4,
+ PB5,
+ PB6,
+ PB7,
+ PB8,
+ PB9,
+ PB10,
+ PB11,
+ PB12,
+ PB13,
+ PB14,
+ PB15,
+ PC0 = 0x30,
+ PC1,
+ PC2,
+ PC3,
+ PC4,
+ PC5,
+ PC6,
+ PC7,
+ PC8,
+ PC9,
+ PC10,
+ PC11,
+ PC12,
+ PC13,
+ PC14,
+ PC15,
+ PD0 = 0x40,
+ PD1,
+ PD2,
+ PD3,
+ PD4,
+ PD5,
+ PD6,
+ PD7,
+ PD8,
+ PD9,
+ PD10,
+ PD11,
+ PD12,
+ PD13,
+ PD14,
+ PD15,
+ PE0 = 0x50,
+ PE1,
+ PE2,
+ PE3,
+ PE4,
+ PE5,
+ PE6,
+ PE7,
+ PE8,
+ PE9,
+ PE10,
+ PE11,
+ PE12,
+ PE13,
+ PE14,
+ PE15,
+ PF0 = 0x60,
+ PF1,
+ PF2,
+ PF3,
+ PF4,
+ PF5,
+ PF6,
+ PF7,
+ PF8,
+ PF9,
+ PF10,
+ PF11,
+ PF12,
+ PF13,
+ PF14,
+ PF15,
+ PG0 = 0x70,
+ PG1,
+ PG2,
+ PG3,
+ PG4,
+ PG5,
+ PG6,
+ PG7,
+ PG8,
+ PG9,
+ PG10,
+ PG11,
+ PG12,
+ PG13,
+ PG14,
+ PG15,
+} Pin_t;
+
+const char* pinname(Pin_t pin);
\ No newline at end of file
diff --git a/iflytop_xsync/xs_basic.c b/iflytop_xsync/xs_basic.c
new file mode 100644
index 0000000..e69de29
diff --git a/iflytop_xsync/xs_basic.h b/iflytop_xsync/xs_basic.h
new file mode 100644
index 0000000..184b2e4
--- /dev/null
+++ b/iflytop_xsync/xs_basic.h
@@ -0,0 +1,9 @@
+#pragma once
+#include "main.h"
+//
+#include "project_configs.h"
+//
+#include "cmsis_os.h"
+//
+#include
+#include
diff --git a/iflytop_xsync/xs_delay.c b/iflytop_xsync/xs_delay.c
new file mode 100644
index 0000000..777fac0
--- /dev/null
+++ b/iflytop_xsync/xs_delay.c
@@ -0,0 +1,51 @@
+#include "xs_delay.h"
+
+#include "xs_basic.h"
+
+extern TIM_HandleTypeDef PC_SYS_DELAY_US_TIMER;
+
+static HAL_StatusTypeDef _HAL_TIM_Base_Start(TIM_HandleTypeDef* htim) __attribute__((optimize("O2")));
+static HAL_StatusTypeDef _HAL_TIM_Base_Stop(TIM_HandleTypeDef* htim) __attribute__((optimize("O2")));
+static HAL_StatusTypeDef _HAL_TIM_Base_Start(TIM_HandleTypeDef* htim) {
+ uint32_t tmpsmcr;
+ /* Check the TIM state */
+ if (htim->State != HAL_TIM_STATE_READY) {
+ return HAL_ERROR;
+ }
+ htim->State = HAL_TIM_STATE_BUSY;
+ if (IS_TIM_SLAVE_INSTANCE(htim->Instance)) {
+ tmpsmcr = htim->Instance->SMCR & TIM_SMCR_SMS;
+ if (!IS_TIM_SLAVEMODE_TRIGGER_ENABLED(tmpsmcr)) {
+ __HAL_TIM_ENABLE(htim);
+ }
+ } else {
+ __HAL_TIM_ENABLE(htim);
+ }
+ return HAL_OK;
+}
+static HAL_StatusTypeDef _HAL_TIM_Base_Stop(TIM_HandleTypeDef* htim) {
+ /* Disable the Peripheral */
+ __HAL_TIM_DISABLE(htim);
+ /* Set the TIM state */
+ htim->State = HAL_TIM_STATE_READY;
+ /* Return function status */
+ return HAL_OK;
+}
+
+void xs_delay_us(int var_nus) {
+ volatile uint32_t counter = 0;
+ __HAL_TIM_SET_COUNTER(&PC_SYS_DELAY_US_TIMER, 0);
+ _HAL_TIM_Base_Start(&PC_SYS_DELAY_US_TIMER);
+ while (counter < var_nus) {
+ counter = __HAL_TIM_GET_COUNTER(&PC_SYS_DELAY_US_TIMER);
+ }
+ _HAL_TIM_Base_Stop(&PC_SYS_DELAY_US_TIMER);
+}
+void xs_delay_ms(int ms) {
+ for (int i = 0; i < ms; i++) {
+ xs_delay_us(1000);
+ }
+}
+void xs_os_delay_ms(int ms) { osDelay(ms); }
+
+int32_t xs_get_ticket(void) { return HAL_GetTick(); }
diff --git a/iflytop_xsync/xs_delay.h b/iflytop_xsync/xs_delay.h
new file mode 100644
index 0000000..41d10c1
--- /dev/null
+++ b/iflytop_xsync/xs_delay.h
@@ -0,0 +1,6 @@
+#pragma once
+#include
+void xs_delay_us(int us);
+void xs_delay_ms(int ms);
+void xs_os_delay_ms(int ms);
+int32_t xs_get_ticket(void);
diff --git a/iflytop_xsync/xs_gpio.c b/iflytop_xsync/xs_gpio.c
new file mode 100644
index 0000000..fe487e9
--- /dev/null
+++ b/iflytop_xsync/xs_gpio.c
@@ -0,0 +1,306 @@
+#include "xs_gpio.h"
+
+static bool gpio_enable_clock(GPIO_TypeDef *m_gpio) {
+#ifdef GPIOA
+ if (m_gpio == GPIOA) {
+ __HAL_RCC_GPIOA_CLK_ENABLE();
+ return true;
+ }
+#endif
+#ifdef GPIOB
+ if (m_gpio == GPIOB) {
+ __HAL_RCC_GPIOB_CLK_ENABLE();
+ return true;
+ }
+#endif
+#ifdef GPIOC
+ if (m_gpio == GPIOC) {
+ __HAL_RCC_GPIOC_CLK_ENABLE();
+ return true;
+ }
+#endif
+#ifdef GPIOD
+ if (m_gpio == GPIOD) {
+ __HAL_RCC_GPIOD_CLK_ENABLE();
+ return true;
+ }
+#endif
+#ifdef GPIOE
+ if (m_gpio == GPIOE) {
+ __HAL_RCC_GPIOE_CLK_ENABLE();
+ return true;
+ }
+#endif
+#ifdef GPIOF
+ if (m_gpio == GPIOF) {
+ __HAL_RCC_GPIOF_CLK_ENABLE();
+ return true;
+ }
+#endif
+#ifdef GPIOG
+ if (m_gpio == GPIOG) {
+ __HAL_RCC_GPIOG_CLK_ENABLE();
+ return true;
+ }
+#endif
+#ifdef GPIOH
+ if (m_gpio == GPIOH) {
+ __HAL_RCC_GPIOH_CLK_ENABLE();
+ return true;
+ }
+#endif
+#ifdef GPIOI
+ if (m_gpio == GPIOI) {
+ __HAL_RCC_GPIOI_CLK_ENABLE();
+ return true;
+ }
+#endif
+#ifdef GPIOJ
+ if (m_gpio == GPIOJ) {
+ __HAL_RCC_GPIOJ_CLK_ENABLE();
+ return true;
+ }
+#endif
+#ifdef GPIOK
+ if (m_gpio == GPIOK) {
+ __HAL_RCC_GPIOK_CLK_ENABLE();
+ return true;
+ }
+#endif
+ return false;
+}
+
+static GPIO_TypeDef *_chip_get_gpio(Pin_t pin) {
+ int port = pin >> 4;
+
+ switch (port) {
+ case 1:
+#ifdef GPIOA
+ return GPIOA;
+#endif
+ break;
+ case 2:
+#ifdef GPIOB
+ return GPIOB;
+#endif
+ break;
+ case 3:
+#ifdef GPIOC
+ return GPIOC;
+#endif
+ break;
+ case 4:
+#ifdef GPIOD
+ return GPIOD;
+#endif
+ break;
+
+ case 5:
+#ifdef GPIOE
+ return GPIOE;
+#endif
+ break;
+ case 6:
+#ifdef GPIOF
+ return GPIOF;
+#endif
+ break;
+ case 7:
+#ifdef GPIOG
+ return GPIOG;
+#endif
+ break;
+ default:
+ break;
+ }
+ return NULL;
+}
+static uint16_t _chip_get_pinoff(Pin_t pin) {
+ uint16_t pinoff = pin & 0x0F;
+ switch (pinoff) {
+ case 0:
+ return GPIO_PIN_0;
+ case 1:
+ return GPIO_PIN_1;
+ case 2:
+ return GPIO_PIN_2;
+ case 3:
+ return GPIO_PIN_3;
+ case 4:
+ return GPIO_PIN_4;
+ case 5:
+ return GPIO_PIN_5;
+ case 6:
+ return GPIO_PIN_6;
+ case 7:
+ return GPIO_PIN_7;
+ case 8:
+ return GPIO_PIN_8;
+ case 9:
+ return GPIO_PIN_9;
+ case 10:
+ return GPIO_PIN_10;
+ case 11:
+ return GPIO_PIN_11;
+ case 12:
+ return GPIO_PIN_12;
+ case 13:
+ return GPIO_PIN_13;
+ case 14:
+ return GPIO_PIN_14;
+ case 15:
+ return GPIO_PIN_15;
+ default:
+ break;
+ };
+ return 0;
+}
+
+IRQn_Type getEXTIIRQn(int32_t m_pinoff) {
+ switch (m_pinoff) {
+ case GPIO_PIN_0:
+ return EXTI0_IRQn;
+ case GPIO_PIN_1:
+ return EXTI1_IRQn;
+ case GPIO_PIN_2:
+ return EXTI2_IRQn;
+ case GPIO_PIN_3:
+ return EXTI3_IRQn;
+ case GPIO_PIN_4:
+ return EXTI4_IRQn;
+ case GPIO_PIN_5:
+ case GPIO_PIN_6:
+ case GPIO_PIN_7:
+ case GPIO_PIN_8:
+ case GPIO_PIN_9:
+ return EXTI9_5_IRQn;
+ case GPIO_PIN_10:
+ case GPIO_PIN_11:
+ case GPIO_PIN_12:
+ case GPIO_PIN_13:
+ case GPIO_PIN_14:
+ case GPIO_PIN_15:
+ return EXTI15_10_IRQn;
+ default:
+ XS_ASSERT(0);
+ }
+ return EXTI0_IRQn;
+}
+
+void xs_gpio_init_as_input(xs_gpio_t *gpio, Pin_t pin, xs_gpio_mode_t mode, xs_gpio_irq_t irqtype, bool mirror) {
+ if (pin == PinNull) return;
+
+ gpio->mirror = mirror;
+ gpio->mode = mode;
+ gpio->irqtype = irqtype;
+ gpio->gpiotype = kxs_gpio_input;
+
+ gpio->pin = pin;
+ gpio->gpio = _chip_get_gpio(pin);
+ gpio->pinoff = _chip_get_pinoff(pin);
+
+ // kxs_gpio_nopull, //
+ // kxs_gpio_pullup, //
+ // kxs_gpio_pulldown, //
+ // kxs_gpio_od,
+
+ uint32_t pulluptype = 0;
+ if (mode == kxs_gpio_nopull) {
+ pulluptype = GPIO_NOPULL;
+ } else if (mode == kxs_gpio_pullup) {
+ pulluptype = GPIO_PULLUP;
+ } else if (mode == kxs_gpio_pulldown) {
+ pulluptype = GPIO_PULLDOWN;
+ }
+
+ gpio_enable_clock(gpio->gpio);
+ // kxs_gpio_no_irq,
+ // kxs_gpio_rising_irq,
+ // kxs_gpio_falling_irq,
+ // kxs_gpio_rising_and_falling_irq,
+
+ GPIO_InitTypeDef init_type_def = {0};
+ if (gpio->irqtype == kxs_gpio_no_irq) {
+ init_type_def.Pin = gpio->pinoff;
+ init_type_def.Mode = GPIO_MODE_INPUT;
+ init_type_def.Pull = pulluptype;
+ init_type_def.Speed = GPIO_SPEED_FREQ_LOW;
+ } else if (gpio->irqtype == kxs_gpio_rising_irq) {
+ init_type_def.Pin = gpio->pinoff;
+ init_type_def.Mode = gpio->mirror ? GPIO_MODE_IT_FALLING : GPIO_MODE_IT_RISING;
+ init_type_def.Pull = pulluptype;
+ init_type_def.Speed = GPIO_SPEED_FREQ_LOW;
+ } else if (gpio->irqtype == kxs_gpio_falling_irq) {
+ init_type_def.Pin = gpio->pinoff;
+ init_type_def.Mode = !gpio->mirror ? GPIO_MODE_IT_FALLING : GPIO_MODE_IT_RISING;
+ init_type_def.Pull = pulluptype;
+ init_type_def.Speed = GPIO_SPEED_FREQ_LOW;
+ } else if (gpio->irqtype == kxs_gpio_rising_and_falling_irq) {
+ init_type_def.Pin = gpio->pinoff;
+ init_type_def.Mode = GPIO_MODE_IT_RISING_FALLING;
+ init_type_def.Pull = pulluptype;
+ init_type_def.Speed = GPIO_SPEED_FREQ_LOW;
+ }
+
+ HAL_GPIO_Init(gpio->gpio, &init_type_def);
+ if (gpio->irqtype != kxs_gpio_no_irq) {
+ HAL_NVIC_SetPriority(getEXTIIRQn(gpio->pinoff), PC_IRQ_PREEMPTPRIORITY_DEFAULT, 0);
+ HAL_NVIC_EnableIRQ(getEXTIIRQn(gpio->pinoff));
+ }
+
+ gpio->inited = true;
+ return;
+}
+void xs_gpio_init_as_output(xs_gpio_t *gpio, Pin_t pin, xs_gpio_mode_t mode, bool mirror, bool initLevel) {
+ if (pin == PinNull) return;
+
+ gpio->mirror = mirror;
+ gpio->mode = mode;
+ gpio->irqtype = kxs_gpio_no_irq;
+ gpio->gpiotype = kxs_gpio_output;
+ gpio->pin = pin;
+ gpio->gpio = _chip_get_gpio(pin);
+ gpio->pinoff = _chip_get_pinoff(pin);
+
+ gpio_enable_clock(gpio->gpio);
+
+ GPIO_InitTypeDef init_type_def = {0};
+ initLevel = gpio->mirror ? !initLevel : initLevel;
+ GPIO_PinState pinState = initLevel ? GPIO_PIN_SET : GPIO_PIN_RESET;
+
+ HAL_GPIO_WritePin(gpio->gpio, gpio->pinoff, pinState);
+
+ if (gpio->mode == kxs_gpio_nopull) {
+ init_type_def.Pin = gpio->pinoff;
+ init_type_def.Mode = GPIO_MODE_OUTPUT_PP;
+ init_type_def.Pull = GPIO_NOPULL;
+ init_type_def.Speed = GPIO_SPEED_FREQ_LOW;
+ } else if (gpio->mode == kxs_gpio_pullup) {
+ init_type_def.Pin = gpio->pinoff;
+ init_type_def.Mode = GPIO_MODE_OUTPUT_PP;
+ init_type_def.Pull = GPIO_PULLUP;
+ init_type_def.Speed = GPIO_SPEED_FREQ_LOW;
+ } else if (gpio->mode == kxs_gpio_pulldown) {
+ init_type_def.Pin = gpio->pinoff;
+ init_type_def.Mode = GPIO_MODE_OUTPUT_PP;
+ init_type_def.Pull = GPIO_PULLDOWN;
+ init_type_def.Speed = GPIO_SPEED_FREQ_LOW;
+ } else if (gpio->mode == kxs_gpio_od) {
+ init_type_def.Pin = gpio->pinoff;
+ init_type_def.Mode = GPIO_MODE_OUTPUT_OD;
+ init_type_def.Pull = 0;
+ init_type_def.Speed = GPIO_SPEED_FREQ_LOW;
+ }
+ HAL_GPIO_Init(gpio->gpio, &init_type_def);
+ gpio->inited = true;
+ return;
+}
+bool xs_gpio_read(xs_gpio_t *gpio) {
+ GPIO_PinState pinState = HAL_GPIO_ReadPin(gpio->gpio, gpio->pinoff);
+ return !gpio->mirror ? pinState == GPIO_PIN_SET : pinState != GPIO_PIN_SET;
+}
+void xs_gpio_write(xs_gpio_t *gpio, bool level) {
+ level = gpio->mirror ? !level : level;
+ GPIO_PinState pinState = level ? GPIO_PIN_SET : GPIO_PIN_RESET;
+ HAL_GPIO_WritePin(gpio->gpio, gpio->pinoff, pinState);
+}
diff --git a/iflytop_xsync/xs_gpio.h b/iflytop_xsync/xs_gpio.h
new file mode 100644
index 0000000..1838062
--- /dev/null
+++ b/iflytop_xsync/xs_gpio.h
@@ -0,0 +1,36 @@
+#pragma once
+#include "pin.h"
+#include "xs_basic.h"
+#include "xs_log.h"
+
+typedef enum {
+ kxs_gpio_nopull, //
+ kxs_gpio_pullup, //
+ kxs_gpio_pulldown, //
+ kxs_gpio_od, //
+} xs_gpio_mode_t;
+
+typedef enum { kxs_gpio_ain, kxs_gpio_input, kxs_gpio_output } xs_gpio_type_t;
+
+typedef enum {
+ kxs_gpio_no_irq,
+ kxs_gpio_rising_irq,
+ kxs_gpio_falling_irq,
+ kxs_gpio_rising_and_falling_irq,
+} xs_gpio_irq_t;
+
+typedef struct {
+ Pin_t pin;
+ GPIO_TypeDef *gpio;
+ uint16_t pinoff;
+ xs_gpio_mode_t mode;
+ xs_gpio_type_t gpiotype;
+ xs_gpio_irq_t irqtype;
+ bool mirror;
+ bool inited;
+} xs_gpio_t;
+
+void xs_gpio_init_as_input(xs_gpio_t *gpio, Pin_t pin, xs_gpio_mode_t mode, xs_gpio_irq_t irqtype, bool mirror);
+void xs_gpio_init_as_output(xs_gpio_t *gpio, Pin_t pin, xs_gpio_mode_t mode, bool mirror, bool initLevel);
+bool xs_gpio_read(xs_gpio_t *gpio);
+void xs_gpio_write(xs_gpio_t *gpio, bool level);
\ No newline at end of file
diff --git a/iflytop_xsync/xs_log.c b/iflytop_xsync/xs_log.c
new file mode 100644
index 0000000..b79c8fd
--- /dev/null
+++ b/iflytop_xsync/xs_log.c
@@ -0,0 +1,39 @@
+#include "xs_log.h"
+
+#include
+#include
+#include
+#include
+#include
+bool g_xs_enable_log = true;
+extern UART_HandleTypeDef PC_DEBUG_UART;
+/*********************************************************************
+ * @fn _write
+ *
+ * @brief Support Printf Function
+ *
+ * @param *buf - UART send Data.
+ * size - Data length
+ *
+ * @return size: Data length
+ */
+__attribute__((used)) int _write(int fd, char* buf, int size) {
+ int i;
+
+ for (i = 0; i < size; i++) {
+ uint8_t c = *buf++;
+ HAL_UART_Transmit(&PC_DEBUG_UART, &c, 1, 100);
+ }
+
+ return size;
+}
+
+void xs_log_enable(bool enable) { g_xs_enable_log = enable; }
+void xs_log(const char* fmt, ...) {
+ if (g_xs_enable_log) {
+ va_list args;
+ va_start(args, fmt);
+ vprintf(fmt, args);
+ va_end(args);
+ }
+}
diff --git a/iflytop_xsync/xs_log.h b/iflytop_xsync/xs_log.h
new file mode 100644
index 0000000..a68c8b9
--- /dev/null
+++ b/iflytop_xsync/xs_log.h
@@ -0,0 +1,37 @@
+#pragma once
+#include "xs_basic.h"
+#include "xs_delay.h"
+
+
+extern bool g_xs_enable_log;
+#define XS_LOG_RELEASE(TAG, fmt, ...) \
+ if (g_xs_enable_log) { \
+ xs_log(TAG "" fmt "\n", ##__VA_ARGS__); \
+ }
+#define XS_LOGI(TAG, fmt, ...) \
+ if (g_xs_enable_log) { \
+ xs_log("%08lu INFO [%-8s] " fmt "\n", xs_get_ticket(), TAG, ##__VA_ARGS__); \
+ }
+#define XS_LOGD(TAG, fmt, ...) \
+ if (g_xs_enable_log) { \
+ xs_log("%08lu DEBU [%-8s] " fmt "\n", xs_get_ticket(), TAG, ##__VA_ARGS__); \
+ }
+#define XS_LOGE(TAG, fmt, ...) \
+ if (g_xs_enable_log) { \
+ xs_log("%08lu ERRO [%-8s] " fmt "\n", xs_get_ticket(), TAG, ##__VA_ARGS__); \
+ }
+
+#define XS_LOGW(TAG, fmt, ...) \
+ if (g_xs_enable_log) { \
+ xs_log("%08lu WARN [%-8s] " fmt "\n", xs_get_ticket(), TAG, ##__VA_ARGS__); \
+ }
+
+#define XS_ASSERT(cond) \
+ if (!(cond)) { \
+ while (1) { \
+ xs_log("ASSERT: %s [%s:%d]\n", #cond, __FILE__, __LINE__); \
+ xs_delay_ms(1000); \
+ } \
+ }
+void xs_log(const char* fmt, ...);
+void xs_log_enable(bool enable);
\ No newline at end of file
diff --git a/usrc/device.cpp b/usrc/device.cpp
index f6dc2bb..08ad2d5 100644
--- a/usrc/device.cpp
+++ b/usrc/device.cpp
@@ -1,20 +1,33 @@
#include "device.hpp"
+#include "iflytop_xsync/iflytop_xsync.h"
#include "project_configs.h"
using namespace iflytop;
-extern DMA_HandleTypeDef PC_DEBUG_UART_DMA_HANDLER;
+// extern DMA_HandleTypeDef PC_DEBUG_UART_DMA_HANDLER;
+#define TAG "Device"
void Device::init() {
- chip_cfg_t chipcfg = {};
- chipcfg.us_dleay_tim = &PC_SYS_DELAY_US_TIMER;
- chipcfg.tim_irq_scheduler_tim = &PC_SYS_TIM_IRQ_SCHEDULER_TIMER;
- chipcfg.huart = &PC_DEBUG_UART;
- chipcfg.debuglight = PC_DEBUG_LIGHT_GPIO;
+ xs_gpio_init_as_output(&m_debug_led, PC_DEBUG_LIGHT_GPIO, kxs_gpio_nopull, false, false);
- chip_init(&chipcfg);
+ XS_LOGI(TAG, "%s:%s", PC_PROJECT_NAME, PC_VERSION);
- zos_cfg_t zoscfg;
- zos_init(&zoscfg);
+ // chip_cfg_t chipcfg = {};
+ // chipcfg.us_dleay_tim = &PC_SYS_DELAY_US_TIMER;
+ // chipcfg.tim_irq_scheduler_tim = &PC_SYS_TIM_IRQ_SCHEDULER_TIMER;
+ // chipcfg.huart = &PC_DEBUG_UART;
+ // chipcfg.debuglight = PC_DEBUG_LIGHT_GPIO;
+
+ // chip_init(&chipcfg);
+
+ // zos_cfg_t zoscfg;
+ // zos_init(&zoscfg);
+}
+void Device::loop() {
+ while (1) {
+ xs_gpio_write(&m_debug_led, true);
+ xs_delay_ms(1000);
+ xs_gpio_write(&m_debug_led, false);
+ xs_delay_ms(1000);
+ }
}
-void Device::loop() {}
diff --git a/usrc/device.hpp b/usrc/device.hpp
index d628cf9..23e9ed4 100644
--- a/usrc/device.hpp
+++ b/usrc/device.hpp
@@ -1,8 +1,10 @@
#pragma once
+#include "iflytop_xsync/iflytop_xsync.h"
#include "project_configs.h"
-#include "sdk/os/zos.hpp"
namespace iflytop {
class Device {
+ xs_gpio_t m_debug_led;
+
public:
void init();
void loop();
diff --git a/usrc/main.cpp b/usrc/main.cpp
index 95f197e..ddc8fb6 100644
--- a/usrc/main.cpp
+++ b/usrc/main.cpp
@@ -3,7 +3,6 @@
#include "device.hpp"
#include "project_configs.h"
-#include "sdk/os/zos.hpp"
//
#define TAG "main"
using namespace iflytop;
diff --git a/xsync_stm32 Debug.launch b/xsync_stm32 Debug.launch
index a9750a1..cb5f98f 100644
--- a/xsync_stm32 Debug.launch
+++ b/xsync_stm32 Debug.launch
@@ -40,6 +40,7 @@
+
diff --git a/xsync_v3.pdf b/xsync_v3.pdf
new file mode 100644
index 0000000..befc29f
Binary files /dev/null and b/xsync_v3.pdf differ