change printf to syslog on ch438

This commit is contained in:
wgzAIIT 2022-04-26 18:27:15 +08:00
parent a09caa272f
commit e3cb9df9b6
3 changed files with 67 additions and 34 deletions

View File

@ -1,31 +1,22 @@
/**************************************************************************** /*
* apps/examples/sx127x_demo/sx127x_demo.c * Copyright (c) 2020 AIIT XUOS Lab
* * XiOS is licensed under Mulan PSL v2.
* Licensed to the Apache Software Foundation (ASF) under one or more * You can use this software according to the terms and conditions of the Mulan PSL v2.
* contributor license agreements. See the NOTICE file distributed with * You may obtain a copy of Mulan PSL v2 at:
* this work for additional information regarding copyright ownership. The * http://license.coscl.org.cn/MulanPSL2
* ASF licenses this file to you under the Apache License, Version 2.0 (the * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* "License"); you may not use this file except in compliance with the * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* License. You may obtain a copy of the License at * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* * See the Mulan PSL v2 for more details.
* http://www.apache.org/licenses/LICENSE-2.0 */
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/** /**
* @file ch438_demo.c * @file ch438_demo.c
* @brief nuttx source code * @brief imxrt board sd card automount
* https://github.com/apache/incubator-nuttx-apps * @version 1.0
* @version 10.2.0 * @author AIIT XUOS Lab
* @author AIIT XUOS Lab * @date 2022.04.26
* @date 2022-03-17 */
*/
/**************************************************************************** /****************************************************************************
* Included Files * Included Files
@ -48,6 +39,7 @@
#include <debug.h> #include <debug.h>
#include <poll.h> #include <poll.h>
#include <fcntl.h> #include <fcntl.h>
#include <syslog.h>
#include "imxrt_ch438.h" #include "imxrt_ch438.h"
@ -57,14 +49,14 @@
void CH438Demo(void) void CH438Demo(void)
{ {
int i=0; int i=0;
printf("ch438_main\n"); syslog(LOG_INFO,"ch438_main\n");
Ch438InitDefault(); Ch438InitDefault();
ch438_irq_enable(); ch438_irq_enable();
up_mdelay(1000); up_mdelay(1000);
while(1) while(1)
{ {
CH438UARTSend(2,"AT+BAUD=?",9); CH438UARTSend(2,"AT+BAUD=?",9);
printf("send success\n"); syslog(LOG_INFO,"send success\n");
ImxrtCh438ReadData(NULL); ImxrtCh438ReadData(NULL);
up_mdelay(2000); up_mdelay(2000);
} }

View File

@ -1,7 +1,28 @@
/*
* Copyright (c) 2020 AIIT XUOS Lab
* XiOS is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
*/
/**
* @file imxrt_ch438.c
* @brief imxrt board sd card automount
* @version 1.0
* @author AIIT XUOS Lab
* @date 2022.04.26
*/
#include <nuttx/config.h> #include <nuttx/config.h>
#include <sys/types.h> #include <sys/types.h>
#include <errno.h> #include <errno.h>
#include <syslog.h>
#include <nuttx/arch.h> #include <nuttx/arch.h>
#include <nuttx/irq.h> #include <nuttx/irq.h>
@ -91,12 +112,12 @@ void* ImxrtCh438ReadData(void *parameter)
// abstime.tv_sec = 2; // abstime.tv_sec = 2;
// while (1) // while (1)
// { // {
printf("sem_438 is %d\n",sem_438.semcount); syslog(LOG_INFO, "sem_438 is %d\n",sem_438.semcount);
result = sem_wait(&sem_438); result = sem_wait(&sem_438);
if (result == OK) if (result == OK)
{ {
gInterruptStatus = ReadCH438Data( REG_SSR_ADDR ); gInterruptStatus = ReadCH438Data( REG_SSR_ADDR );
printf("gInterruptStatus is %d\n", gInterruptStatus); syslog(LOG_INFO,"gInterruptStatus is %d\n", gInterruptStatus);
if(!gInterruptStatus) if(!gInterruptStatus)
{ {
@ -122,7 +143,7 @@ void* ImxrtCh438ReadData(void *parameter)
REG_MSR_ADDR = offsetadd[ext_uart_no] | REG_MSR0_ADDR; REG_MSR_ADDR = offsetadd[ext_uart_no] | REG_MSR0_ADDR;
InterruptStatus = ReadCH438Data( REG_IIR_ADDR ) & 0x0f; /* 读串口的中断状态 */ InterruptStatus = ReadCH438Data( REG_IIR_ADDR ) & 0x0f; /* 读串口的中断状态 */
printf("InterruptStatus is %d\n", InterruptStatus); syslog(LOG_INFO,"InterruptStatus is %d\n", InterruptStatus);
switch( InterruptStatus ) switch( InterruptStatus )
{ {
@ -136,7 +157,7 @@ void* ImxrtCh438ReadData(void *parameter)
RevLen = CH438UARTRcv(ext_uart_no, buff[ext_uart_no]); RevLen = CH438UARTRcv(ext_uart_no, buff[ext_uart_no]);
for(i=0;i<RevLen;++i) for(i=0;i<RevLen;++i)
{ {
printf("%c(0x%x) ", buff[ext_uart_no][i], buff[ext_uart_no][i]); syslog(LOG_INFO,"%c(0x%x) ", buff[ext_uart_no][i], buff[ext_uart_no][i]);
} }
for(i=0;i<128;i++) for(i=0;i<128;i++)
@ -170,13 +191,13 @@ void Ch438InitDefault(void)
int ret = 0; int ret = 0;
sem_init(&sem_438, 0, 0); sem_init(&sem_438, 0, 0);
printf("sem_438 init is %d\n",sem_438.semcount); syslog(LOG_INFO,"sem_438 init is %d\n",sem_438.semcount);
// attr.priority = 120; // attr.priority = 120;
// attr.stacksize = 8192; // attr.stacksize = 8192;
// ret = pthread_create(&thr_438, &attr, &ImxrtCh438ReadData, NULL); // ret = pthread_create(&thr_438, &attr, &ImxrtCh438ReadData, NULL);
if (ret != 0){ if (ret != 0){
printf("ImxrtCh438ReadData: task create failed, status=%d\n", ret); syslog(LOG_INFO,"ImxrtCh438ReadData: task create failed, status=%d\n", ret);
} }
ImxrtCH438Init(); ImxrtCH438Init();

View File

@ -1,3 +1,23 @@
/*
* Copyright (c) 2020 AIIT XUOS Lab
* XiOS is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
*/
/**
* @file imxrt_ch438.h
* @brief imxrt board sd card automount
* @version 1.0
* @author AIIT XUOS Lab
* @date 2022.04.26
*/
#ifndef __QC_TEST_CH438__ #ifndef __QC_TEST_CH438__
#define __QC_TEST_CH438__ #define __QC_TEST_CH438__