#ifdef SUPPORT_AT_CHARGE\r
#include "charge_at_cmd.h"\r
#endif\r
+#ifdef SUPPORT_AT_CROWN\r
+#include "crown_at_cmd.h"\r
+#endif\r
static void register_at_service(void)\r
{\r
#ifdef SUPPORT_AT_GRAPHIC\r
at_cmd_table_t *charge_table = get_charge_cmd_table(&charge_cmd_count);\r
at_cmd_add_moudle(charge_table, charge_cmd_count); \r
#endif\r
+#ifdef SUPPORT_AT_CROWN\r
+ uint32_t crown_cmd_count;\r
+ at_cmd_table_t *crown_table = get_crown_cmd_table(&crown_cmd_count);\r
+ at_cmd_add_moudle(crown_table, crown_cmd_count); \r
+#endif\r
}\r
\r
#ifdef CONFIG_OTA_UPDATE_SUPPORT\r
elseif("ROTARYENCODER_U8" IN_LIST DEFINES)
set(SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/crown/crown.c
+ ${CMAKE_CURRENT_SOURCE_DIR}/crown/crown_at_cmd.c
)
set(PUBLIC_HEADER
${CMAKE_CURRENT_SOURCE_DIR}/crown
)
set(PUBLIC_DEFINES
+SUPPORT_AT_CROWN
)
endif()
--- /dev/null
+/*
+ * @Author: penglei 1624952103@qq.com
+ * @Date: 2024-12-31 10:20:16
+ * @LastEditors: penglei 1624952103@qq.com
+ * @LastEditTime: 2025-01-02 20:18:27
+ * @FilePath: /sdk615/code/sdk/zhihui/drivers/rotary_encoder/crown/crown.c
+ * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
+ */
+#include "pinctrl.h"
+#include "button_porting.h"
+#include "platform_core.h"
+#include "gpio.h"
+#include "gpio_porting.h"
+#include "debug_print.h"
+#include "rtc.h"
+#include "timer.h"
+#include "systick.h"
+#include "chip_core_irq.h"
+#include "tcxo.h"
+#include "errcode.h"
+#include "pm_veto.h"
+#include "crown.h"
+#include "cmsis_os2.h"
+
+static int16_t crown_result = 0;
+static uint8_t stand_still = 1; //静止标志 1 静止,0 转动
+static uint8_t direction = 0; //方向标志 1 顺时针,2 逆时针
+
+bool crown_timer_running = false; //ots定时器是否运行标志
+
+static osTimerId_t g_crown_timer = NULL;
+
+void crown_int_callback(pin_t pin, uintptr_t param)
+{
+ uapi_gpio_clear_interrupt(pin);
+
+ if(pin == PIN_TYHX_SDIO)
+ {
+ if (uapi_gpio_get_val(PIN_TYHX_SCLK))
+ {
+ direction = 1; // 顺时针旋转
+ crown_result++;
+ }
+ }
+ else if (pin == PIN_TYHX_SCLK)
+ {
+ if (uapi_gpio_get_val(PIN_TYHX_SDIO))
+ {
+ direction = 2; // 逆时针旋转
+ crown_result--;
+ }
+ }
+ PRINT("pin : %d , direction : %d , crown_result : %d \n",pin,direction,crown_result);
+}
+
+
+int16_t crown_get_stand_still(void)
+{
+ return stand_still;
+}
+/**
+ * 获取表冠的数据结果接口函数
+ * @param NULL
+*/
+int16_t crown_get_crown_result(void)
+{
+ int16_t resulttemp;
+ resulttemp=crown_result;
+ crown_result = 0;
+ return resulttemp;
+}
+
+void crown_start(void)
+{
+ if(crown_timer_running == false)
+ {
+ // app_timer_start(g_hx3509_timer, APP_TIMER_TICKS(50), NULL);//定义为50ms定时器间隔
+ osTimerStart(g_crown_timer,50);
+ crown_timer_running = true;
+ }
+}
+
+void crown_stop(void)
+{
+ if(crown_timer_running == true)
+ {
+ osTimerStop(g_crown_timer);
+ crown_timer_running = false;
+ }
+}
+
+void crown_timer_handler(void)
+{
+ PRINT("crown_result : %d \n",crown_result);
+ crown_result = 0;
+}
+
+
+void crown_init(void)
+{
+ if(!g_crown_timer)
+ g_crown_timer = osTimerNew((osTimerFunc_t)crown_timer_handler, osTimerPeriodic, NULL, NULL);
+}
+
+// #endif
+
--- /dev/null
+/*
+ * @Author: penglei 1624952103@qq.com
+ * @Date: 2024-12-31 10:20:24
+ * @LastEditors: penglei 1624952103@qq.com
+ * @LastEditTime: 2025-01-02 19:57:42
+ * @FilePath: /sdk615/code/sdk/zhihui/drivers/rotary_encoder/crown/crown.h
+ * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
+ */
+#ifndef CROWN_H_
+#define CROWN_H_
+
+#include "debug_print.h"
+/*----------------------使用的IO定义-------------------------------*/
+
+#define PIN_TYHX_SDIO S_AGPIO_L12 //custom to do here
+#define PIN_TYHX_SCLK S_AGPIO_L13 //custom to do here
+
+void crown_int_callback(pin_t pin, uintptr_t param);
+int16_t crown_get_stand_still(void);
+int16_t crown_get_crown_result(void);
+
+void crown_start(void);
+void crown_stop(void);
+void crown_timer_handler(void);
+void crown_init(void);
+
+#endif
--- /dev/null
+/*
+ * @Author: penglei 1624952103@qq.com
+ * @Date: 2024-12-18 10:23:22
+ * @LastEditors: penglei 1624952103@qq.com
+ * @LastEditTime: 2025-01-02 20:04:56
+ * @FilePath: /sdk615/code/sdk/drivers/peripheral/rotary_encoder/crown/crown_at_cmd.c
+ * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
+ */
+
+// #include "crown.h"
+
+
+#include "at_cmd_api.h"
+#include "pm_control.h"
+#include "debug_print.h"
+#include "crown.h"
+#include "custom_utils.h"
+
+
+#define ARRAY_COUNT(array) (sizeof(array) / sizeof(array[0]))
+#define CROWN_MAX_ARGC 8
+#define CROWN_MAX_ARGV_LEN 64
+
+#define CROWN_SUCCESS 0
+#define CROWN_FAILED (-1)
+
+static int ConvertCmdToParam(uint8_t *para, uint32_t paraLen,
+ uint8_t argv[CROWN_MAX_ARGC][CROWN_MAX_ARGV_LEN], uint32_t* argc)
+{
+ uint32_t pos = 0;
+ *argc = 0;
+
+ for (uint32_t i = 0; i < paraLen; i++) {
+ if ((para[i] == ' ' || para[i] == '\n') && pos != 0) {
+ argv[*argc][pos] = '\0';
+ *argc += 1;
+ pos = 0;
+ if (*argc >= CROWN_MAX_ARGC) {
+ return CROWN_FAILED;
+ }
+ } else {
+ argv[*argc][pos] = para[i];
+ pos++;
+ if (pos >= CROWN_MAX_ARGV_LEN) {
+ return CROWN_FAILED;
+ }
+ }
+ }
+ if (pos != 0) {
+ *argc += 1;
+ }
+
+ return CROWN_SUCCESS;
+}
+
+static uint8_t g_crown_test_started = 0;
+static uint32_t crown_test(uint8_t *para, uint32_t paraLen, char *strCommonCmd)
+{
+ UNUSED(strCommonCmd);
+ uint8_t argv[CROWN_MAX_ARGC][CROWN_MAX_ARGV_LEN] = { 0 };
+ uint32_t argc = 0;
+
+ int ret = ConvertCmdToParam(para, paraLen, argv, &argc);
+ if (ret != CROWN_SUCCESS) {
+ PRINT("CROWNTEST ATCMD Convert Command Failed\n");
+ return ERRCODE_FAIL;
+ }
+
+ if (argc != 1) {
+ PRINT("CROWNTEST ATCMD Set Parameter Failed argc %d\n",argc);
+ return ERRCODE_FAIL;
+ }
+ uint8_t start = (uint8_t)atoi((char*)argv[0]);
+ if (start == 1)
+ {
+ // if (g_crown_test_started == 1)
+ // {
+ // PRINT("SKIP crowntest start, already started\r\n");
+ // return 0;
+ // }
+ crown_init();
+ crown_start();
+ g_crown_test_started = 1;
+ }else if (start == 2){
+ if (g_crown_test_started == 0)
+ {
+ PRINT("SKIP crowntest stop, already stopped\r\n");
+ return 0;
+ }
+ crown_stop();
+ g_crown_test_started = 0 ;
+ }
+ return ERRCODE_SUCC;
+}
+static const at_cmd_table_t g_crown_cmd[] = {
+ { (char *)"AT^CROWNTEST", crown_test, (char *)"1" },
+};
+
+at_cmd_table_t *get_crown_cmd_table(uint32_t *cmd_count)
+{
+ *cmd_count = ARRAY_COUNT(g_crown_cmd);
+ return (at_cmd_table_t *)g_crown_cmd;
+}
--- /dev/null
+/*
+ * @Author: penglei 1624952103@qq.com
+ * @Date: 2025-01-02 19:52:36
+ * @LastEditors: penglei 1624952103@qq.com
+ * @LastEditTime: 2025-01-02 20:04:46
+ * @FilePath: /sdk615/code/sdk/zhihui/drivers/rotary_encoder/crown/crown_at_cmd.h
+ * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
+ */
+/**
+ * Copyright (c) @CompanyNameMagicTag 2022-2022. All rights reserved. \n
+ *
+ * Description: Provides at cmd register func \n
+ * Author: @CompanyNameTag \n
+ * History: \n
+ * 2022-07-20, Create file. \n
+ */
+#ifndef CROWN_AT_PROCESS_H
+#define CROWN_AT_PROCESS_H
+
+#include <stdint.h>
+#include <stdio.h>
+#include "errcode.h"
+#include "soc_osal.h"
+#include "at_cmd_api.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+#endif /* __cplusplus */
+
+at_cmd_table_t *get_crown_cmd_table(uint32_t *cmd_count);
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cplusplus */
+#endif /* __cplusplus */
+
+#endif
return ((void *)&g_hx3509_api);
}
-void *rotary_encoder_get_peri_hx3509_attr(void)
+void *rotary_encoder_get_hx3509_peri_attr(void)
{
return ((void *)NULL);
}
\ No newline at end of file
* @Author: penglei 1624952103@qq.com
* @Date: 2024-12-23 15:11:25
* @LastEditors: penglei 1624952103@qq.com
- * @LastEditTime: 2024-12-30 17:28:53
+ * @LastEditTime: 2025-01-02 19:43:35
* @FilePath: /sdk615/code/sdk/zhihui/drivers/rotary_encoder/hx3509/hx3509_hal.h
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE;
*/
#endif /* __cplusplus */
void *rotary_encoder_get_hx3509_api(void);
-void *rotary_encoder_get_peri_hx3509_attr(void);
+void *rotary_encoder_get_hx3509_peri_attr(void);
#ifdef __cplusplus
#if __cplusplus
g_encoder_drv.private_data = rotary_encoder_get_peri_hx3507_attr();
g_encoder_drv.encoder_api = rotary_encoder_get_hx3507_api();
#elif defined ROTARYENCODER_HX3509
- g_encoder_drv.private_data = rotary_encoder_get_peri_hx3509_attr();
+ g_encoder_drv.private_data = rotary_encoder_get_hx3509_peri_attr();
g_encoder_drv.encoder_api = rotary_encoder_get_hx3509_api();
#endif
g_encoder_drv.ops = &g_re_status_ops;