forked from xuos/xiuos
				
			Merge branch 'prepare_for_master' of https://gitlink.org.cn/xuos/xiuos into jerryscript
This commit is contained in:
		
						commit
						fa439abd68
					
				| 
						 | 
					@ -335,10 +335,22 @@ void TestSocket(int argc, char* argv[])
 | 
				
			||||||
    if (mode == IPERF_MODE_SERVER) {
 | 
					    if (mode == IPERF_MODE_SERVER) {
 | 
				
			||||||
        printf("[%s] Running iperf server at port %d.\n", __func__, iperf_param.port);
 | 
					        printf("[%s] Running iperf server at port %d.\n", __func__, iperf_param.port);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        PrivTaskCreate(&thd, NULL, TestIperfServer, (void*)&iperf_param);
 | 
					#ifdef ADD_XIZI_FEATURES
 | 
				
			||||||
 | 
					        char task_name[] = "test_iperf_server";
 | 
				
			||||||
 | 
					        pthread_args_t args;
 | 
				
			||||||
 | 
					        args.pthread_name = task_name;
 | 
				
			||||||
 | 
					        args.arg = (void *)&iperf_param;
 | 
				
			||||||
 | 
					        PrivTaskCreate(&thd, NULL, TestIperfServer, (void*)&args);
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
    } else if (mode == IPERF_MODE_CLIENT) {
 | 
					    } else if (mode == IPERF_MODE_CLIENT) {
 | 
				
			||||||
        printf("[%s] Running iperf client to server at %s:%d.\n", __func__, iperf_param.host, iperf_param.port);
 | 
					        printf("[%s] Running iperf client to server at %s:%d.\n", __func__, iperf_param.host, iperf_param.port);
 | 
				
			||||||
        PrivTaskCreate(&thd, NULL, TestIperfClient, (void*)&iperf_param);
 | 
					#ifdef ADD_XIZI_FEATURES
 | 
				
			||||||
 | 
					        char task_name[] = "test_iperf_client";
 | 
				
			||||||
 | 
					        pthread_args_t args;
 | 
				
			||||||
 | 
					        args.pthread_name = task_name;
 | 
				
			||||||
 | 
					        args.arg = (void *)&iperf_param;
 | 
				
			||||||
 | 
					        PrivTaskCreate(&thd, NULL, TestIperfClient, (void*)&args);
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    PrivTaskStartup(&thd);
 | 
					    PrivTaskStartup(&thd);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -549,13 +549,19 @@ static int ATAgentInit(ATAgentType agent)
 | 
				
			||||||
    attr.priority = 18;
 | 
					    attr.priority = 18;
 | 
				
			||||||
    attr.stacksize = 8192;
 | 
					    attr.stacksize = 8192;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    PrivTaskCreate(&agent->at_handler, &attr, ATAgentReceiveProcess, agent);
 | 
				
			||||||
#else
 | 
					#else
 | 
				
			||||||
    pthread_attr_t attr;
 | 
					    pthread_attr_t attr;
 | 
				
			||||||
    attr.schedparam.sched_priority = 25;
 | 
					    attr.schedparam.sched_priority = 25;
 | 
				
			||||||
    attr.stacksize = 4096;
 | 
					    attr.stacksize = 4096;
 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    PrivTaskCreate(&agent->at_handler, &attr, ATAgentReceiveProcess, agent);
 | 
					    char task_name[] = "at_agent";
 | 
				
			||||||
 | 
					    pthread_args_t args;
 | 
				
			||||||
 | 
					    args.pthread_name = task_name;
 | 
				
			||||||
 | 
					    args.arg = (void *)agent;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    PrivTaskCreate(&agent->at_handler, &attr, ATAgentReceiveProcess, (void *)&args);
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return result;
 | 
					    return result;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -848,8 +848,10 @@ static int AdapterLoraRegister(struct Adapter *adapter)
 | 
				
			||||||
    ret = AdapterDeviceRegister(adapter);
 | 
					    ret = AdapterDeviceRegister(adapter);
 | 
				
			||||||
    if (ret < 0) {
 | 
					    if (ret < 0) {
 | 
				
			||||||
        printf("Adapter4G register error\n");
 | 
					        printf("Adapter4G register error\n");
 | 
				
			||||||
 | 
					#ifdef AS_LORA_GATEWAY_ROLE
 | 
				
			||||||
        if (lora_gateway)
 | 
					        if (lora_gateway)
 | 
				
			||||||
            PrivFree(lora_gateway);
 | 
					            PrivFree(lora_gateway);
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
        if (lora_client)
 | 
					        if (lora_client)
 | 
				
			||||||
            PrivFree(lora_client);
 | 
					            PrivFree(lora_client);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -952,22 +954,32 @@ int AdapterLoraTest(void)
 | 
				
			||||||
    pthread_attr_t lora_gateway_attr = PTHREAD_ATTR_INITIALIZER;
 | 
					    pthread_attr_t lora_gateway_attr = PTHREAD_ATTR_INITIALIZER;
 | 
				
			||||||
    lora_gateway_attr.priority = 20;
 | 
					    lora_gateway_attr.priority = 20;
 | 
				
			||||||
    lora_gateway_attr.stacksize = 2048;
 | 
					    lora_gateway_attr.stacksize = 2048;
 | 
				
			||||||
 | 
					    PrivTaskCreate(&lora_recv_data_task, &lora_gateway_attr, &LoraReceiveTask, (void *)adapter);
 | 
				
			||||||
#else
 | 
					#else
 | 
				
			||||||
    pthread_attr_t lora_gateway_attr;
 | 
					    pthread_attr_t lora_gateway_attr;
 | 
				
			||||||
    lora_gateway_attr.schedparam.sched_priority = 20;
 | 
					    lora_gateway_attr.schedparam.sched_priority = 20;
 | 
				
			||||||
    lora_gateway_attr.stacksize = 2048;
 | 
					    lora_gateway_attr.stacksize = 2048;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    char task_name_1[] = "adapter_lora_recv";
 | 
				
			||||||
 | 
					    pthread_args_t args;
 | 
				
			||||||
 | 
					    args.pthread_name = task_name_1;
 | 
				
			||||||
 | 
					    args.arg = (void *)adapter;
 | 
				
			||||||
 | 
					    PrivTaskCreate(&lora_recv_data_task, &lora_gateway_attr, &LoraReceiveTask, (void *)&args);
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    PrivTaskCreate(&lora_recv_data_task, &lora_gateway_attr, &LoraReceiveTask, (void *)adapter);
 | 
					 | 
				
			||||||
    PrivTaskStartup(&lora_recv_data_task);
 | 
					    PrivTaskStartup(&lora_recv_data_task);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef ADD_NUTTX_FEATURES
 | 
					#ifdef ADD_NUTTX_FEATURES
 | 
				
			||||||
    lora_gateway_attr.priority = 20;
 | 
					    lora_gateway_attr.priority = 20;
 | 
				
			||||||
 | 
					    PrivTaskCreate(&lora_gateway_task, &lora_gateway_attr, &LoraGatewayTask, (void *)adapter);
 | 
				
			||||||
#else   
 | 
					#else   
 | 
				
			||||||
    lora_gateway_attr.schedparam.sched_priority = 20;
 | 
					    lora_gateway_attr.schedparam.sched_priority = 20;
 | 
				
			||||||
 | 
					    char task_name_2[] = "adapter_lora_gateway";
 | 
				
			||||||
 | 
					    args.pthread_name = task_name_2;
 | 
				
			||||||
 | 
					    args.arg = (void *)adapter;
 | 
				
			||||||
 | 
					    PrivTaskCreate(&lora_recv_data_task, &lora_gateway_attr, &LoraReceiveTask, (void *)&args);
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    PrivTaskCreate(&lora_gateway_task, &lora_gateway_attr, &LoraGatewayTask, (void *)adapter);
 | 
					 | 
				
			||||||
    PrivTaskStartup(&lora_gateway_task);
 | 
					    PrivTaskStartup(&lora_gateway_task);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#else //AS_LORA_CLIENT_ROLE
 | 
					#else //AS_LORA_CLIENT_ROLE
 | 
				
			||||||
| 
						 | 
					@ -975,22 +987,34 @@ int AdapterLoraTest(void)
 | 
				
			||||||
    pthread_attr_t lora_client_attr = PTHREAD_ATTR_INITIALIZER;
 | 
					    pthread_attr_t lora_client_attr = PTHREAD_ATTR_INITIALIZER;
 | 
				
			||||||
    lora_client_attr.priority = 20;
 | 
					    lora_client_attr.priority = 20;
 | 
				
			||||||
    lora_client_attr.stacksize = 2048;
 | 
					    lora_client_attr.stacksize = 2048;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    PrivTaskCreate(&lora_recv_data_task, &lora_client_attr, &LoraReceiveTask, (void *)adapter);
 | 
				
			||||||
#else
 | 
					#else
 | 
				
			||||||
    pthread_attr_t lora_client_attr;
 | 
					    pthread_attr_t lora_client_attr;
 | 
				
			||||||
    lora_client_attr.schedparam.sched_priority = 20;
 | 
					    lora_client_attr.schedparam.sched_priority = 20;
 | 
				
			||||||
    lora_client_attr.stacksize = 2048;
 | 
					    lora_client_attr.stacksize = 2048;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    char task_name_1[] = "adapter_lora_recv";
 | 
				
			||||||
 | 
					    pthread_args_t args;
 | 
				
			||||||
 | 
					    args.pthread_name = task_name_1;
 | 
				
			||||||
 | 
					    args.arg = (void *)adapter;
 | 
				
			||||||
 | 
					    PrivTaskCreate(&lora_recv_data_task, &lora_client_attr, &LoraReceiveTask, (void *)&args);
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
    PrivTaskCreate(&lora_recv_data_task, &lora_client_attr, &LoraReceiveTask, (void *)adapter);
 | 
					
 | 
				
			||||||
    PrivTaskStartup(&lora_recv_data_task);
 | 
					    PrivTaskStartup(&lora_recv_data_task);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef ADD_NUTTX_FEATURES
 | 
					#ifdef ADD_NUTTX_FEATURES
 | 
				
			||||||
    lora_client_attr.priority = 20;
 | 
					    lora_client_attr.priority = 20;
 | 
				
			||||||
 | 
					    PrivTaskCreate(&lora_client_data_task, &lora_client_attr, &LoraClientDataTask, (void *)adapter);
 | 
				
			||||||
#else   
 | 
					#else   
 | 
				
			||||||
    lora_client_attr.schedparam.sched_priority = 20;
 | 
					    lora_client_attr.schedparam.sched_priority = 20;
 | 
				
			||||||
 | 
					    char task_name_2[] = "adapter_lora_client";
 | 
				
			||||||
 | 
					    args.pthread_name = task_name_2;
 | 
				
			||||||
 | 
					    args.arg = (void *)adapter;
 | 
				
			||||||
 | 
					    PrivTaskCreate(&lora_client_data_task, &lora_client_attr, &LoraClientDataTask, (void *)&args);
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    //create lora client task
 | 
					    //create lora client task
 | 
				
			||||||
    PrivTaskCreate(&lora_client_data_task, &lora_client_attr, &LoraClientDataTask, (void *)adapter);
 | 
					 | 
				
			||||||
    PrivTaskStartup(&lora_client_data_task);
 | 
					    PrivTaskStartup(&lora_client_data_task);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -322,7 +322,12 @@ int ControlProtocolOpenDef(struct ControlProtocol *control_protocol)
 | 
				
			||||||
    attr.schedparam.sched_priority = 19;
 | 
					    attr.schedparam.sched_priority = 19;
 | 
				
			||||||
    attr.stacksize = 2048;
 | 
					    attr.stacksize = 2048;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    PrivTaskCreate(&recv_plc_data_task, &attr, &ReceivePlcDataTask, control_protocol);
 | 
					    char task_name[] = "control_recv_data";
 | 
				
			||||||
 | 
					    pthread_args_t args;
 | 
				
			||||||
 | 
					    args.pthread_name = task_name;
 | 
				
			||||||
 | 
					    args.arg = (void *)control_protocol;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    PrivTaskCreate(&recv_plc_data_task, &attr, &ReceivePlcDataTask, (void *)&args);
 | 
				
			||||||
    PrivTaskStartup(&recv_plc_data_task);
 | 
					    PrivTaskStartup(&recv_plc_data_task);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -80,7 +80,12 @@ static int SensorDeviceOpen(struct SensorDevice *sdev)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    result = PrivIoctl(sdev->fd, OPE_INT, &cfg);
 | 
					    result = PrivIoctl(sdev->fd, OPE_INT, &cfg);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    PrivTaskCreate(&active_task_id, NULL, &ReadTask, sdev);
 | 
					    char task_name[] = "ps5308_recv_data";
 | 
				
			||||||
 | 
					    pthread_args_t args;
 | 
				
			||||||
 | 
					    args.pthread_name = task_name;
 | 
				
			||||||
 | 
					    args.arg = (void *)sdev;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    PrivTaskCreate(&active_task_id, NULL, &ReadTask, (void *)&args);
 | 
				
			||||||
    PrivTaskStartup(&active_task_id);
 | 
					    PrivTaskStartup(&active_task_id);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return result;
 | 
					    return result;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -116,7 +116,12 @@ static int SensorDeviceOpen(struct SensorDevice *sdev)
 | 
				
			||||||
    attr.schedparam.sched_priority = 20;
 | 
					    attr.schedparam.sched_priority = 20;
 | 
				
			||||||
    attr.stacksize = 2048;
 | 
					    attr.stacksize = 2048;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    PrivTaskCreate(&active_task_id, &attr, &ReadTask, sdev);
 | 
					    char task_name[] = "d124_recv_data";
 | 
				
			||||||
 | 
					    pthread_args_t args;
 | 
				
			||||||
 | 
					    args.pthread_name = task_name;
 | 
				
			||||||
 | 
					    args.arg = (void *)sdev;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    PrivTaskCreate(&active_task_id, &attr, &ReadTask, (void *)&args);
 | 
				
			||||||
    PrivTaskStartup(&active_task_id);
 | 
					    PrivTaskStartup(&active_task_id);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return result;
 | 
					    return result;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -72,6 +72,11 @@ extern "C" {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
typedef int   pid_t;
 | 
					typedef int   pid_t;
 | 
				
			||||||
// typedef int pthread_mutex_t ;
 | 
					// typedef int pthread_mutex_t ;
 | 
				
			||||||
 | 
					typedef struct pthread_args
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    void *arg;
 | 
				
			||||||
 | 
					    const char *pthread_name;
 | 
				
			||||||
 | 
					}pthread_args_t;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* scheduling algorithms */
 | 
					/* scheduling algorithms */
 | 
				
			||||||
#define SCHED_OTHER		0
 | 
					#define SCHED_OTHER		0
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -29,28 +29,40 @@
 | 
				
			||||||
int pthread_create(pthread_t *thread, const pthread_attr_t *attr,
 | 
					int pthread_create(pthread_t *thread, const pthread_attr_t *attr,
 | 
				
			||||||
                   void *(*start_routine)(void *), void *arg)
 | 
					                   void *(*start_routine)(void *), void *arg)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    int ret ;
 | 
					    int ret;
 | 
				
			||||||
    int pid ;
 | 
					    int pid;
 | 
				
			||||||
    char task_name[32] = {0};
 | 
					    char task_name[32] = {0};
 | 
				
			||||||
    static int utask_id = 0;
 | 
					    static int utask_id = 0;
 | 
				
			||||||
    UtaskType task ;
 | 
					    UtaskType task;
 | 
				
			||||||
 | 
					    pthread_args_t *pthread_args = (pthread_args_t *)arg;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (NULL == attr) {
 | 
					    if (NULL == attr) {
 | 
				
			||||||
        task.prio = KTASK_PRIORITY_MAX / 2;
 | 
					        task.prio = KTASK_PRIORITY_MAX / 2;
 | 
				
			||||||
        task.stack_size = 4096 ;
 | 
					        task.stack_size = 4096;
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
        task.prio = attr->schedparam.sched_priority ;
 | 
					        task.prio = attr->schedparam.sched_priority;
 | 
				
			||||||
        task.stack_size = attr->stacksize ;
 | 
					        task.stack_size = attr->stacksize;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    task.func_entry = start_routine;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (NULL == pthread_args) {
 | 
				
			||||||
 | 
					        task.func_param = NULL;
 | 
				
			||||||
 | 
					        snprintf(task_name, sizeof(task_name) - 1, "utask%02d", utask_id++);
 | 
				
			||||||
 | 
					    } else {
 | 
				
			||||||
 | 
					        task.func_param = pthread_args->arg;
 | 
				
			||||||
 | 
					        if (NULL == pthread_args->pthread_name) {
 | 
				
			||||||
 | 
					            snprintf(task_name, sizeof(task_name) - 1, "utask%02d", utask_id++);
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					            snprintf(task_name, sizeof(task_name) - 1, pthread_args->pthread_name);
 | 
				
			||||||
 | 
					        } 
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    task.func_entry = start_routine ;
 | 
					 | 
				
			||||||
    task.func_param = arg;
 | 
					 | 
				
			||||||
    snprintf(task_name, sizeof(task_name) - 1, "utask%02d",utask_id++);
 | 
					 | 
				
			||||||
    memcpy(task.name , task_name, sizeof(task_name) - 1);
 | 
					    memcpy(task.name , task_name, sizeof(task_name) - 1);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    pid = UserTaskCreate(task);
 | 
					    pid = UserTaskCreate(task);
 | 
				
			||||||
    if (pid < 0)
 | 
					    if (pid < 0)
 | 
				
			||||||
      return -1 ;
 | 
					        return -1;
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    ret = UserTaskStartup(pid);
 | 
					    ret = UserTaskStartup(pid);
 | 
				
			||||||
    *thread = (pthread_t)(long)pid;
 | 
					    *thread = (pthread_t)(long)pid;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -25,8 +25,11 @@
 | 
				
			||||||
#include "include/semaphore.h"
 | 
					#include "include/semaphore.h"
 | 
				
			||||||
#include "include/pthread.h"
 | 
					#include "include/pthread.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static sem_t timer_sem;
 | 
					#define TIMER_NUM 20
 | 
				
			||||||
static pthread_t timer_task;
 | 
					
 | 
				
			||||||
 | 
					static sem_t timer_sem[TIMER_NUM];
 | 
				
			||||||
 | 
					static pthread_t timer_task[TIMER_NUM];
 | 
				
			||||||
 | 
					static char timer_idx[TIMER_NUM];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct timer_func {
 | 
					struct timer_func {
 | 
				
			||||||
    union sigval value;
 | 
					    union sigval value;
 | 
				
			||||||
| 
						 | 
					@ -34,16 +37,17 @@ struct timer_func {
 | 
				
			||||||
    void (* user_timer_function)(union sigval val);
 | 
					    void (* user_timer_function)(union sigval val);
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct timer_func g_timer_func;
 | 
					struct timer_func g_timer_func[TIMER_NUM];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void *timer_callback(void *args) 
 | 
					static void *timer_callback(void *args) 
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    struct sigevent *evp = (struct sigevent *)args;
 | 
					    clockid_t clockid = *((clockid_t *)args);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    while (1) {
 | 
					    while (1) {
 | 
				
			||||||
        if (g_timer_func.user_timer_function != NULL) {
 | 
					        if (g_timer_func[clockid].user_timer_function != NULL) {
 | 
				
			||||||
            if (0 == sem_timedwait(&timer_sem, NULL)) {
 | 
					            if (0 == sem_timedwait(&(timer_sem[clockid]), NULL)) {
 | 
				
			||||||
                g_timer_func.user_timer_function(g_timer_func.value);
 | 
					                g_timer_func[clockid].value.sival_ptr = &clockid;
 | 
				
			||||||
 | 
					                g_timer_func[clockid].user_timer_function(g_timer_func[clockid].value);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
| 
						 | 
					@ -68,30 +72,37 @@ int timer_create(clockid_t clockid, struct sigevent * evp, timer_t * timerid)
 | 
				
			||||||
    memset(timer_name, 0, sizeof(timer_name));
 | 
					    memset(timer_name, 0, sizeof(timer_name));
 | 
				
			||||||
    snprintf(timer_name, sizeof(timer_name), "timer_%ld", clockid);
 | 
					    snprintf(timer_name, sizeof(timer_name), "timer_%ld", clockid);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    sem_init(&timer_sem, 0, 0);
 | 
					    sem_init(&(timer_sem[clockid]), 0, 0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    g_timer_func.value = evp->sigev_value;
 | 
					    g_timer_func[clockid].value = evp->sigev_value;
 | 
				
			||||||
    g_timer_func.user_timer_function = evp->sigev_notify_function;
 | 
					    g_timer_func[clockid].user_timer_function = evp->sigev_notify_function;
 | 
				
			||||||
    g_timer_func.timer_flags = *(int *)(evp->sigev_notify_attributes);
 | 
					    g_timer_func[clockid].timer_flags = *(int *)(evp->sigev_notify_attributes);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    pthread_attr_t attr;
 | 
					    pthread_attr_t attr;
 | 
				
			||||||
    attr.schedparam.sched_priority = 22;
 | 
					    attr.schedparam.sched_priority = 22;
 | 
				
			||||||
    attr.stacksize = 2048;
 | 
					    attr.stacksize = 2048;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    pthread_create(&timer_task, &attr, &timer_callback, (void *)evp);
 | 
					    pthread_args_t args;
 | 
				
			||||||
 | 
					    args.pthread_name = timer_name;
 | 
				
			||||||
 | 
					    args.arg = &clockid;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    timer_id = UserTimerCreate(timer_name, NULL, (void *)&timer_sem, 1000, g_timer_func.timer_flags);
 | 
					    pthread_create(&(timer_task[clockid]), &attr, &timer_callback, (void *)&args);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    timer_id = UserTimerCreate(timer_name, NULL, (void *)&(timer_sem[clockid]), clockid, g_timer_func[clockid].timer_flags);
 | 
				
			||||||
    *timerid = timer_id;
 | 
					    *timerid = timer_id;
 | 
				
			||||||
    return timer_id;
 | 
					    return timer_id;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int timer_delete(timer_t timerid)
 | 
					int timer_delete(timer_t timerid)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    pthread_kill(timer_task, 0);
 | 
					    sem_t sem;
 | 
				
			||||||
 | 
					    int timer_id = timerid;
 | 
				
			||||||
 | 
					    pthread_kill(timer_task[timer_id], 0);
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    UserTimerQuitRun(timerid);
 | 
					    UserTimerQuitRun(timerid);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    sem_destroy(&timer_sem);
 | 
					    sem = timer_sem[timer_id];
 | 
				
			||||||
 | 
					    sem_destroy(&sem);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return 0;
 | 
					    return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -20,10 +20,14 @@ xiuos/APP_Framework/lib/lorawan
 | 
				
			||||||
 | 
					
 | 
				
			||||||
```
 | 
					```
 | 
				
			||||||
# 下载代码
 | 
					# 下载代码
 | 
				
			||||||
# 进入APP_Framework/lib/lorawan目录下载更新子模块
 | 
					# 进入APP_Framework/lib/lorawan目录下载更新子模块,首先执行以下命令:
 | 
				
			||||||
git submodule init
 | 
					git submodule init
 | 
				
			||||||
 | 
					# 若需要使用lora_radio_driver子模块,执行以下命令:
 | 
				
			||||||
git submodule update APP_Framework/lib/lorawan/lora_radio_driver
 | 
					git submodule update APP_Framework/lib/lorawan/lora_radio_driver
 | 
				
			||||||
 | 
					# 若需要使用lorawan_devicenode子模块,执行以下命令:
 | 
				
			||||||
git submodule update APP_Framework/lib/lorawan/lorawan_devicenode
 | 
					git submodule update APP_Framework/lib/lorawan/lorawan_devicenode
 | 
				
			||||||
 | 
					# 若需要使用lorawan_gateway_single_channel子模块,执行以下命令:
 | 
				
			||||||
 | 
					git submodule update APP_Framework/lib/lorawan/lorawan_gateway_single_channel
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# 进入 APP_Framework/lib/lorawan/Kconfig 配置,增加子模块source路径,从而编译时可找到相应lib的配置
 | 
					# 进入 APP_Framework/lib/lorawan/Kconfig 配置,增加子模块source路径,从而编译时可找到相应lib的配置
 | 
				
			||||||
menuconfig LIB_USING_LORAWAN_GATEWAY_SC
 | 
					menuconfig LIB_USING_LORAWAN_GATEWAY_SC
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1 +1 @@
 | 
				
			||||||
Subproject commit a94c007cb4ee726cc29b10626f8bbfc19c989b89
 | 
					Subproject commit 0ced8f47f86ea96a414479424d7f534426a818eb
 | 
				
			||||||
| 
						 | 
					@ -1 +1 @@
 | 
				
			||||||
Subproject commit 254754bc7d06011cbec4655cd229c8ccfb95240b
 | 
					Subproject commit 4c543f77fcc639696939098a31145fdc1654f0f6
 | 
				
			||||||
| 
						 | 
					@ -1 +1 @@
 | 
				
			||||||
Subproject commit ac1c6516ec9b2998c0c50796a4e5a8b78781dc8c
 | 
					Subproject commit 986318f686df3e77eb3dc6cc690b3d1da3a32359
 | 
				
			||||||
| 
						 | 
					@ -5,7 +5,7 @@ MAKEFLAGS += --no-print-directory
 | 
				
			||||||
.PHONY:COMPILE_APP COMPILE_KERNEL
 | 
					.PHONY:COMPILE_APP COMPILE_KERNEL
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
riscv_support := kd233 maix-go hifive1-rev-B gapuino gd32vf103-rvstar rv32m1-vega aiit-riscv64-board xidatong-riscv64 edu-riscv64
 | 
					riscv_support := kd233 maix-go hifive1-rev-B gapuino gd32vf103-rvstar rv32m1-vega aiit-riscv64-board xidatong-riscv64 edu-riscv64 ch32v307vct6
 | 
				
			||||||
arm_support += stm32f407-st-discovery stm32f407zgt6 stm32f103-nano nuvoton-m2354 ok1052-c imxrt1176-sbc aiit-arm32-board xidatong-arm32 xiwangtong-arm32 edu-arm32
 | 
					arm_support += stm32f407-st-discovery stm32f407zgt6 stm32f103-nano nuvoton-m2354 ok1052-c imxrt1176-sbc aiit-arm32-board xidatong-arm32 xiwangtong-arm32 edu-arm32
 | 
				
			||||||
emulator_support += hifive1-emulator k210-emulator cortex-m0-emulator cortex-m3-emulator cortex-m4-emulator
 | 
					emulator_support += hifive1-emulator k210-emulator cortex-m0-emulator cortex-m3-emulator cortex-m4-emulator
 | 
				
			||||||
support := $(riscv_support) $(arm_support) $(emulator_support) 
 | 
					support := $(riscv_support) $(arm_support) $(emulator_support) 
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,6 +1,6 @@
 | 
				
			||||||
export CROSS_COMPILE ?=/usr/bin/arm-none-eabi-
 | 
					export CROSS_COMPILE ?=/usr/bin/arm-none-eabi-
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export CFLAGS := -mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=softfp -ffunction-sections -fdata-sections -Dgcc -O0 -fgnu89-inline -Wa,-mimplicit-it=thumb -Werror -Wformat -Wuninitialized
 | 
					export CFLAGS := -mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=softfp -ffunction-sections -fdata-sections -Dgcc -O0 -fgnu89-inline -Wa,-mimplicit-it=thumb -Werror -Wuninitialized
 | 
				
			||||||
# export CFLAGS := -mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=softfp -ffunction-sections -fdata-sections -Dgcc -O0 -gdwarf-2 -g -fgnu89-inline -Wa,-mimplicit-it=thumb -Werror
 | 
					# export CFLAGS := -mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=softfp -ffunction-sections -fdata-sections -Dgcc -O0 -gdwarf-2 -g -fgnu89-inline -Wa,-mimplicit-it=thumb -Werror
 | 
				
			||||||
export AFLAGS := -c -mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=softfp -ffunction-sections -fdata-sections -x assembler-with-cpp -Wa,-mimplicit-it=thumb  -gdwarf-2
 | 
					export AFLAGS := -c -mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=softfp -ffunction-sections -fdata-sections -x assembler-with-cpp -Wa,-mimplicit-it=thumb  -gdwarf-2
 | 
				
			||||||
export LFLAGS := -mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=softfp -ffunction-sections -fdata-sections -Wl,--gc-sections,-Map=XiZi-edu-arm32.map,-cref,-u,Reset_Handler -T $(BSP_ROOT)/link.lds
 | 
					export LFLAGS := -mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=softfp -ffunction-sections -fdata-sections -Wl,--gc-sections,-Map=XiZi-edu-arm32.map,-cref,-u,Reset_Handler -T $(BSP_ROOT)/link.lds
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -775,19 +775,24 @@ uint8_t UserGetTaskPriority(int32_t id)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef KERNEL_SOFTTIMER
 | 
					#ifdef KERNEL_SOFTTIMER
 | 
				
			||||||
static int32 timer_sem;
 | 
					#define TIMER_NUM 20
 | 
				
			||||||
 | 
					static int32 timer_sem[TIMER_NUM];
 | 
				
			||||||
 | 
					static uint32_t timer_id[TIMER_NUM];
 | 
				
			||||||
static void UserTimerCallback(void *parameter)
 | 
					static void UserTimerCallback(void *parameter)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
   KSemaphoreAbandon(timer_sem);
 | 
					   uint32_t timer_id = *((uint32_t *)parameter);
 | 
				
			||||||
 | 
					   KSemaphoreAbandon(timer_sem[timer_id]);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int32 UserTimerCreate(const char *name, void (*timeout)(void *parameter), void *parameter, uint32_t time, uint8_t trigger_mode)
 | 
					int32 UserTimerCreate(const char *name, void (*timeout)(void *parameter), void *parameter, uint32_t time, uint8_t trigger_mode)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
   int32 ret;
 | 
					   int32 ret;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   timer_sem = *((int *)parameter);
 | 
					   timer_id[time] = time;
 | 
				
			||||||
 | 
					   timer_sem[time] = *((int *)parameter);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   ret = KCreateTimer(name, UserTimerCallback, (void *)&(timer_id[time]), 1000, trigger_mode);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   ret = KCreateTimer(name, UserTimerCallback, NONE, time, trigger_mode);
 | 
					 | 
				
			||||||
   return ret;
 | 
					   return ret;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -301,7 +301,9 @@ void CheckTimerList(void)
 | 
				
			||||||
                ((WorkQueueDoneType *)sys_workq->done)->WorkSubmit((WorkqueueType *)sys_workq->property, t->t_work, 0);
 | 
					                ((WorkQueueDoneType *)sys_workq->done)->WorkSubmit((WorkqueueType *)sys_workq->property, t->t_work, 0);
 | 
				
			||||||
                lock = CriticalAreaLock();
 | 
					                lock = CriticalAreaLock();
 | 
				
			||||||
            } else {
 | 
					            } else {
 | 
				
			||||||
                KPrintf("sortlist run unactive timer(%s), quit this timer\n", t->name);
 | 
					                // KPrintf("sortlist run unactive timer(%s), current %d deadline %d quit this timer\n", 
 | 
				
			||||||
 | 
					                //     t->name, current_tick, t->deadline_timeslice);
 | 
				
			||||||
 | 
					                break;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        else
 | 
					        else
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -286,6 +286,7 @@ static inline int SerialDevDMARead(struct SerialHardwareDevice *serial_dev, stru
 | 
				
			||||||
    x_size_t read_dma_length;
 | 
					    x_size_t read_dma_length;
 | 
				
			||||||
    x_size_t read_dma_size = SerialGetRxFifoLength(serial_dev);
 | 
					    x_size_t read_dma_size = SerialGetRxFifoLength(serial_dev);
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
 | 
					    lock = CriticalAreaLock();
 | 
				
			||||||
    if (serial_cfg->data_cfg.serial_buffer_size) {
 | 
					    if (serial_cfg->data_cfg.serial_buffer_size) {
 | 
				
			||||||
        if(read_length < (int)read_dma_size)
 | 
					        if(read_length < (int)read_dma_size)
 | 
				
			||||||
            read_dma_length = read_length;
 | 
					            read_dma_length = read_length;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue