From 48cddf247aefe73e5eccb705a6c63ec99a3939a0 Mon Sep 17 00:00:00 2001 From: gaoyang3513 Date: Tue, 28 Apr 2026 21:11:30 +0800 Subject: [PATCH] =?UTF-8?q?[Mod]=20AHT10=E9=A9=B1=E5=8A=A8=20=E8=B5=84?= =?UTF-8?q?=E6=BA=90=E7=AE=A1=E7=90=86=E5=99=A8=E7=89=88=E6=9C=AC=20?= =?UTF-8?q?=E6=A8=A1=E6=9D=BF=E5=AF=BC=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/drivers/i2c/aht10/aht10.c | 64 +++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/src/drivers/i2c/aht10/aht10.c b/src/drivers/i2c/aht10/aht10.c index 70aa289..16e76f0 100644 --- a/src/drivers/i2c/aht10/aht10.c +++ b/src/drivers/i2c/aht10/aht10.c @@ -1,4 +1,67 @@ #include +#include +#include +#include +#include +#include + +static resmgr_connect_funcs_t connect_func; +static resmgr_io_funcs_t io_func; +static iofunc_attr_t attr; + +int main (int argc, char **argv) +{ + thread_pool_attr_t pool_attr; + thread_pool_t *tpp; + dispatch_t *dpp; + resmgr_attr_t resmgr_attr; + int id; + + if ((dpp = dispatch_create ()) == NULL) { + fprintf (stderr,"%s: Unable to allocate dispatch context.\n", argv [0]); + return (EXIT_FAILURE); + } + + memset (&pool_attr, 0, sizeof (pool_attr)); + pool_attr.handle = dpp; + pool_attr.context_alloc = (void *) dispatch_context_alloc; + pool_attr.block_func = (void *) dispatch_block; + pool_attr.handler_func = (void *) dispatch_handler; + pool_attr.context_free = (void *) dispatch_context_free; + + // 1) set up the number of threads that you want + pool_attr.lo_water = 2; + pool_attr.hi_water = 4; + pool_attr.increment = 1; + pool_attr.maximum = 50; + + if ((tpp = thread_pool_create (&pool_attr, POOL_FLAG_EXIT_SELF)) == NULL) { + fprintf (stderr, "%s: Unable to initialize thread pool.\n", argv [0]); + return (EXIT_FAILURE); + } + + iofunc_func_init (_RESMGR_CONNECT_NFUNCS, &connect_func, _RESMGR_IO_NFUNCS, &io_func); + iofunc_attr_init (&attr, S_IFNAM | 0777, 0, 0); + + // 2) override functions in "connect_func" and "io_func" as required here + memset (&resmgr_attr, 0, sizeof (resmgr_attr)); + resmgr_attr.nparts_max = 1; + resmgr_attr.msg_max_size = 2048; + + // 3) replace "/dev/whatever" with your device name + if ((id = resmgr_attach (dpp, &resmgr_attr, "/dev/whatever", _FTYPE_ANY, 0, &connect_func, &io_func, &attr)) == -1) { + fprintf (stderr, "%s: Unable to attach name.\n", argv [0]); + return (EXIT_FAILURE); + } + + // Never returns + thread_pool_start (tpp); + + return (EXIT_SUCCESS); +} + +/* +#include #include #include #include @@ -43,3 +106,4 @@ int main() { return 0; } +*/