diff --git a/examples/app_test_config_rgb_port/Makefile b/examples/app_test_config_rgb_port/Makefile
new file mode 100644
index 0000000..5fe0145
--- /dev/null
+++ b/examples/app_test_config_rgb_port/Makefile
@@ -0,0 +1,24 @@
+# `TARGET` 变量决定了应用程序编译的目标系统。它可以引用源目录中的一个 XN 文件,或者是在编译时作为 `--target` 选项的一个有效参数。
+
+TARGET = PXUA-316-MC-MAX.xn
+
+# 编译选项
+# 构建应用程序时传递给 xcc 的参数
+# O2: xcc编译器优化等级2
+# report: 打开编译报告
+# g: 生成调试信息
+# fxscope: 使用 xSCOPE,对代码进行跟踪(默认使用xlink)
+BUILD_FLAGS = -O2 -g -DDEBUG_PRINT_ENABLE=1 -report -fxscope
+
+USED_MODULES = lib_rgb
+
+XCC_FLAGS = $(BUILD_FLAGS)
+
+XMOS_MODULE_PATH = ../../..
+XCOMMON_DISABLE_AUTO_MODULE_SEARCH = 1
+
+#=============================================================================
+# 下面部分的 Makefile 包含了用于编译 XMOS 应用程序的公共构建基础设施。你无需编辑此处以下的内容。
+
+XMOS_MAKE_PATH ?= ../..
+include $(XMOS_MAKE_PATH)/xcommon/module_xcommon/build/Makefile.common
\ No newline at end of file
diff --git a/examples/app_test_config_rgb_port/src/core/PXUA-316-MC-MAX.xn b/examples/app_test_config_rgb_port/src/core/PXUA-316-MC-MAX.xn
new file mode 100644
index 0000000..036f02c
--- /dev/null
+++ b/examples/app_test_config_rgb_port/src/core/PXUA-316-MC-MAX.xn
@@ -0,0 +1,106 @@
+
+
+ Board
+ PXUA-316-MC-MAX
+
+ tileref tile[2]
+ tileref usb_tile
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/examples/app_test_config_rgb_port/src/core/xua_conf.h b/examples/app_test_config_rgb_port/src/core/xua_conf.h
new file mode 100644
index 0000000..d02bfae
--- /dev/null
+++ b/examples/app_test_config_rgb_port/src/core/xua_conf.h
@@ -0,0 +1,15 @@
+/**
+ * @file xua_conf.h
+ * @brief Defines relating to device configuration and customisation.
+ * For PXUA-XU316-MC-MAX
+ */
+#ifndef _XUA_CONF_H_
+#define _XUA_CONF_H_
+
+/* Defines relating to feature placement regarding tiles */
+#ifndef RGB_TILE
+#define RGB_TILE (1)
+#endif
+
+#include "rgb_driver.h"
+#endif
diff --git a/examples/app_test_config_rgb_port/src/main.xc b/examples/app_test_config_rgb_port/src/main.xc
new file mode 100644
index 0000000..b4cc7e5
--- /dev/null
+++ b/examples/app_test_config_rgb_port/src/main.xc
@@ -0,0 +1,26 @@
+/** @brief 测试output_rgb_array
+ *
+ * @author Vergil Wong
+ * @date 2023-11-25
+ * @param
+ * @return
+ */
+
+#include // 包含对封装的定义,引用以使用 on tile[] 语法
+
+extern "C"
+{
+ void test_output_rgb_array_example();
+}
+
+int main() // 定义主函数
+{
+ par
+ {
+ on tile[1]:
+ {
+ test_output_rgb_array_example();
+ }
+ }
+ return 0; // 返回0,表示程序正常结束
+}
diff --git a/examples/app_test_config_rgb_port/src/test_cycleHSV_with_vol_level_example.c b/examples/app_test_config_rgb_port/src/test_cycleHSV_with_vol_level_example.c
new file mode 100644
index 0000000..e9f8c64
--- /dev/null
+++ b/examples/app_test_config_rgb_port/src/test_cycleHSV_with_vol_level_example.c
@@ -0,0 +1,16 @@
+#include
+#include
+#include "rgb_effect.h"
+void test_output_rgb_array_example()
+{
+ uint32_t buf[NUM_RGBS]; // 定义一个用于存储RGB值的缓冲区,大小由NUM_RGBS宏确定
+ uint32_t num_rgbs = 12;
+
+ // Initialize the buffer with example RGB values
+ for (uint32_t i = 0; i < num_rgbs; ++i) {
+ buf[i] = (i << 16) | (i << 8) | i; // Just an example pattern for RGB values
+ }
+
+ // Call the function with the test buffer and number of RGBs
+ output_rgb_array(buf, num_rgbs);
+}
\ No newline at end of file
diff --git a/lib_rgb/api/rgb_driver.h b/lib_rgb/api/rgb_driver.h
index eea05a7..e76da58 100644
--- a/lib_rgb/api/rgb_driver.h
+++ b/lib_rgb/api/rgb_driver.h
@@ -2,6 +2,16 @@
#define RGB_DRIVER_H
#include
+#include
+//TODO: 在XUA工程环境中测试
+
+#ifndef RGB_TILE
+#define RGB_TILE (1)
+#endif
+
+#ifndef PORT_RGB_DAISY_CHAIN
+#define PORT_RGB_DAISY_CHAIN XS1_PORT_4A
+#endif
/** 串行输出24位值。
*
diff --git a/lib_rgb/src/rgb_driver.xc b/lib_rgb/src/rgb_driver.xc
index d424811..e2e12ef 100644
--- a/lib_rgb/src/rgb_driver.xc
+++ b/lib_rgb/src/rgb_driver.xc
@@ -4,6 +4,7 @@
#include
#include "xclib.h"
#include
+#include "rgb_driver.h"
// 如果灯的显示没有出现问题,不要修改这些宏
#define MICROSECONDS 100
@@ -13,8 +14,9 @@
#define T0L_DELAY (93) // 0.9 μs
#define T1L_DELAY (63) // 0.6 μs
+// RGB_TILE 通常为0/1,PORT_RGB_DAISY_CHAIN为4bit port
+on tile[RGB_TILE]: out port p_rgb_4bit = PORT_RGB_DAISY_CHAIN;
-on tile[1] : out port p_rgb_rgb = XS1_PORT_4A; // 注意:当前代码仅适用于4bit端口
timer tmr;
// 向4A3写时序,点亮RT23
@@ -22,19 +24,19 @@ uint32_t output_bit_on_4th_pin(uint32_t bit, uint32_t fall_time)
{
if (bit == 1)
{
- p_rgb_rgb<:0xff; // 输出到4位端口
+ p_rgb_4bit<:0xff; // 输出到4位端口
tmr when timerafter(fall_time + T1H_DELAY):> fall_time; // 等待T1H时长
// printf("[x]fall_time: %u\n", fall_time);
- p_rgb_rgb<:0x00; // 将第4位设置为低电平
+ p_rgb_4bit<:0x00; // 将第4位设置为低电平
tmr when timerafter(fall_time + T1L_DELAY):> fall_time; // 等待T1L时长
// printf("[x]fall_time: %u\n", fall_time);
}
else if (bit == 0)
{
- p_rgb_rgb<:0xff; // 输出到4位端口
+ p_rgb_4bit<:0xff; // 输出到4位端口
tmr when timerafter(fall_time + T0H_DELAY):> fall_time; // 等待T0H时长
// printf("[x]fall_time: %u\n", fall_time);
- p_rgb_rgb<:0x00; // 将第4位设置为低电平
+ p_rgb_4bit<:0x00; // 将第4位设置为低电平
tmr when timerafter(fall_time + T0L_DELAY):> fall_time; // 等待T0L时长
// printf("[x]fall_time: %u\n", fall_time);
}
@@ -52,7 +54,7 @@ void output_24bit_value_serially(uint32_t value)
uint32_t fall_time = 0;
tmr:> fall_time;
// // 重置 RT23,由于引脚默认为低,此处不做重置
- // p_rgb_rgb <: 0x000000;
+ // p_rgb_4bit <: 0x000000;
// tmr when timerafter(fall_time + RT23_RST_DELAY):> fall_time;
value = value << 8;