forked from xuos/xiuos
Compare commits
No commits in common. "wang_weigen_master" and "master" have entirely different histories.
wang_weige
...
master
|
|
@ -1,15 +1,9 @@
|
|||
import os
|
||||
Import('RTT_ROOT')
|
||||
Import('rtconfig')
|
||||
from building import *
|
||||
|
||||
cwd = GetCurrentDir()
|
||||
|
||||
SOURCES = ['framework_init.c']
|
||||
path = [cwd]
|
||||
objs = []
|
||||
group = DefineGroup('sensor', SOURCES, depend = [], CPPPATH = [cwd])
|
||||
objs = objs + group
|
||||
list = os.listdir(cwd)
|
||||
|
||||
for d in list:
|
||||
|
|
|
|||
|
|
@ -11,16 +11,13 @@
|
|||
*/
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <transform.h>
|
||||
#include <user_api.h>
|
||||
|
||||
extern int SensorFrameworkInit(void);
|
||||
extern int AdapterFrameworkInit(void);
|
||||
|
||||
extern int Adapter4GInit(void);
|
||||
extern int AdapterNbiotInit(void);
|
||||
extern int AdapterBlueToothInit(void);
|
||||
extern int AdapterWifiInit(void);
|
||||
extern int AdapterZigbeeInit(void);
|
||||
|
||||
extern int D124VoiceInit(void);
|
||||
extern int Hs300xTemperatureInit(void);
|
||||
|
|
@ -92,19 +89,10 @@ static struct InitDesc sensor_desc[] =
|
|||
|
||||
static struct InitDesc connection_desc[] =
|
||||
{
|
||||
#ifdef CONNECTION_ADAPTER_4G
|
||||
#ifdef ADAPTER_4G
|
||||
{ "4G adpter", Adapter4GInit},
|
||||
#endif
|
||||
#ifdef CONNECTION_ADAPTER_NB
|
||||
{ "NB adpter", AdapterNbiotInit},
|
||||
#endif
|
||||
#ifdef CONNECTION_ADAPTER_ZIGBEE
|
||||
{ "zigbee adpter", AdapterZigbeeInit},
|
||||
#endif
|
||||
#ifdef CONNECTION_ADAPTER_BLUETOOTH
|
||||
{ "BlueTooth adpter", AdapterBlueToothInit},
|
||||
#endif
|
||||
#ifdef CONNECTION_ADAPTER_WIFI
|
||||
#ifdef ADAPTER_WIFI
|
||||
{ "Wifi adpter", AdapterWifiInit},
|
||||
#endif
|
||||
{ "NULL", NULL },
|
||||
|
|
|
|||
|
|
@ -1,14 +0,0 @@
|
|||
import os
|
||||
Import('RTT_ROOT')
|
||||
from building import *
|
||||
|
||||
cwd = GetCurrentDir()
|
||||
objs = []
|
||||
list = os.listdir(cwd)
|
||||
|
||||
for d in list:
|
||||
path = os.path.join(cwd, d)
|
||||
if os.path.isfile(os.path.join(path, 'SConscript')):
|
||||
objs = objs + SConscript(os.path.join(path, 'SConscript'))
|
||||
|
||||
Return('objs')
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
import os
|
||||
from building import *
|
||||
Import('RTT_ROOT')
|
||||
Import('rtconfig')
|
||||
cwd = GetCurrentDir()
|
||||
DEPENDS = [""]
|
||||
|
||||
SOURCES = ['double_list.c'] + ['single_list.c']
|
||||
path = [cwd]
|
||||
objs = DefineGroup('list', src = SOURCES, depend = DEPENDS,CPPPATH = path)
|
||||
Return("objs")
|
||||
|
|
@ -23,7 +23,7 @@
|
|||
#define __LIST_H__
|
||||
|
||||
#include "libc.h"
|
||||
#include<stddef.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -9,6 +9,5 @@ menu "knowing app"
|
|||
source "$APP_DIR/Applications/knowing_app/instrusion_detect/Kconfig"
|
||||
source "$APP_DIR/Applications/knowing_app/helmet_detect/Kconfig"
|
||||
source "$APP_DIR/Applications/knowing_app/iris_ml_demo/Kconfig"
|
||||
source "$APP_DIR/Applications/knowing_app/k210_fft_test/Kconfig"
|
||||
endif
|
||||
endmenu
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
#define STACK_SIZE (128 * 1024)
|
||||
#define JSON_FILE_PATH "/kmodel/detect.json"
|
||||
#define JSON_BUFFER_SIZE (4 * 1024)
|
||||
static dmac_channel_number_t dma_ch = DMAC_CHANNEL_MAX;
|
||||
|
||||
// params from json
|
||||
static float anchor[ANCHOR_NUM * 2] = {};
|
||||
static int net_output_shape[3] = {};
|
||||
|
|
@ -184,23 +184,23 @@ void face_detect()
|
|||
}
|
||||
_ioctl_set_dvp_reso set_dvp_reso = {sensor_output_size[1], sensor_output_size[0]};
|
||||
ioctl(g_fd, IOCTRL_CAMERA_SET_DVP_RESO, &set_dvp_reso);
|
||||
showbuffer = (unsigned char *)rt_malloc_align(sensor_output_size[0] * sensor_output_size[1] * 2,64);
|
||||
showbuffer = (unsigned char *)malloc(sensor_output_size[0] * sensor_output_size[1] * 2);
|
||||
if (NULL == showbuffer) {
|
||||
close(g_fd);
|
||||
printf("showbuffer apply memory fail !!");
|
||||
return;
|
||||
}
|
||||
kpurgbbuffer = (unsigned char *)rt_malloc_align(net_input_size[0] * net_input_size[1] * 3,64);
|
||||
kpurgbbuffer = (unsigned char *)malloc(net_input_size[0] * net_input_size[1] * 3);
|
||||
if (NULL == kpurgbbuffer) {
|
||||
close(g_fd);
|
||||
rt_free_align(showbuffer);
|
||||
free(showbuffer);
|
||||
printf("kpurgbbuffer apply memory fail !!");
|
||||
return;
|
||||
}
|
||||
model_data = (unsigned char *)malloc(kmodel_size + 255);
|
||||
if (NULL == model_data) {
|
||||
rt_free_align(showbuffer);
|
||||
rt_free_align(kpurgbbuffer);
|
||||
free(showbuffer);
|
||||
free(kpurgbbuffer);
|
||||
close(g_fd);
|
||||
printf("model_data apply memory fail !!");
|
||||
return;
|
||||
|
|
@ -296,33 +296,27 @@ static void *thread_face_detcet_entry(void *parameter)
|
|||
pthread_exit(NULL);
|
||||
return NULL;
|
||||
}
|
||||
if (dmalock_sync_take(&dma_ch, 2000))
|
||||
{
|
||||
printf("Fail to take DMA channel");
|
||||
}
|
||||
kpu_run_kmodel(&face_detect_task, kpurgbbuffer, DMAC_CHANNEL5, ai_done, NULL);
|
||||
while (!g_ai_done_flag)
|
||||
;
|
||||
dmalock_release(dma_ch);
|
||||
float *output;
|
||||
size_t output_size;
|
||||
kpu_get_output(&face_detect_task, 0, (uint8_t **)&output, &output_size);
|
||||
face_detect_rl.input = output;
|
||||
region_layer_run(&face_detect_rl, &face_detect_info);
|
||||
/* display result */
|
||||
|
||||
#ifdef BSP_USING_LCD
|
||||
for (int face_cnt = 0; face_cnt < face_detect_info.obj_number; face_cnt++) {
|
||||
draw_edge((uint32_t *)showbuffer, &face_detect_info, face_cnt, 0xF800, (uint16_t)sensor_output_size[1],
|
||||
(uint16_t)sensor_output_size[0]);
|
||||
// printf("%d: (%d, %d, %d, %d) cls: %s conf: %f\t", face_cnt, face_detect_info.obj[face_cnt].x1,
|
||||
// face_detect_info.obj[face_cnt].y1, face_detect_info.obj[face_cnt].x2, face_detect_info.obj[face_cnt].y2,
|
||||
// labels[face_detect_info.obj[face_cnt].class_id], face_detect_info.obj[face_cnt].prob);
|
||||
}
|
||||
#ifdef BSP_USING_LCD
|
||||
lcd_draw_picture(0, 0, (uint16_t)sensor_output_size[1], (uint16_t)sensor_output_size[0], (uint32_t *)showbuffer);
|
||||
//lcd_show_image(0, 0, (uint16_t)sensor_output_size[1], (uint16_t)sensor_output_size[0], (unsigned int *)showbuffer);
|
||||
printf("%d: (%d, %d, %d, %d) cls: %s conf: %f\t", face_cnt, face_detect_info.obj[face_cnt].x1,
|
||||
face_detect_info.obj[face_cnt].y1, face_detect_info.obj[face_cnt].x2, face_detect_info.obj[face_cnt].y2,
|
||||
labels[face_detect_info.obj[face_cnt].class_id], face_detect_info.obj[face_cnt].prob);
|
||||
}
|
||||
if (0 != face_detect_info.obj_number) printf("\n");
|
||||
lcd_draw_picture(0, 0, (uint16_t)sensor_output_size[1], (uint16_t)sensor_output_size[0], (unsigned int *)showbuffer);
|
||||
#endif
|
||||
usleep(500);
|
||||
usleep(1);
|
||||
if (1 == if_exit) {
|
||||
if_exit = 0;
|
||||
printf("thread_face_detcet_entry exit");
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@
|
|||
"kmodel_path": "/kmodel/human.kmodel",
|
||||
"kmodel_size": 2713236,
|
||||
"obj_thresh": [
|
||||
0.7
|
||||
0.55
|
||||
],
|
||||
"labels": [
|
||||
"human"
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
#include <transform.h>
|
||||
#include <unistd.h>
|
||||
#ifdef LIB_USING_CJSON
|
||||
#include <cJSON.h>
|
||||
#endif
|
||||
|
|
@ -8,9 +7,7 @@
|
|||
#define STACK_SIZE (128 * 1024)
|
||||
#define JSON_FILE_PATH "/kmodel/human.json"
|
||||
#define JSON_BUFFER_SIZE (4 * 1024)
|
||||
static dmac_channel_number_t dma_ch = DMAC_CHANNEL_MAX;
|
||||
|
||||
extern void lcd_show_image(int x, int y, int wide, int height,const rt_uint8_t *buf);
|
||||
// params from json
|
||||
static float anchor[ANCHOR_NUM * 2] = {};
|
||||
static int net_output_shape[3] = {};
|
||||
|
|
@ -187,23 +184,23 @@ void instrusion_detect()
|
|||
}
|
||||
_ioctl_set_dvp_reso set_dvp_reso = {sensor_output_size[1], sensor_output_size[0]};
|
||||
ioctl(g_fd, IOCTRL_CAMERA_SET_DVP_RESO, &set_dvp_reso);
|
||||
showbuffer = (unsigned char *)rt_malloc_align(sensor_output_size[0] * sensor_output_size[1] * 2,64);
|
||||
showbuffer = (unsigned char *)malloc(sensor_output_size[0] * sensor_output_size[1] * 2);
|
||||
if (NULL == showbuffer) {
|
||||
close(g_fd);
|
||||
printf("showbuffer apply memory fail !!");
|
||||
return;
|
||||
}
|
||||
kpurgbbuffer = (unsigned char *)rt_malloc_align(net_input_size[0] * net_input_size[1] * 3,64);
|
||||
kpurgbbuffer = (unsigned char *)malloc(net_input_size[0] * net_input_size[1] * 3);
|
||||
if (NULL == kpurgbbuffer) {
|
||||
close(g_fd);
|
||||
rt_free_align(showbuffer);
|
||||
free(showbuffer);
|
||||
printf("kpurgbbuffer apply memory fail !!");
|
||||
return;
|
||||
}
|
||||
model_data = (unsigned char *)malloc(kmodel_size + 255);
|
||||
if (NULL == model_data) {
|
||||
rt_free_align(showbuffer);
|
||||
rt_free_align(kpurgbbuffer);
|
||||
free(showbuffer);
|
||||
free(kpurgbbuffer);
|
||||
close(g_fd);
|
||||
printf("model_data apply memory fail !!");
|
||||
return;
|
||||
|
|
@ -284,12 +281,10 @@ void instrusion_detect()
|
|||
#ifdef __RT_THREAD_H__
|
||||
MSH_CMD_EXPORT(instrusion_detect, instrusion detect task);
|
||||
#endif
|
||||
extern void lcd_draw_picture(uint16_t x1, uint16_t y1, uint16_t width, uint16_t height, uint32_t * ptr);
|
||||
extern void lcd_show_image(int x, int y, int wide, int height,const rt_uint8_t *buf);
|
||||
extern void lcd_draw_16_picture(uint16_t x1, uint16_t y1, uint16_t width, uint16_t height, uint32_t * ptr);
|
||||
|
||||
static void *thread_instrusion_detect_entry(void *parameter)
|
||||
{
|
||||
extern void lcd_draw_picture(uint16_t x1, uint16_t y1, uint16_t width, uint16_t height, uint32_t * ptr);
|
||||
printf("thread_instrusion_detect_entry start!\n");
|
||||
int ret = 0;
|
||||
// sysctl_enable_irq();
|
||||
|
|
@ -304,35 +299,31 @@ static void *thread_instrusion_detect_entry(void *parameter)
|
|||
pthread_exit(NULL);
|
||||
return NULL;
|
||||
}
|
||||
if (dmalock_sync_take(&dma_ch, 2000))
|
||||
{
|
||||
printf("Fail to take DMA channel");
|
||||
}
|
||||
kpu_run_kmodel(&instrusion_detect_task, kpurgbbuffer, DMAC_CHANNEL5, ai_done, NULL);
|
||||
while (!g_ai_done_flag)
|
||||
;
|
||||
dmalock_release(dma_ch);
|
||||
float *output;
|
||||
size_t output_size;
|
||||
kpu_get_output(&instrusion_detect_task, 0, (uint8_t **)&output, &output_size);
|
||||
instrusion_detect_rl.input = output;
|
||||
region_layer_run(&instrusion_detect_rl, &instrusion_detect_info);
|
||||
/* display result */
|
||||
for (int instrusion_cnt = 0; instrusion_cnt < instrusion_detect_info.obj_number; instrusion_cnt++)
|
||||
{
|
||||
draw_edge((uint32_t *)showbuffer, &instrusion_detect_info, instrusion_cnt, 0xF800,(uint16_t)sensor_output_size[1],(uint16_t)sensor_output_size[0]);
|
||||
|
||||
for (int instrusion_cnt = 0; instrusion_cnt < instrusion_detect_info.obj_number; instrusion_cnt++) {
|
||||
// draw_edge((uint32_t *)showbuffer, &instrusion_detect_info, instrusion_cnt, 0xF800,
|
||||
// (uint16_t)sensor_output_size[1],
|
||||
// (uint16_t)sensor_output_size[0]);
|
||||
printf("%d: (%d, %d, %d, %d) cls: %s conf: %f\t", instrusion_cnt, instrusion_detect_info.obj[instrusion_cnt].x1,
|
||||
instrusion_detect_info.obj[instrusion_cnt].y1, instrusion_detect_info.obj[instrusion_cnt].x2,
|
||||
instrusion_detect_info.obj[instrusion_cnt].y2, labels[instrusion_detect_info.obj[instrusion_cnt].class_id],
|
||||
instrusion_detect_info.obj[instrusion_cnt].prob);
|
||||
}
|
||||
#ifdef BSP_USING_LCD
|
||||
//lcd_show_image(0, 0,(uint16_t)sensor_output_size[1], (uint16_t)sensor_output_size[0],(unsigned int *)showbuffer);
|
||||
lcd_draw_picture(0, 0, (uint16_t)sensor_output_size[1], (uint16_t)sensor_output_size[0], (uint32_t *)showbuffer);
|
||||
#endif
|
||||
if (0 != instrusion_detect_info.obj_number) {
|
||||
printf("\n");
|
||||
}
|
||||
#ifdef BSP_USING_LCD
|
||||
lcd_draw_picture(0, 0, (uint16_t)sensor_output_size[1], (uint16_t)sensor_output_size[0], (unsigned int *)showbuffer);
|
||||
#endif
|
||||
usleep(1);
|
||||
if (1 == if_exit) {
|
||||
if_exit = 0;
|
||||
|
|
|
|||
|
|
@ -1,3 +0,0 @@
|
|||
config K210_FFT_TEST
|
||||
bool "enable apps/k210 fft test"
|
||||
default n
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
from building import *
|
||||
|
||||
cwd = GetCurrentDir()
|
||||
src = Glob('*.c') + Glob('*.cpp')
|
||||
CPPPATH = [cwd]
|
||||
|
||||
group = DefineGroup('Applications', src, depend = ['K210_FFT_TEST'], LOCAL_CPPPATH = CPPPATH)
|
||||
|
||||
Return('group')
|
||||
|
|
@ -1,101 +0,0 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include "fft_soft.h"
|
||||
|
||||
#define PI 3.14159265358979323846
|
||||
complex add(complex a, complex b)
|
||||
{
|
||||
complex ret = {a.real + b.real, a.imag + b.imag};
|
||||
return ret;
|
||||
}
|
||||
|
||||
complex sub(complex a, complex b)
|
||||
{
|
||||
complex ret = {a.real - b.real, a.imag - b.imag};
|
||||
return ret;
|
||||
}
|
||||
|
||||
complex mul(complex a, complex b)
|
||||
{
|
||||
complex ret = {a.real * b.real - a.imag * b.imag, a.real * b.imag + a.imag * b.real};
|
||||
return ret;
|
||||
}
|
||||
|
||||
void bitrev(complex *data, int n)
|
||||
{
|
||||
int j = 0;
|
||||
int m = 0;
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
if (j > i)
|
||||
SWAP(data[i], data[j]);
|
||||
m = n / 2;
|
||||
while (j >= m && m != 0)
|
||||
{
|
||||
j -= m;
|
||||
m >>= 1;
|
||||
}
|
||||
j += m;
|
||||
}
|
||||
}
|
||||
|
||||
void fft_soft(complex *data, int n)
|
||||
{
|
||||
int M = 0;
|
||||
for (int i = n; i > 1; i = i >> 1, M++);
|
||||
|
||||
bitrev(data, n);
|
||||
|
||||
for (int m = 0; m < M; m++)
|
||||
{
|
||||
int K = n >> (m + 1);
|
||||
for (int k = 0; k < K; k++)
|
||||
{
|
||||
int J = 2 << m;
|
||||
int base = k * J;
|
||||
for (int j = 0; j < J / 2; j++)
|
||||
{
|
||||
int t = base + j;
|
||||
complex w = {cos(-2 * PI * j * K / n), sin(-2 * PI * j * K / n)};
|
||||
complex wn = mul(data[t + J / 2], w);
|
||||
complex temp = data[t];
|
||||
data[t] = add(data[t], wn);
|
||||
data[t + J / 2] = sub(temp, wn);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ifft_soft(complex *data, int n)
|
||||
{
|
||||
int M = 0;
|
||||
for (int i = n; i > 1; i = i >> 1, M++);
|
||||
|
||||
bitrev(data, n);
|
||||
|
||||
for (int m = 0; m < M; m++)
|
||||
{
|
||||
int K = n >> (m + 1);
|
||||
for (int k = 0; k < K; k++)
|
||||
{
|
||||
int J = 2 << m;
|
||||
int base = k * J;
|
||||
for (int j = 0; j < J / 2; j++)
|
||||
{
|
||||
int t = base + j;
|
||||
complex w = {cos(2 * PI * j * K / n), sin(2 * PI * j * K / n)};
|
||||
complex wn = mul(data[t + J / 2], w);
|
||||
complex temp = data[t];
|
||||
data[t] = add(data[t], wn);
|
||||
data[t + J / 2] = sub(temp, wn);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
data[i].real /= n;
|
||||
data[i].imag /= n;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
#ifndef _FFT_SOFT_H
|
||||
#define _FFT_SOFT_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#define SWAP(a, b) do {complex t = (a); (a) = (b); (b) = t;} while(0)
|
||||
|
||||
typedef struct{double real, imag;} complex;
|
||||
|
||||
void fft_soft(complex *data, int n);
|
||||
void ifft_soft(complex *data, int n);
|
||||
void show(complex *data, int n);
|
||||
|
||||
#endif /* _FFT_SOFT_H */
|
||||
|
|
@ -1,159 +0,0 @@
|
|||
/* Copyright 2018 Canaan Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
#include <transform.h>
|
||||
#include <math.h>
|
||||
#include "encoding.h"
|
||||
#include "dmac.h"
|
||||
#include "fft.h"
|
||||
#include "encoding.h"
|
||||
#include "sysctl.h"
|
||||
#include "fft_soft.h"
|
||||
|
||||
#define FFT_N 512U
|
||||
#define FFT_FORWARD_SHIFT 0x0U
|
||||
#define FFT_BACKWARD_SHIFT 0x1ffU
|
||||
#define PI 3.14159265358979323846
|
||||
|
||||
typedef enum _complex_mode
|
||||
{
|
||||
FFT_HARD = 0,
|
||||
FFT_SOFT = 1,
|
||||
FFT_COMPLEX_MAX,
|
||||
} complex_mode_t;
|
||||
|
||||
int16_t real[FFT_N];
|
||||
int16_t imag[FFT_N];
|
||||
float hard_power[FFT_N];
|
||||
float soft_power[FFT_N];
|
||||
float hard_angel[FFT_N];
|
||||
float soft_angel[FFT_N];
|
||||
uint64_t fft_out_data[FFT_N / 2];
|
||||
uint64_t buffer_input[FFT_N];
|
||||
uint64_t buffer_output[FFT_N];
|
||||
uint64_t cycle[FFT_COMPLEX_MAX][FFT_DIR_MAX];
|
||||
|
||||
uint16_t get_bit1_num(uint32_t data)
|
||||
{
|
||||
uint16_t num;
|
||||
for (num = 0; data; num++)
|
||||
data &= data - 1;
|
||||
return num;
|
||||
}
|
||||
|
||||
void k210_fft_test(void)
|
||||
{
|
||||
int32_t i;
|
||||
float tempf1[3];
|
||||
fft_data_t *output_data;
|
||||
fft_data_t *input_data;
|
||||
uint16_t bit1_num = get_bit1_num(FFT_FORWARD_SHIFT);
|
||||
complex_hard_t data_hard[FFT_N] = {0};
|
||||
complex data_soft[FFT_N] = {0};
|
||||
for (i = 0; i < FFT_N; i++)
|
||||
{
|
||||
tempf1[0] = 0.3 * cosf(2 * PI * i / FFT_N + PI / 3) * 256;
|
||||
tempf1[1] = 0.1 * cosf(16 * 2 * PI * i / FFT_N - PI / 9) * 256;
|
||||
tempf1[2] = 0.5 * cosf((19 * 2 * PI * i / FFT_N) + PI / 6) * 256;
|
||||
data_hard[i].real = (int16_t)(tempf1[0] + tempf1[1] + tempf1[2] + 10);
|
||||
data_hard[i].imag = (int16_t)0;
|
||||
data_soft[i].real = data_hard[i].real;
|
||||
data_soft[i].imag = data_hard[i].imag;
|
||||
}
|
||||
for (int i = 0; i < FFT_N / 2; ++i)
|
||||
{
|
||||
input_data = (fft_data_t *)&buffer_input[i];
|
||||
input_data->R1 = data_hard[2 * i].real;
|
||||
input_data->I1 = data_hard[2 * i].imag;
|
||||
input_data->R2 = data_hard[2 * i + 1].real;
|
||||
input_data->I2 = data_hard[2 * i + 1].imag;
|
||||
}
|
||||
cycle[FFT_HARD][FFT_DIR_FORWARD] = read_cycle();
|
||||
fft_complex_uint16_dma(DMAC_CHANNEL0, DMAC_CHANNEL1, FFT_FORWARD_SHIFT, FFT_DIR_FORWARD, buffer_input, FFT_N, buffer_output);
|
||||
cycle[FFT_HARD][FFT_DIR_FORWARD] = read_cycle() - cycle[FFT_HARD][FFT_DIR_FORWARD];
|
||||
cycle[FFT_SOFT][FFT_DIR_FORWARD] = read_cycle();
|
||||
fft_soft(data_soft, FFT_N);
|
||||
cycle[FFT_SOFT][FFT_DIR_FORWARD] = read_cycle() - cycle[FFT_SOFT][FFT_DIR_FORWARD];
|
||||
for (i = 0; i < FFT_N / 2; i++)
|
||||
{
|
||||
output_data = (fft_data_t*)&buffer_output[i];
|
||||
data_hard[2 * i].imag = output_data->I1 ;
|
||||
data_hard[2 * i].real = output_data->R1 ;
|
||||
data_hard[2 * i + 1].imag = output_data->I2 ;
|
||||
data_hard[2 * i + 1].real = output_data->R2 ;
|
||||
}
|
||||
|
||||
for (i = 0; i < FFT_N; i++)
|
||||
{
|
||||
hard_power[i] = sqrt(data_hard[i].real * data_hard[i].real + data_hard[i].imag * data_hard[i].imag) * 2;
|
||||
soft_power[i] = sqrt(data_soft[i].real * data_soft[i].real + data_soft[i].imag * data_soft[i].imag) * 2;
|
||||
}
|
||||
|
||||
printf("\n[hard fft real][soft fft real][hard fft imag][soft fft imag]\n");
|
||||
for (i = 0; i < FFT_N / 2; i++)
|
||||
printf("%3d:%7d %7d %7d %7d\n",
|
||||
i, data_hard[i].real, (int32_t)data_soft[i].real, data_hard[i].imag, (int32_t)data_soft[i].imag);
|
||||
|
||||
printf("\nhard power soft power:\n");
|
||||
printf("%3d : %f %f\n", 0, hard_power[0] / 2 / FFT_N * (1 << bit1_num), soft_power[0] / 2 / FFT_N);
|
||||
for (i = 1; i < FFT_N / 2; i++)
|
||||
printf("%3d : %f %f\n", i, hard_power[i] / FFT_N * (1 << bit1_num), soft_power[i] / FFT_N);
|
||||
|
||||
printf("\nhard phase soft phase:\n");
|
||||
for (i = 0; i < FFT_N / 2; i++)
|
||||
{
|
||||
hard_angel[i] = atan2(data_hard[i].imag, data_hard[i].real);
|
||||
soft_angel[i] = atan2(data_soft[i].imag, data_soft[i].real);
|
||||
printf("%3d : %f %f\n", i, hard_angel[i] * 180 / PI, soft_angel[i] * 180 / PI);
|
||||
}
|
||||
|
||||
for (int i = 0; i < FFT_N / 2; ++i)
|
||||
{
|
||||
input_data = (fft_data_t *)&buffer_input[i];
|
||||
input_data->R1 = data_hard[2 * i].real;
|
||||
input_data->I1 = data_hard[2 * i].imag;
|
||||
input_data->R2 = data_hard[2 * i + 1].real;
|
||||
input_data->I2 = data_hard[2 * i + 1].imag;
|
||||
}
|
||||
cycle[FFT_HARD][FFT_DIR_BACKWARD] = read_cycle();
|
||||
fft_complex_uint16_dma(DMAC_CHANNEL0, DMAC_CHANNEL1, FFT_BACKWARD_SHIFT, FFT_DIR_BACKWARD, buffer_input, FFT_N, buffer_output);
|
||||
cycle[FFT_HARD][FFT_DIR_BACKWARD] = read_cycle() - cycle[FFT_HARD][FFT_DIR_BACKWARD];
|
||||
cycle[FFT_SOFT][FFT_DIR_BACKWARD] = read_cycle();
|
||||
ifft_soft(data_soft, FFT_N);
|
||||
cycle[FFT_SOFT][FFT_DIR_BACKWARD] = read_cycle() - cycle[FFT_SOFT][FFT_DIR_BACKWARD];
|
||||
for (i = 0; i < FFT_N / 2; i++)
|
||||
{
|
||||
output_data = (fft_data_t*)&buffer_output[i];
|
||||
data_hard[2 * i].imag = output_data->I1 ;
|
||||
data_hard[2 * i].real = output_data->R1 ;
|
||||
data_hard[2 * i + 1].imag = output_data->I2 ;
|
||||
data_hard[2 * i + 1].real = output_data->R2 ;
|
||||
}
|
||||
printf("\n[hard ifft real][soft ifft real][hard ifft imag][soft ifft imag]\n");
|
||||
for (i = 0; i < FFT_N / 2; i++)
|
||||
printf("%3d:%7d %7d %7d %7d\n",
|
||||
i, data_hard[i].real, (int32_t)data_soft[i].real, data_hard[i].imag, (int32_t)data_soft[i].imag);
|
||||
|
||||
printf("[hard fft test] [%d bytes] forward time = %ld us, backward time = %ld us\n",
|
||||
FFT_N,
|
||||
cycle[FFT_HARD][FFT_DIR_FORWARD]/(sysctl_clock_get_freq(SYSCTL_CLOCK_CPU)/1000000),
|
||||
cycle[FFT_HARD][FFT_DIR_BACKWARD]/(sysctl_clock_get_freq(SYSCTL_CLOCK_CPU)/1000000));
|
||||
printf("[soft fft test] [%d bytes] forward time = %ld us, backward time = %ld us\n",
|
||||
FFT_N,
|
||||
cycle[FFT_SOFT][FFT_DIR_FORWARD]/(sysctl_clock_get_freq(SYSCTL_CLOCK_CPU)/1000000),
|
||||
cycle[FFT_SOFT][FFT_DIR_BACKWARD]/(sysctl_clock_get_freq(SYSCTL_CLOCK_CPU)/1000000));
|
||||
}
|
||||
#ifdef __RT_THREAD_H__
|
||||
MSH_CMD_EXPORT(k210_fft_test,k210 fft test );
|
||||
#endif
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
import os
|
||||
from building import *
|
||||
Import('RTT_ROOT')
|
||||
Import('rtconfig')
|
||||
cwd = GetCurrentDir()
|
||||
DEPENDS = ["SUPPORT_SENSOR_FRAMEWORK"]
|
||||
SOURCES = []
|
||||
if GetDepend(['APPLICATION_SENSOR_CO2_ZG09']):
|
||||
SOURCES = ['co2_zg09.c'] + SOURCES
|
||||
if GetDepend(['APPLICATION_SENSOR_PM1_0_PS5308']):
|
||||
SOURCES = ['pm1_0_ps5308.c.c'] + SOURCES
|
||||
if GetDepend(['APPLICATION_SENSOR_VOICE_D124']):
|
||||
SOURCES = ['voice_d124.c'] + SOURCES
|
||||
if GetDepend(['APPLICATION_SENSOR_HUMIDITY_HS300X']):
|
||||
SOURCES = ['humidity_hs300x.c'] + SOURCES
|
||||
if GetDepend(['APPLICATION_SENSOR_TEMPERATURE_HS300X']):
|
||||
SOURCES = ['temperature_hs300x.c'] + SOURCES
|
||||
path = [cwd]
|
||||
objs = DefineGroup('sensor_app', src = SOURCES, depend = DEPENDS,CPPPATH = path)
|
||||
Return("objs")
|
||||
|
|
@ -29,7 +29,7 @@ void Pm10Ps5308(void)
|
|||
{
|
||||
struct SensorQuantity *pm1_0 = SensorQuantityFind(SENSOR_QUANTITY_PS5308_PM1_0, SENSOR_QUANTITY_PM);
|
||||
SensorQuantityOpen(pm1_0);
|
||||
PrivTaskDelay(2000);
|
||||
UserTaskDelay(2000);
|
||||
printf("PM1.0 : %d ug/m³\n", SensorQuantityRead(pm1_0));
|
||||
SensorQuantityClose(pm1_0);
|
||||
}
|
||||
|
|
@ -18,7 +18,7 @@
|
|||
* @date 2021.04.23
|
||||
*/
|
||||
|
||||
#include <transform.h>
|
||||
#include <user_api.h>
|
||||
#include <sensor.h>
|
||||
|
||||
/**
|
||||
|
|
@ -29,7 +29,7 @@ void VoiceD124(void)
|
|||
{
|
||||
struct SensorQuantity *voice = SensorQuantityFind(SENSOR_QUANTITY_D124_VOICE, SENSOR_QUANTITY_VOICE);
|
||||
SensorQuantityOpen(voice);
|
||||
PrivTaskDelay(2000);
|
||||
UserTaskDelay(2000);
|
||||
uint16 result = SensorQuantityRead(voice);
|
||||
printf("voice : %d.%d dB\n", result/(10*voice->value.decimal_places), result%(10*voice->value.decimal_places));
|
||||
SensorQuantityClose(voice);
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ if ADD_XIUOS_FETURES
|
|||
|
||||
config ADAPTER_EC200T_DRIVER
|
||||
string "EC200T device uart driver path"
|
||||
default "/dev/usart2_dev2"
|
||||
default "/dev/uart2_dev2"
|
||||
depends on !ADAPTER_EC200T_DRIVER_EXTUART
|
||||
|
||||
if ADAPTER_EC200T_DRIVER_EXTUART
|
||||
|
|
@ -21,21 +21,6 @@
|
|||
#include <adapter.h>
|
||||
#include <at_agent.h>
|
||||
|
||||
#define EC200T_AT_MODE_CMD "+++"
|
||||
#define EC200T_GET_CCID_CMD "AT+CCID\r\n"
|
||||
#define EC200T_GET_CPIN_CMD "AT+CPIN?\r\n"
|
||||
#define EC200T_GET_CREG_CMD "AT+CREG?\r\n"
|
||||
#define EC200T_OPEN_SOCKET_CMD "AT+QIOPEN=1,%u"
|
||||
#define EC200T_CLOSE_SOCKET_CMD "AT+QICLOSE=%u\r\n"
|
||||
#define EC200T_ACTIVE_PDP_CMD "AT+QIACT=1\r\n"
|
||||
#define EC200T_DEACTIVE_PDP_CMD "AT+QIDEACT=1\r\n"
|
||||
#define EC200T_CFG_TCP_CMD "AT+QICSGP"
|
||||
|
||||
#define EC200T_OK_REPLY "OK"
|
||||
#define EC200T_READY_REPLY "READY"
|
||||
#define EC200T_CREG_REPLY ",1"
|
||||
#define EC200T_CONNECT_REPLY "CONNECT"
|
||||
|
||||
static void Ec200tPowerSet(void)
|
||||
{
|
||||
int pin_fd;
|
||||
|
|
@ -43,7 +28,7 @@ static void Ec200tPowerSet(void)
|
|||
|
||||
struct PinParam pin_param;
|
||||
pin_param.cmd = GPIO_CONFIG_MODE;
|
||||
pin_param.mode = GPIO_CFG_OUTPUT;
|
||||
pin_param.mode = GPIO_CFG_INPUT_PULLUP;
|
||||
pin_param.pin = ADAPTER_EC200T_PWRKEY;
|
||||
|
||||
struct PrivIoctlCfg ioctl_cfg;
|
||||
|
|
@ -62,8 +47,6 @@ static void Ec200tPowerSet(void)
|
|||
PrivWrite(pin_fd, &pin_stat, 1);
|
||||
|
||||
PrivClose(pin_fd);
|
||||
|
||||
PrivTaskDelay(10000);
|
||||
}
|
||||
|
||||
static int Ec200tOpen(struct Adapter *adapter)
|
||||
|
|
@ -87,6 +70,32 @@ static int Ec200tOpen(struct Adapter *adapter)
|
|||
adapter->agent = at_agent;
|
||||
}
|
||||
|
||||
/*step3: serial write "+++", quit transparent mode*/
|
||||
ATOrderSend(adapter->agent, REPLY_TIME_OUT, NULL, "+++");
|
||||
|
||||
/*step4: serial write "AT+CCID", get SIM ID*/
|
||||
ATOrderSend(adapter->agent, REPLY_TIME_OUT, NULL, "AT+CCID\r\n");
|
||||
|
||||
PrivTaskDelay(2500);
|
||||
|
||||
/*step5: serial write "AT+CPIN?", check SIM status*/
|
||||
ATOrderSend(adapter->agent, REPLY_TIME_OUT, NULL, "AT+CPIN?\r\n");
|
||||
|
||||
PrivTaskDelay(2500);
|
||||
|
||||
/*step6: serial write "AT+CREG?", check whether registered to GSM net*/
|
||||
ATOrderSend(adapter->agent, REPLY_TIME_OUT, NULL, "AT+CREG?\r\n");
|
||||
|
||||
PrivTaskDelay(2500);
|
||||
|
||||
/*step7: serial write "AT+QICLOSE", close socket connect before open socket*/
|
||||
ATOrderSend(adapter->agent, REPLY_TIME_OUT, NULL, "AT+QICLOSE=0\r\n");
|
||||
|
||||
PrivTaskDelay(2500);
|
||||
|
||||
/*step8: serial write "AT+QIDEACT", close TCP net before open socket*/
|
||||
ATOrderSend(adapter->agent, REPLY_TIME_OUT, NULL, "AT+QIDEACT=1\r\n");
|
||||
|
||||
PrivTaskDelay(2500);
|
||||
|
||||
ADAPTER_DEBUG("Ec200t open done\n");
|
||||
|
|
@ -96,41 +105,31 @@ static int Ec200tOpen(struct Adapter *adapter)
|
|||
|
||||
static int Ec200tClose(struct Adapter *adapter)
|
||||
{
|
||||
int ret = 0;
|
||||
uint8_t ec200t_cmd[64];
|
||||
|
||||
if (!adapter->agent) {
|
||||
printf("Ec200tClose AT agent NULL\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
AtSetReplyEndChar(adapter->agent, 0x4F, 0x4B);
|
||||
|
||||
/*step1: serial write "+++", quit transparent mode*/
|
||||
ATOrderSend(adapter->agent, REPLY_TIME_OUT, NULL, "+++");
|
||||
|
||||
/*step2: serial write "AT+QICLOSE", close socket connect before open socket*/
|
||||
memset(ec200t_cmd, 0, sizeof(ec200t_cmd));
|
||||
sprintf(ec200t_cmd, EC200T_CLOSE_SOCKET_CMD, adapter->socket.socket_id);
|
||||
ret = AtCmdConfigAndCheck(adapter->agent, ec200t_cmd, EC200T_OK_REPLY);
|
||||
if (ret < 0) {
|
||||
goto out;
|
||||
}
|
||||
ATOrderSend(adapter->agent, REPLY_TIME_OUT, NULL, "AT+QICLOSE=0\r\n");
|
||||
|
||||
PrivTaskDelay(2500);
|
||||
|
||||
/*step3: serial write "AT+QIDEACT", close TCP net before open socket*/
|
||||
ret = AtCmdConfigAndCheck(adapter->agent, EC200T_DEACTIVE_PDP_CMD, EC200T_OK_REPLY);
|
||||
if (ret < 0) {
|
||||
goto out;
|
||||
}
|
||||
ATOrderSend(adapter->agent, REPLY_TIME_OUT, NULL, "AT+QIDEACT=1\r\n");
|
||||
|
||||
PrivTaskDelay(2500);
|
||||
|
||||
out:
|
||||
/*step4: close ec200t serial port*/
|
||||
PrivClose(adapter->fd);
|
||||
|
||||
/*step5: power down ec200t*/
|
||||
Ec200tPowerSet();
|
||||
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int Ec200tIoctl(struct Adapter *adapter, int cmd, void *args)
|
||||
|
|
@ -160,41 +159,15 @@ static int Ec200tIoctl(struct Adapter *adapter, int cmd, void *args)
|
|||
ioctl_cfg.ioctl_driver_type = SERIAL_TYPE;
|
||||
ioctl_cfg.args = &serial_cfg;
|
||||
PrivIoctl(adapter->fd, OPE_INT, &ioctl_cfg);
|
||||
|
||||
Ec200tPowerSet();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int Ec200tConnect(struct Adapter *adapter, enum NetRoleType net_role, const char *ip, const char *port, enum IpType ip_type)
|
||||
{
|
||||
int ret = 0;
|
||||
uint8_t ec200t_cmd[64];
|
||||
|
||||
AtSetReplyEndChar(adapter->agent, 0x4F, 0x4B);
|
||||
|
||||
/*step1: serial write "+++", quit transparent mode*/
|
||||
ATOrderSend(adapter->agent, REPLY_TIME_OUT, NULL, "+++");
|
||||
|
||||
/*step2: serial write "AT+CCID", get SIM ID*/
|
||||
ret = AtCmdConfigAndCheck(adapter->agent, EC200T_GET_CCID_CMD, EC200T_OK_REPLY);
|
||||
if (ret < 0) {
|
||||
goto out;
|
||||
}
|
||||
|
||||
/*step3: serial write "AT+CPIN?", check SIM status*/
|
||||
ret = AtCmdConfigAndCheck(adapter->agent, EC200T_GET_CPIN_CMD, EC200T_READY_REPLY);
|
||||
if (ret < 0) {
|
||||
goto out;
|
||||
}
|
||||
|
||||
/*step4: serial write "AT+CREG?", check whether registered to GSM net*/
|
||||
ret = AtCmdConfigAndCheck(adapter->agent, EC200T_GET_CREG_CMD, EC200T_CREG_REPLY);
|
||||
if (ret < 0) {
|
||||
goto out;
|
||||
}
|
||||
|
||||
/*step5: serial write "AT+QICSGP", connect to China Mobile using ipv4 or ipv6*/
|
||||
/*step1: serial write "AT+QICSGP", connect to China Mobile using ipv4 or ipv6*/
|
||||
memset(ec200t_cmd, 0, sizeof(ec200t_cmd));
|
||||
|
||||
if (IPV4 == ip_type) {
|
||||
|
|
@ -203,105 +176,58 @@ static int Ec200tConnect(struct Adapter *adapter, enum NetRoleType net_role, con
|
|||
strcpy(ec200t_cmd, "AT+QICSGP=1,2,\"CMNET\",\"\",\"\",1\r\n");
|
||||
}
|
||||
|
||||
ret = AtCmdConfigAndCheck(adapter->agent, ec200t_cmd, EC200T_OK_REPLY);
|
||||
if (ret < 0) {
|
||||
goto out;
|
||||
}
|
||||
ATOrderSend(adapter->agent, REPLY_TIME_OUT, NULL, ec200t_cmd);
|
||||
|
||||
/*step6: serial write "AT+QICLOSE", close socket connect before open socket*/
|
||||
PrivTaskDelay(2500);
|
||||
|
||||
/*step2: serial write "AT+QIACT", open TCP net*/
|
||||
ATOrderSend(adapter->agent, REPLY_TIME_OUT, NULL, "AT+QIACT=1\r\n");
|
||||
|
||||
PrivTaskDelay(2500);
|
||||
|
||||
/*step3: serial write "AT+QIOPEN", connect socket using TCP*/
|
||||
memset(ec200t_cmd, 0, sizeof(ec200t_cmd));
|
||||
sprintf(ec200t_cmd, EC200T_CLOSE_SOCKET_CMD, adapter->socket.socket_id);
|
||||
ret = AtCmdConfigAndCheck(adapter->agent, ec200t_cmd, EC200T_OK_REPLY);
|
||||
if (ret < 0) {
|
||||
goto out;
|
||||
}
|
||||
|
||||
/*step7: serial write "AT+QIDEACT", close TCP net before open socket*/
|
||||
ret = AtCmdConfigAndCheck(adapter->agent, EC200T_DEACTIVE_PDP_CMD, EC200T_OK_REPLY);
|
||||
if (ret < 0) {
|
||||
goto out;
|
||||
}
|
||||
|
||||
/*step8: serial write "AT+QIACT", open TCP net*/
|
||||
ret = AtCmdConfigAndCheck(adapter->agent, EC200T_ACTIVE_PDP_CMD, EC200T_OK_REPLY);
|
||||
if (ret < 0) {
|
||||
goto out;
|
||||
}
|
||||
|
||||
/*step9: serial write "AT+QIOPEN", connect socket using TCP*/
|
||||
memset(ec200t_cmd, 0, sizeof(ec200t_cmd));
|
||||
sprintf(ec200t_cmd, EC200T_OPEN_SOCKET_CMD, adapter->socket.socket_id);
|
||||
strcat(ec200t_cmd, ",\"TCP\",\"");
|
||||
strcpy(ec200t_cmd, "AT+QIOPEN=1,0,\"TCP\",\"");
|
||||
strcat(ec200t_cmd, ip);
|
||||
strcat(ec200t_cmd, "\",");
|
||||
strcat(ec200t_cmd, port);
|
||||
strcat(ec200t_cmd, ",0,2\r\n");
|
||||
|
||||
AtSetReplyEndChar(adapter->agent, 0x43, 0x54);
|
||||
|
||||
ret = AtCmdConfigAndCheck(adapter->agent, ec200t_cmd, EC200T_CONNECT_REPLY);
|
||||
if (ret < 0) {
|
||||
goto out;
|
||||
}
|
||||
ADAPTER_DEBUG("Ec200t connect AT CMD :%s\n", ec200t_cmd);
|
||||
ATOrderSend(adapter->agent, REPLY_TIME_OUT, NULL, ec200t_cmd);
|
||||
|
||||
ADAPTER_DEBUG("Ec200t connect TCP done\n");
|
||||
|
||||
return 0;
|
||||
|
||||
out:
|
||||
ADAPTER_DEBUG("Ec200t connect TCP failed. Power down\n");
|
||||
Ec200tPowerSet();
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int Ec200tSend(struct Adapter *adapter, const void *buf, size_t len)
|
||||
{
|
||||
x_err_t result = EOK;
|
||||
if (adapter->agent) {
|
||||
EntmSend(adapter->agent, (const char *)buf, len);
|
||||
} else {
|
||||
printf("Ec200tSend can not find agent\n");
|
||||
}
|
||||
PrivWrite(adapter->fd, buf, len);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int Ec200tRecv(struct Adapter *adapter, void *buf, size_t len)
|
||||
{
|
||||
if (adapter->agent) {
|
||||
return EntmRecv(adapter->agent, (char *)buf, len, 40000);
|
||||
} else {
|
||||
printf("Ec200tRecv can not find agent\n");
|
||||
}
|
||||
|
||||
return -1;
|
||||
PrivRead(adapter->fd, buf, len);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int Ec200tDisconnect(struct Adapter *adapter)
|
||||
{
|
||||
int ret = 0;
|
||||
uint8_t ec200t_cmd[64];
|
||||
|
||||
AtSetReplyEndChar(adapter->agent, 0x4F, 0x4B);
|
||||
|
||||
/*step1: serial write "+++", quit transparent mode*/
|
||||
ATOrderSend(adapter->agent, REPLY_TIME_OUT, NULL, "+++");
|
||||
|
||||
/*step2: serial write "AT+QICLOSE", close socket connect before open socket*/
|
||||
memset(ec200t_cmd, 0, sizeof(ec200t_cmd));
|
||||
sprintf(ec200t_cmd, EC200T_CLOSE_SOCKET_CMD, adapter->socket.socket_id);
|
||||
ret = AtCmdConfigAndCheck(adapter->agent, ec200t_cmd, EC200T_OK_REPLY);
|
||||
if (ret < 0) {
|
||||
goto out;
|
||||
}
|
||||
ATOrderSend(adapter->agent, REPLY_TIME_OUT, NULL, "AT+QICLOSE=0\r\n");
|
||||
|
||||
PrivTaskDelay(2500);
|
||||
|
||||
ADAPTER_DEBUG("Ec200t disconnect TCP done\n");
|
||||
|
||||
return 0;
|
||||
|
||||
out:
|
||||
ADAPTER_DEBUG("Ec200t disconnect TCP failed. Power down\n");
|
||||
Ec200tPowerSet();
|
||||
return -1;
|
||||
}
|
||||
|
||||
static const struct IpProtocolDone ec200t_done =
|
||||
|
|
@ -324,16 +250,21 @@ static const struct IpProtocolDone ec200t_done =
|
|||
|
||||
AdapterProductInfoType Ec200tAttach(struct Adapter *adapter)
|
||||
{
|
||||
struct AdapterProductInfo *product_info = PrivMalloc(sizeof(struct AdapterProductInfo));
|
||||
struct AdapterProductInfo *product_info = malloc(sizeof(struct AdapterProductInfo));
|
||||
if (!product_info) {
|
||||
printf("Ec200tAttach malloc product_info error\n");
|
||||
PrivFree(product_info);
|
||||
free(product_info);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
strcpy(product_info->model_name, ADAPTER_4G_EC200T);
|
||||
product_info->model_name = ADAPTER_4G_EC200T;
|
||||
|
||||
product_info->model_done = (void *)&ec200t_done;
|
||||
|
||||
Ec200tPowerSet();
|
||||
|
||||
return product_info;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
config ADAPTER_4G
|
||||
bool "Using 4G adapter function"
|
||||
default y
|
||||
|
||||
if ADAPTER_4G
|
||||
config ADAPTER_EC200T
|
||||
bool "Using 4G adapter device EC200T"
|
||||
default y
|
||||
|
||||
if ADAPTER_EC200T
|
||||
source "$APP_DIR/Framework/connection/4G/EC200T/Kconfig"
|
||||
endif
|
||||
|
||||
endif
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
SRC_FILES := adapter_4G.c
|
||||
|
||||
ifeq ($(CONFIG_ADAPTER_EC200T),y)
|
||||
SRC_DIR += EC200T
|
||||
endif
|
||||
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
||||
|
|
@ -49,14 +49,12 @@ int Adapter4GInit(void)
|
|||
{
|
||||
int ret = 0;
|
||||
|
||||
struct Adapter *adapter = PrivMalloc(sizeof(struct Adapter));
|
||||
struct Adapter *adapter = malloc(sizeof(struct Adapter));
|
||||
if (!adapter) {
|
||||
free(adapter);
|
||||
return -1;
|
||||
}
|
||||
|
||||
memset(adapter, 0, sizeof(struct Adapter));
|
||||
|
||||
ret = Adapter4GRegister(adapter);
|
||||
if (ret < 0) {
|
||||
printf("Adapter4GInit register 4G adapter error\n");
|
||||
|
|
@ -84,18 +82,16 @@ int Adapter4GInit(void)
|
|||
/******************4G TEST*********************/
|
||||
int Adapter4GTest(void)
|
||||
{
|
||||
const char *send_msg = "Adapter_4G Test";
|
||||
char recv_msg[256] = {0};
|
||||
const char *send_msg = "SendHeart";
|
||||
char recv_msg[128];
|
||||
int baud_rate = BAUD_RATE_115200;
|
||||
|
||||
struct Adapter* adapter = AdapterDeviceFindByName(ADAPTER_4G_NAME);
|
||||
|
||||
#ifdef ADAPTER_EC200T
|
||||
//Using Hang Xiao server to test 4G Socket connection
|
||||
uint8 server_addr[64] = "101.68.82.219";
|
||||
uint8 server_port[64] = "9898";
|
||||
|
||||
adapter->socket.socket_id = 0;
|
||||
//Using DSD server to test 4G Socket connection
|
||||
uint8 server_addr[64] = "115.238.53.61";
|
||||
uint8 server_port[64] = "33333";
|
||||
|
||||
AdapterDeviceOpen(adapter);
|
||||
AdapterDeviceControl(adapter, OPE_INT, &baud_rate);
|
||||
|
|
@ -104,9 +100,8 @@ int Adapter4GTest(void)
|
|||
|
||||
while (1) {
|
||||
AdapterDeviceSend(adapter, send_msg, strlen(send_msg));
|
||||
AdapterDeviceRecv(adapter, recv_msg, 256);
|
||||
AdapterDeviceRecv(adapter, recv_msg, 128);
|
||||
printf("4G recv msg %s\n", recv_msg);
|
||||
memset(recv_msg, 0, 256);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
config ADAPTER_EC200T
|
||||
bool "Using 4G adapter device EC200T"
|
||||
default y
|
||||
|
||||
if ADAPTER_EC200T
|
||||
source "$APP_DIR/Framework/connection/4g/ec200t/Kconfig"
|
||||
endif
|
||||
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
SRC_FILES := adapter_4g.c
|
||||
|
||||
ifeq ($(CONFIG_ADAPTER_EC200T),y)
|
||||
SRC_DIR += ec200t
|
||||
endif
|
||||
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
||||
|
|
@ -1,3 +1,3 @@
|
|||
SRC_FILES := adapter_5g.c
|
||||
SRC_FILES := adapter_5G.c
|
||||
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
||||
|
|
@ -11,7 +11,7 @@
|
|||
*/
|
||||
|
||||
/**
|
||||
* @file adapter_5g.c
|
||||
* @file adapter_5G.c
|
||||
* @brief Implement the connection 5G adapter function
|
||||
* @version 1.1
|
||||
* @author AIIT XUOS Lab
|
||||
|
|
@ -18,7 +18,7 @@ if SUPPORT_CONNECTION_FRAMEWORK
|
|||
bool "Using 4G adapter device"
|
||||
default n
|
||||
if CONNECTION_ADAPTER_4G
|
||||
source "$APP_DIR/Framework/connection/4g/Kconfig"
|
||||
source "$APP_DIR/Framework/connection/4G/Kconfig"
|
||||
endif
|
||||
|
||||
menuconfig CONNECTION_ADAPTER_NB
|
||||
|
|
@ -60,6 +60,6 @@ if SUPPORT_CONNECTION_FRAMEWORK
|
|||
bool "Using 5G adapter device"
|
||||
default n
|
||||
if CONNECTION_ADAPTER_5G
|
||||
source "$APP_DIR/Framework/connection/5g/Kconfig"
|
||||
source "$APP_DIR/Framework/connection/5G/Kconfig"
|
||||
endif
|
||||
endif
|
||||
|
|
|
|||
|
|
@ -1,35 +1,35 @@
|
|||
SRC_FILES := adapter.c adapter_agent.c
|
||||
|
||||
ifeq ($(CONFIG_CONNECTION_ADAPTER_LORA),y)
|
||||
ifeq ($(CONFIG_ADAPTER_LORA),y)
|
||||
SRC_DIR += lora
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_CONNECTION_ADAPTER_4G),y)
|
||||
SRC_DIR += 4g
|
||||
ifeq ($(CONFIG_ADAPTER_4G),y)
|
||||
SRC_DIR += 4G
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_CONNECTION_ADAPTER_NB),y)
|
||||
ifeq ($(CONFIG_ADAPTER_NB),y)
|
||||
SRC_DIR += nbiot
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_CONNECTION_ADAPTER_WIFI),y)
|
||||
ifeq ($(CONFIG_ADAPTER_WIFI),y)
|
||||
SRC_DIR += wifi
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_CONNECTION_ADAPTER_ETHERNET),y)
|
||||
ifeq ($(CONFIG_ADAPTER_ETHERNET),y)
|
||||
SRC_DIR += ethernet
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_CONNECTION_ADAPTER_BLUETOOTH),y)
|
||||
ifeq ($(CONFIG_ADAPTER_BLUETOOTH),y)
|
||||
SRC_DIR += bluetooth
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_CONNECTION_ADAPTER_ZIGBEE),y)
|
||||
ifeq ($(CONFIG_ADAPTER_ZIGBEE),y)
|
||||
SRC_DIR += zigbee
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_CONNECTION_ADAPTER_5G),y)
|
||||
SRC_DIR += 5g
|
||||
ifeq ($(CONFIG_ADAPTER_5G),y)
|
||||
SRC_DIR += 5G
|
||||
endif
|
||||
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
||||
|
|
@ -39,10 +39,19 @@ extern "C" {
|
|||
#define ADAPTER_LWIP_OPERATION 2
|
||||
#define ADAPTER_RAWIP_OPERATION 3
|
||||
|
||||
#define ADAPTER_LORA_FUNC ((uint32_t)(1 << ATAPTER_LORA))
|
||||
#define ADAPTER_4G_FUNC ((uint32_t)(1 << ADAPTER_4G))
|
||||
#define ADAPTER_NBIOT_FUNC ((uint32_t)(1 << ADAPTER_NBIOT))
|
||||
#define ADAPTER_WIFI_FUNC ((uint32_t)(1 << ADAPTER_WIFI))
|
||||
#define ADAPTER_ETHERNET_FUNC ((uint32_t)(1 << ADAPTER_ETHERNET))
|
||||
#define ADAPTER_BLUETOOTH_FUNC ((uint32_t)(1 << ADAPTER_BLUETOOTH))
|
||||
#define ADAPTER_ZIGBEE_FUNC ((uint32_t)(1 << ADAPTER_ZIGBEE))
|
||||
#define ADAPTER_5G_FUNC ((uint32_t)(1 << ADAPTER_5G))
|
||||
|
||||
#ifdef CONNECTION_FRAMEWORK_DEBUG
|
||||
#define ADAPTER_DEBUG printf
|
||||
#else
|
||||
#define ADAPTER_DEBUG
|
||||
#define ADAPTER_DEBUF
|
||||
#endif
|
||||
|
||||
struct Adapter;
|
||||
|
|
@ -52,14 +61,8 @@ typedef struct AdapterProductInfo *AdapterProductInfoType;
|
|||
|
||||
struct Socket
|
||||
{
|
||||
uint8_t type; ///< socket type:DGRAM->UDP,STREAM->TCP
|
||||
uint8_t protocal; ///< udp or tcp
|
||||
unsigned short listen_port; ///< 0-65535
|
||||
uint8_t socket_id; ///< socket id
|
||||
uint8_t recv_control; ///< receive control
|
||||
uint8_t af_type; ///< IPv4 or IPv6
|
||||
char *src_ip_addr; ///< source P address
|
||||
char *dst_ip_addr; ///< destination IP address
|
||||
int id;
|
||||
struct Adapter *adapter;
|
||||
};
|
||||
|
||||
enum AdapterType
|
||||
|
|
@ -87,9 +90,6 @@ enum NetRoleType
|
|||
SERVER,
|
||||
MASTER,
|
||||
SLAVE,
|
||||
COORDINATOR,
|
||||
ROUTER,
|
||||
END_DEVICE,
|
||||
ROLE_NONE,
|
||||
};
|
||||
|
||||
|
|
@ -110,9 +110,8 @@ enum IpType
|
|||
struct AdapterProductInfo
|
||||
{
|
||||
uint32_t functions;
|
||||
char vendor_name[NAME_NUM_MAX];
|
||||
char model_name[NAME_NUM_MAX];
|
||||
uint32_t work_mode;
|
||||
const char *vendor_name;
|
||||
const char *model_name;
|
||||
|
||||
void *model_done;
|
||||
};
|
||||
|
|
@ -155,14 +154,14 @@ struct PrivProtocolDone
|
|||
|
||||
struct Adapter
|
||||
{
|
||||
char name[NAME_NUM_MAX];
|
||||
char *name;
|
||||
int fd;
|
||||
|
||||
int product_info_flag;
|
||||
struct AdapterProductInfo *info;
|
||||
ATAgentType agent;
|
||||
|
||||
struct Socket socket;
|
||||
//struct Socket *socket;
|
||||
|
||||
enum NetProtocolType net_protocol;
|
||||
enum NetRoleType net_role;
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <user_api.h>
|
||||
#include <bus.h>
|
||||
|
||||
#define AT_CMD_MAX_LEN 128
|
||||
#define AT_AGENT_MAX 2
|
||||
|
|
@ -35,19 +36,18 @@ static uint32 last_cmd_len = 0;
|
|||
|
||||
static struct ATAgent at_agent_table[AT_AGENT_MAX] = {0};
|
||||
|
||||
unsigned int IpTint(char *ipstr)
|
||||
{
|
||||
uint IpTint(char *ipstr){
|
||||
if (ipstr == NULL)
|
||||
return 0;
|
||||
|
||||
char *token;
|
||||
unsigned int i = 3, total = 0, cur;
|
||||
uint i = 3, total = 0, cur;
|
||||
|
||||
token = strtok(ipstr, ".");
|
||||
|
||||
while (token != NULL) {
|
||||
while (token != NULL){
|
||||
cur = atoi(token);
|
||||
if (cur >= 0 && cur <= 255) {
|
||||
if (cur >= 0 && cur <= 255){
|
||||
total += cur * pow(256, i);
|
||||
}
|
||||
i--;
|
||||
|
|
@ -61,8 +61,8 @@ void SwapStr(char *str, int begin, int end)
|
|||
{
|
||||
int i, j;
|
||||
|
||||
for (i = begin, j = end; i <= j; i++, j--) {
|
||||
if (str[i] != str[j]) {
|
||||
for (i = begin, j = end; i <= j; i++, j--){
|
||||
if (str[i] != str[j]){
|
||||
str[i] = str[i] ^ str[j];
|
||||
str[j] = str[i] ^ str[j];
|
||||
str[i] = str[i] ^ str[j];
|
||||
|
|
@ -70,16 +70,16 @@ void SwapStr(char *str, int begin, int end)
|
|||
}
|
||||
}
|
||||
|
||||
char *IpTstr(unsigned int ipint)
|
||||
char *IpTstr(uint ipint)
|
||||
{
|
||||
int LEN = 16;
|
||||
char *new = (char *)PrivMalloc(LEN);
|
||||
char *new = (char *)malloc(LEN);
|
||||
memset(new, '\0', LEN);
|
||||
new[0] = '.';
|
||||
char token[4];
|
||||
int bt, ed, len, cur;
|
||||
|
||||
while (ipint) {
|
||||
while (ipint){
|
||||
cur = ipint % 256;
|
||||
sprintf(token, "%d", cur);
|
||||
strcat(new, token);
|
||||
|
|
@ -91,8 +91,8 @@ char *IpTstr(unsigned int ipint)
|
|||
len = strlen(new);
|
||||
SwapStr(new, 0, len - 1);
|
||||
|
||||
for (bt = ed = 0; ed < len;) {
|
||||
while (ed < len && new[ed] != '.') {
|
||||
for (bt = ed = 0; ed < len;){
|
||||
while (ed < len && new[ed] != '.'){
|
||||
ed++;
|
||||
}
|
||||
SwapStr(new, bt, ed - 1);
|
||||
|
|
@ -120,21 +120,17 @@ int ParseATReply(char *str, const char *format, ...)
|
|||
uint32 ATSprintf(int fd, const char *format, va_list params)
|
||||
{
|
||||
last_cmd_len = vsnprintf(send_buf, sizeof(send_buf), format, params);
|
||||
printf("ATSprintf send %s len %u\n",send_buf, last_cmd_len);
|
||||
printf("ATSprintf send %s\n",send_buf);
|
||||
PrivWrite(fd, send_buf, last_cmd_len);
|
||||
}
|
||||
|
||||
int ATOrderSend(ATAgentType agent, uint32 timeout_s, ATReplyType reply, const char *cmd_expr, ...)
|
||||
int ATOrderSend(ATAgentType agent, uint32 timeout, ATReplyType reply, const char *cmd_expr, ...)
|
||||
{
|
||||
if (agent == NULL) {
|
||||
if (agent == NULL){
|
||||
printf("ATAgent is null");
|
||||
return -ERROR;
|
||||
}
|
||||
|
||||
struct timespec abstime;
|
||||
|
||||
abstime.tv_sec = timeout_s;
|
||||
|
||||
agent->receive_mode = AT_MODE;
|
||||
|
||||
memset(agent->maintain_buffer, 0x00, agent->maintain_max);
|
||||
|
|
@ -151,16 +147,16 @@ int ATOrderSend(ATAgentType agent, uint32 timeout_s, ATReplyType reply, const ch
|
|||
|
||||
agent->reply = reply;
|
||||
|
||||
if(agent->reply != NULL) {
|
||||
if(agent->reply != NULL){
|
||||
reply->reply_len = 0;
|
||||
va_start(params, cmd_expr);
|
||||
ATSprintf(agent->fd, cmd_expr, params);
|
||||
va_end(params);
|
||||
if (PrivSemaphoreObtainWait(&agent->rsp_sem, &abstime) != EOK) {
|
||||
if (UserSemaphoreObtain(agent->rsp_sem, timeout) != EOK){
|
||||
result = -ETIMEOUT;
|
||||
goto __out;
|
||||
}
|
||||
} else {
|
||||
}else{
|
||||
va_start(params, cmd_expr);
|
||||
ATSprintf(agent->fd, cmd_expr, params);
|
||||
va_end(params);
|
||||
|
|
@ -170,87 +166,16 @@ int ATOrderSend(ATAgentType agent, uint32 timeout_s, ATReplyType reply, const ch
|
|||
__out:
|
||||
agent->reply = NULL;
|
||||
PrivMutexAbandon(&agent->lock);
|
||||
agent->receive_mode = DEFAULT_MODE;
|
||||
agent->receive_mode = ENTM_MODE;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
int AtCmdConfigAndCheck(ATAgentType agent, char *cmd, char *check)
|
||||
{
|
||||
int ret = 0;
|
||||
char *result = NULL;
|
||||
if (NULL == agent || NULL == cmd || NULL == check ) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
ATReplyType reply = CreateATReply(64);
|
||||
if (NULL == reply) {
|
||||
printf("%s %d at_create_resp failed!\n",__func__,__LINE__);
|
||||
ret = -1;
|
||||
goto __exit;
|
||||
}
|
||||
|
||||
ATOrderSend(agent, REPLY_TIME_OUT, reply, cmd);
|
||||
PrivTaskDelay(3000);
|
||||
|
||||
result = GetReplyText(reply);
|
||||
if (!result) {
|
||||
printf("%s %n get reply failed.\n",__func__,__LINE__);
|
||||
ret = -1;
|
||||
goto __exit;
|
||||
}
|
||||
printf("[reply result :\n");
|
||||
printf("%s]\n", result);
|
||||
if(!strstr(result, check)) {
|
||||
printf("%s %d check[%s] reply[%s] failed.\n",__func__,__LINE__,check,result);
|
||||
ret = -1;
|
||||
goto __exit;
|
||||
}
|
||||
|
||||
__exit:
|
||||
DeleteATReply(reply);
|
||||
return ret;
|
||||
}
|
||||
|
||||
char *GetReplyText(ATReplyType reply)
|
||||
{
|
||||
return reply->reply_buffer;
|
||||
}
|
||||
|
||||
int AtSetReplyLrEnd(ATAgentType agent, char enable)
|
||||
{
|
||||
if (!agent) {
|
||||
return -ERROR;
|
||||
}
|
||||
|
||||
agent->reply_lr_end = enable;
|
||||
|
||||
return EOK;
|
||||
}
|
||||
|
||||
int AtSetReplyEndChar(ATAgentType agent, char last_ch, char end_ch)
|
||||
{
|
||||
if (!agent) {
|
||||
return -ERROR;
|
||||
}
|
||||
|
||||
agent->reply_end_last_char = last_ch;
|
||||
agent->reply_end_char = end_ch;
|
||||
|
||||
return EOK;
|
||||
}
|
||||
|
||||
int AtSetReplyCharNum(ATAgentType agent, unsigned int num)
|
||||
{
|
||||
if (!agent) {
|
||||
return -ERROR;
|
||||
}
|
||||
|
||||
agent->reply_char_num = num;
|
||||
|
||||
return EOK;
|
||||
}
|
||||
|
||||
int EntmSend(ATAgentType agent, const char *data, int len)
|
||||
{
|
||||
char send_buf[128];
|
||||
|
|
@ -260,40 +185,32 @@ int EntmSend(ATAgentType agent, const char *data, int len)
|
|||
memcpy(send_buf, data, len);
|
||||
memcpy(send_buf + len, "!@", 2);
|
||||
|
||||
PrivWrite(agent->fd, send_buf, len + 2);
|
||||
write(agent->fd, send_buf, len + 2);
|
||||
|
||||
return EOK;
|
||||
}
|
||||
|
||||
int EntmRecv(ATAgentType agent, char *rev_buffer, int buffer_len, int timeout_s)
|
||||
int EntmRecv(ATAgentType agent, char *rev_buffer, int buffer_len, int time_out)
|
||||
{
|
||||
struct timespec abstime;
|
||||
|
||||
abstime.tv_sec = timeout_s;
|
||||
|
||||
agent->receive_mode = ENTM_MODE;
|
||||
|
||||
PrivTaskDelay(1000);
|
||||
|
||||
if (PrivSemaphoreObtainWait(&agent->entm_rx_notice, &abstime)) {
|
||||
return -ERROR;
|
||||
}
|
||||
|
||||
PrivMutexObtain(&agent->lock);
|
||||
|
||||
if (buffer_len < agent->entm_recv_len) {
|
||||
return -ERROR;
|
||||
}
|
||||
|
||||
printf("EntmRecv once len %u.\n", agent->entm_recv_len);
|
||||
|
||||
agent->entm_recv_buf[agent->entm_recv_len - 1] = '\0';
|
||||
memcpy(rev_buffer, agent->entm_recv_buf, agent->entm_recv_len - 2);
|
||||
UserTaskDelay(1000);
|
||||
|
||||
memset(agent->entm_recv_buf, 0, ENTM_RECV_MAX);
|
||||
agent->entm_recv_len = 0;
|
||||
|
||||
PrivMutexAbandon(&agent->lock);
|
||||
UserSemaphoreSetValue(agent->entm_rx_notice, 0);
|
||||
|
||||
if (UserSemaphoreObtain(agent->entm_rx_notice, time_out)){
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
if (buffer_len < agent->entm_recv_len){
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
printf("EntmRecv once .\n");
|
||||
|
||||
agent->entm_recv_buf[agent->entm_recv_len - 2] = '\0';
|
||||
memcpy(rev_buffer, agent->entm_recv_buf, agent->entm_recv_len - 2);
|
||||
|
||||
return EOK;
|
||||
}
|
||||
|
|
@ -307,49 +224,42 @@ static int GetCompleteATReply(ATAgentType agent)
|
|||
memset(agent->maintain_buffer, 0x00, agent->maintain_max);
|
||||
agent->maintain_len = 0;
|
||||
|
||||
while (1) {
|
||||
PrivRead(agent->fd, &ch, 1);
|
||||
#ifdef CONNECTION_FRAMEWORK_DEBUG
|
||||
printf(" %c (0x%x)\n", ch, ch);
|
||||
#endif
|
||||
while (1){
|
||||
read(agent->fd, &ch, 1);
|
||||
|
||||
printf(" %c(0x%x)\n", ch, ch);
|
||||
|
||||
if (agent->receive_mode == ENTM_MODE){
|
||||
if (agent->entm_recv_len < ENTM_RECV_MAX) {
|
||||
PrivMutexObtain(&agent->lock);
|
||||
|
||||
agent->entm_recv_buf[agent->entm_recv_len] = ch;
|
||||
agent->entm_recv_len++;
|
||||
|
||||
PrivMutexAbandon(&agent->lock);
|
||||
if (agent->entm_recv_len < ENTM_RECV_MAX){
|
||||
agent->entm_recv_buf[agent->entm_recv_len++] = ch;
|
||||
|
||||
if (last_ch == '!' && ch == '@'){
|
||||
PrivSemaphoreAbandon(&agent->entm_rx_notice);
|
||||
UserSemaphoreAbandon(agent->entm_rx_notice);
|
||||
}
|
||||
|
||||
last_ch = ch;
|
||||
} else {
|
||||
}
|
||||
else{
|
||||
printf("entm_recv_buf is_full ...\n");
|
||||
}
|
||||
} else if (agent->receive_mode == AT_MODE) {
|
||||
}
|
||||
else if (agent->receive_mode == AT_MODE){
|
||||
if (read_len < agent->maintain_max){
|
||||
agent->maintain_buffer[read_len] = ch;
|
||||
read_len++;
|
||||
agent->maintain_buffer[read_len++] = ch;
|
||||
agent->maintain_len = read_len;
|
||||
} else {
|
||||
}else{
|
||||
printf("maintain_len is_full ...\n");
|
||||
is_full = true;
|
||||
}
|
||||
|
||||
if (((ch == '\n') && (last_ch == '\r') && (agent->reply_lr_end)) ||
|
||||
((ch == agent->reply_end_char) && (agent->reply_end_char) &&
|
||||
(last_ch == agent->reply_end_last_char) && (agent->reply_end_last_char)) ||
|
||||
((read_len == agent->reply_char_num) && (agent->reply_char_num))){
|
||||
if (is_full) {
|
||||
if ((ch == '\n' && last_ch == '\r')){
|
||||
if (is_full){
|
||||
printf("read line failed. The line data length is out of buffer size(%d)!", agent->maintain_max);
|
||||
memset(agent->maintain_buffer, 0x00, agent->maintain_max);
|
||||
agent->maintain_len = 0;
|
||||
return -ERROR;
|
||||
}
|
||||
printf("GetCompleteATReply done\n");
|
||||
printf("GetCompleteATReply get n r ...\n");
|
||||
break;
|
||||
}
|
||||
last_ch = ch;
|
||||
|
|
@ -362,8 +272,8 @@ static int GetCompleteATReply(ATAgentType agent)
|
|||
ATAgentType GetATAgent(const char *agent_name)
|
||||
{
|
||||
struct ATAgent* result = NULL;
|
||||
for (int i = 0; i < AT_AGENT_MAX; i++) {
|
||||
if (strcmp(at_agent_table[i].agent_name, agent_name) == 0) {
|
||||
for (int i = 0; i < AT_AGENT_MAX; i++){
|
||||
if (strcmp(at_agent_table[i].agent_name, agent_name) == 0){
|
||||
result = &at_agent_table[i];
|
||||
}
|
||||
}
|
||||
|
|
@ -374,51 +284,52 @@ ATAgentType GetATAgent(const char *agent_name)
|
|||
|
||||
static int DeleteATAgent(ATAgentType agent)
|
||||
{
|
||||
if (agent->lock) {
|
||||
if (agent->lock){
|
||||
PrivMutexDelete(&agent->lock);
|
||||
}
|
||||
|
||||
if (agent->entm_rx_notice) {
|
||||
PrivSemaphoreDelete(&agent->entm_rx_notice);
|
||||
if (agent->entm_rx_notice){
|
||||
UserSemaphoreDelete(agent->entm_rx_notice);
|
||||
}
|
||||
|
||||
if (agent->fd > 0) {
|
||||
PrivClose(agent->fd);
|
||||
if (agent->fd > 0){
|
||||
close(agent->fd);
|
||||
}
|
||||
|
||||
if (agent->rsp_sem) {
|
||||
PrivSemaphoreDelete(&agent->rsp_sem);
|
||||
if (agent->rsp_sem){
|
||||
UserSemaphoreDelete(agent->rsp_sem);
|
||||
}
|
||||
|
||||
if (agent->maintain_buffer) {
|
||||
PrivFree(agent->maintain_buffer);
|
||||
if (agent->maintain_buffer){
|
||||
free(agent->maintain_buffer);
|
||||
}
|
||||
|
||||
memset(agent, 0x00, sizeof(struct ATAgent));
|
||||
}
|
||||
|
||||
static void *ATAgentReceiveProcess(void *param)
|
||||
static void ATAgentReceiveProcess(void *param)
|
||||
{
|
||||
ATAgentType agent = (ATAgentType)param;
|
||||
const struct at_urc *urc;
|
||||
|
||||
while (1) {
|
||||
if (GetCompleteATReply(agent) > 0) {
|
||||
while (1){
|
||||
if (GetCompleteATReply(agent) > 0){
|
||||
if (agent->reply != NULL){
|
||||
ATReplyType reply = agent->reply;
|
||||
|
||||
agent->maintain_buffer[agent->maintain_len] = '\0';
|
||||
agent->maintain_buffer[agent->maintain_len - 1] = '\0';
|
||||
|
||||
if (agent->maintain_len < reply->reply_max_len) {
|
||||
if (agent->maintain_len < reply->reply_max_len){
|
||||
memcpy(reply->reply_buffer, agent->maintain_buffer, agent->maintain_len);
|
||||
|
||||
reply->reply_len = agent->maintain_len;
|
||||
} else {
|
||||
}
|
||||
else{
|
||||
printf("out of memory (%d)!", reply->reply_max_len);
|
||||
}
|
||||
|
||||
agent->reply = NULL;
|
||||
PrivSemaphoreAbandon(&agent->rsp_sem);
|
||||
UserSemaphoreAbandon(agent->rsp_sem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -428,48 +339,56 @@ static int ATAgentInit(ATAgentType agent)
|
|||
{
|
||||
int result = EOK;
|
||||
UtaskType at_utask;
|
||||
do
|
||||
{
|
||||
agent->maintain_len = 0;
|
||||
agent->maintain_buffer = (char *)malloc(agent->maintain_max);
|
||||
|
||||
agent->maintain_len = 0;
|
||||
agent->maintain_buffer = (char *)PrivMalloc(agent->maintain_max);
|
||||
if (agent->maintain_buffer == NONE){
|
||||
break;
|
||||
}
|
||||
|
||||
if (agent->maintain_buffer == NONE) {
|
||||
printf("ATAgentInit malloc maintain_buffer error\n");
|
||||
goto __out;
|
||||
}
|
||||
agent->entm_rx_notice = UserSemaphoreCreate(0);
|
||||
if (agent->entm_rx_notice == 0){
|
||||
break;
|
||||
}
|
||||
|
||||
memset(agent->maintain_buffer, 0, agent->maintain_max);
|
||||
agent->rsp_sem = UserSemaphoreCreate(0);
|
||||
if (agent->rsp_sem == 0){
|
||||
break;
|
||||
}
|
||||
if(PrivMutexCreate(&agent->lock, 0) < 0) {
|
||||
printf("AdapterFrameworkInit mutex create failed.\n");
|
||||
}
|
||||
if (agent->lock == 0){
|
||||
break;
|
||||
}
|
||||
|
||||
result = PrivSemaphoreCreate(&agent->entm_rx_notice, 0, 0);
|
||||
if (result < 0) {
|
||||
printf("ATAgentInit create entm sem error\n");
|
||||
goto __out;
|
||||
}
|
||||
agent->receive_mode = ENTM_MODE;
|
||||
|
||||
result = PrivSemaphoreCreate(&agent->rsp_sem, 0, 0);
|
||||
if (result < 0) {
|
||||
printf("ATAgentInit create rsp sem error\n");
|
||||
goto __out;
|
||||
}
|
||||
strncpy(at_utask.name, "recv_task", strlen("recv_task"));
|
||||
at_utask.func_entry = ATAgentReceiveProcess;
|
||||
at_utask.func_param = agent;
|
||||
at_utask.stack_size = 1024;
|
||||
at_utask.prio = 18;
|
||||
|
||||
if(PrivMutexCreate(&agent->lock, 0) < 0) {
|
||||
printf("AdapterFrameworkInit mutex create failed.\n");
|
||||
goto __out;
|
||||
}
|
||||
agent->at_handler = UserTaskCreate(at_utask);
|
||||
|
||||
agent->receive_mode = ENTM_MODE;
|
||||
// struct SerialDataCfg data_cfg;
|
||||
// memset(&data_cfg, 0, sizeof(struct SerialDataCfg));
|
||||
// data_cfg.serial_baud_rate = 57600;
|
||||
// ioctl(agent->fd, OPE_INT, &data_cfg);
|
||||
|
||||
pthread_attr_t attr;
|
||||
attr.schedparam.sched_priority = 18;
|
||||
attr.stacksize = 2048;
|
||||
if (agent->at_handler == 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
PrivTaskCreate(&agent->at_handler, &attr, ATAgentReceiveProcess, agent);
|
||||
result = EOK;
|
||||
return result;
|
||||
} while (1);
|
||||
|
||||
return result;
|
||||
|
||||
__out:
|
||||
DeleteATAgent(agent);
|
||||
result = -ERROR;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
@ -503,8 +422,9 @@ int InitATAgent(const char *agent_name, int agent_fd, uint32 maintain_max)
|
|||
agent->maintain_max = maintain_max;
|
||||
|
||||
result = ATAgentInit(agent);
|
||||
if (result == EOK) {
|
||||
PrivTaskStartup(&agent->at_handler);
|
||||
if (result == EOK)
|
||||
{
|
||||
UserTaskStartup(agent->at_handler);
|
||||
}
|
||||
|
||||
return result;
|
||||
|
|
@ -514,37 +434,38 @@ ATReplyType CreateATReply(uint32 reply_max_len)
|
|||
{
|
||||
ATReplyType reply = NULL;
|
||||
|
||||
reply = (ATReplyType)PrivMalloc(sizeof(struct ATReply));
|
||||
if (reply == NULL) {
|
||||
reply = (ATReplyType)malloc(sizeof(struct ATReply));
|
||||
if (reply == NULL){
|
||||
printf("no more memory\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
reply->reply_max_len = reply_max_len;
|
||||
|
||||
reply->reply_buffer = (char *)PrivMalloc(reply_max_len);
|
||||
if (reply->reply_buffer == NULL) {
|
||||
reply->reply_buffer = (char *)malloc(reply_max_len);
|
||||
if (reply->reply_buffer == NULL){
|
||||
printf("no more memory\n");
|
||||
PrivFree(reply);
|
||||
free(reply);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
memset(reply->reply_buffer, 0, reply_max_len);
|
||||
|
||||
return reply;
|
||||
}
|
||||
|
||||
void DeleteATReply(ATReplyType reply)
|
||||
{
|
||||
if (reply) {
|
||||
if (reply->reply_buffer) {
|
||||
PrivFree(reply->reply_buffer);
|
||||
if (reply){
|
||||
if (reply->reply_buffer){
|
||||
free(reply->reply_buffer);
|
||||
reply->reply_buffer = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (reply) {
|
||||
PrivFree(reply);
|
||||
if (reply){
|
||||
free(reply);
|
||||
reply = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -26,11 +26,8 @@
|
|||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#define REPLY_TIME_OUT 3
|
||||
|
||||
enum ReceiveMode
|
||||
{
|
||||
DEFAULT_MODE = 0,
|
||||
ENTM_MODE = 1,
|
||||
AT_MODE = 2,
|
||||
};
|
||||
|
|
@ -55,13 +52,9 @@ struct ATAgent
|
|||
int lock;
|
||||
|
||||
ATReplyType reply;
|
||||
char reply_lr_end;
|
||||
char reply_end_last_char;
|
||||
char reply_end_char;
|
||||
uint32 reply_char_num;
|
||||
int rsp_sem;
|
||||
|
||||
pthread_t at_handler;
|
||||
int32 at_handler;
|
||||
|
||||
#define ENTM_RECV_MAX 256
|
||||
char entm_recv_buf[ENTM_RECV_MAX];
|
||||
|
|
@ -72,20 +65,18 @@ struct ATAgent
|
|||
typedef struct ATAgent *ATAgentType;
|
||||
|
||||
int EntmSend(ATAgentType agent, const char *data, int len);
|
||||
int EntmRecv(ATAgentType agent, char *rev_buffer, int buffer_len, int timeout_s);
|
||||
int EntmRecv(ATAgentType agent, char *rev_buffer, int buffer_len, int time_out);
|
||||
char *GetReplyText(ATReplyType reply);
|
||||
int AtSetReplyEndChar(ATAgentType agent, char last_ch, char end_ch);
|
||||
int AtSetReplyCharNum(ATAgentType agent, unsigned int num);
|
||||
int AtSetReplyLrEnd(ATAgentType agent, char enable);
|
||||
ATReplyType CreateATReply(uint32 reply_max_len);
|
||||
unsigned int IpTint(char *ipstr);
|
||||
uint IpTint(char *ipstr);
|
||||
void SwapStr(char *str, int begin, int end);
|
||||
char* IpTstr(unsigned int ipint);
|
||||
char* IpTstr(uint ipint);
|
||||
ATAgentType GetATAgent(const char *agent_name);
|
||||
int InitATAgent(const char *agent_name, int fd, uint32 maintain_max);
|
||||
int ParseATReply(char* str, const char *format, ...);
|
||||
void DeleteATReply(ATReplyType reply);
|
||||
int ATOrderSend(ATAgentType agent, uint32 timeout_s, ATReplyType reply, const char *cmd_expr, ...);
|
||||
int AtCmdConfigAndCheck(ATAgentType agent, char *cmd, char *check);
|
||||
int ATOrderSend(ATAgentType agent, uint32 timeout, ATReplyType reply, const char *cmd_expr, ...);
|
||||
|
||||
#define REPLY_TIME_OUT 3000
|
||||
|
||||
#endif
|
||||
|
|
@ -3,14 +3,6 @@ config ADAPTER_BLUETOOTH_HC08
|
|||
default "hc08"
|
||||
|
||||
if ADD_XIUOS_FETURES
|
||||
config ADAPTER_HC08_RECV_BUFFER_SIZE
|
||||
int "HC08 recv data buffer size"
|
||||
default "128"
|
||||
|
||||
config ADAPTER_HC08_WORK_ROLE
|
||||
string "HC08 work role M(MASTER) or S(SLAVER)"
|
||||
default "M"
|
||||
|
||||
config ADAPTER_HC08_DRIVER_EXTUART
|
||||
bool "Using extra uart to support bluetooth"
|
||||
default n
|
||||
|
|
@ -0,0 +1,170 @@
|
|||
/*
|
||||
* Copyright (c) 2020 AIIT XUOS Lab
|
||||
* XiUOS 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 hc08.c
|
||||
* @brief Implement the connection Bluetooth adapter function, using HC08 device
|
||||
* @version 1.1
|
||||
* @author AIIT XUOS Lab
|
||||
* @date 2021.07.12
|
||||
*/
|
||||
|
||||
#include <adapter.h>
|
||||
#include <at_agent.h>
|
||||
|
||||
static int rx_sem;
|
||||
static sem_t *hc08_sem;
|
||||
static pthread_t hc08_recv_thread;
|
||||
|
||||
void Hc08RecvThreadEntry(void *parameter)
|
||||
{
|
||||
|
||||
while (1)
|
||||
{
|
||||
PrivRead(adapter->fd, buf, len);
|
||||
|
||||
UserSemaphoreAbandon(rx_sem);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
static int Hc08Open(struct Adapter *adapter)
|
||||
{
|
||||
if (INSTALL == adapter->adapter_status) {
|
||||
printf("Hc08 has already been open\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*step1: open hc08 serial port*/
|
||||
adapter->fd = PrivOpen(ADAPTER_HC08_DRIVER, O_RDWR);
|
||||
if (adapter->fd < 0) {
|
||||
printf("Hc08Open get serial %s fd error\n", ADAPTER_HC08_DRIVER);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*step2: init AT agent*/
|
||||
if (!adapter->agent) {
|
||||
char *agent_name = "bluetooth_uart_client";
|
||||
if (EOK != InitATAgent(agent_name, adapter->fd, 512)) {
|
||||
printf("at agent init failed !\n");
|
||||
return -1;
|
||||
}
|
||||
ATAgentType at_agent = GetATAgent(agent_name);
|
||||
|
||||
adapter->agent = at_agent;
|
||||
}
|
||||
|
||||
/*step3: create bluetooth receive task*/
|
||||
PrivSemaphoreCreate(hc08_sem, 0, rx_sem);
|
||||
|
||||
PrivTaskCreate(&hc08_recv_thread, NULL, Hc08RecvThreadEntry, NULL);
|
||||
|
||||
ADAPTER_DEBUG("Hc08 open done\n");
|
||||
}
|
||||
|
||||
static int Hc08Close(struct Adapter *adapter)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int Hc08Ioctl(struct Adapter *adapter, int cmd, void *args)
|
||||
{
|
||||
if (OPE_INT != cmd) {
|
||||
printf("Hc08Ioctl only support OPE_INT, do not support %d\n", cmd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
uint32_t baud_rate = *((uint32_t *)args);
|
||||
|
||||
struct SerialDataCfg serial_cfg;
|
||||
memset(&serial_cfg, 0 ,sizeof(struct SerialDataCfg));
|
||||
serial_cfg.serial_baud_rate = baud_rate;
|
||||
serial_cfg.serial_data_bits = DATA_BITS_8;
|
||||
serial_cfg.serial_stop_bits = STOP_BITS_1;
|
||||
serial_cfg.serial_buffer_size = SERIAL_RB_BUFSZ;
|
||||
serial_cfg.serial_parity_mode = PARITY_NONE;
|
||||
serial_cfg.serial_bit_order = STOP_BITS_1;
|
||||
serial_cfg.serial_invert_mode = NRZ_NORMAL;
|
||||
#ifdef ADAPTER_HC08_DRIVER_EXT_PORT
|
||||
serial_cfg.ext_uart_no = ADAPTER_HC08_DRIVER_EXT_PORT;
|
||||
serial_cfg.port_configure = PORT_CFG_INIT;
|
||||
#endif
|
||||
|
||||
struct PrivIoctlCfg ioctl_cfg;
|
||||
ioctl_cfg.ioctl_driver_type = SERIAL_TYPE;
|
||||
ioctl_cfg.args = &serial_cfg;
|
||||
PrivIoctl(adapter->fd, OPE_INT, &ioctl_cfg);
|
||||
|
||||
ADAPTER_DEBUG("Hc08 ioctl done\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int Hc08SetAddr(struct Adapter *adapter, const char *ip, const char *gateway, const char *netmask)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static int Hc08Connect(struct Adapter *adapter, enum NetRoleType net_role, const char *ip, const char *port, enum IpType ip_type)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static int Hc08Send(struct Adapter *adapter, const void *buf, size_t len)
|
||||
{
|
||||
PrivWrite(adapter->fd, buf, len);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int Hc08Recv(struct Adapter *adapter, void *buf, size_t len)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int Hc08Disconnect(struct Adapter *adapter)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static const struct IpProtocolDone hc08_done =
|
||||
{
|
||||
.open = Hc08Open,
|
||||
.close = Hc08Close,
|
||||
.ioctl = Hc08Ioctl,
|
||||
.setup = NULL,
|
||||
.setdown = NULL,
|
||||
.setaddr = Hc08SetAddr,
|
||||
.setdns = NULL,
|
||||
.setdhcp = NULL,
|
||||
.ping = NULL,
|
||||
.netstat = NULL,
|
||||
.connect = Hc08Connect,
|
||||
.send = Hc08Send,
|
||||
.recv = Hc08Recv,
|
||||
.disconnect = Hc08Disconnect,
|
||||
};
|
||||
|
||||
AdapterProductInfoType Hc08Attach(struct Adapter *adapter)
|
||||
{
|
||||
struct AdapterProductInfo *product_info = malloc(sizeof(struct AdapterProductInfo));
|
||||
if (!product_info) {
|
||||
printf("Hc08Attach malloc product_info error\n");
|
||||
free(product_info);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
product_info->model_name = ADAPTER_BLUETOOTH_HC08;
|
||||
|
||||
product_info->model_done = (void *)&hc08_done;
|
||||
|
||||
return product_info;
|
||||
}
|
||||
|
|
@ -1,7 +1,14 @@
|
|||
config ADAPTER_HC08
|
||||
bool "Using bluetooth adapter device HC08"
|
||||
config ADAPTER_BLUETOOTH
|
||||
bool "Using bluetooth adapter function"
|
||||
default y
|
||||
|
||||
if ADAPTER_HC08
|
||||
source "$APP_DIR/Framework/connection/bluetooth/hc08/Kconfig"
|
||||
endif
|
||||
if ADAPTER_BLUETOOTH
|
||||
config ADAPTER_HC08
|
||||
bool "Using bluetooth adapter device HC08"
|
||||
default y
|
||||
|
||||
if ADAPTER_HC08
|
||||
source "$APP_DIR/Framework/connection/bluetooth/HC08/Kconfig"
|
||||
endif
|
||||
|
||||
endif
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
SRC_FILES := adapter_bluetooth.c
|
||||
|
||||
ifeq ($(CONFIG_ADAPTER_HC08),y)
|
||||
SRC_DIR += hc08
|
||||
SRC_DIR += HC08
|
||||
endif
|
||||
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
||||
|
|
|
|||
|
|
@ -17,96 +17,3 @@
|
|||
* @author AIIT XUOS Lab
|
||||
* @date 2021.06.25
|
||||
*/
|
||||
|
||||
#include <adapter.h>
|
||||
|
||||
#ifdef ADAPTER_HC08
|
||||
extern AdapterProductInfoType Hc08Attach(struct Adapter *adapter);
|
||||
#endif
|
||||
|
||||
#define ADAPTER_BLUETOOTH_NAME "BlueTooth"
|
||||
|
||||
static int AdapterBlueToothRegister(struct Adapter *adapter)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
strncpy(adapter->name, ADAPTER_BLUETOOTH_NAME, NAME_NUM_MAX);
|
||||
|
||||
adapter->net_protocol = IP_PROTOCOL;
|
||||
adapter->adapter_status = UNREGISTERED;
|
||||
|
||||
ret = AdapterDeviceRegister(adapter);
|
||||
if (ret < 0) {
|
||||
printf("AdapterBlueToothRegister register error\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int AdapterBlueToothInit(void)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
struct Adapter *adapter = PrivMalloc(sizeof(struct Adapter));
|
||||
if (!adapter) {
|
||||
free(adapter);
|
||||
return -1;
|
||||
}
|
||||
|
||||
memset(adapter, 0, sizeof(struct Adapter));
|
||||
|
||||
ret = AdapterBlueToothRegister(adapter);
|
||||
if (ret < 0) {
|
||||
printf("AdapterBlueToothInit register BT adapter error\n");
|
||||
free(adapter);
|
||||
return -1;
|
||||
}
|
||||
|
||||
#ifdef ADAPTER_HC08
|
||||
AdapterProductInfoType product_info = Hc08Attach(adapter);
|
||||
if (!product_info) {
|
||||
printf("AdapterBlueToothInit hc08 attach error\n");
|
||||
free(adapter);
|
||||
return -1;
|
||||
}
|
||||
|
||||
adapter->product_info_flag = 1;
|
||||
adapter->info = product_info;
|
||||
adapter->done = product_info->model_done;
|
||||
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/******************4G TEST*********************/
|
||||
int AdapterBlueToothTest(void)
|
||||
{
|
||||
const char *bluetooth_msg = "BT Adapter Test";
|
||||
char bluetooth_recv_msg[128];
|
||||
int len;
|
||||
int baud_rate = BAUD_RATE_115200;
|
||||
|
||||
struct Adapter *adapter = AdapterDeviceFindByName(ADAPTER_BLUETOOTH_NAME);
|
||||
|
||||
#ifdef ADAPTER_HC08
|
||||
AdapterDeviceOpen(adapter);
|
||||
AdapterDeviceControl(adapter, OPE_INT, &baud_rate);
|
||||
|
||||
len = strlen(bluetooth_msg);
|
||||
|
||||
while (1) {
|
||||
AdapterDeviceRecv(adapter, bluetooth_recv_msg, 128);
|
||||
printf("bluetooth_recv_msg %s\n", bluetooth_recv_msg);
|
||||
AdapterDeviceSend(adapter, bluetooth_msg, len);
|
||||
printf("send %s after recv\n", bluetooth_msg);
|
||||
PrivTaskDelay(100);
|
||||
memset(bluetooth_recv_msg, 0, 128);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_PARAM_NUM(0)|SHELL_CMD_DISABLE_RETURN, AdapterBlueToothTest, AdapterBlueToothTest, show adapter BT information);
|
||||
|
|
|
|||
|
|
@ -1,430 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2020 AIIT XUOS Lab
|
||||
* XiUOS 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 hc08.c
|
||||
* @brief Implement the connection Bluetooth adapter function, using HC08 device
|
||||
* @version 1.1
|
||||
* @author AIIT XUOS Lab
|
||||
* @date 2021.07.12
|
||||
*/
|
||||
|
||||
#include <adapter.h>
|
||||
#include <at_agent.h>
|
||||
|
||||
#define HC08_DETECT_CMD "AT"
|
||||
#define HC08_DEFAULT_CMD "AT+DEFAULT"
|
||||
#define HC08_RESET_CMD "AT+RESET"
|
||||
#define HC08_CLEAR_CMD "AT+CLEAR"
|
||||
#define HC08_GET_DEVICE_INFO "AT+RX"
|
||||
|
||||
#define HC08_GET_BAUDRATE_CMD "AT+BAUD=?"
|
||||
#define HC08_SET_BAUDRATE_CMD "AT+BAUD=%u"
|
||||
#define HC08_GET_CONNECTABLE "AT+CONT=?"
|
||||
#define HC08_SET_CONNECTABLE "AT+CONT=%s"
|
||||
#define HC08_GET_ROLE_CMD "AT+ROLE=?"
|
||||
#define HC08_SET_ROLE_CMD "AT+ROLE=%s"
|
||||
#define HC08_GET_ADDR_CMD "AT+ADDR=?"
|
||||
#define HC08_SET_ADDR_CMD "AT+ADDR=%s"
|
||||
#define HC08_GET_NAME_CMD "AT+NAME=%s"
|
||||
#define HC08_SET_NAME_CMD "AT+NAME=?"
|
||||
|
||||
#define HC08_OK_RESP "OK"
|
||||
|
||||
#define HC08_CMD_STR_DEFAULT_SIZE 64
|
||||
#define HC08_RESP_DEFAULT_SIZE 64
|
||||
|
||||
enum Hc08AtCmd
|
||||
{
|
||||
HC08_AT_CMD_DETECT = 0,
|
||||
HC08_AT_CMD_DEFAULT,
|
||||
HC08_AT_CMD_RESET,
|
||||
HC08_AT_CMD_CLEAR,
|
||||
HC08_AT_CMD_GET_DEVICE_INFO,
|
||||
HC08_AT_CMD_GET_BAUDRATE,
|
||||
HC08_AT_CMD_SET_BAUDRATE,
|
||||
HC08_AT_CMD_SET_CONNECTABLE,
|
||||
HC08_AT_CMD_GET_CONNECTABLE,
|
||||
HC08_AT_CMD_SET_ROLE,
|
||||
HC08_AT_CMD_GET_ROLE,
|
||||
HC08_AT_CMD_SET_ADDR,
|
||||
HC08_AT_CMD_GET_ADDR,
|
||||
HC08_AT_CMD_SET_NAME,
|
||||
HC08_AT_CMD_GET_NAME,
|
||||
HC08_AT_CMD_END,
|
||||
};
|
||||
|
||||
static int Hc08CheckMacHex(char *hex, int len)
|
||||
{
|
||||
int i = 0;
|
||||
while (i < len)
|
||||
{
|
||||
if ((hex[i] >= 'A' && hex[i] <= 'F') ||
|
||||
(hex[i] >= 'a' && hex[i] <= 'f') ||
|
||||
(hex[i] >= '0' && hex[i] <= '9'))
|
||||
{
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
//HC08 AT cmd function
|
||||
static int Hc08AtConfigure(ATAgentType agent, enum Hc08AtCmd hc08_at_cmd, void *param, char *reply_info)
|
||||
{
|
||||
const char *result_buf;
|
||||
char *connectable, *role;
|
||||
unsigned int baudrate;
|
||||
char reply_ok_flag = 1;
|
||||
char cmd_str[HC08_CMD_STR_DEFAULT_SIZE] = {0};
|
||||
|
||||
ATReplyType reply = CreateATReply(64);
|
||||
if (NULL == reply) {
|
||||
printf("Hc08AtConfigure CreateATReply failed !\n");
|
||||
return -ENOMEMORY;
|
||||
}
|
||||
|
||||
switch (hc08_at_cmd)
|
||||
{
|
||||
case HC08_AT_CMD_DETECT:
|
||||
AtSetReplyEndChar(agent, 0x4F, 0x4B);
|
||||
ATOrderSend(agent, REPLY_TIME_OUT, reply, HC08_DETECT_CMD);
|
||||
break;
|
||||
case HC08_AT_CMD_DEFAULT:
|
||||
AtSetReplyEndChar(agent, 0x4F, 0x4B);
|
||||
ATOrderSend(agent, REPLY_TIME_OUT, reply, HC08_DEFAULT_CMD);
|
||||
break;
|
||||
case HC08_AT_CMD_RESET:
|
||||
AtSetReplyEndChar(agent, 0x4F, 0x4B);
|
||||
ATOrderSend(agent, REPLY_TIME_OUT, reply, HC08_RESET_CMD);
|
||||
break;
|
||||
case HC08_AT_CMD_CLEAR:
|
||||
AtSetReplyEndChar(agent, 0x4F, 0x4B);
|
||||
ATOrderSend(agent, REPLY_TIME_OUT, reply, HC08_CLEAR_CMD);
|
||||
break;
|
||||
case HC08_AT_CMD_GET_DEVICE_INFO:
|
||||
ATOrderSend(agent, REPLY_TIME_OUT, reply, HC08_GET_DEVICE_INFO);
|
||||
reply_ok_flag = 0;
|
||||
break;
|
||||
case HC08_AT_CMD_SET_BAUDRATE:
|
||||
baudrate = *(unsigned int *)param;
|
||||
sprintf(cmd_str, HC08_SET_BAUDRATE_CMD, baudrate);
|
||||
strcat(cmd_str, ",N");
|
||||
AtSetReplyEndChar(agent, 0x4E, 0x45);
|
||||
ATOrderSend(agent, REPLY_TIME_OUT, reply, cmd_str);
|
||||
reply_ok_flag = 0;
|
||||
break;
|
||||
case HC08_AT_CMD_GET_BAUDRATE:
|
||||
AtSetReplyEndChar(agent, 0x2C, 0x4E);
|
||||
ATOrderSend(agent, REPLY_TIME_OUT, reply, HC08_GET_BAUDRATE_CMD);
|
||||
reply_ok_flag = 0;
|
||||
break;
|
||||
case HC08_AT_CMD_SET_CONNECTABLE:
|
||||
connectable = (char *)param;
|
||||
sprintf(cmd_str, HC08_SET_CONNECTABLE, connectable);
|
||||
AtSetReplyEndChar(agent, 0x4F, 0x4B);
|
||||
ATOrderSend(agent, REPLY_TIME_OUT, reply, cmd_str);
|
||||
break;
|
||||
case HC08_AT_CMD_GET_CONNECTABLE:
|
||||
AtSetReplyEndChar(agent, 0x6C, 0x65);
|
||||
ATOrderSend(agent, REPLY_TIME_OUT, reply, HC08_GET_CONNECTABLE);
|
||||
reply_ok_flag = 0;
|
||||
break;
|
||||
case HC08_AT_CMD_SET_ROLE:
|
||||
role = (char *)param;
|
||||
sprintf(cmd_str, HC08_SET_ROLE_CMD, role);
|
||||
AtSetReplyCharNum(agent, 1);
|
||||
ATOrderSend(agent, REPLY_TIME_OUT, reply, cmd_str);
|
||||
break;
|
||||
case HC08_AT_CMD_GET_ROLE:
|
||||
AtSetReplyCharNum(agent, 1);
|
||||
ATOrderSend(agent, REPLY_TIME_OUT, reply, HC08_GET_ROLE_CMD);
|
||||
reply_ok_flag = 0;
|
||||
break;
|
||||
// case HC08_AT_CMD_SET_ADDR:
|
||||
// ATOrderSend(agent, REPLY_TIME_OUT, reply, HC08_SET_ROLE_CMD);
|
||||
// break;
|
||||
// case HC08_AT_CMD_GET_ADDR:
|
||||
// ATOrderSend(agent, REPLY_TIME_OUT, reply, HC08_GET_ROLE_CMD);
|
||||
// reply_ok_flag = 0;
|
||||
// break;
|
||||
// case HC08_AT_CMD_SET_NAME:
|
||||
// ATOrderSend(agent, REPLY_TIME_OUT, reply, HC08_SET_NAME_CMD);
|
||||
// break;
|
||||
// case HC08_AT_CMD_GET_NAME:
|
||||
// ATOrderSend(agent, REPLY_TIME_OUT, reply, HC08_GET_NAME_CMD);
|
||||
// reply_ok_flag = 0;
|
||||
// break;
|
||||
default:
|
||||
printf("hc08 do not support no.%d cmd\n", hc08_at_cmd);
|
||||
DeleteATReply(reply);
|
||||
return -1;
|
||||
}
|
||||
|
||||
PrivTaskDelay(200);
|
||||
|
||||
result_buf = GetReplyText(reply);
|
||||
|
||||
if (reply_ok_flag) {
|
||||
if (!strstr(HC08_OK_RESP, result_buf)) {
|
||||
printf("%u cmd get reply OK failed:get reply %s\n", hc08_at_cmd, result_buf);
|
||||
}
|
||||
}
|
||||
|
||||
if (reply_info) {
|
||||
strncpy(reply_info, result_buf, reply->reply_len);
|
||||
}
|
||||
|
||||
DeleteATReply(reply);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int Hc08Open(struct Adapter *adapter)
|
||||
{
|
||||
if (INSTALL == adapter->adapter_status) {
|
||||
printf("Hc08 has already been open\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
//step1: open hc08 serial port
|
||||
adapter->fd = PrivOpen(ADAPTER_HC08_DRIVER, O_RDWR);
|
||||
if (adapter->fd < 0) {
|
||||
printf("Hc08Open get serial %s fd error\n", ADAPTER_HC08_DRIVER);
|
||||
return -1;
|
||||
}
|
||||
|
||||
//step2: init AT agent
|
||||
if (!adapter->agent) {
|
||||
char *agent_name = "bluetooth_uart_client";
|
||||
printf("InitATAgent agent_name %s fd %u\n", agent_name, adapter->fd);
|
||||
if (EOK != InitATAgent(agent_name, adapter->fd, 512)) {
|
||||
printf("at agent init failed !\n");
|
||||
return -1;
|
||||
}
|
||||
ATAgentType at_agent = GetATAgent(agent_name);
|
||||
|
||||
adapter->agent = at_agent;
|
||||
|
||||
printf("Hc08Open adapter agent %p\n", adapter->agent);
|
||||
}
|
||||
|
||||
PrivTaskDelay(200);
|
||||
|
||||
ADAPTER_DEBUG("Hc08 open done\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int Hc08Close(struct Adapter *adapter)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int Hc08Ioctl(struct Adapter *adapter, int cmd, void *args)
|
||||
{
|
||||
if (OPE_INT != cmd) {
|
||||
printf("Hc08Ioctl only support OPE_INT, do not support %d\n", cmd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
char hc08_baudrate[HC08_RESP_DEFAULT_SIZE] = {0};
|
||||
uint32_t baud_rate = *((uint32_t *)args);
|
||||
|
||||
struct SerialDataCfg serial_cfg;
|
||||
memset(&serial_cfg, 0 ,sizeof(struct SerialDataCfg));
|
||||
serial_cfg.serial_baud_rate = baud_rate;
|
||||
serial_cfg.serial_data_bits = DATA_BITS_8;
|
||||
serial_cfg.serial_stop_bits = STOP_BITS_1;
|
||||
serial_cfg.serial_buffer_size = SERIAL_RB_BUFSZ;
|
||||
serial_cfg.serial_parity_mode = PARITY_NONE;
|
||||
serial_cfg.serial_bit_order = STOP_BITS_1;
|
||||
serial_cfg.serial_invert_mode = NRZ_NORMAL;
|
||||
#ifdef ADAPTER_HC08_DRIVER_EXT_PORT
|
||||
serial_cfg.ext_uart_no = ADAPTER_HC08_DRIVER_EXT_PORT;
|
||||
serial_cfg.port_configure = PORT_CFG_INIT;
|
||||
#endif
|
||||
|
||||
struct PrivIoctlCfg ioctl_cfg;
|
||||
ioctl_cfg.ioctl_driver_type = SERIAL_TYPE;
|
||||
ioctl_cfg.args = &serial_cfg;
|
||||
PrivIoctl(adapter->fd, OPE_INT, &ioctl_cfg);
|
||||
|
||||
//Step1 : detect hc08 serial function
|
||||
if (Hc08AtConfigure(adapter->agent, HC08_AT_CMD_DETECT, NULL, NULL) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
//Step2 : set hc08 device serial baud, hc08_set_baud send "AT+BAUD=%s"
|
||||
if (Hc08AtConfigure(adapter->agent, HC08_AT_CMD_SET_BAUDRATE, args, NULL) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
PrivTaskDelay(200);
|
||||
|
||||
//Step3 : show hc08 device info, hc08_get send "AT+RX" response device info
|
||||
char device_info[HC08_RESP_DEFAULT_SIZE * 2] = {0};
|
||||
if (Hc08AtConfigure(adapter->agent, HC08_AT_CMD_GET_DEVICE_INFO, NULL, device_info) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
ADAPTER_DEBUG("Hc08 ioctl done\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int Hc08SetAddr(struct Adapter *adapter, const char *ip, const char *gateway, const char *netmask)
|
||||
{
|
||||
char mac_addr[HC08_RESP_DEFAULT_SIZE] = {0};
|
||||
|
||||
//Step1 : hc08_get_addr send "AT+ADDR=?" response mac "XX,XX,XX,XX,XX,XX"
|
||||
if (Hc08AtConfigure(adapter->agent, HC08_AT_CMD_GET_ADDR, NULL, mac_addr) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
printf("HC08 old mac addr: %s\n", mac_addr);
|
||||
|
||||
//Step2 : hc08_set_addr send "AT+ADDR=%s" response "OK"
|
||||
if (!Hc08CheckMacHex((char *)gateway, 12)) {
|
||||
if (Hc08AtConfigure(adapter->agent, HC08_AT_CMD_SET_ADDR, (void *)gateway, NULL) < 0) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
//Step3 : check mac addr, hc08_get_addr send "AT+ADDR=?" response mac "XX,XX,XX,XX,XX,XX"
|
||||
if (Hc08AtConfigure(adapter->agent, HC08_AT_CMD_GET_ADDR, NULL, mac_addr) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
printf("HC08 new mac addr: %s\n", mac_addr);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int Hc08Connect(struct Adapter *adapter, enum NetRoleType net_role, const char *ip, const char *port, enum IpType ip_type)
|
||||
{
|
||||
char connect_status[HC08_RESP_DEFAULT_SIZE] = {0};
|
||||
|
||||
//Step1 : hc08_detect send "AT" response "OK"
|
||||
if (Hc08AtConfigure(adapter->agent, HC08_AT_CMD_DETECT, NULL, NULL) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
//Step2 : hc08_set_role send "AT+ROLE=%s" response "OK"
|
||||
if (Hc08AtConfigure(adapter->agent, HC08_AT_CMD_SET_ROLE, ADAPTER_HC08_WORK_ROLE, NULL) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
//Step3 : hc08_connectable send "AT+CONT=0" response "OK"
|
||||
if (Hc08AtConfigure(adapter->agent, HC08_AT_CMD_SET_CONNECTABLE, "0", NULL) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
//Step4 : check connectable status,hc08_connectable send "AT+CONT=?" response "Connectable"
|
||||
if (Hc08AtConfigure(adapter->agent, HC08_AT_CMD_GET_CONNECTABLE, NULL, connect_status) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
printf("Hc08Connect status %s\n", connect_status);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int Hc08Send(struct Adapter *adapter, const void *buf, size_t len)
|
||||
{
|
||||
x_err_t result = EOK;
|
||||
if (adapter->agent) {
|
||||
EntmSend(adapter->agent, (const char *)buf, len);
|
||||
} else {
|
||||
printf("Hc08Send can not find agent\n");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int Hc08Recv(struct Adapter *adapter, void *buf, size_t len)
|
||||
{
|
||||
if (adapter->agent) {
|
||||
return EntmRecv(adapter->agent, (char *)buf, len, 40);
|
||||
} else {
|
||||
printf("Hc08Recv can not find agent\n");
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int Hc08Disconnect(struct Adapter *adapter)
|
||||
{
|
||||
char connect_status[HC08_RESP_DEFAULT_SIZE] = {0};
|
||||
|
||||
//Step1 : hc08_detect send "AT" response "OK"
|
||||
if (Hc08AtConfigure(adapter->agent, HC08_AT_CMD_DETECT, NULL, NULL) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
//Step2 : hc08_connectable send "AT+CONT=1" response "OK"
|
||||
if (Hc08AtConfigure(adapter->agent, HC08_AT_CMD_SET_CONNECTABLE, "1", NULL) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
//Step3 : check connectable status,hc08_connectable send "AT+CONT=?" response "Not-Connectable"
|
||||
if (Hc08AtConfigure(adapter->agent, HC08_AT_CMD_GET_CONNECTABLE, NULL, connect_status) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
printf("Hc08Disconnect status %s\n", connect_status);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct IpProtocolDone hc08_done =
|
||||
{
|
||||
.open = Hc08Open,
|
||||
.close = Hc08Close,
|
||||
.ioctl = Hc08Ioctl,
|
||||
.setup = NULL,
|
||||
.setdown = NULL,
|
||||
.setaddr = Hc08SetAddr,
|
||||
.setdns = NULL,
|
||||
.setdhcp = NULL,
|
||||
.ping = NULL,
|
||||
.netstat = NULL,
|
||||
.connect = Hc08Connect,
|
||||
.send = Hc08Send,
|
||||
.recv = Hc08Recv,
|
||||
.disconnect = Hc08Disconnect,
|
||||
};
|
||||
|
||||
AdapterProductInfoType Hc08Attach(struct Adapter *adapter)
|
||||
{
|
||||
struct AdapterProductInfo *product_info = PrivMalloc(sizeof(struct AdapterProductInfo));
|
||||
if (!product_info) {
|
||||
printf("Hc08Attach malloc product_info error\n");
|
||||
free(product_info);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ("M" == ADAPTER_HC08_WORK_ROLE) {
|
||||
adapter->net_role = MASTER;
|
||||
} else if ("S" == ADAPTER_HC08_WORK_ROLE) {
|
||||
adapter->net_role = SLAVE;
|
||||
} else {
|
||||
adapter->net_role = ROLE_NONE;
|
||||
}
|
||||
|
||||
strcpy(product_info->model_name, ADAPTER_BLUETOOTH_HC08);
|
||||
|
||||
product_info->model_done = (void *)&hc08_done;
|
||||
|
||||
return product_info;
|
||||
}
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
if CONNECTION_ADAPTER_NB
|
||||
config ADAPTER_BC28
|
||||
bool "Using nbiot adapter device BC28"
|
||||
default y
|
||||
|
||||
if ADAPTER_BC28
|
||||
source "$APP_DIR/Framework/connection/nbiot/bc28/Kconfig"
|
||||
endif
|
||||
|
||||
endif
|
||||
|
|
@ -1,7 +1,3 @@
|
|||
SRC_FILES := adapter_nbiot.c
|
||||
|
||||
ifeq ($(CONFIG_ADAPTER_BC28),y)
|
||||
SRC_DIR += bc28
|
||||
endif
|
||||
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
||||
|
|
|
|||
|
|
@ -17,156 +17,3 @@
|
|||
* @author AIIT XUOS Lab
|
||||
* @date 2021.06.25
|
||||
*/
|
||||
#include <adapter.h>
|
||||
|
||||
|
||||
#ifdef ADAPTER_BC28
|
||||
extern AdapterProductInfoType BC28Attach(struct Adapter *adapter);
|
||||
#endif
|
||||
|
||||
#define ADAPTER_NBIOT_NAME "nbiot"
|
||||
|
||||
static int AdapterNbiotRegister(struct Adapter *adapter)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
strncpy(adapter->name, ADAPTER_NBIOT_NAME, NAME_NUM_MAX);
|
||||
|
||||
adapter->net_protocol = IP_PROTOCOL;
|
||||
adapter->net_role = CLIENT;
|
||||
|
||||
adapter->adapter_status = UNREGISTERED;
|
||||
|
||||
ret = AdapterDeviceRegister(adapter);
|
||||
if (ret < 0) {
|
||||
printf("AdapterNbiot register error\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int AdapterNbiotInit(void)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
struct Adapter *adapter = malloc(sizeof(struct Adapter));
|
||||
if (!adapter) {
|
||||
printf("malloc adapter failed.\n");
|
||||
return -1;
|
||||
}
|
||||
memset(adapter, 0, sizeof(struct Adapter));
|
||||
ret = AdapterNbiotRegister(adapter);
|
||||
if (ret < 0) {
|
||||
printf("register nbiot adapter error\n");
|
||||
free(adapter);
|
||||
return -1;
|
||||
}
|
||||
#ifdef ADAPTER_BC28
|
||||
AdapterProductInfoType product_info = BC28Attach(adapter);
|
||||
if (!product_info) {
|
||||
printf("bc28 attach error\n");
|
||||
free(adapter);
|
||||
return -1;
|
||||
}
|
||||
|
||||
adapter->product_info_flag = 1;
|
||||
adapter->info = product_info;
|
||||
adapter->done = product_info->model_done;
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/******************TEST*********************/
|
||||
int opennb(void)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
struct Adapter* adapter = AdapterDeviceFindByName(ADAPTER_NBIOT_NAME);
|
||||
|
||||
#ifdef ADAPTER_BC28
|
||||
ret = AdapterDeviceOpen(adapter);
|
||||
if(ret < 0){
|
||||
printf("open adapter failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_PARAM_NUM(0)|SHELL_CMD_DISABLE_RETURN, opennb, opennb, show adapter nb information);
|
||||
int closenb(void)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
struct Adapter* adapter = AdapterDeviceFindByName(ADAPTER_NBIOT_NAME);
|
||||
|
||||
#ifdef ADAPTER_BC28
|
||||
ret = AdapterDeviceClose(adapter);
|
||||
if(ret < 0){
|
||||
printf("open adapter failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_PARAM_NUM(0)|SHELL_CMD_DISABLE_RETURN, closenb, closenb, show adapter nb information);
|
||||
|
||||
int connectnb(int argc, char *argv[])
|
||||
{
|
||||
const char *send_msg = argv[1];
|
||||
int ret = 0;
|
||||
|
||||
struct Adapter* adapter = AdapterDeviceFindByName(ADAPTER_NBIOT_NAME);
|
||||
|
||||
|
||||
ret = AdapterDeviceConnect(adapter, 1, "101.68.82.219","9898",1);
|
||||
if(ret < 0){
|
||||
printf(" adapter send failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN)|SHELL_CMD_PARAM_NUM(2)|SHELL_CMD_DISABLE_RETURN, connectnb, connectnb, show adapter nb information);
|
||||
|
||||
int sendnb(int argc, char *argv[])
|
||||
{
|
||||
const char *send_msg = argv[1];
|
||||
int msg_len = atoi(argv[2]);
|
||||
int ret = 0;
|
||||
|
||||
struct Adapter* adapter = AdapterDeviceFindByName(ADAPTER_NBIOT_NAME);
|
||||
|
||||
printf("send argv1 %s len = %d\n",argv[1],msg_len);
|
||||
ret = AdapterDeviceSend(adapter, send_msg, msg_len);
|
||||
if(ret < 0){
|
||||
printf(" adapter send failed\n");
|
||||
return -1;
|
||||
}
|
||||
printf("nb send msg %s\n", send_msg);
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN)|SHELL_CMD_PARAM_NUM(2)|SHELL_CMD_DISABLE_RETURN, sendnb, sendnb, show adapter nb information);
|
||||
|
||||
int recvnb(void)
|
||||
{
|
||||
char recv_msg[128];
|
||||
struct Adapter* adapter = AdapterDeviceFindByName(ADAPTER_NBIOT_NAME);
|
||||
memset(recv_msg,0,128);
|
||||
AdapterDeviceRecv(adapter, recv_msg, 128);
|
||||
PrivTaskDelay(2000);
|
||||
printf("nb recv msg %s\n", recv_msg);
|
||||
|
||||
return 0;
|
||||
}
|
||||
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_PARAM_NUM(0)|SHELL_CMD_DISABLE_RETURN, recvnb, recvnb, show adapter nb information);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +0,0 @@
|
|||
#ifndef ADAPTER_NBIOT_H
|
||||
#define ADAPTER_NBIOT_H
|
||||
|
||||
#define CONFIG_NBIOT_RESET (0)
|
||||
#define CONFIG_NBIOT_CREATE_SOCKET (1)
|
||||
#define CONFIG_NBIOT_DELETE_SOCKET (2)
|
||||
|
||||
#define SOCKET_TYPE_DGRAM (0)
|
||||
#define SOCKET_TYPE_STREAM (1)
|
||||
|
||||
|
||||
#endif
|
||||
|
|
@ -1,40 +0,0 @@
|
|||
config ADAPTER_NBIOT_BC28
|
||||
string "BC28 adapter name"
|
||||
default "bc28"
|
||||
|
||||
if ADD_XIUOS_FETURES
|
||||
config ADAPTER_BC28_RESETPIN
|
||||
int "BC28 RESET pin number"
|
||||
default "100"
|
||||
|
||||
config ADAPTER_BC28_PIN_DRIVER
|
||||
string "BC28 device pin driver path"
|
||||
default "/dev/pin_dev"
|
||||
|
||||
config ADAPTER_BC28_DRIVER_EXTUART
|
||||
bool "Using extra uart to support nbiot"
|
||||
default n
|
||||
|
||||
config ADAPTER_BC28_DRIVER
|
||||
string "BC28 device uart driver path"
|
||||
default "/dev/usart2_dev2"
|
||||
depends on !ADAPTER_BC28_DRIVER_EXTUART
|
||||
|
||||
if ADAPTER_BC28_DRIVER_EXTUART
|
||||
config ADAPTER_BC28_DRIVER
|
||||
string "BC28 device extra uart driver path"
|
||||
default "/dev/extuart_dev5"
|
||||
|
||||
config ADAPTER_BC28_DRIVER_EXT_PORT
|
||||
int "if BC28 device using extuart, choose port"
|
||||
default "5"
|
||||
endif
|
||||
endif
|
||||
|
||||
if ADD_NUTTX_FETURES
|
||||
|
||||
endif
|
||||
|
||||
if ADD_RTTHREAD_FETURES
|
||||
|
||||
endif
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
SRC_FILES := bc28.c
|
||||
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
||||
|
|
@ -1,551 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2020 AIIT XUOS Lab
|
||||
* XiUOS 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 bc28.c
|
||||
* @brief Implement the connection nbiot adapter function, using BC28 device
|
||||
* @version 1.1
|
||||
* @author AIIT XUOS Lab
|
||||
* @date 2021.09.15
|
||||
*/
|
||||
|
||||
#include <adapter.h>
|
||||
#include <at_agent.h>
|
||||
#include "../adapter_nbiot.h"
|
||||
|
||||
#define SOCKET_PROTOCOL_TCP (6)
|
||||
#define SOCKET_PROTOCOL_UDP (17)
|
||||
|
||||
#define NET_TYPE_AF_INET (0)
|
||||
#define NET_TYPE_AF_INET6 (1)
|
||||
|
||||
#define SOCKET_INVALID_ID (-1)
|
||||
|
||||
|
||||
static int BC28UartOpen(struct Adapter *adapter)
|
||||
{
|
||||
if (NULL == adapter) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Open device in read-write mode */
|
||||
adapter->fd = PrivOpen(ADAPTER_BC28_DRIVER,O_RDWR);
|
||||
if (adapter->fd < 0) {
|
||||
printf("BC28UartOpen get serial %s fd error\n", ADAPTER_BC28_DRIVER);
|
||||
return -1;
|
||||
}
|
||||
/* set serial config, serial_baud_rate = 9600 */
|
||||
|
||||
struct SerialDataCfg cfg;
|
||||
memset(&cfg, 0 ,sizeof(struct SerialDataCfg));
|
||||
|
||||
cfg.serial_baud_rate = BAUD_RATE_9600;
|
||||
cfg.serial_data_bits = DATA_BITS_8;
|
||||
cfg.serial_stop_bits = STOP_BITS_1;
|
||||
cfg.serial_parity_mode = PARITY_NONE;
|
||||
cfg.serial_bit_order = BIT_ORDER_LSB;
|
||||
cfg.serial_invert_mode = NRZ_NORMAL;
|
||||
cfg.serial_buffer_size = SERIAL_RB_BUFSZ;
|
||||
|
||||
/*aiit board use ch438, so it needs more serial configuration*/
|
||||
#ifdef ADAPTER_BC28_DRIVER_EXTUART
|
||||
cfg.ext_uart_no = ADAPTER_BC28_DRIVER_EXT_PORT;
|
||||
cfg.port_configure = PORT_CFG_INIT;
|
||||
#endif
|
||||
|
||||
struct PrivIoctlCfg ioctl_cfg;
|
||||
ioctl_cfg.ioctl_driver_type = SERIAL_TYPE;
|
||||
ioctl_cfg.args = &cfg;
|
||||
|
||||
PrivIoctl(adapter->fd, OPE_INT, &ioctl_cfg);
|
||||
PrivTaskDelay(1000);
|
||||
|
||||
printf("NBIot uart config ready\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void BC28PowerSet(void)
|
||||
{
|
||||
int pin_fd;
|
||||
pin_fd = PrivOpen(ADAPTER_BC28_PIN_DRIVER, O_RDWR);
|
||||
|
||||
struct PinParam pin_param;
|
||||
pin_param.cmd = GPIO_CONFIG_MODE;
|
||||
pin_param.mode = GPIO_CFG_OUTPUT;
|
||||
pin_param.pin = ADAPTER_BC28_RESETPIN;
|
||||
|
||||
struct PrivIoctlCfg ioctl_cfg;
|
||||
ioctl_cfg.ioctl_driver_type = PIN_TYPE;
|
||||
ioctl_cfg.args = &pin_param;
|
||||
PrivIoctl(pin_fd, OPE_CFG, &ioctl_cfg);
|
||||
|
||||
struct PinStat pin_stat;
|
||||
pin_stat.pin = ADAPTER_BC28_RESETPIN;
|
||||
pin_stat.val = GPIO_HIGH;
|
||||
PrivWrite(pin_fd, &pin_stat, 1);
|
||||
|
||||
PrivTaskDelay(200);//at least 200ms
|
||||
|
||||
pin_stat.val = GPIO_LOW;
|
||||
PrivWrite(pin_fd, &pin_stat, 1);
|
||||
|
||||
PrivClose(pin_fd);
|
||||
}
|
||||
|
||||
int NBIoTStatusCheck(struct Adapter *adapter )
|
||||
{
|
||||
int32 result = 0;
|
||||
|
||||
if (!adapter ){
|
||||
return -1;
|
||||
}
|
||||
|
||||
char at_cmd[64] = {0};
|
||||
|
||||
AtSetReplyEndChar(adapter->agent, 0x4F, 0x4B); /* set receive end flag as 'OK'*/
|
||||
|
||||
memcpy(at_cmd, "AT+CSQ", 6);
|
||||
strcat(at_cmd, "\n");
|
||||
printf("cmd : %s\n", at_cmd);
|
||||
result = AtCmdConfigAndCheck(adapter->agent, at_cmd, "OK");
|
||||
if(result < 0) {
|
||||
printf("%s %d cmd[%s] config failed!\n",__func__,__LINE__,at_cmd);
|
||||
result = -1;
|
||||
}
|
||||
|
||||
memcpy(at_cmd, "AT+CFUN?", 8);
|
||||
strcat(at_cmd, "\n");
|
||||
printf("cmd : %s\n", at_cmd);
|
||||
result = AtCmdConfigAndCheck(adapter->agent, at_cmd, "OK");
|
||||
if(result < 0) {
|
||||
printf("%s %d cmd[%s] config failed!\n",__func__,__LINE__,at_cmd);
|
||||
result = -1;
|
||||
}
|
||||
|
||||
memcpy(at_cmd, "AT+CIMI", 7);
|
||||
strcat(at_cmd, "\n");
|
||||
printf("cmd : %s\n", at_cmd);
|
||||
result = AtCmdConfigAndCheck(adapter->agent, at_cmd, "OK");
|
||||
if(result < 0) {
|
||||
printf("%s %d cmd[%s] config failed!\n",__func__,__LINE__,at_cmd);
|
||||
result = -1;
|
||||
}
|
||||
|
||||
memcpy(at_cmd, "AT+CEREG?", 9);
|
||||
strcat(at_cmd, "\n");
|
||||
printf("cmd : %s\n", at_cmd);
|
||||
result = AtCmdConfigAndCheck(adapter->agent, at_cmd, "OK");
|
||||
if(result < 0) {
|
||||
printf("%s %d cmd[%s] config failed!\n",__func__,__LINE__,at_cmd);
|
||||
result = -1;
|
||||
}
|
||||
|
||||
memcpy(at_cmd, "AT+CGATT?", 9);
|
||||
strcat(at_cmd, "\n");
|
||||
printf("cmd : %s\n", at_cmd);
|
||||
result = AtCmdConfigAndCheck(adapter->agent, at_cmd, "OK");
|
||||
if(result < 0) {
|
||||
printf("%s %d cmd[%s] config failed!\n",__func__,__LINE__,at_cmd);
|
||||
result = -1;
|
||||
}
|
||||
|
||||
memcpy(at_cmd, "AT+CGPADDR", 10);
|
||||
strcat(at_cmd, "\n");
|
||||
printf("cmd : %s\n", at_cmd);
|
||||
result = AtCmdConfigAndCheck(adapter->agent, at_cmd, "OK");
|
||||
if(result < 0) {
|
||||
printf("%s %d cmd[%s] config failed!\n",__func__,__LINE__,at_cmd);
|
||||
result = -1;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: NBIoT device create a socket connection
|
||||
* @param adapter - NBIoT adapter AT
|
||||
* @param socket_fd - socket file description
|
||||
* @param type - socket type
|
||||
* @param af_type - IPv4 or IPv6
|
||||
* @return success: EOK, failure: -ERROR
|
||||
*/
|
||||
int NBIoTSocketCreate(struct Adapter *adapter, struct Socket *socket )
|
||||
{
|
||||
int32 result = 0;
|
||||
|
||||
if (!adapter || !socket){
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ( socket->af_type == NET_TYPE_AF_INET6 ) {
|
||||
printf("IPv6 not surport !\n");
|
||||
result = -1;
|
||||
goto out;
|
||||
}
|
||||
|
||||
char *str_af_type = "AF_INET";
|
||||
char *str_type;
|
||||
char str_fd[3] = {1};
|
||||
char *str_protocol ;
|
||||
char at_cmd[64] = {0};
|
||||
char listen_port[] = {0};
|
||||
|
||||
if (socket->socket_id >= 0 && socket->socket_id < 7) {
|
||||
itoa(socket->socket_id, str_fd, 10);
|
||||
adapter->socket.socket_id = socket->socket_id;
|
||||
} else {
|
||||
printf("surport max 0-6, socket_id = [%d] is error!\n",socket->socket_id);
|
||||
result = -1;
|
||||
goto out;
|
||||
}
|
||||
|
||||
if( socket->listen_port >= 0 && socket->listen_port <= 65535){
|
||||
itoa(socket->listen_port, listen_port, 10);
|
||||
}
|
||||
|
||||
adapter->socket.af_type = NET_TYPE_AF_INET;
|
||||
|
||||
if (socket->type == SOCKET_TYPE_STREAM) { //tcp = AT+NSOCR=STREAM,6,0,1,AF_INET
|
||||
adapter->socket.protocal = SOCKET_PROTOCOL_TCP;
|
||||
adapter->socket.type = SOCKET_TYPE_STREAM;
|
||||
str_type = "STREAM";
|
||||
str_protocol = "6";
|
||||
|
||||
} else if ( socket->type == SOCKET_TYPE_DGRAM ){ //udp
|
||||
adapter->socket.type = SOCKET_TYPE_DGRAM;
|
||||
adapter->socket.protocal = SOCKET_PROTOCOL_UDP;
|
||||
str_type = "DGRAM";
|
||||
str_protocol = "17";
|
||||
|
||||
} else {
|
||||
printf("error socket type \n");
|
||||
result = -1;
|
||||
goto out;
|
||||
}
|
||||
|
||||
memcpy(at_cmd, "AT+NSOCR=", 9);
|
||||
strcat(at_cmd, str_type);
|
||||
strcat(at_cmd, ",");
|
||||
strcat(at_cmd, str_protocol);
|
||||
strcat(at_cmd, ",");
|
||||
strcat(at_cmd, listen_port);
|
||||
strcat(at_cmd, ",");
|
||||
strcat(at_cmd, str_fd);
|
||||
strcat(at_cmd, ",");
|
||||
strcat(at_cmd, str_af_type);
|
||||
strcat(at_cmd, "\n");
|
||||
|
||||
printf("cmd : %s\n", at_cmd);
|
||||
|
||||
AtSetReplyEndChar(adapter->agent, 0x4F, 0x4B); /* set receive end flag as 'OK'*/
|
||||
|
||||
result = AtCmdConfigAndCheck(adapter->agent, at_cmd, "OK");
|
||||
if(result < 0) {
|
||||
printf("%s %d cmd[%s] config failed!\n",__func__,__LINE__,at_cmd);
|
||||
result = -1;
|
||||
}
|
||||
|
||||
out:
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: NBIoT device close a socket connection
|
||||
* @param adapter - NBIoT adapter AT
|
||||
* @param socket_fd - socket file description
|
||||
* @return success: EOK, failure: -ERROR
|
||||
*/
|
||||
int NBIoTSocketDelete(struct Adapter *adapter )
|
||||
{
|
||||
|
||||
if (!adapter) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (adapter->socket.socket_id >= 7) {
|
||||
printf("socket fd error \n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
char str_fd[2] = {0};
|
||||
char at_cmd[16] = {0};
|
||||
itoa(adapter->socket.socket_id, str_fd, 10);
|
||||
|
||||
memcpy(at_cmd, "AT+NSOCL=", 9);
|
||||
strcat(at_cmd, str_fd);
|
||||
strcat(at_cmd, "\n");
|
||||
|
||||
printf("cmd : %s\n", at_cmd);
|
||||
AtSetReplyCharNum(adapter->agent, 1);
|
||||
ATOrderSend(adapter->agent, REPLY_TIME_OUT, NULL, at_cmd);
|
||||
PrivTaskDelay(300);
|
||||
|
||||
adapter->socket.socket_id = SOCKET_INVALID_ID;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int BC28Open(struct Adapter *adapter)
|
||||
{
|
||||
int ret = 0;
|
||||
struct Socket create_socket;
|
||||
|
||||
if (NULL == adapter) {
|
||||
return -1;
|
||||
}
|
||||
/*step1: open BC8 serial port*/
|
||||
ret = BC28UartOpen(adapter);
|
||||
if (ret < 0) {
|
||||
printf("bc18 setup failed.\n");
|
||||
return -1;
|
||||
}
|
||||
/*step2: init AT agent*/
|
||||
if (!adapter->agent) {
|
||||
char *agent_name = "niot_device";
|
||||
if (EOK != InitATAgent(agent_name, adapter->fd, 512)) {
|
||||
printf("at agent init failed !\n");
|
||||
return -1;
|
||||
}
|
||||
ATAgentType at_agent = GetATAgent(agent_name);
|
||||
adapter->agent = at_agent;
|
||||
}
|
||||
create_socket.type = SOCKET_TYPE_STREAM;
|
||||
create_socket.listen_port = 0;
|
||||
create_socket.socket_id = 1;
|
||||
create_socket.af_type = NET_TYPE_AF_INET;
|
||||
|
||||
BC28PowerSet(); /* reset bc28 module by set reset pin */
|
||||
PrivTaskDelay(6000);
|
||||
|
||||
NBIoTStatusCheck(adapter); /* ask module status*/
|
||||
|
||||
/*step3: create a tcp socket default */
|
||||
ret = NBIoTSocketCreate(adapter, &create_socket);
|
||||
if(ret < 0){
|
||||
printf("NBIot create tcp socket failed.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
printf("NBiot BC28 open successful\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int BC28Close(struct Adapter *adapter)
|
||||
{
|
||||
NBIoTSocketDelete(adapter);
|
||||
PrivClose(adapter->fd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int BC28Ioctl(struct Adapter *adapter, int cmd, void *args)
|
||||
{
|
||||
int ret = 0;
|
||||
switch (cmd)
|
||||
{
|
||||
case CONFIG_NBIOT_RESET: /* reset nbiot */
|
||||
BC28PowerSet();
|
||||
break;
|
||||
case CONFIG_NBIOT_CREATE_SOCKET: /* create tcp/UDP socket */
|
||||
if(!args){
|
||||
return -1;
|
||||
}
|
||||
struct Socket *create_socket = ( struct Socket *) args;
|
||||
ret = NBIoTSocketCreate(adapter, create_socket);
|
||||
break;
|
||||
case CONFIG_NBIOT_DELETE_SOCKET: /* close socket */
|
||||
ret = NBIoTSocketDelete(adapter);
|
||||
break;
|
||||
default:
|
||||
ret = -1;
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int BC28Connect(struct Adapter *adapter, enum NetRoleType net_role, const char *ip, const char *port, enum IpType ip_type)
|
||||
{
|
||||
int result = 0;
|
||||
|
||||
if (adapter->socket.socket_id > 6) {
|
||||
printf("socket fd error \n");
|
||||
result = -1;
|
||||
goto __exit;
|
||||
}
|
||||
|
||||
if ( ip_type != SOCKET_TYPE_STREAM) {
|
||||
printf("socket type error \n");
|
||||
result = -1;
|
||||
goto __exit;
|
||||
}
|
||||
|
||||
char at_cmd[64] = {0};
|
||||
char str_fd[2] = {0};
|
||||
|
||||
itoa(adapter->socket.socket_id, str_fd, 10);
|
||||
|
||||
memcpy(at_cmd, "AT+NSOCO=", 9);
|
||||
strcat(at_cmd, str_fd);
|
||||
strcat(at_cmd, ",");
|
||||
strcat(at_cmd, ip);
|
||||
strcat(at_cmd, ",");
|
||||
strcat(at_cmd, port);
|
||||
strcat(at_cmd, "\n");
|
||||
|
||||
printf("cmd : %s\n", at_cmd);
|
||||
AtSetReplyEndChar(adapter->agent, 0x4F, 0x4B);
|
||||
result = AtCmdConfigAndCheck(adapter->agent, at_cmd, "OK");
|
||||
if(result < 0) {
|
||||
printf("%s %d cmd[%s] config failed!\n",__func__,__LINE__,at_cmd);
|
||||
result = -1;
|
||||
}
|
||||
|
||||
__exit:
|
||||
return result;
|
||||
}
|
||||
|
||||
static int BC28Send(struct Adapter *adapter, const void *buf, size_t len)
|
||||
{
|
||||
uint32_t result = 0;
|
||||
char at_cmd[64] = {0};
|
||||
char str_fd[2] = {0};
|
||||
|
||||
|
||||
if (adapter->socket.type == SOCKET_TYPE_STREAM ) {
|
||||
|
||||
char size[2] = {0};
|
||||
|
||||
itoa(adapter->socket.socket_id, str_fd, 10);
|
||||
size[0] = len + '0';
|
||||
|
||||
memcpy(at_cmd, "AT+NSOSD=", 9);
|
||||
strcat(at_cmd, str_fd);
|
||||
strcat(at_cmd, ",");
|
||||
strcat(at_cmd, size);
|
||||
strcat(at_cmd, ",");
|
||||
strcat(at_cmd, buf);
|
||||
strcat(at_cmd, "\n");
|
||||
|
||||
} else if(adapter->socket.type == SOCKET_TYPE_DGRAM ) {
|
||||
|
||||
char listen_port[] = {0};
|
||||
|
||||
itoa(adapter->socket.socket_id, str_fd, 10);
|
||||
|
||||
itoa(adapter->socket.listen_port, listen_port, 10);
|
||||
|
||||
memcpy(at_cmd, "AT+NSOST=", 9);
|
||||
strcat(at_cmd, str_fd);
|
||||
strcat(at_cmd, ",");
|
||||
strcat(at_cmd, adapter->socket.dst_ip_addr);
|
||||
strcat(at_cmd, ",");
|
||||
strcat(at_cmd, listen_port);
|
||||
strcat(at_cmd, ",");
|
||||
strcat(at_cmd, buf);
|
||||
strcat(at_cmd, "\n");
|
||||
|
||||
}
|
||||
|
||||
printf("cmd : %s\n", at_cmd);
|
||||
AtSetReplyEndChar(adapter->agent, 0x4F, 0x4B);
|
||||
result = AtCmdConfigAndCheck(adapter->agent, at_cmd, "OK");
|
||||
if(result < 0) {
|
||||
printf("%s %d cmd[%s] config failed!\n",__func__,__LINE__,at_cmd);
|
||||
result = -1;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static int BC28Recv(struct Adapter *adapter, void *buf, size_t len)
|
||||
{
|
||||
char at_cmd[64] = {0};
|
||||
char str_fd[2] = {0};
|
||||
char size[2] = {0};
|
||||
char *result = NULL;
|
||||
|
||||
ATReplyType reply = CreateATReply(64);
|
||||
if (NULL == reply) {
|
||||
printf("at create failed ! \n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
itoa(adapter->socket.socket_id, str_fd, 10);
|
||||
itoa(len, size, 10);
|
||||
|
||||
memcpy(at_cmd, "AT+NSORF=", 9);
|
||||
strcat(at_cmd, str_fd);
|
||||
strcat(at_cmd, ",");
|
||||
strcat(at_cmd, size);
|
||||
strcat(at_cmd, "\n");
|
||||
|
||||
printf("cmd : %s\n", at_cmd);
|
||||
ATOrderSend(adapter->agent, REPLY_TIME_OUT, reply, at_cmd);
|
||||
PrivTaskDelay(300);
|
||||
|
||||
result = GetReplyText(reply);
|
||||
if (!result) {
|
||||
printf("%s %n get reply failed.\n",__func__,__LINE__);
|
||||
}
|
||||
memcpy(buf, result, reply->reply_len);
|
||||
|
||||
if (reply) {
|
||||
DeleteATReply(reply);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int BC28Disconnect(struct Adapter *adapter)
|
||||
{
|
||||
if (!adapter) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return NBIoTSocketDelete(adapter);
|
||||
}
|
||||
|
||||
static const struct IpProtocolDone BC28_done =
|
||||
{
|
||||
.open = BC28Open,
|
||||
.close = BC28Close,
|
||||
.ioctl = BC28Ioctl,
|
||||
.setup = NULL,
|
||||
.setdown = NULL,
|
||||
.setaddr = NULL,
|
||||
.setdns = NULL,
|
||||
.setdhcp = NULL,
|
||||
.ping = NULL,
|
||||
.netstat = NULL,
|
||||
.connect = BC28Connect,
|
||||
.send = BC28Send,
|
||||
.recv = BC28Recv,
|
||||
.disconnect = BC28Disconnect,
|
||||
};
|
||||
|
||||
AdapterProductInfoType BC28Attach(struct Adapter *adapter)
|
||||
{
|
||||
struct AdapterProductInfo *product_info = malloc(sizeof(struct AdapterProductInfo));
|
||||
if (!product_info) {
|
||||
printf("BC28Attach malloc product_info error\n");
|
||||
return NULL;
|
||||
}
|
||||
memset(product_info, 0, sizeof(struct AdapterProductInfo));
|
||||
|
||||
strncpy(product_info->model_name, ADAPTER_NBIOT_BC28,sizeof(product_info->model_name));
|
||||
product_info->model_done = (void *)&BC28_done;
|
||||
|
||||
return product_info;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
config ADAPTER_WIFI_HFA21
|
||||
string "HFA21 WIFI adapter name"
|
||||
default "hfa21_wifi"
|
||||
string "HFA21 adapter name"
|
||||
default "hfa21"
|
||||
|
||||
if ADD_XIUOS_FETURES
|
||||
|
||||
|
|
@ -1,3 +1,3 @@
|
|||
SRC_FILES := hfa21_wifi.c
|
||||
SRC_FILES := hfa21.c
|
||||
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
||||
|
|
@ -116,7 +116,7 @@ static int Hfa21Receive(struct Adapter *adapter, void *rev_buffer, size_t buffer
|
|||
printf("hfa21 receive waiting ... \n");
|
||||
|
||||
if (adapter->agent) {
|
||||
return EntmRecv(adapter->agent, (char *)rev_buffer, buffer_len, 40);
|
||||
return EntmRecv(adapter->agent, (char *)rev_buffer, buffer_len, 40000);
|
||||
} else {
|
||||
printf("Can not find agent \n");
|
||||
}
|
||||
|
|
@ -210,10 +210,10 @@ static int Hfa21SetAddr(struct Adapter *adapter, const char *ip, const char *gat
|
|||
char *gw_str = NULL;
|
||||
char *mask_str = NULL;
|
||||
|
||||
dhcp_mode = (char *) PrivCalloc(1, 8);
|
||||
ip_str = (char *) PrivCalloc(1, 17);
|
||||
gw_str = (char *) PrivCalloc(1, 17);
|
||||
mask_str = (char *) PrivCalloc(1, 17);
|
||||
dhcp_mode = (char *) UserCalloc(1, 8);
|
||||
ip_str = (char *) UserCalloc(1, 17);
|
||||
gw_str = (char *) UserCalloc(1, 17);
|
||||
mask_str = (char *) UserCalloc(1, 17);
|
||||
|
||||
Hfa21InitAtCmd(adapter->agent);
|
||||
|
||||
|
|
@ -260,8 +260,8 @@ static int Hfa21Ping(struct Adapter *adapter, const char *destination)
|
|||
{
|
||||
char *ping_result = NONE;
|
||||
char *dst = NONE;
|
||||
ping_result = (char *) PrivCalloc(1, 17);
|
||||
dst = (char *) PrivCalloc(1, 17);
|
||||
ping_result = (char *) UserCalloc(1, 17);
|
||||
dst = (char *) UserCalloc(1, 17);
|
||||
strcpy(dst, destination);
|
||||
strcat(dst, "\r");
|
||||
|
||||
|
|
@ -327,11 +327,11 @@ static int Hfa21Netstat(struct Adapter *adapter)
|
|||
char *local_ipaddr = NULL;
|
||||
char *gateway = NULL;
|
||||
char *netmask = NULL;
|
||||
local_ipaddr = (char *) PrivCalloc(1, HFA21_NETSTAT_IPADDR_SIZE);
|
||||
gateway = (char *) PrivCalloc(1, HFA21_NETSTAT_IPADDR_SIZE);
|
||||
netmask = (char *) PrivCalloc(1, HFA21_NETSTAT_IPADDR_SIZE);
|
||||
work_mode = (char *) PrivCalloc(1, HFA21_NETSTAT_IPADDR_SIZE);
|
||||
ip_mode = (char *) PrivCalloc(1, HFA21_NETSTAT_IPADDR_SIZE);
|
||||
local_ipaddr = (char *) UserCalloc(1, HFA21_NETSTAT_IPADDR_SIZE);
|
||||
gateway = (char *) UserCalloc(1, HFA21_NETSTAT_IPADDR_SIZE);
|
||||
netmask = (char *) UserCalloc(1, HFA21_NETSTAT_IPADDR_SIZE);
|
||||
work_mode = (char *) UserCalloc(1, HFA21_NETSTAT_IPADDR_SIZE);
|
||||
ip_mode = (char *) UserCalloc(1, HFA21_NETSTAT_IPADDR_SIZE);
|
||||
|
||||
reply = CreateATReply(HFA21_NETSTAT_RESP_SIZE);
|
||||
if (reply == NULL) {
|
||||
|
|
@ -391,13 +391,13 @@ __exit:
|
|||
if (reply)
|
||||
DeleteATReply(reply);
|
||||
if (local_ipaddr)
|
||||
PrivFree(local_ipaddr);
|
||||
UserFree(local_ipaddr);
|
||||
if (netmask)
|
||||
PrivFree(netmask);
|
||||
UserFree(netmask);
|
||||
if (gateway)
|
||||
PrivFree(gateway);
|
||||
UserFree(gateway);
|
||||
if (work_mode)
|
||||
PrivFree(work_mode);
|
||||
UserFree(work_mode);
|
||||
}
|
||||
|
||||
static int Hfa21Connect(struct Adapter *adapter, enum NetRoleType net_role, const char *ip, const char *port, enum IpType ip_type)
|
||||
|
|
@ -501,14 +501,14 @@ static const struct IpProtocolDone hfa21_done =
|
|||
*/
|
||||
AdapterProductInfoType Hfa21Attach(struct Adapter *adapter)
|
||||
{
|
||||
struct AdapterProductInfo *product_info = PrivMalloc(sizeof(struct AdapterProductInfo));
|
||||
struct AdapterProductInfo *product_info = malloc(sizeof(struct AdapterProductInfo));
|
||||
if (!product_info) {
|
||||
printf("Hfa21Attach Attach malloc product_info error\n");
|
||||
PrivFree(product_info);
|
||||
free(product_info);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
strcpy(product_info->model_name, ADAPTER_WIFI_HFA21);
|
||||
product_info->model_name = ADAPTER_WIFI_HFA21;
|
||||
|
||||
product_info->model_done = (void *)&hfa21_done;
|
||||
|
||||
|
|
@ -1,7 +1,14 @@
|
|||
config ADAPTER_HFA21_WIFI
|
||||
bool "Using wifi adapter device HFA21"
|
||||
config ADAPTER_WIFI
|
||||
bool "Using WIFI adapter function"
|
||||
default y
|
||||
|
||||
if ADAPTER_HFA21_WIFI
|
||||
source "$APP_DIR/Framework/connection/wifi/hfa21_wifi/Kconfig"
|
||||
endif
|
||||
if ADAPTER_WIFI
|
||||
config ADAPTER_HFA21
|
||||
bool "Using wifi adapter device HFA21"
|
||||
default y
|
||||
|
||||
if ADAPTER_HFA21
|
||||
source "$APP_DIR/Framework/connection/wifi/HFA21/Kconfig"
|
||||
endif
|
||||
|
||||
endif
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
SRC_FILES := adapter_wifi.c
|
||||
|
||||
ifeq ($(CONFIG_ADAPTER_HFA21_WIFI),y)
|
||||
SRC_DIR += hfa21_wifi
|
||||
ifeq ($(CONFIG_ADAPTER_HFA21),y)
|
||||
SRC_DIR += HFA21
|
||||
endif
|
||||
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@
|
|||
#include <adapter.h>
|
||||
#include <bus_pin.h>
|
||||
|
||||
#ifdef ADAPTER_HFA21_WIFI
|
||||
#ifdef ADAPTER_HFA21
|
||||
extern AdapterProductInfoType Hfa21Attach(struct Adapter *adapter);
|
||||
#endif
|
||||
|
||||
|
|
@ -49,15 +49,13 @@ int AdapterWifiInit(void)
|
|||
{
|
||||
int ret = 0;
|
||||
|
||||
struct Adapter *adapter = PrivMalloc(sizeof(struct Adapter));
|
||||
struct Adapter *adapter = malloc(sizeof(struct Adapter));
|
||||
if (!adapter) {
|
||||
printf("AdapterWifiInit malloc error\n");
|
||||
free(adapter);
|
||||
return -1;
|
||||
}
|
||||
|
||||
memset(adapter, 0, sizeof(struct Adapter));
|
||||
|
||||
ret = AdapterWifiRegister(adapter);
|
||||
if (ret < 0) {
|
||||
printf("AdapterWifiInit register wifi adapter error\n");
|
||||
|
|
@ -65,7 +63,7 @@ int AdapterWifiInit(void)
|
|||
return -1;
|
||||
}
|
||||
|
||||
#ifdef ADAPTER_HFA21_WIFI
|
||||
#ifdef ADAPTER_HFA21
|
||||
AdapterProductInfoType product_info = Hfa21Attach(adapter);
|
||||
if (!product_info) {
|
||||
printf("AdapterWifiInit hfa21 attach error\n");
|
||||
|
|
|
|||
|
|
@ -1,10 +0,0 @@
|
|||
if CONNECTION_ADAPTER_ZIGBEE
|
||||
config ADAPTER_E18
|
||||
bool "Using zigbee adapter device E18"
|
||||
default y
|
||||
|
||||
if ADAPTER_E18
|
||||
source "$APP_DIR/Framework/connection/zigbee/e18/Kconfig"
|
||||
endif
|
||||
|
||||
endif
|
||||
|
|
@ -1,7 +1,3 @@
|
|||
SRC_FILES := adapter_zigbee.c
|
||||
|
||||
ifeq ($(CONFIG_ADAPTER_E18),y)
|
||||
SRC_DIR += e18
|
||||
endif
|
||||
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
||||
|
|
|
|||
|
|
@ -15,143 +15,5 @@
|
|||
* @brief Implement the connection zigbee adapter function
|
||||
* @version 1.1
|
||||
* @author AIIT XUOS Lab
|
||||
* @date 2021.09.15
|
||||
* @date 2021.06.25
|
||||
*/
|
||||
|
||||
#include <adapter.h>
|
||||
#include "adapter_zigbee.h"
|
||||
|
||||
|
||||
#ifdef ADAPTER_E18
|
||||
extern AdapterProductInfoType E18Attach(struct Adapter *adapter);
|
||||
#endif
|
||||
|
||||
#define ADAPTER_ZIGBEE_NAME "zigbee"
|
||||
|
||||
static int AdapterZigbeeRegister(struct Adapter *adapter)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
strncpy(adapter->name, ADAPTER_ZIGBEE_NAME, NAME_NUM_MAX);
|
||||
|
||||
/* config adapter net protocol as network mode */
|
||||
adapter->net_protocol = PRIVATE_PROTOCOL;
|
||||
|
||||
/* config adapter net role as coordinator/router/end_device */
|
||||
#ifdef AS_COORDINATOR_ROLE
|
||||
adapter->net_role = COORDINATOR;
|
||||
#endif
|
||||
#ifdef AS_ROUTER_ROLE
|
||||
adapter->net_role = ROUTER;
|
||||
#endif
|
||||
#ifdef AS_END_DEVICE_ROLE
|
||||
adapter->net_role = END_DEVICE;
|
||||
#endif
|
||||
|
||||
adapter->adapter_status = UNREGISTERED;
|
||||
|
||||
ret = AdapterDeviceRegister(adapter);
|
||||
if (ret < 0) {
|
||||
printf("AdapterZigbee register error\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int AdapterZigbeeInit(void)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
struct Adapter *adapter = malloc(sizeof(struct Adapter));
|
||||
if (!adapter) {
|
||||
printf("malloc adapter failed.\n");
|
||||
return -1;
|
||||
}
|
||||
memset(adapter, 0, sizeof(struct Adapter));
|
||||
ret = AdapterZigbeeRegister(adapter);
|
||||
if (ret < 0) {
|
||||
printf("AdapterZigbeeRegister register zigbee adapter error\n");
|
||||
free(adapter);
|
||||
return -1;
|
||||
}
|
||||
#ifdef ADAPTER_E18
|
||||
AdapterProductInfoType product_info = E18Attach(adapter);
|
||||
if (!product_info) {
|
||||
printf("AdapterZigbeeRegister e18 attach error\n");
|
||||
free(adapter);
|
||||
return -1;
|
||||
}
|
||||
|
||||
adapter->product_info_flag = 1;
|
||||
adapter->info = product_info;
|
||||
adapter->done = product_info->model_done;
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/******************TEST*********************/
|
||||
int openzigbee(void)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
struct Adapter* adapter = AdapterDeviceFindByName(ADAPTER_ZIGBEE_NAME);
|
||||
|
||||
#ifdef ADAPTER_E18
|
||||
ret = AdapterDeviceOpen(adapter);
|
||||
if(ret < 0){
|
||||
printf("open adapter failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
adapter->info->work_mode = 1;
|
||||
ret = AdapterDeviceControl(adapter, CONFIG_ZIGBEE_NET_MODE,NULL);
|
||||
if(ret < 0){
|
||||
printf("control adapter failed\n");
|
||||
return -1;
|
||||
}
|
||||
ret = AdapterDeviceJoin(adapter, NULL);
|
||||
if(ret < 0){
|
||||
printf("join adapter failed\n");
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_PARAM_NUM(0)|SHELL_CMD_DISABLE_RETURN, openzigbee, openzigbee, show adapter zigbee information);
|
||||
|
||||
int sendzigbee(int argc, char *argv[])
|
||||
{
|
||||
const char *send_msg = argv[1];
|
||||
int ret = 0;
|
||||
|
||||
struct Adapter* adapter = AdapterDeviceFindByName(ADAPTER_ZIGBEE_NAME);
|
||||
|
||||
printf("send argv1 %s\n",argv[1]);
|
||||
ret = AdapterDeviceSend(adapter, send_msg, strlen(send_msg));
|
||||
if(ret < 0){
|
||||
printf(" adapter send failed\n");
|
||||
return -1;
|
||||
}
|
||||
printf("zigbee send msg %s\n", send_msg);
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN)|SHELL_CMD_PARAM_NUM(2)|SHELL_CMD_DISABLE_RETURN, sendzigbee, sendzigbee, show adapter zigbee information);
|
||||
|
||||
int recvzigbee(void)
|
||||
{
|
||||
char recv_msg[128];
|
||||
struct Adapter* adapter = AdapterDeviceFindByName(ADAPTER_ZIGBEE_NAME);
|
||||
memset(recv_msg,0,128);
|
||||
AdapterDeviceRecv(adapter, recv_msg, 128);
|
||||
PrivTaskDelay(2000);
|
||||
printf("zigbee recv msg %s\n", recv_msg);
|
||||
|
||||
return 0;
|
||||
}
|
||||
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_PARAM_NUM(0)|SHELL_CMD_DISABLE_RETURN, recvzigbee, recvzigbee, show adapter zigbee information);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,9 +0,0 @@
|
|||
#ifndef ADAPTER_ZIGBEE_H
|
||||
#define ADAPTER_ZIGBEE_H
|
||||
|
||||
#define CONFIG_ZIGBEE_NET_ROLE (1)
|
||||
#define CONFIG_ZIGBEE_NET_MODE (2)
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
|
@ -1,48 +0,0 @@
|
|||
config ADAPTER_ZIGBEE_E18
|
||||
string "E18 adapter name"
|
||||
default "e18"
|
||||
|
||||
choice
|
||||
prompt "E18 adapter select net role type "
|
||||
default AS_END_DEVICE_ROLE
|
||||
|
||||
config AS_COORDINATOR_ROLE
|
||||
bool "config as a coordinator"
|
||||
|
||||
config AS_ROUTER_ROLE
|
||||
bool "config as a router"
|
||||
|
||||
config AS_END_DEVICE_ROLE
|
||||
bool "config as an end device"
|
||||
endchoice
|
||||
|
||||
|
||||
if ADD_XIUOS_FETURES
|
||||
|
||||
config ADAPTER_E18_DRIVER_EXTUART
|
||||
bool "Using extra uart to support zigbee"
|
||||
default n
|
||||
|
||||
config ADAPTER_E18_DRIVER
|
||||
string "E18 device uart driver path"
|
||||
default "/dev/uart2_dev2"
|
||||
depends on !ADAPTER_E18_DRIVER_EXTUART
|
||||
|
||||
if ADAPTER_E18_DRIVER_EXTUART
|
||||
config ADAPTER_E18_DRIVER
|
||||
string "E18 device extra uart driver path"
|
||||
default "/dev/extuart_dev0"
|
||||
|
||||
config ADAPTER_E18_DRIVER_EXT_PORT
|
||||
int "if E18 device using extuart, choose port"
|
||||
default "0"
|
||||
endif
|
||||
endif
|
||||
|
||||
if ADD_NUTTX_FETURES
|
||||
|
||||
endif
|
||||
|
||||
if ADD_RTTHREAD_FETURES
|
||||
|
||||
endif
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
SRC_FILES := e18.c
|
||||
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
||||
|
|
@ -1,419 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2020 AIIT XUOS Lab
|
||||
* XiUOS 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 e18.c
|
||||
* @brief Implement the connection zigbee adapter function, using E18 device
|
||||
* @version 1.1
|
||||
* @author AIIT XUOS Lab
|
||||
* @date 2021.09.15
|
||||
*/
|
||||
|
||||
#include <adapter.h>
|
||||
#include <at_agent.h>
|
||||
#include "../adapter_zigbee.h"
|
||||
#include "e18.h"
|
||||
|
||||
char *cmd_hex2at = "+++";
|
||||
char *cmd_exit = "AT+EXIT";
|
||||
char *cmd_ask_panid = "AT+PANID=?";
|
||||
char *cmd_set_panid = "AT+PANID=A1B2";
|
||||
char *cmd_ask_mode = "AT+MODE=?";
|
||||
char *cmd_mode_as_tt = "AT+MODE=1"; /*mode 1:transparent transmission*/
|
||||
char *cmd_mode_as_stt = "AT+MODE=2"; /*mode 2:Semi transparent transmission*/
|
||||
char *cmd_mode_as_protocol = "AT+MODE=3"; /*mode 3:Protocol mode*/
|
||||
char *cmd_ask_role = "AT+DEV=?";
|
||||
char *cmd_role_as_c = "AT+DEV=C"; /*set device type for coordinater*/
|
||||
char *cmd_role_as_e = "AT+DEV=E"; /*set device type for end device*/
|
||||
char *cmd_role_as_r = "AT+DEV=R"; /*set device type for router*/
|
||||
char *cmd_set_ch = "AT+CH=11"; /*set channel as 11*/
|
||||
|
||||
static int E18UartOpen(struct Adapter *adapter)
|
||||
{
|
||||
if (NULL == adapter) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Open device in read-write mode */
|
||||
adapter->fd = PrivOpen(ADAPTER_E18_DRIVER,O_RDWR);
|
||||
if (adapter->fd < 0) {
|
||||
printf("E18UartSetUp get serial %s fd error\n", ADAPTER_E18_DRIVER);
|
||||
return -1;
|
||||
}
|
||||
/* set serial config, serial_baud_rate = 115200 */
|
||||
|
||||
struct SerialDataCfg cfg;
|
||||
memset(&cfg, 0 ,sizeof(struct SerialDataCfg));
|
||||
|
||||
cfg.serial_baud_rate = BAUD_RATE_115200;
|
||||
cfg.serial_data_bits = DATA_BITS_8;
|
||||
cfg.serial_stop_bits = STOP_BITS_1;
|
||||
cfg.serial_parity_mode = PARITY_NONE;
|
||||
cfg.serial_bit_order = BIT_ORDER_LSB;
|
||||
cfg.serial_invert_mode = NRZ_NORMAL;
|
||||
cfg.serial_buffer_size = SERIAL_RB_BUFSZ;
|
||||
|
||||
/*aiit board use ch438, so it needs more serial configuration*/
|
||||
#ifdef ADAPTER_E18_DRIVER_EXTUART
|
||||
cfg.ext_uart_no = ADAPTER_E18_DRIVER_EXT_PORT;
|
||||
cfg.port_configure = PORT_CFG_INIT;
|
||||
#endif
|
||||
|
||||
struct PrivIoctlCfg ioctl_cfg;
|
||||
ioctl_cfg.ioctl_driver_type = SERIAL_TYPE;
|
||||
ioctl_cfg.args = &cfg;
|
||||
|
||||
PrivIoctl(adapter->fd, OPE_INT, &ioctl_cfg);
|
||||
PrivTaskDelay(1000);
|
||||
|
||||
printf("Zigbee uart config ready\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int E18NetworkModeConfig(struct Adapter *adapter)
|
||||
{
|
||||
int ret = 0;
|
||||
if (NULL == adapter) {
|
||||
return -1;
|
||||
}
|
||||
ret = AtCmdConfigAndCheck(adapter->agent, cmd_hex2at, "+OK");
|
||||
if(ret < 0) {
|
||||
printf("%s %d cmd[%s] config failed!\n",__func__,__LINE__,cmd_hex2at);
|
||||
ret = -1;
|
||||
goto out;
|
||||
}
|
||||
|
||||
switch (adapter->info->work_mode)
|
||||
{
|
||||
case TT_MODE1:
|
||||
ret = AtCmdConfigAndCheck(adapter->agent, cmd_mode_as_tt, "+OK");
|
||||
ret |= AtCmdConfigAndCheck(adapter->agent, cmd_ask_mode, "MODE=1");
|
||||
if(ret < 0) {
|
||||
printf("%s %d config net mode as transparent transmission failed!\n",__func__,__LINE__);
|
||||
ret = -1;
|
||||
goto out;
|
||||
}
|
||||
break;
|
||||
case STT_MODE2:
|
||||
ret = AtCmdConfigAndCheck(adapter->agent, cmd_mode_as_stt, "+OK");
|
||||
ret |= AtCmdConfigAndCheck(adapter->agent, cmd_ask_mode, "MODE=2");
|
||||
if(ret < 0) {
|
||||
printf("%s %d config net mode as semi transparent transmission failed!\n",__func__,__LINE__);
|
||||
ret = -1;
|
||||
goto out;
|
||||
}
|
||||
break;
|
||||
case PROTOCOL_MODE3:
|
||||
ret = AtCmdConfigAndCheck(adapter->agent, cmd_mode_as_protocol, "+OK");
|
||||
ret |= AtCmdConfigAndCheck(adapter->agent, cmd_ask_mode, "MODE=3");
|
||||
if(ret < 0) {
|
||||
printf("%s %d config net mode as protocol failed!\n",__func__,__LINE__);
|
||||
ret = -1;
|
||||
goto out;
|
||||
}
|
||||
break;
|
||||
default :
|
||||
ret = -1;
|
||||
break;
|
||||
}
|
||||
|
||||
out:
|
||||
AtCmdConfigAndCheck(adapter->agent, cmd_exit, "+OK");
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int E18NetRoleConfig(struct Adapter *adapter)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
if (NULL == adapter) {
|
||||
printf("%s %d adapter is null!\n",__func__,__LINE__);
|
||||
ret = -1;
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = AtCmdConfigAndCheck(adapter->agent, cmd_hex2at, "+OK");
|
||||
if(ret < 0) {
|
||||
printf("%s %d cmd[%s] config failed!\n",__func__,__LINE__,cmd_hex2at);
|
||||
ret = -1;
|
||||
goto out;
|
||||
}
|
||||
|
||||
switch (adapter->net_role)
|
||||
{
|
||||
case COORDINATOR:
|
||||
ret = AtCmdConfigAndCheck(adapter->agent, cmd_role_as_c, "+OK");
|
||||
ret |= AtCmdConfigAndCheck(adapter->agent, cmd_ask_role, "DEV=C");
|
||||
if(ret < 0) {
|
||||
printf("%s %d config net role as coordinator failed!\n",__func__,__LINE__);
|
||||
ret = -1;
|
||||
goto out;
|
||||
}
|
||||
break;
|
||||
case ROUTER:
|
||||
ret = AtCmdConfigAndCheck(adapter->agent, cmd_role_as_r, "+OK");
|
||||
ret |= AtCmdConfigAndCheck(adapter->agent, cmd_role_as_r, "DEV=R");
|
||||
if(ret < 0) {
|
||||
printf("%s %d config net role as router failed!\n",__func__,__LINE__);
|
||||
ret = -1;
|
||||
goto out;
|
||||
}
|
||||
break;
|
||||
case END_DEVICE:
|
||||
ret = AtCmdConfigAndCheck(adapter->agent, cmd_role_as_e, "+OK");
|
||||
ret |= AtCmdConfigAndCheck(adapter->agent, cmd_ask_role, "DEV=E");
|
||||
if(ret < 0) {
|
||||
printf("%s %d config net role as device failed!\n",__func__,__LINE__);
|
||||
ret = -1;
|
||||
goto out;
|
||||
}
|
||||
break;
|
||||
default :
|
||||
ret = -1;
|
||||
break;
|
||||
}
|
||||
|
||||
out:
|
||||
AtCmdConfigAndCheck(adapter->agent, cmd_exit, "+OK");
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int E18Open(struct Adapter *adapter)
|
||||
{
|
||||
int ret = 0;
|
||||
int try_times = 5;
|
||||
|
||||
if (NULL == adapter) {
|
||||
return -1;
|
||||
}
|
||||
/*step1: open e18 serial port*/
|
||||
ret = E18UartOpen(adapter);
|
||||
if (ret < 0) {
|
||||
printf("e18 setup failed.\n");
|
||||
return -1;
|
||||
}
|
||||
/*step2: init AT agent*/
|
||||
if (!adapter->agent) {
|
||||
char *agent_name = "zigbee_device";
|
||||
if (EOK != InitATAgent(agent_name, adapter->fd, 512)) {
|
||||
printf("at agent init failed !\n");
|
||||
return -1;
|
||||
}
|
||||
ATAgentType at_agent = GetATAgent(agent_name);
|
||||
adapter->agent = at_agent;
|
||||
}
|
||||
|
||||
AtSetReplyLrEnd(adapter->agent, 1);
|
||||
|
||||
try_again:
|
||||
while(try_times--){
|
||||
ret = E18NetRoleConfig(adapter);
|
||||
if(ret < 0){
|
||||
printf("E18NetRoleConfig failed [%d] times.\n",try_times);
|
||||
goto try_again;
|
||||
}
|
||||
}
|
||||
|
||||
if(ret < 0){
|
||||
printf("E18NetRoleConfig failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
printf("Zigbee E18 open successful\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int E18Close(struct Adapter *adapter)
|
||||
{
|
||||
PrivClose(adapter->fd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int E18Ioctl(struct Adapter *adapter, int cmd, void *args)
|
||||
{
|
||||
int ret = 0;
|
||||
switch (cmd)
|
||||
{
|
||||
case CONFIG_ZIGBEE_NET_ROLE: /* config E18 net role */
|
||||
ret = E18NetRoleConfig(adapter);
|
||||
break;
|
||||
case CONFIG_ZIGBEE_NET_MODE: /* config E18 network mode */
|
||||
ret = E18NetworkModeConfig(adapter);
|
||||
break;
|
||||
default:
|
||||
ret = -1;
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int E18Join(struct Adapter *adapter, const char *priv_net_group)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
ret = AtCmdConfigAndCheck(adapter->agent, cmd_hex2at, "+OK");
|
||||
if(ret < 0) {
|
||||
printf("%s %d cmd[%s] config failed!\n",__func__,__LINE__,cmd_hex2at);
|
||||
ret = -1;
|
||||
goto out;
|
||||
}
|
||||
|
||||
switch (adapter->net_role)
|
||||
{
|
||||
case COORDINATOR:
|
||||
case ROUTER:
|
||||
case END_DEVICE:
|
||||
/* config panid */
|
||||
ret = AtCmdConfigAndCheck(adapter->agent, cmd_set_panid, "+OK");
|
||||
ret |= AtCmdConfigAndCheck(adapter->agent, cmd_ask_panid, "PANID=A1B2");
|
||||
if(ret < 0) {
|
||||
printf("%s %d cmd[%s] config failed!\n",__func__,__LINE__,cmd_set_panid);
|
||||
ret = -1;
|
||||
goto out;
|
||||
}
|
||||
|
||||
/* config channel*/
|
||||
ret = AtCmdConfigAndCheck(adapter->agent, cmd_set_ch, "+OK");
|
||||
if(ret < 0) {
|
||||
printf("%s %d cmd[%s] config failed!\n",__func__,__LINE__,cmd_set_ch);
|
||||
ret = -1;
|
||||
goto out;
|
||||
}
|
||||
break;
|
||||
default :
|
||||
ret = -1;
|
||||
break;
|
||||
}
|
||||
|
||||
// switch (adapter->info->work_mode)
|
||||
// {
|
||||
// case TT_MODE1:
|
||||
// break;
|
||||
// case STT_MODE2:
|
||||
// /* need to do */
|
||||
// ret = 0;
|
||||
// break;
|
||||
// case PROTOCOL_MODE3:
|
||||
// /* need to do */
|
||||
// ret = 0;
|
||||
// break;
|
||||
// default:
|
||||
// ret = -1;
|
||||
// break;
|
||||
|
||||
// }
|
||||
if(!ret){
|
||||
ret = AtCmdConfigAndCheck(adapter->agent, cmd_exit, "+OK");
|
||||
if(ret < 0) {
|
||||
printf("%s %d cmd[%s] config failed!\n",__func__,__LINE__,cmd_exit);
|
||||
ret = -1;
|
||||
}
|
||||
}
|
||||
|
||||
out:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int E18Send(struct Adapter *adapter, const void *buf, size_t len)
|
||||
{
|
||||
int ret = 0;
|
||||
switch (adapter->info->work_mode)
|
||||
{
|
||||
case TT_MODE1:
|
||||
EntmSend(adapter->agent, buf, len);
|
||||
break;
|
||||
case STT_MODE2:
|
||||
/* need to do */
|
||||
ret = 0;
|
||||
break;
|
||||
case PROTOCOL_MODE3:
|
||||
/* need to do */
|
||||
ret = 0;
|
||||
break;
|
||||
default:
|
||||
ret = -1;
|
||||
break;
|
||||
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int E18Recv(struct Adapter *adapter, void *buf, size_t len)
|
||||
{
|
||||
int ret = 0;
|
||||
switch (adapter->info->work_mode)
|
||||
{
|
||||
case TT_MODE1:
|
||||
if(!adapter->agent){
|
||||
PrivRead(adapter->fd, buf, len);
|
||||
} else {
|
||||
EntmRecv(adapter->agent, buf, len, 3);/* wait timeout 3000ms*/
|
||||
}
|
||||
break;
|
||||
case STT_MODE2:
|
||||
/* need to do */
|
||||
ret = 0;
|
||||
break;
|
||||
case PROTOCOL_MODE3:
|
||||
/* need to do */
|
||||
ret = 0;
|
||||
break;
|
||||
default:
|
||||
ret = -1;
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int E18Quit(struct Adapter *adapter)
|
||||
{
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct PrivProtocolDone E18_done =
|
||||
{
|
||||
.open = E18Open,
|
||||
.close = E18Close,
|
||||
.ioctl = E18Ioctl,
|
||||
.setup = NULL,
|
||||
.setdown = NULL,
|
||||
.setaddr = NULL,
|
||||
.setdns = NULL,
|
||||
.setdhcp = NULL,
|
||||
.ping = NULL,
|
||||
.netstat = NULL,
|
||||
.join = E18Join,
|
||||
.send = E18Send,
|
||||
.recv = E18Recv,
|
||||
.quit = E18Quit,
|
||||
};
|
||||
|
||||
AdapterProductInfoType E18Attach(struct Adapter *adapter)
|
||||
{
|
||||
struct AdapterProductInfo *product_info = malloc(sizeof(struct AdapterProductInfo));
|
||||
if (!product_info) {
|
||||
printf("E18Attach malloc product_info error\n");
|
||||
return NULL;
|
||||
}
|
||||
memset(product_info, 0, sizeof(struct AdapterProductInfo));
|
||||
|
||||
strncpy(product_info->model_name, ADAPTER_ZIGBEE_E18,sizeof(product_info->model_name));
|
||||
product_info->model_done = (void *)&E18_done;
|
||||
|
||||
return product_info;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
#ifndef E18_H
|
||||
#define E18_H
|
||||
|
||||
enum ZigbeeE18WorkModeType
|
||||
{
|
||||
TT_MODE1 = 1,
|
||||
STT_MODE2,
|
||||
PROTOCOL_MODE3,
|
||||
MODE_NONE,
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
import os
|
||||
Import('RTT_ROOT')
|
||||
Import('rtconfig')
|
||||
from building import *
|
||||
|
||||
cwd = GetCurrentDir()
|
||||
SOURCES = []
|
||||
if GetDepend(['SUPPORT_SENSOR_FRAMEWORK']):
|
||||
SOURCES = ['sensor.c'] + SOURCES
|
||||
path = [cwd]
|
||||
objs = []
|
||||
group = DefineGroup('sensor', SOURCES, depend = [], CPPPATH = [cwd])
|
||||
objs = objs + group
|
||||
list = os.listdir(cwd)
|
||||
|
||||
for d in list:
|
||||
path = os.path.join(cwd, d)
|
||||
if os.path.isfile(os.path.join(path, 'SConscript')):
|
||||
objs = objs + SConscript(os.path.join(path, 'SConscript'))
|
||||
|
||||
Return('objs')
|
||||
|
|
@ -81,7 +81,7 @@ static int SensorDeviceRead(struct SensorDevice *sdev, size_t len)
|
|||
PrivRead(sdev->fd, &tmp, 1);
|
||||
if ((tmp == 0xFE) || (timeout >= 1000))
|
||||
break;
|
||||
PrivTaskDelay(10);
|
||||
UserTaskDelay(10);
|
||||
++timeout;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ static int SensorDeviceRead(struct SensorDevice *sdev, size_t len)
|
|||
if (PrivWrite(sdev->fd, NULL, 0) != 1)
|
||||
return -1;
|
||||
|
||||
PrivTaskDelay(50);
|
||||
UserTaskDelay(50);
|
||||
|
||||
if (PrivRead(sdev->fd, sdev->buffer, len) != 1)
|
||||
return -1;
|
||||
|
|
|
|||
|
|
@ -21,8 +21,8 @@
|
|||
#include <sensor.h>
|
||||
|
||||
static struct SensorDevice ps5308;
|
||||
static pthread_t active_task_id;
|
||||
static pthread_mutex_t buff_lock;
|
||||
static int32_t active_task_id;
|
||||
static int buff_lock;
|
||||
|
||||
static struct SensorProductInfo info =
|
||||
{
|
||||
|
|
@ -35,14 +35,13 @@ static struct SensorProductInfo info =
|
|||
* @description: Read sensor task
|
||||
* @param sdev - sensor device pointer
|
||||
*/
|
||||
static void *ReadTask(void *parameter)
|
||||
static void ReadTask(struct SensorDevice *sdev)
|
||||
{
|
||||
struct SensorDevice *sdev = (struct SensorDevice *)parameter;
|
||||
while (1) {
|
||||
PrivMutexObtain(&buff_lock);
|
||||
UserMutexObtain(buff_lock, WAITING_FOREVER);
|
||||
sdev->done->read(sdev, 32);
|
||||
PrivMutexAbandon(&buff_lock);
|
||||
PrivTaskDelay(750);
|
||||
UserMutexAbandon(buff_lock);
|
||||
UserTaskDelay(750);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -55,7 +54,7 @@ static int SensorDeviceOpen(struct SensorDevice *sdev)
|
|||
{
|
||||
int result = 0;
|
||||
|
||||
PrivMutexCreate(&buff_lock, 0);
|
||||
buff_lock = UserMutexCreate();
|
||||
|
||||
sdev->fd = open(SENSOR_DEVICE_PS5308_DEV, O_RDWR);
|
||||
|
||||
|
|
@ -74,8 +73,17 @@ static int SensorDeviceOpen(struct SensorDevice *sdev)
|
|||
|
||||
result = ioctl(sdev->fd, OPE_INT, &cfg);
|
||||
|
||||
PrivTaskCreate(&active_task_id, NULL, &ReadTask, sdev);
|
||||
PrivTaskStartup(&active_task_id);
|
||||
UtaskType active_task;
|
||||
const char name[NAME_NUM_MAX] = "ps5308_task";
|
||||
|
||||
strncpy(active_task.name, name, strlen(name));
|
||||
active_task.func_entry = ReadTask;
|
||||
active_task.func_param = sdev;
|
||||
active_task.prio = KTASK_PRIORITY_MAX/2;
|
||||
active_task.stack_size = 1024;
|
||||
|
||||
active_task_id = UserTaskCreate(active_task);
|
||||
result = UserTaskStartup(active_task_id);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
@ -87,8 +95,8 @@ static int SensorDeviceOpen(struct SensorDevice *sdev)
|
|||
*/
|
||||
static int SensorDeviceClose(struct SensorDevice *sdev)
|
||||
{
|
||||
PrivTaskDelete(active_task_id, 0);
|
||||
PrivMutexDelete(&buff_lock);
|
||||
UserTaskDelete(active_task_id);
|
||||
UserMutexDelete(buff_lock);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -106,7 +114,7 @@ static int SensorDeviceRead(struct SensorDevice *sdev, size_t len)
|
|||
read(sdev->fd, &tmp, 1);
|
||||
if ((tmp == 0x44) || (timeout >= 1000))
|
||||
break;
|
||||
PrivTaskDelay(10);
|
||||
UserTaskDelay(10);
|
||||
++timeout;
|
||||
}
|
||||
|
||||
|
|
@ -167,7 +175,7 @@ static int32_t ReadPm1_0(struct SensorQuantity *quant)
|
|||
uint32_t result;
|
||||
if (quant->sdev->done->read != NULL) {
|
||||
uint16_t checksum = 0;
|
||||
PrivMutexObtain(&buff_lock);
|
||||
UserMutexObtain(buff_lock, WAITING_FOREVER);
|
||||
|
||||
for (uint8_t i = 0; i < 30; i++)
|
||||
checksum += quant->sdev->buffer[i];
|
||||
|
|
@ -234,7 +242,7 @@ static int32_t ReadPm2_5(struct SensorQuantity *quant)
|
|||
uint32_t result;
|
||||
if (quant->sdev->done->read != NULL) {
|
||||
uint16_t checksum = 0;
|
||||
PrivMutexObtain(&buff_lock);
|
||||
UserMutexObtain(buff_lock, WAITING_FOREVER);
|
||||
|
||||
for (uint i = 0; i < 30; i++)
|
||||
checksum += quant->sdev->buffer[i];
|
||||
|
|
@ -301,7 +309,7 @@ static int32_t ReadPm10(struct SensorQuantity *quant)
|
|||
uint32_t result;
|
||||
if (quant->sdev->done->read != NULL) {
|
||||
uint16_t checksum = 0;
|
||||
PrivMutexObtain(&buff_lock);
|
||||
UserMutexObtain(buff_lock, WAITING_FOREVER);
|
||||
|
||||
for (uint i = 0; i < 30; i++)
|
||||
checksum += quant->sdev->buffer[i];
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ static int SensorDeviceRead(struct SensorDevice *sdev, size_t len)
|
|||
if (PrivWrite(sdev->fd, NULL, 0) != 1)
|
||||
return -1;
|
||||
|
||||
PrivTaskDelay(50);
|
||||
UserTaskDelay(50);
|
||||
|
||||
if (PrivRead(sdev->fd, sdev->buffer, len) != 1)
|
||||
return -1;
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ config SENSOR_D124
|
|||
default "d124_1"
|
||||
|
||||
config SENSOR_QUANTITY_D124_VOICE
|
||||
string "D124 quantity voice name"
|
||||
string "D124 quantity PM1.0 name"
|
||||
default "voice_1"
|
||||
|
||||
if ADD_XIUOS_FETURES
|
||||
|
|
|
|||
|
|
@ -1,14 +0,0 @@
|
|||
import os
|
||||
Import('RTT_ROOT')
|
||||
from building import *
|
||||
|
||||
cwd = GetCurrentDir()
|
||||
objs = []
|
||||
list = os.listdir(cwd)
|
||||
|
||||
for d in list:
|
||||
path = os.path.join(cwd, d)
|
||||
if os.path.isfile(os.path.join(path, 'SConscript')):
|
||||
objs = objs + SConscript(os.path.join(path, 'SConscript'))
|
||||
|
||||
Return('objs')
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
from building import *
|
||||
import os
|
||||
|
||||
cwd = GetCurrentDir()
|
||||
src = []
|
||||
if GetDepend(['SENSOR_D124']):
|
||||
src += ['d124.c']
|
||||
group = DefineGroup('sensor voice d124', src, depend = [], CPPPATH = [cwd])
|
||||
|
||||
Return('group')
|
||||
|
|
@ -21,8 +21,8 @@
|
|||
#include <sensor.h>
|
||||
|
||||
static struct SensorDevice d124;
|
||||
static pthread_t active_task_id;
|
||||
static pthread_mutex_t buff_lock;
|
||||
static int32_t active_task_id;
|
||||
static int buff_lock;
|
||||
|
||||
static struct SensorProductInfo info =
|
||||
{
|
||||
|
|
@ -35,14 +35,13 @@ static struct SensorProductInfo info =
|
|||
* @description: Read sensor task
|
||||
* @param sdev - sensor device pointer
|
||||
*/
|
||||
static void *ReadTask(void *parameter)
|
||||
static void ReadTask(struct SensorDevice *sdev)
|
||||
{
|
||||
struct SensorDevice *sdev = (struct SensorDevice *)parameter;
|
||||
while (1) {
|
||||
PrivMutexObtain(&buff_lock);
|
||||
UserMutexObtain(buff_lock, WAITING_FOREVER);
|
||||
sdev->done->read(sdev, 5);
|
||||
PrivMutexAbandon(&buff_lock);
|
||||
PrivTaskDelay(750);
|
||||
UserMutexAbandon(buff_lock);
|
||||
UserTaskDelay(750);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -54,9 +53,8 @@ static void *ReadTask(void *parameter)
|
|||
static int SensorDeviceOpen(struct SensorDevice *sdev)
|
||||
{
|
||||
int result = 0;
|
||||
pthread_attr_t attr;
|
||||
|
||||
PrivMutexCreate(&buff_lock, 0);
|
||||
buff_lock = UserMutexCreate();
|
||||
|
||||
sdev->fd = PrivOpen(SENSOR_DEVICE_D124_DEV, O_RDWR);
|
||||
|
||||
|
|
@ -78,11 +76,17 @@ static int SensorDeviceOpen(struct SensorDevice *sdev)
|
|||
ioctl_cfg.args = &cfg;
|
||||
result = PrivIoctl(sdev->fd, OPE_INT, &ioctl_cfg);
|
||||
|
||||
attr.schedparam.sched_priority = 20;
|
||||
attr.stacksize = 2048;
|
||||
UtaskType active_task;
|
||||
const char name[NAME_NUM_MAX] = "d124_task";
|
||||
|
||||
PrivTaskCreate(&active_task_id, &attr, &ReadTask, sdev);
|
||||
PrivTaskStartup(&active_task_id);
|
||||
strncpy(active_task.name, name, strlen(name));
|
||||
active_task.func_entry = ReadTask;
|
||||
active_task.func_param = sdev;
|
||||
active_task.prio = KTASK_PRIORITY_MAX/2;
|
||||
active_task.stack_size = 2048;
|
||||
|
||||
active_task_id = UserTaskCreate(active_task);
|
||||
result = UserTaskStartup(active_task_id);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
@ -94,8 +98,8 @@ static int SensorDeviceOpen(struct SensorDevice *sdev)
|
|||
*/
|
||||
static int SensorDeviceClose(struct SensorDevice *sdev)
|
||||
{
|
||||
PrivTaskDelete(active_task_id, 0);
|
||||
PrivMutexDelete(&buff_lock);
|
||||
UserTaskDelete(active_task_id);
|
||||
UserMutexDelete(buff_lock);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -113,7 +117,7 @@ static int SensorDeviceRead(struct SensorDevice *sdev, size_t len)
|
|||
PrivRead(sdev->fd, &tmp, 1);
|
||||
if ((tmp == 0xAA) || (timeout >= 1000))
|
||||
break;
|
||||
PrivTaskDelay(10);
|
||||
UserTaskDelay(10);
|
||||
++timeout;
|
||||
}
|
||||
|
||||
|
|
@ -172,7 +176,7 @@ static int32_t ReadVoice(struct SensorQuantity *quant)
|
|||
|
||||
uint32_t result;
|
||||
if (quant->sdev->done->read != NULL) {
|
||||
PrivMutexObtain(&buff_lock);
|
||||
UserMutexObtain(buff_lock, WAITING_FOREVER);
|
||||
|
||||
if (quant->sdev->buffer[3] == quant->sdev->buffer[1] + quant->sdev->buffer[2]) {
|
||||
result = ((uint16_t)quant->sdev->buffer[1] << 8) + (uint16_t)quant->sdev->buffer[2];
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ Import('rtconfig')
|
|||
cwd = GetCurrentDir()
|
||||
DEPENDS = [""]
|
||||
|
||||
SOURCES = ['transform.c']
|
||||
SOURCES = []
|
||||
path = [cwd]
|
||||
objs = DefineGroup('transform', src = SOURCES, depend = DEPENDS,CPPPATH = path)
|
||||
Return("objs")
|
||||
|
|
@ -1,191 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2020 AIIT XUOS Lab
|
||||
* XiUOS 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 xiuos.c
|
||||
* @brief Converts the framework interface to an operating system interface
|
||||
* @version 1.0
|
||||
* @author AIIT XUOS Lab
|
||||
* @date 2021.06.07
|
||||
*/
|
||||
|
||||
#include <transform.h>
|
||||
|
||||
/**************************mutex***************************/
|
||||
/* private mutex API */
|
||||
int PrivMutexCreate(pthread_mutex_t *p_mutex, const pthread_mutexattr_t *attr)
|
||||
{
|
||||
return pthread_mutex_init(p_mutex, attr);
|
||||
}
|
||||
|
||||
int PrivMutexDelete(pthread_mutex_t *p_mutex)
|
||||
{
|
||||
return pthread_mutex_destroy(p_mutex);
|
||||
}
|
||||
|
||||
int PrivMutexObtain(pthread_mutex_t *p_mutex)
|
||||
{
|
||||
return pthread_mutex_lock(p_mutex);
|
||||
}
|
||||
|
||||
int PrivMutexAbandon(pthread_mutex_t *p_mutex)
|
||||
{
|
||||
return pthread_mutex_unlock(p_mutex);
|
||||
}
|
||||
|
||||
/**********************semaphore****************************/
|
||||
int PrivSemaphoreCreate(sem_t *sem, int pshared, unsigned int value)
|
||||
{
|
||||
return sem_init(sem, pshared, value);
|
||||
}
|
||||
|
||||
int PrivSemaphoreDelete(sem_t *sem)
|
||||
{
|
||||
return sem_destroy(sem);
|
||||
}
|
||||
|
||||
int PrivSemaphoreObtainWait(sem_t *sem, const struct timespec *abstime)
|
||||
{
|
||||
return sem_timedwait(sem, abstime);
|
||||
}
|
||||
|
||||
int PrivSemaphoreObtainNoWait(sem_t *sem)
|
||||
{
|
||||
return sem_trywait(sem);
|
||||
}
|
||||
|
||||
int PrivSemaphoreAbandon(sem_t *sem)
|
||||
{
|
||||
return sem_post(sem);
|
||||
}
|
||||
|
||||
/**************************task*************************/
|
||||
int PrivTaskCreate(pthread_t *thread, const pthread_attr_t *attr,
|
||||
void *(*start_routine)(void *), void *arg)
|
||||
{
|
||||
pthread_attr_t attrtmp ;
|
||||
pthread_attr_init(&attrtmp);
|
||||
pthread_attr_setschedparam(&attrtmp, &(attr->schedparam)); /* 修改属性对应的优先级 */
|
||||
pthread_attr_setstacksize(&attrtmp, (size_t)((attr->stacksize)));
|
||||
return pthread_create(thread, &attrtmp, start_routine, arg);
|
||||
}
|
||||
|
||||
int PrivTaskStartup(pthread_t *thread)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int PrivTaskDelete(pthread_t thread, int sig)
|
||||
{
|
||||
_pthread_data_t *ptd;
|
||||
ptd = _pthread_get_data(thread);
|
||||
return rt_thread_detach(ptd->tid);
|
||||
}
|
||||
|
||||
void PrivTaskQuit(void *value_ptr)
|
||||
{
|
||||
pthread_exit(value_ptr);
|
||||
}
|
||||
|
||||
int PrivTaskDelay(int32_t ms)
|
||||
{
|
||||
rt_thread_mdelay(ms);
|
||||
}
|
||||
|
||||
/*********************fs**************************/
|
||||
|
||||
/************************Driver Posix Transform***********************/
|
||||
int PrivOpen(const char *path, int flags)
|
||||
{
|
||||
return open(path, flags);
|
||||
}
|
||||
|
||||
int PrivClose(int fd)
|
||||
{
|
||||
return close(fd);
|
||||
}
|
||||
|
||||
int PrivRead(int fd, void *buf, size_t len)
|
||||
{
|
||||
return read(fd, buf, len);
|
||||
}
|
||||
|
||||
int PrivWrite(int fd, const void *buf, size_t len)
|
||||
{
|
||||
return write(fd, buf, len);
|
||||
}
|
||||
|
||||
static int PrivSerialIoctl(int fd, int cmd, void *args)
|
||||
{
|
||||
struct dfs_fd *rt_fd;
|
||||
int ret = 0;
|
||||
struct serial_configure config = RT_SERIAL_CONFIG_DEFAULT;
|
||||
struct SerialDataCfg *serial_cfg = (struct SerialDataCfg *)args;
|
||||
config.baud_rate = serial_cfg->serial_baud_rate;
|
||||
config.data_bits = serial_cfg->serial_data_bits;
|
||||
config.stop_bits = serial_cfg->serial_stop_bits;
|
||||
config.bufsz = RT_SERIAL_RB_BUFSZ;
|
||||
config.parity = serial_cfg->serial_parity_mode;
|
||||
config.invert = serial_cfg->serial_invert_mode;
|
||||
rt_fd = fd_get(fd);
|
||||
ret = rt_fd->fops->ioctl(rt_fd, RT_DEVICE_CTRL_CONFIG, &config);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int PrivPinIoctl(int fd, int cmd, void *args)
|
||||
{
|
||||
struct PinParam *pin_cfg = (struct PinParam *)args;
|
||||
|
||||
return ioctl(fd, cmd, pin_cfg);
|
||||
}
|
||||
|
||||
int PrivIoctl(int fd, int cmd, void *args)
|
||||
{
|
||||
int ret;
|
||||
struct PrivIoctlCfg *ioctl_cfg = (struct PrivIoctlCfg *)args;
|
||||
|
||||
switch (ioctl_cfg->ioctl_driver_type)
|
||||
{
|
||||
case SERIAL_TYPE:
|
||||
ret = PrivSerialIoctl(fd, cmd, ioctl_cfg->args);
|
||||
break;
|
||||
case PIN_TYPE:
|
||||
ret = PrivPinIoctl(fd, cmd, ioctl_cfg->args);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/********************memory api************/
|
||||
void *PrivMalloc(size_t size)
|
||||
{
|
||||
return malloc(size);
|
||||
}
|
||||
|
||||
void *PrivRealloc(void *pointer, size_t size)
|
||||
{
|
||||
return realloc(pointer, size);
|
||||
}
|
||||
|
||||
void *PrivCalloc(size_t count, size_t size)
|
||||
{
|
||||
return calloc(count, size);
|
||||
}
|
||||
|
||||
void PrivFree(void *pointer)
|
||||
{
|
||||
free(pointer);
|
||||
}
|
||||
|
||||
|
|
@ -30,170 +30,26 @@
|
|||
#include <sys/time.h>
|
||||
#include <errno.h>
|
||||
#include <pthread.h>
|
||||
#include <pthread_internal.h>
|
||||
#include <semaphore.h>
|
||||
#include <sched.h>
|
||||
#include <unistd.h>
|
||||
#include <dfs_poll.h>
|
||||
#include <dfs_posix.h>
|
||||
#include <dfs.h>
|
||||
#include<sys/ioctl.h>
|
||||
#ifdef RT_USING_POSIX_TERMIOS
|
||||
#include <posix_termios.h>
|
||||
#endif
|
||||
#ifdef DRV_USING_OV2640
|
||||
#include <drv_ov2640.h>
|
||||
#endif
|
||||
#if defined(RT_USING_SAL)&& defined (RT_USING_LWIP)
|
||||
#if defined(RT_USING_SAL)
|
||||
#include <netdb.h>
|
||||
#include <sys/socket.h>
|
||||
#elif defined RT_USING_LWIP
|
||||
#else
|
||||
#include <lwip/netdb.h>
|
||||
#include <lwip/sockets.h>
|
||||
#endif /* RT_USING_SAL */
|
||||
#ifdef BOARD_K210_EVB
|
||||
#include <dmac.h>
|
||||
#include <dmalock.h>
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef signed char int8;
|
||||
typedef signed short int16;
|
||||
typedef signed int int32;
|
||||
typedef unsigned char uint8;
|
||||
typedef unsigned short uint16;
|
||||
typedef unsigned int uint32;
|
||||
|
||||
#ifdef ARCH_CPU_64BIT
|
||||
typedef signed long int64;
|
||||
typedef unsigned long uint64;
|
||||
#else
|
||||
typedef signed long long int64;
|
||||
typedef unsigned long long uint64;
|
||||
#endif
|
||||
|
||||
#define OPE_INT 0x0000
|
||||
#define OPE_CFG 0x0001
|
||||
|
||||
#define NAME_NUM_MAX 32
|
||||
|
||||
/*********************GPIO define*********************/
|
||||
#define GPIO_LOW 0x00
|
||||
#define GPIO_HIGH 0x01
|
||||
|
||||
#define GPIO_CFG_OUTPUT 0x00
|
||||
#define GPIO_CFG_INPUT 0x01
|
||||
#define GPIO_CFG_INPUT_PULLUP 0x02
|
||||
#define GPIO_CFG_INPUT_PULLDOWN 0x03
|
||||
#define GPIO_CFG_OUTPUT_OD 0x04
|
||||
|
||||
#define GPIO_CONFIG_MODE 0xffffffff
|
||||
#ifndef SERIAL_RB_BUFSZ
|
||||
#define SERIAL_RB_BUFSZ 128
|
||||
#endif
|
||||
|
||||
struct PinDevIrq
|
||||
{
|
||||
int irq_mode;//< RISING/FALLING/HIGH/LOW
|
||||
void (*hdr) (void *args);//< callback function
|
||||
void *args;//< the params of callback function
|
||||
};
|
||||
|
||||
struct PinParam
|
||||
{
|
||||
int cmd;//< cmd:GPIO_CONFIG_MODE/GPIO_IRQ_REGISTER/GPIO_IRQ_FREE/GPIO_IRQ_DISABLE/GPIO_IRQ_ENABLE
|
||||
long pin;//< pin number
|
||||
int mode;//< pin mode: input/output
|
||||
struct PinDevIrq irq_set;//< pin irq set
|
||||
uint64_t arg;
|
||||
};
|
||||
|
||||
struct PinStat
|
||||
{
|
||||
long pin;//< pin number
|
||||
uint16_t val;//< pin level
|
||||
};
|
||||
|
||||
enum ExtSerialPortConfigure
|
||||
{
|
||||
PORT_CFG_INIT = 0,
|
||||
PORT_CFG_PARITY_CHECK,
|
||||
PORT_CFG_DISABLE,
|
||||
PORT_CFG_DIV,
|
||||
};
|
||||
|
||||
struct SerialDataCfg
|
||||
{
|
||||
uint32_t serial_baud_rate;
|
||||
uint8_t serial_data_bits;
|
||||
uint8_t serial_stop_bits;
|
||||
uint8_t serial_parity_mode;
|
||||
uint8_t serial_bit_order;
|
||||
uint8_t serial_invert_mode;
|
||||
uint16_t serial_buffer_size;
|
||||
|
||||
uint8_t ext_uart_no;
|
||||
enum ExtSerialPortConfigure port_configure;
|
||||
};
|
||||
|
||||
enum IoctlDriverType
|
||||
{
|
||||
SERIAL_TYPE = 0,
|
||||
SPI_TYPE,
|
||||
I2C_TYPE,
|
||||
PIN_TYPE,
|
||||
DEFAULT_TYPE,
|
||||
};
|
||||
|
||||
struct PrivIoctlCfg
|
||||
{
|
||||
enum IoctlDriverType ioctl_driver_type;
|
||||
void *args;
|
||||
};
|
||||
|
||||
/**********************mutex**************************/
|
||||
|
||||
int PrivMutexCreate(pthread_mutex_t *p_mutex, const pthread_mutexattr_t *attr);
|
||||
int PrivMutexDelete(pthread_mutex_t *p_mutex);
|
||||
int PrivMutexObtain(pthread_mutex_t *p_mutex);
|
||||
int PrivMutexAbandon(pthread_mutex_t *p_mutex);
|
||||
|
||||
/*********************semaphore**********************/
|
||||
|
||||
int PrivSemaphoreCreate(sem_t *sem, int pshared, unsigned int value);
|
||||
int PrivSemaphoreDelete(sem_t *sem);
|
||||
int PrivSemaphoreObtainWait(sem_t *sem, const struct timespec *abstime);
|
||||
int PrivSemaphoreObtainNoWait(sem_t *sem);
|
||||
int PrivSemaphoreAbandon(sem_t *sem);
|
||||
int32_t PrivSemaphoreSetValue(int32_t sem, uint16_t val);
|
||||
|
||||
/*********************task**************************/
|
||||
|
||||
int PrivTaskCreate(pthread_t *thread, const pthread_attr_t *attr,
|
||||
void *(*start_routine)(void *), void *arg);
|
||||
int PrivTaskStartup(pthread_t *thread);
|
||||
int PrivTaskDelete(pthread_t thread, int sig);
|
||||
void PrivTaskQuit(void *value_ptr);
|
||||
int PrivTaskDelay(int32_t ms);
|
||||
|
||||
/*********************driver*************************/
|
||||
|
||||
int PrivOpen(const char *path, int flags);
|
||||
int PrivRead(int fd, void *buf, size_t len);
|
||||
int PrivWrite(int fd, const void *buf, size_t len);
|
||||
int PrivClose(int fd);
|
||||
int PrivIoctl(int fd, int cmd, void *args);
|
||||
|
||||
/*********************memory***********************/
|
||||
|
||||
void *PrivMalloc(size_t size);
|
||||
void *PrivRealloc(void *pointer, size_t size);
|
||||
void *PrivCalloc(size_t count, size_t size);
|
||||
void PrivFree(void *pointer);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
|||
|
|
@ -18,8 +18,7 @@
|
|||
* @date: 2020/4/20
|
||||
*
|
||||
*/
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include<string.h>
|
||||
#include "include/pthread.h"
|
||||
|
||||
int pthread_create(pthread_t *thread, const pthread_attr_t *attr,
|
||||
|
|
@ -27,22 +26,12 @@ int pthread_create(pthread_t *thread, const pthread_attr_t *attr,
|
|||
{
|
||||
int ret ;
|
||||
int pid ;
|
||||
char task_name[32] = {0};
|
||||
static int utask_id = 0;
|
||||
UtaskType task ;
|
||||
|
||||
if (NULL == attr) {
|
||||
task.prio = KTASK_PRIORITY_MAX / 2;
|
||||
task.stack_size = 1024 ;
|
||||
} else {
|
||||
task.prio = attr->schedparam.sched_priority ;
|
||||
task.stack_size = attr->stacksize ;
|
||||
}
|
||||
|
||||
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);
|
||||
task.func_param = arg ;
|
||||
memcpy(task.name , "utask", 6);
|
||||
task.prio = 20 ;
|
||||
task.stack_size = 1024 ;
|
||||
|
||||
pid = UserTaskCreate(task);
|
||||
if (pid < 0)
|
||||
|
|
|
|||
|
|
@ -24,8 +24,9 @@
|
|||
|
||||
int sem_init(sem_t *sem, int pshared, unsigned int value)
|
||||
{
|
||||
*sem = UserSemaphoreCreate(value);
|
||||
if (*sem < 0) {
|
||||
int32 ret = 0;
|
||||
ret = UserSemaphoreCreate(value);
|
||||
if (ret < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@
|
|||
#ifndef XS_USER_API_H
|
||||
#define XS_USER_API_H
|
||||
|
||||
#include <xiuos.h>
|
||||
#include <xsconfig.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
|
|
|||
|
|
@ -1748,15 +1748,6 @@ config ARCH_BOARD_STM32F4_DISCOVERY
|
|||
---help---
|
||||
STMicro STM32F4-Discovery board based on the STMicro STM32F407VGT6 MCU.
|
||||
|
||||
config ARCH_BOARD_STM32F4_AIIT
|
||||
bool "STMicro STM32F4-AIIT board"
|
||||
depends on ARCH_CHIP_STM32F407VG
|
||||
select ARCH_HAVE_LEDS
|
||||
select ARCH_HAVE_BUTTONS
|
||||
select ARCH_HAVE_IRQBUTTONS
|
||||
---help---
|
||||
STMicro STM32F4-Discovery board based on the STMicro STM32F407VGT6 MCU.
|
||||
|
||||
config ARCH_BOARD_STM32F411E_DISCO
|
||||
bool "STMicro STM32F411E-Discovery board"
|
||||
depends on ARCH_CHIP_STM32F411VE
|
||||
|
|
@ -2424,7 +2415,6 @@ config ARCH_BOARD
|
|||
default "stm32f3discovery" if ARCH_BOARD_STM32F3_DISCOVERY
|
||||
default "stm32f334-disco" if ARCH_BOARD_STM32F334_DISCO
|
||||
default "stm32f4discovery" if ARCH_BOARD_STM32F4_DISCOVERY
|
||||
default "aiit-arm32-board" if ARCH_BOARD_STM32F4_AIIT
|
||||
default "stm32f411e-disco" if ARCH_BOARD_STM32F411E_DISCO
|
||||
default "stm32f429i-disco" if ARCH_BOARD_STM32F429I_DISCO
|
||||
default "stm32f746g-disco" if ARCH_BOARD_STM32F746G_DISCO
|
||||
|
|
@ -2814,9 +2804,6 @@ endif
|
|||
if ARCH_BOARD_STM32H747I_DISCO
|
||||
source "boards/arm/stm32h7/stm32h747i-disco/Kconfig"
|
||||
endif
|
||||
if ARCH_BOARD_STM32F4_AIIT
|
||||
source "boards/arm/stm32/aiit-arm32-board/Kconfig"
|
||||
endif
|
||||
if ARCH_BOARD_NUCLEO_H743ZI
|
||||
source "boards/arm/stm32h7/nucleo-h743zi/Kconfig"
|
||||
endif
|
||||
|
|
|
|||
|
|
@ -756,9 +756,6 @@ boards/arm/stm32/stm32f103-minimum
|
|||
boards/arm/stm32/stm32f4discovery
|
||||
STMicro STM32F4-Discovery board based on the STMicro STM32F407VGT6 MCU.
|
||||
|
||||
boards/arm/stm32/aiit-arm32-board
|
||||
STMicro STM32F4-AIIT board based on the STMicro STM32F407VGT6 MCU.
|
||||
|
||||
boards/arm/stm32/stm32f411e-disco
|
||||
This is a minimal configuration that supports low-level test of the
|
||||
STMicro STM32F411E-Discovery Board.
|
||||
|
|
|
|||
|
|
@ -1,125 +0,0 @@
|
|||
#
|
||||
# For a description of the syntax of this configuration file,
|
||||
# see the file kconfig-language.txt in the NuttX tools repository.
|
||||
#
|
||||
|
||||
if ARCH_BOARD_STM32F4_AIIT
|
||||
|
||||
config STM32F4DISBB
|
||||
bool "STM32F4DIS-BB base board"
|
||||
default n
|
||||
---help---
|
||||
Select if you are using the STM32F4DIS-BB base board with the
|
||||
STM32F4Discovery.
|
||||
|
||||
config STM32F4AIIT
|
||||
bool "STM32F4AIIT base board"
|
||||
default n
|
||||
---help---
|
||||
Select if you are using the STM32F4AIIT base board with the
|
||||
STM32F4AIIT.
|
||||
|
||||
config STM32_ROMFS
|
||||
bool "Automount baked-in ROMFS image"
|
||||
default n
|
||||
depends on FS_ROMFS
|
||||
---help---
|
||||
Select STM32_ROMFS_IMAGEFILE, STM32_ROMFS_DEV_MINOR, STM32_ROMFS_MOUNTPOINT
|
||||
|
||||
config STM32_ROMFS_DEV_MINOR
|
||||
int "Minor for the block device backing the data"
|
||||
depends on STM32_ROMFS
|
||||
default 64
|
||||
|
||||
config STM32_ROMFS_MOUNTPOINT
|
||||
string "Mountpoint of the custom romfs image"
|
||||
depends on STM32_ROMFS
|
||||
default "/rom"
|
||||
|
||||
config STM32_ROMFS_IMAGEFILE
|
||||
string "ROMFS image file to include into build"
|
||||
depends on STM32_ROMFS
|
||||
default "../../../../../rom.img"
|
||||
|
||||
config STM32F4DISCO_USBHOST_STACKSIZE
|
||||
int "USB host waiter stack size"
|
||||
default 1024
|
||||
depends on USBHOST
|
||||
|
||||
config STM32F4DISCO_USBHOST_PRIO
|
||||
int "USB host waiter task priority"
|
||||
default 100
|
||||
depends on USBHOST
|
||||
|
||||
config STM32F4DISCO_QETIMER
|
||||
int "Timer to use with QE encoder"
|
||||
default 2
|
||||
depends on SENSORS_QENCODER
|
||||
|
||||
config STM32F4DISCO_LIS3DSH
|
||||
bool "Enable LIS3DSH driver for the IMU on STM32F4Discovery (rev. MB997C)"
|
||||
default n
|
||||
depends on SPI
|
||||
depends on LIS3DSH
|
||||
default n
|
||||
select SENSORS_LIS3DSH
|
||||
---help---
|
||||
Select to create a LIS3DSH driver instance for the builtin accelerometer of
|
||||
STM32F4Discovery. Provides /dev/acc0 device file.
|
||||
Also see apps/examples/lis3dsh_reader.
|
||||
The LIS3DSH is available on the STM32F4Discovery rev. MB997C (see the board manual).
|
||||
|
||||
config PM_BUTTONS
|
||||
bool "PM button support"
|
||||
default n
|
||||
depends on PM && ARCH_IRQBUTTONS
|
||||
---help---
|
||||
Enable PM button EXTI interrupts to support PM testing
|
||||
|
||||
config PM_BUTTON_ACTIVITY
|
||||
int "Button PM activity weight"
|
||||
default 10
|
||||
depends on PM_BUTTONS
|
||||
---help---
|
||||
The activity weight to report to the power management subsystem when
|
||||
a button is pressed.
|
||||
|
||||
config PM_ALARM_SEC
|
||||
int "PM_STANDBY delay (seconds)"
|
||||
default 15
|
||||
depends on PM && RTC_ALARM
|
||||
---help---
|
||||
Number of seconds to wait in PM_STANDBY before going to PM_STANDBY
|
||||
mode.
|
||||
|
||||
config PM_ALARM_NSEC
|
||||
int "PM_STANDBY delay (nanoseconds)"
|
||||
default 0
|
||||
depends on PM && RTC_ALARM
|
||||
---help---
|
||||
Number of additional nanoseconds to wait in PM_STANDBY before going
|
||||
to PM_STANDBY mode.
|
||||
|
||||
config PM_SLEEP_WAKEUP
|
||||
bool "PM_SLEEP wake-up alarm"
|
||||
default n
|
||||
depends on PM && RTC_ALARM
|
||||
---help---
|
||||
Wake-up of PM_SLEEP mode after a delay and resume normal operation.
|
||||
|
||||
config PM_SLEEP_WAKEUP_SEC
|
||||
int "PM_SLEEP delay (seconds)"
|
||||
default 10
|
||||
depends on PM && RTC_ALARM
|
||||
---help---
|
||||
Number of seconds to wait in PM_SLEEP before going to PM_STANDBY mode.
|
||||
|
||||
config PM_SLEEP_WAKEUP_NSEC
|
||||
int "PM_SLEEP delay (nanoseconds)"
|
||||
default 0
|
||||
depends on PM && RTC_ALARM
|
||||
---help---
|
||||
Number of additional nanoseconds to wait in PM_SLEEP before going to
|
||||
PM_STANDBY mode.
|
||||
|
||||
endif
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -1,87 +0,0 @@
|
|||
#
|
||||
# This file is autogenerated: PLEASE DO NOT EDIT IT.
|
||||
#
|
||||
# You can use "make menuconfig" to make any modifications to the installed .config file.
|
||||
# You can then do "make savedefconfig" to generate a new defconfig file that includes your
|
||||
# modifications.
|
||||
#
|
||||
# CONFIG_ARCH_FPU is not set
|
||||
# CONFIG_NSH_ARGCAT is not set
|
||||
# CONFIG_NSH_CMDOPT_HEXDUMP is not set
|
||||
# CONFIG_NSH_CMDPARMS is not set
|
||||
CONFIG_ADBD_FILE_SERVICE=y
|
||||
CONFIG_ADBD_SHELL_SERVICE=y
|
||||
CONFIG_ADBD_USB_SERVER=y
|
||||
CONFIG_ARCH="arm"
|
||||
CONFIG_ARCH_BOARD="aiit-arm32-board"
|
||||
CONFIG_ARCH_BOARD_STM32F4_AIIT=y
|
||||
CONFIG_ARCH_BUTTONS=y
|
||||
CONFIG_ARCH_CHIP="stm32"
|
||||
CONFIG_ARCH_CHIP_STM32=y
|
||||
CONFIG_ARCH_CHIP_STM32F407VG=y
|
||||
CONFIG_ARCH_STACKDUMP=y
|
||||
CONFIG_BOARDCTL_RESET=y
|
||||
CONFIG_BOARDCTL_USBDEVCTRL=y
|
||||
CONFIG_BOARD_LOOPSPERMSEC=16717
|
||||
CONFIG_BUILTIN=y
|
||||
CONFIG_CLOCK_MONOTONIC=y
|
||||
CONFIG_DEBUG_FULLOPT=y
|
||||
CONFIG_DEBUG_SYMBOLS=y
|
||||
CONFIG_DEV_FIFO_SIZE=128
|
||||
CONFIG_DEV_PIPE_MAXSIZE=128
|
||||
CONFIG_DEV_PIPE_SIZE=128
|
||||
CONFIG_DEV_URANDOM=y
|
||||
CONFIG_ELF=y
|
||||
CONFIG_EXAMPLES_HELLO=m
|
||||
CONFIG_FAT_LFN=y
|
||||
CONFIG_FS_FAT=y
|
||||
CONFIG_FS_FATTIME=y
|
||||
CONFIG_FS_PROCFS=y
|
||||
CONFIG_HAVE_CXX=y
|
||||
CONFIG_HAVE_CXXINITIALIZE=y
|
||||
CONFIG_INTELHEX_BINARY=y
|
||||
CONFIG_LIBC_EXECFUNCS=y
|
||||
CONFIG_LIBUV=y
|
||||
CONFIG_LIBUV_PIPE=y
|
||||
CONFIG_LIBUV_STREAM=y
|
||||
CONFIG_LIB_ENVPATH=y
|
||||
CONFIG_MAX_TASKS=16
|
||||
CONFIG_MMCSD=y
|
||||
CONFIG_NSH_ARCHINIT=y
|
||||
CONFIG_NSH_BUILTIN_APPS=y
|
||||
CONFIG_NSH_FILEIOSIZE=512
|
||||
CONFIG_NSH_FILE_APPS=y
|
||||
CONFIG_NSH_LINELEN=128
|
||||
CONFIG_NSH_READLINE=y
|
||||
CONFIG_PATH_INITIAL="/mnt/sd0/bin"
|
||||
CONFIG_PIPES=y
|
||||
CONFIG_PREALLOC_TIMERS=4
|
||||
CONFIG_RAM_SIZE=114688
|
||||
CONFIG_RAM_START=0x20000000
|
||||
CONFIG_RAW_BINARY=y
|
||||
CONFIG_SCHED_LPWORK=y
|
||||
CONFIG_SCHED_WAITPID=y
|
||||
CONFIG_SDCLONE_DISABLE=y
|
||||
CONFIG_SENSORS=y
|
||||
CONFIG_STACK_COLORATION=y
|
||||
CONFIG_START_DAY=17
|
||||
CONFIG_START_MONTH=12
|
||||
CONFIG_START_YEAR=2020
|
||||
CONFIG_STM32_DMA2=y
|
||||
CONFIG_STM32_DMACAPABLE=y
|
||||
CONFIG_STM32_JTAG_SW_ENABLE=y
|
||||
CONFIG_STM32_OTGFS=y
|
||||
CONFIG_STM32_PWR=y
|
||||
CONFIG_STM32_SPI2=y
|
||||
CONFIG_STM32_USART2=y
|
||||
CONFIG_SYMTAB_ORDEREDBYNAME=y
|
||||
CONFIG_SYSTEM_ADBD=y
|
||||
CONFIG_SYSTEM_NSH=y
|
||||
CONFIG_SYSTEM_NSH_SYMTAB=y
|
||||
CONFIG_SYSTEM_NSH_SYMTAB_ARRAYNAME="g_symtab"
|
||||
CONFIG_SYSTEM_NSH_SYMTAB_COUNTNAME="g_nsymbols"
|
||||
CONFIG_USART2_SERIAL_CONSOLE=y
|
||||
CONFIG_USBADB=y
|
||||
CONFIG_USBDEV=y
|
||||
CONFIG_USERMAIN_STACKSIZE=3072
|
||||
CONFIG_USER_ENTRYPOINT="nsh_main"
|
||||
|
|
@ -1,79 +0,0 @@
|
|||
#
|
||||
# This file is autogenerated: PLEASE DO NOT EDIT IT.
|
||||
#
|
||||
# You can use "make menuconfig" to make any modifications to the installed .config file.
|
||||
# You can then do "make savedefconfig" to generate a new defconfig file that includes your
|
||||
# modifications.
|
||||
#
|
||||
# CONFIG_ARCH_FPU is not set
|
||||
# CONFIG_NSH_ARGCAT is not set
|
||||
# CONFIG_NSH_CMDOPT_HEXDUMP is not set
|
||||
# CONFIG_NSH_CMDPARMS is not set
|
||||
CONFIG_ARCH="arm"
|
||||
CONFIG_ARCH_BOARD="aiit-arm32-board"
|
||||
CONFIG_ARCH_BOARD_STM32F4_AIIT=y
|
||||
CONFIG_ARCH_BUTTONS=y
|
||||
CONFIG_ARCH_CHIP="stm32"
|
||||
CONFIG_ARCH_CHIP_STM32=y
|
||||
CONFIG_ARCH_CHIP_STM32F407VG=y
|
||||
CONFIG_ARCH_STACKDUMP=y
|
||||
CONFIG_AUDIO=y
|
||||
CONFIG_AUDIO_CS43L22=y
|
||||
CONFIG_AUDIO_CUSTOM_DEV_PATH=y
|
||||
CONFIG_AUDIO_EXCLUDE_TONE=y
|
||||
CONFIG_BOARD_LATE_INITIALIZE=y
|
||||
CONFIG_BOARD_LOOPSPERMSEC=16717
|
||||
CONFIG_BUILTIN=y
|
||||
CONFIG_DRIVERS_AUDIO=y
|
||||
CONFIG_FAT_LCNAMES=y
|
||||
CONFIG_FAT_LFN=y
|
||||
CONFIG_FS_FAT=y
|
||||
CONFIG_FS_PROCFS=y
|
||||
CONFIG_HAVE_CXX=y
|
||||
CONFIG_HAVE_CXXINITIALIZE=y
|
||||
CONFIG_I2C=y
|
||||
CONFIG_I2C_DRIVER=y
|
||||
CONFIG_I2C_POLLED=y
|
||||
CONFIG_I2C_RESET=y
|
||||
CONFIG_INTELHEX_BINARY=y
|
||||
CONFIG_MAX_TASKS=16
|
||||
CONFIG_MM_REGIONS=2
|
||||
CONFIG_NSH_BUILTIN_APPS=y
|
||||
CONFIG_NSH_FILEIOSIZE=512
|
||||
CONFIG_NSH_LINELEN=64
|
||||
CONFIG_NSH_READLINE=y
|
||||
CONFIG_NXPLAYER_DEFAULT_MEDIADIR="/mnt/music"
|
||||
CONFIG_PREALLOC_TIMERS=4
|
||||
CONFIG_RAM_SIZE=114688
|
||||
CONFIG_RAM_START=0x20000000
|
||||
CONFIG_RAW_BINARY=y
|
||||
CONFIG_RR_INTERVAL=200
|
||||
CONFIG_SCHED_HPWORK=y
|
||||
CONFIG_SCHED_WAITPID=y
|
||||
CONFIG_SDCLONE_DISABLE=y
|
||||
CONFIG_START_DAY=6
|
||||
CONFIG_START_MONTH=12
|
||||
CONFIG_START_YEAR=2011
|
||||
CONFIG_STM32_DMA1=y
|
||||
CONFIG_STM32_DMACAPABLE=y
|
||||
CONFIG_STM32_I2C1=y
|
||||
CONFIG_STM32_I2S3=y
|
||||
CONFIG_STM32_I2S3_TX=y
|
||||
CONFIG_STM32_I2S_MCK=y
|
||||
CONFIG_STM32_JTAG_SW_ENABLE=y
|
||||
CONFIG_STM32_OTGFS=y
|
||||
CONFIG_STM32_OTGFS_SOFINTR=y
|
||||
CONFIG_STM32_PWR=y
|
||||
CONFIG_STM32_SPI1=y
|
||||
CONFIG_STM32_SPI3=y
|
||||
CONFIG_STM32_SPI_DMA=y
|
||||
CONFIG_STM32_USART2=y
|
||||
CONFIG_STM32_USBHOST=y
|
||||
CONFIG_SYSTEM_NSH=y
|
||||
CONFIG_SYSTEM_NXPLAYER=y
|
||||
CONFIG_USART2_RXBUFSIZE=128
|
||||
CONFIG_USART2_SERIAL_CONSOLE=y
|
||||
CONFIG_USART2_TXBUFSIZE=128
|
||||
CONFIG_USBHOST_ISOC_DISABLE=y
|
||||
CONFIG_USBHOST_MSC=y
|
||||
CONFIG_USER_ENTRYPOINT="nsh_main"
|
||||
|
|
@ -1,57 +0,0 @@
|
|||
#
|
||||
# This file is autogenerated: PLEASE DO NOT EDIT IT.
|
||||
#
|
||||
# You can use "make menuconfig" to make any modifications to the installed .config file.
|
||||
# You can then do "make savedefconfig" to generate a new defconfig file that includes your
|
||||
# modifications.
|
||||
#
|
||||
# CONFIG_ARCH_FPU is not set
|
||||
# CONFIG_NSH_ARGCAT is not set
|
||||
# CONFIG_NSH_CMDOPT_HEXDUMP is not set
|
||||
# CONFIG_NSH_CMDPARMS is not set
|
||||
CONFIG_ARCH="arm"
|
||||
CONFIG_ARCH_BOARD="stm32f4discovery"
|
||||
CONFIG_ARCH_BOARD_STM32F4_DISCOVERY=y
|
||||
CONFIG_ARCH_BUTTONS=y
|
||||
CONFIG_ARCH_CHIP="stm32"
|
||||
CONFIG_ARCH_CHIP_STM32=y
|
||||
CONFIG_ARCH_CHIP_STM32F407VG=y
|
||||
CONFIG_ARCH_STACKDUMP=y
|
||||
CONFIG_BOARD_LOOPSPERMSEC=16717
|
||||
CONFIG_BUILTIN=y
|
||||
CONFIG_CANUTILS_LIBCANARD=y
|
||||
CONFIG_CAN_EXTID=y
|
||||
CONFIG_CLOCK_MONOTONIC=y
|
||||
CONFIG_EXAMPLES_LIBCANARD=y
|
||||
CONFIG_FS_PROCFS=y
|
||||
CONFIG_HAVE_CXX=y
|
||||
CONFIG_HAVE_CXXINITIALIZE=y
|
||||
CONFIG_INTELHEX_BINARY=y
|
||||
CONFIG_MAX_TASKS=16
|
||||
CONFIG_MM_REGIONS=2
|
||||
CONFIG_NSH_BUILTIN_APPS=y
|
||||
CONFIG_NSH_FILEIOSIZE=512
|
||||
CONFIG_NSH_LINELEN=64
|
||||
CONFIG_NSH_READLINE=y
|
||||
CONFIG_PREALLOC_TIMERS=4
|
||||
CONFIG_RAM_SIZE=114688
|
||||
CONFIG_RAM_START=0x20000000
|
||||
CONFIG_RAW_BINARY=y
|
||||
CONFIG_RR_INTERVAL=200
|
||||
CONFIG_SCHED_WAITPID=y
|
||||
CONFIG_SDCLONE_DISABLE=y
|
||||
CONFIG_START_DAY=6
|
||||
CONFIG_START_MONTH=12
|
||||
CONFIG_START_YEAR=2011
|
||||
CONFIG_STM32_CAN1=y
|
||||
CONFIG_STM32_CAN1_BAUD=500000
|
||||
CONFIG_STM32_JTAG_SW_ENABLE=y
|
||||
CONFIG_STM32_PWR=y
|
||||
CONFIG_STM32_SPI1=y
|
||||
CONFIG_STM32_USART2=y
|
||||
CONFIG_SYSTEM_NSH=y
|
||||
CONFIG_SYSTEM_TIME64=y
|
||||
CONFIG_USART2_RXBUFSIZE=128
|
||||
CONFIG_USART2_SERIAL_CONSOLE=y
|
||||
CONFIG_USART2_TXBUFSIZE=128
|
||||
CONFIG_USER_ENTRYPOINT="nsh_main"
|
||||
|
|
@ -1,66 +0,0 @@
|
|||
############################################################################
|
||||
# boards/arm/stm32/stm32f4discovery/configs/cxxtest/Make.defs
|
||||
#
|
||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
# contributor license agreements. See the NOTICE file distributed with
|
||||
# this work for additional information regarding copyright ownership. The
|
||||
# ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance with the
|
||||
# License. You may obtain a copy of the License at
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
############################################################################
|
||||
|
||||
include $(TOPDIR)/.config
|
||||
include $(TOPDIR)/tools/Config.mk
|
||||
include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs
|
||||
|
||||
LDSCRIPT = ld.script
|
||||
ifeq ($(CONFIG_CYGWIN_WINTOOL),y)
|
||||
ARCHSCRIPT = -T "${shell cygpath -w $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT)}"
|
||||
else
|
||||
ARCHSCRIPT = -T$(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT)
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
|
||||
ARCHOPTIMIZATION = -g
|
||||
endif
|
||||
|
||||
ifneq ($(CONFIG_DEBUG_NOOPT),y)
|
||||
ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -fno-strength-reduce -fomit-frame-pointer
|
||||
endif
|
||||
|
||||
ARCHCFLAGS = -fno-builtin
|
||||
ifeq ($(CONFIG_CXX_EXCEPTION),y)
|
||||
ARCHCPUFLAGSXX = -fno-builtin
|
||||
else
|
||||
ARCHCPUFLAGSXX = -fno-builtin -fno-exceptions -fcheck-new
|
||||
endif
|
||||
ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef
|
||||
ARCHWARNINGSXX = -Wall -Wshadow -Wundef
|
||||
ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10
|
||||
|
||||
CFLAGS := $(ARCHCFLAGS) $(ARCHWARNINGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -pipe
|
||||
CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS)
|
||||
CXXFLAGS := $(ARCHCXXFLAGS) $(ARCHWARNINGSXX) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -pipe
|
||||
CXXPICFLAGS = $(ARCHPICFLAGS) $(CXXFLAGS)
|
||||
CPPFLAGS := $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS)
|
||||
AFLAGS := $(CFLAGS) -D__ASSEMBLY__
|
||||
|
||||
NXFLATLDFLAGS1 = -r -d -warn-common
|
||||
NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections
|
||||
LDNXFLATFLAGS = -e main -s 2048
|
||||
|
||||
ifneq ($(CROSSDEV),arm-nuttx-elf-)
|
||||
LDFLAGS += -nostartfiles -nodefaultlibs
|
||||
endif
|
||||
ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
|
||||
LDFLAGS += -g
|
||||
endif
|
||||
|
|
@ -1,45 +0,0 @@
|
|||
#
|
||||
# This file is autogenerated: PLEASE DO NOT EDIT IT.
|
||||
#
|
||||
# You can use "make menuconfig" to make any modifications to the installed .config file.
|
||||
# You can then do "make savedefconfig" to generate a new defconfig file that includes your
|
||||
# modifications.
|
||||
#
|
||||
# CONFIG_ARCH_FPU is not set
|
||||
CONFIG_ARCH="arm"
|
||||
CONFIG_ARCH_BOARD="aiit-arm32-board"
|
||||
CONFIG_ARCH_BOARD_STM32F4_AIIT=y
|
||||
CONFIG_ARCH_CHIP="stm32"
|
||||
CONFIG_ARCH_CHIP_STM32=y
|
||||
CONFIG_ARCH_CHIP_STM32F407VG=y
|
||||
CONFIG_ARCH_STACKDUMP=y
|
||||
CONFIG_BOARD_LOOPSPERMSEC=16717
|
||||
CONFIG_C99_BOOL8=y
|
||||
CONFIG_DISABLE_ENVIRON=y
|
||||
CONFIG_DISABLE_MOUNTPOINT=y
|
||||
CONFIG_HAVE_CXX=y
|
||||
CONFIG_HOST_WINDOWS=y
|
||||
CONFIG_INTELHEX_BINARY=y
|
||||
CONFIG_LIBM=y
|
||||
CONFIG_MAX_TASKS=16
|
||||
CONFIG_MM_REGIONS=2
|
||||
CONFIG_PREALLOC_TIMERS=4
|
||||
CONFIG_RAM_SIZE=114688
|
||||
CONFIG_RAM_START=0x20000000
|
||||
CONFIG_RAW_BINARY=y
|
||||
CONFIG_RR_INTERVAL=200
|
||||
CONFIG_SCHED_ONEXIT=y
|
||||
CONFIG_SCHED_ONEXIT_MAX=4
|
||||
CONFIG_SDCLONE_DISABLE=y
|
||||
CONFIG_START_DAY=2
|
||||
CONFIG_START_MONTH=11
|
||||
CONFIG_START_YEAR=2012
|
||||
CONFIG_STM32_JTAG_SW_ENABLE=y
|
||||
CONFIG_STM32_USART2=y
|
||||
CONFIG_SYMTAB_ORDEREDBYNAME=y
|
||||
CONFIG_TESTING_CXXTEST=y
|
||||
CONFIG_UCLIBCXX=y
|
||||
CONFIG_USART2_RXBUFSIZE=128
|
||||
CONFIG_USART2_SERIAL_CONSOLE=y
|
||||
CONFIG_USART2_TXBUFSIZE=128
|
||||
CONFIG_USER_ENTRYPOINT="cxxtest_main"
|
||||
|
|
@ -1,46 +0,0 @@
|
|||
#
|
||||
# This file is autogenerated: PLEASE DO NOT EDIT IT.
|
||||
#
|
||||
# You can use "make menuconfig" to make any modifications to the installed .config file.
|
||||
# You can then do "make savedefconfig" to generate a new defconfig file that includes your
|
||||
# modifications.
|
||||
#
|
||||
# CONFIG_ARCH_FPU is not set
|
||||
CONFIG_ARCH="arm"
|
||||
CONFIG_ARCH_BOARD="stm32f4discovery"
|
||||
CONFIG_ARCH_BOARD_STM32F4_DISCOVERY=y
|
||||
CONFIG_ARCH_CHIP="stm32"
|
||||
CONFIG_ARCH_CHIP_STM32=y
|
||||
CONFIG_ARCH_CHIP_STM32F407VG=y
|
||||
CONFIG_ARCH_STACKDUMP=y
|
||||
CONFIG_ARMV7M_USEBASEPRI=y
|
||||
CONFIG_BINFMT_CONSTRUCTORS=y
|
||||
CONFIG_BOARD_LATE_INITIALIZE=y
|
||||
CONFIG_BOARD_LOOPSPERMSEC=16717
|
||||
CONFIG_CONSOLE_SYSLOG=y
|
||||
CONFIG_ELF=y
|
||||
CONFIG_ELF_STACKSIZE=4096
|
||||
CONFIG_EXAMPLES_ELF=y
|
||||
CONFIG_FS_ROMFS=y
|
||||
CONFIG_HAVE_CXX=y
|
||||
CONFIG_INTELHEX_BINARY=y
|
||||
CONFIG_LIB_ENVPATH=y
|
||||
CONFIG_MAX_TASKS=16
|
||||
CONFIG_MM_REGIONS=2
|
||||
CONFIG_PATH_INITIAL="/mnt/romfs"
|
||||
CONFIG_PREALLOC_TIMERS=4
|
||||
CONFIG_RAM_SIZE=114688
|
||||
CONFIG_RAM_START=0x20000000
|
||||
CONFIG_RAW_BINARY=y
|
||||
CONFIG_RR_INTERVAL=200
|
||||
CONFIG_SCHED_STARTHOOK=y
|
||||
CONFIG_SDCLONE_DISABLE=y
|
||||
CONFIG_START_DAY=26
|
||||
CONFIG_START_MONTH=10
|
||||
CONFIG_START_YEAR=2012
|
||||
CONFIG_STM32_JTAG_SW_ENABLE=y
|
||||
CONFIG_STM32_USART2=y
|
||||
CONFIG_SYMTAB_ORDEREDBYNAME=y
|
||||
CONFIG_USART2_SERIAL_CONSOLE=y
|
||||
CONFIG_USERMAIN_STACKSIZE=4096
|
||||
CONFIG_USER_ENTRYPOINT="elf_main"
|
||||
|
|
@ -1,79 +0,0 @@
|
|||
#
|
||||
# This file is autogenerated: PLEASE DO NOT EDIT IT.
|
||||
#
|
||||
# You can use "make menuconfig" to make any modifications to the installed .config file.
|
||||
# You can then do "make savedefconfig" to generate a new defconfig file that includes your
|
||||
# modifications.
|
||||
#
|
||||
# CONFIG_ARCH_FPU is not set
|
||||
# CONFIG_NET_ETHERNET is not set
|
||||
# CONFIG_NET_IPv4 is not set
|
||||
# CONFIG_NSH_ARGCAT is not set
|
||||
# CONFIG_NSH_CMDOPT_HEXDUMP is not set
|
||||
# CONFIG_NSH_CMDPARMS is not set
|
||||
# CONFIG_NSH_NETINIT is not set
|
||||
CONFIG_ARCH="arm"
|
||||
CONFIG_ARCH_BOARD="aiit-arm32-board"
|
||||
CONFIG_ARCH_BOARD_STM32F4_AIIT=y
|
||||
CONFIG_ARCH_BUTTONS=y
|
||||
CONFIG_ARCH_CHIP="stm32"
|
||||
CONFIG_ARCH_CHIP_STM32=y
|
||||
CONFIG_ARCH_CHIP_STM32F407VG=y
|
||||
CONFIG_ARCH_INTERRUPTSTACK=2048
|
||||
CONFIG_ARCH_STACKDUMP=y
|
||||
CONFIG_BLUETOOTH_MAX_CONN=2
|
||||
CONFIG_BLUETOOTH_MAX_PAIRED=2
|
||||
CONFIG_BLUETOOTH_UART=y
|
||||
CONFIG_BOARDCTL_RESET=y
|
||||
CONFIG_BOARD_LOOPSPERMSEC=16717
|
||||
CONFIG_BTSAK=y
|
||||
CONFIG_BUILTIN=y
|
||||
CONFIG_DRIVERS_BLUETOOTH=y
|
||||
CONFIG_DRIVERS_WIRELESS=y
|
||||
CONFIG_FS_PROCFS=y
|
||||
CONFIG_HAVE_CXX=y
|
||||
CONFIG_HAVE_CXXINITIALIZE=y
|
||||
CONFIG_INTELHEX_BINARY=y
|
||||
CONFIG_IOB_BUFSIZE=80
|
||||
CONFIG_IOB_NBUFFERS=64
|
||||
CONFIG_IOB_NCHAINS=16
|
||||
CONFIG_IOB_THROTTLE=16
|
||||
CONFIG_LIB_HOSTNAME="STM32F4-Discovery"
|
||||
CONFIG_MAX_TASKS=16
|
||||
CONFIG_NET=y
|
||||
CONFIG_NETDEVICES=y
|
||||
CONFIG_NETDEV_LATEINIT=y
|
||||
CONFIG_NETDEV_PHY_IOCTL=y
|
||||
CONFIG_NET_BLUETOOTH=y
|
||||
CONFIG_NET_SOCKOPTS=y
|
||||
CONFIG_NSH_ARCHINIT=y
|
||||
CONFIG_NSH_BUILTIN_APPS=y
|
||||
CONFIG_NSH_FILEIOSIZE=512
|
||||
CONFIG_NSH_LINELEN=64
|
||||
CONFIG_NSH_READLINE=y
|
||||
CONFIG_PREALLOC_MQ_MSGS=64
|
||||
CONFIG_PREALLOC_TIMERS=4
|
||||
CONFIG_RAM_SIZE=114688
|
||||
CONFIG_RAM_START=0x20000000
|
||||
CONFIG_RAW_BINARY=y
|
||||
CONFIG_RR_INTERVAL=200
|
||||
CONFIG_SCHED_HPWORKPRIORITY=192
|
||||
CONFIG_SCHED_WAITPID=y
|
||||
CONFIG_SDCLONE_DISABLE=y
|
||||
CONFIG_START_DAY=13
|
||||
CONFIG_START_MONTH=9
|
||||
CONFIG_START_YEAR=2014
|
||||
CONFIG_STM32F4AIIT=y
|
||||
CONFIG_STM32_DMA2=y
|
||||
CONFIG_STM32_DMACAPABLE=y
|
||||
CONFIG_STM32_JTAG_SW_ENABLE=y
|
||||
CONFIG_STM32_PWR=y
|
||||
CONFIG_STM32_SPI1=y
|
||||
CONFIG_STM32_USART3=y
|
||||
CONFIG_STM32_USART3_HCIUART=y
|
||||
CONFIG_STM32_USART6=y
|
||||
CONFIG_SYSTEM_NSH=y
|
||||
CONFIG_USART6_SERIAL_CONSOLE=y
|
||||
CONFIG_USER_ENTRYPOINT="nsh_main"
|
||||
CONFIG_WIRELESS=y
|
||||
CONFIG_WIRELESS_BLUETOOTH=y
|
||||
|
|
@ -1,93 +0,0 @@
|
|||
#
|
||||
# This file is autogenerated: PLEASE DO NOT EDIT IT.
|
||||
#
|
||||
# You can use "make menuconfig" to make any modifications to the installed .config file.
|
||||
# You can then do "make savedefconfig" to generate a new defconfig file that includes your
|
||||
# modifications.
|
||||
#
|
||||
# CONFIG_ARCH_FPU is not set
|
||||
# CONFIG_MMCSD_MMCSUPPORT is not set
|
||||
# CONFIG_MMCSD_SPI is not set
|
||||
# CONFIG_NET_IPv4 is not set
|
||||
# CONFIG_NSH_ARGCAT is not set
|
||||
# CONFIG_NSH_CMDOPT_HEXDUMP is not set
|
||||
# CONFIG_NSH_CMDPARMS is not set
|
||||
CONFIG_ARCH="arm"
|
||||
CONFIG_ARCH_BOARD="aiit-arm32-board"
|
||||
CONFIG_ARCH_BOARD_STM32F4_AIIT=y
|
||||
CONFIG_ARCH_BUTTONS=y
|
||||
CONFIG_ARCH_CHIP="stm32"
|
||||
CONFIG_ARCH_CHIP_STM32=y
|
||||
CONFIG_ARCH_CHIP_STM32F407VG=y
|
||||
CONFIG_ARCH_STACKDUMP=y
|
||||
CONFIG_BOARD_LOOPSPERMSEC=16717
|
||||
CONFIG_BUILTIN=y
|
||||
CONFIG_ETH0_PHY_LAN8720=y
|
||||
CONFIG_FAT_LCNAMES=y
|
||||
CONFIG_FAT_LFN=y
|
||||
CONFIG_FS_FAT=y
|
||||
CONFIG_FS_PROCFS=y
|
||||
CONFIG_HAVE_CXX=y
|
||||
CONFIG_HAVE_CXXINITIALIZE=y
|
||||
CONFIG_HOST_WINDOWS=y
|
||||
CONFIG_INTELHEX_BINARY=y
|
||||
CONFIG_LIB_HOSTNAME="STM32F4-Discovery"
|
||||
CONFIG_MAX_TASKS=16
|
||||
CONFIG_MMCSD=y
|
||||
CONFIG_MMCSD_MULTIBLOCK_DISABLE=y
|
||||
CONFIG_MMCSD_SDIO=y
|
||||
CONFIG_NET=y
|
||||
CONFIG_NETINIT_IPv6NETMASK_8=0xff80
|
||||
CONFIG_NETINIT_NOMAC=y
|
||||
CONFIG_NET_BROADCAST=y
|
||||
CONFIG_NET_ICMPv6=y
|
||||
CONFIG_NET_ICMPv6_NEIGHBOR=y
|
||||
CONFIG_NET_ICMPv6_SOCKET=y
|
||||
CONFIG_NET_IPv6=y
|
||||
CONFIG_NET_SOCKOPTS=y
|
||||
CONFIG_NET_SOLINGER=y
|
||||
CONFIG_NET_TCP=y
|
||||
CONFIG_NET_TCPBACKLOG=y
|
||||
CONFIG_NET_TCP_WRITE_BUFFERS=y
|
||||
CONFIG_NET_UDP=y
|
||||
CONFIG_NSH_ARCHINIT=y
|
||||
CONFIG_NSH_BUILTIN_APPS=y
|
||||
CONFIG_NSH_FILEIOSIZE=512
|
||||
CONFIG_NSH_LINELEN=64
|
||||
CONFIG_NSH_READLINE=y
|
||||
CONFIG_PREALLOC_TIMERS=4
|
||||
CONFIG_RAM_SIZE=114688
|
||||
CONFIG_RAM_START=0x20000000
|
||||
CONFIG_RAW_BINARY=y
|
||||
CONFIG_RR_INTERVAL=200
|
||||
CONFIG_SCHED_HPWORK=y
|
||||
CONFIG_SCHED_HPWORKPRIORITY=192
|
||||
CONFIG_SCHED_WAITPID=y
|
||||
CONFIG_SDCLONE_DISABLE=y
|
||||
CONFIG_START_DAY=13
|
||||
CONFIG_START_MONTH=9
|
||||
CONFIG_START_YEAR=2014
|
||||
CONFIG_STM32F4AIIT=y
|
||||
CONFIG_STM32_DMA2=y
|
||||
CONFIG_STM32_DMACAPABLE=y
|
||||
CONFIG_STM32_ETHMAC=y
|
||||
CONFIG_STM32_JTAG_SW_ENABLE=y
|
||||
CONFIG_STM32_PHYADDR=0
|
||||
CONFIG_STM32_PHYSR=31
|
||||
CONFIG_STM32_PHYSR_100FD=0x0018
|
||||
CONFIG_STM32_PHYSR_100HD=0x0008
|
||||
CONFIG_STM32_PHYSR_10FD=0x0014
|
||||
CONFIG_STM32_PHYSR_10HD=0x0004
|
||||
CONFIG_STM32_PHYSR_ALTCONFIG=y
|
||||
CONFIG_STM32_PHYSR_ALTMODE=0x001c
|
||||
CONFIG_STM32_PWR=y
|
||||
CONFIG_STM32_RMII_EXTCLK=y
|
||||
CONFIG_STM32_SDIO=y
|
||||
CONFIG_STM32_SPI1=y
|
||||
CONFIG_STM32_USART6=y
|
||||
CONFIG_SYSTEM_NSH=y
|
||||
CONFIG_SYSTEM_PING6=y
|
||||
CONFIG_USART6_RXBUFSIZE=64
|
||||
CONFIG_USART6_SERIAL_CONSOLE=y
|
||||
CONFIG_USART6_TXBUFSIZE=64
|
||||
CONFIG_USER_ENTRYPOINT="nsh_main"
|
||||
|
|
@ -1,49 +0,0 @@
|
|||
#
|
||||
# This file is autogenerated: PLEASE DO NOT EDIT IT.
|
||||
#
|
||||
# You can use "make menuconfig" to make any modifications to the installed .config file.
|
||||
# You can then do "make savedefconfig" to generate a new defconfig file that includes your
|
||||
# modifications.
|
||||
#
|
||||
# CONFIG_ARCH_FPU is not set
|
||||
CONFIG_ARCH="arm"
|
||||
CONFIG_ARCH_BOARD="stm32f4discovery"
|
||||
CONFIG_ARCH_BOARD_STM32F4_DISCOVERY=y
|
||||
CONFIG_ARCH_CHIP="stm32"
|
||||
CONFIG_ARCH_CHIP_STM32=y
|
||||
CONFIG_ARCH_CHIP_STM32F407VG=y
|
||||
CONFIG_ARCH_STACKDUMP=y
|
||||
CONFIG_ARM_MPU=y
|
||||
CONFIG_BOARD_LATE_INITIALIZE=y
|
||||
CONFIG_BOARD_LOOPSPERMSEC=16717
|
||||
CONFIG_BUILD_PROTECTED=y
|
||||
CONFIG_CONSOLE_SYSLOG=y
|
||||
CONFIG_DISABLE_ENVIRON=y
|
||||
CONFIG_DISABLE_MOUNTPOINT=y
|
||||
CONFIG_HOST_WINDOWS=y
|
||||
CONFIG_INTELHEX_BINARY=y
|
||||
CONFIG_MAX_TASKS=16
|
||||
CONFIG_MM_REGIONS=2
|
||||
CONFIG_NUTTX_USERSPACE=0x08020000
|
||||
CONFIG_PASS1_BUILDIR="boards/arm/stm32/stm32f4discovery/kernel"
|
||||
CONFIG_PREALLOC_TIMERS=4
|
||||
CONFIG_RAM_SIZE=114688
|
||||
CONFIG_RAM_START=0x20000000
|
||||
CONFIG_RAW_BINARY=y
|
||||
CONFIG_RR_INTERVAL=200
|
||||
CONFIG_SCHED_WAITPID=y
|
||||
CONFIG_SDCLONE_DISABLE=y
|
||||
CONFIG_START_DAY=22
|
||||
CONFIG_START_MONTH=3
|
||||
CONFIG_START_YEAR=2013
|
||||
CONFIG_STM32_JTAG_SW_ENABLE=y
|
||||
CONFIG_STM32_USART2=y
|
||||
CONFIG_SYMTAB_ORDEREDBYNAME=y
|
||||
CONFIG_SYS_RESERVED=8
|
||||
CONFIG_TESTING_OSTEST=y
|
||||
CONFIG_TESTING_OSTEST_NBARRIER_THREADS=3
|
||||
CONFIG_TESTING_OSTEST_STACKSIZE=2048
|
||||
CONFIG_USART2_RXBUFSIZE=128
|
||||
CONFIG_USART2_SERIAL_CONSOLE=y
|
||||
CONFIG_USART2_TXBUFSIZE=128
|
||||
CONFIG_USER_ENTRYPOINT="ostest_main"
|
||||
|
|
@ -1,58 +0,0 @@
|
|||
#
|
||||
# This file is autogenerated: PLEASE DO NOT EDIT IT.
|
||||
#
|
||||
# You can use "make menuconfig" to make any modifications to the installed .config file.
|
||||
# You can then do "make savedefconfig" to generate a new defconfig file that includes your
|
||||
# modifications.
|
||||
#
|
||||
# CONFIG_ARCH_FPU is not set
|
||||
# CONFIG_NSH_ARGCAT is not set
|
||||
# CONFIG_NSH_CMDOPT_HEXDUMP is not set
|
||||
# CONFIG_NSH_CMDPARMS is not set
|
||||
CONFIG_ARCH="arm"
|
||||
CONFIG_ARCH_BOARD="stm32f4discovery"
|
||||
CONFIG_ARCH_BOARD_STM32F4_DISCOVERY=y
|
||||
CONFIG_ARCH_BUTTONS=y
|
||||
CONFIG_ARCH_CHIP="stm32"
|
||||
CONFIG_ARCH_CHIP_STM32=y
|
||||
CONFIG_ARCH_CHIP_STM32F407VG=y
|
||||
CONFIG_ARCH_STACKDUMP=y
|
||||
CONFIG_BOARD_LATE_INITIALIZE=y
|
||||
CONFIG_BOARD_LOOPSPERMSEC=16717
|
||||
CONFIG_BUILTIN=y
|
||||
CONFIG_EXAMPLES_HELLO=y
|
||||
CONFIG_EXAMPLES_SLCD=y
|
||||
CONFIG_FS_PROCFS=y
|
||||
CONFIG_HAVE_CXX=y
|
||||
CONFIG_HAVE_CXXINITIALIZE=y
|
||||
CONFIG_I2C=y
|
||||
CONFIG_INTELHEX_BINARY=y
|
||||
CONFIG_LCD_BACKPACK=y
|
||||
CONFIG_LCD_LCD1602=y
|
||||
CONFIG_MAX_TASKS=16
|
||||
CONFIG_MM_REGIONS=2
|
||||
CONFIG_NSH_BUILTIN_APPS=y
|
||||
CONFIG_NSH_FILEIOSIZE=512
|
||||
CONFIG_NSH_LINELEN=64
|
||||
CONFIG_NSH_READLINE=y
|
||||
CONFIG_PREALLOC_TIMERS=4
|
||||
CONFIG_RAM_SIZE=114688
|
||||
CONFIG_RAM_START=0x20000000
|
||||
CONFIG_RAW_BINARY=y
|
||||
CONFIG_RR_INTERVAL=200
|
||||
CONFIG_SCHED_WAITPID=y
|
||||
CONFIG_SDCLONE_DISABLE=y
|
||||
CONFIG_SLCD=y
|
||||
CONFIG_START_DAY=6
|
||||
CONFIG_START_MONTH=12
|
||||
CONFIG_START_YEAR=2011
|
||||
CONFIG_STM32_I2C1=y
|
||||
CONFIG_STM32_JTAG_SW_ENABLE=y
|
||||
CONFIG_STM32_PWR=y
|
||||
CONFIG_STM32_SPI1=y
|
||||
CONFIG_STM32_USART2=y
|
||||
CONFIG_SYSTEM_NSH=y
|
||||
CONFIG_USART2_RXBUFSIZE=128
|
||||
CONFIG_USART2_SERIAL_CONSOLE=y
|
||||
CONFIG_USART2_TXBUFSIZE=128
|
||||
CONFIG_USER_ENTRYPOINT="nsh_main"
|
||||
|
|
@ -1,50 +0,0 @@
|
|||
#
|
||||
# This file is autogenerated: PLEASE DO NOT EDIT IT.
|
||||
#
|
||||
# You can use "make menuconfig" to make any modifications to the installed .config file.
|
||||
# You can then do "make savedefconfig" to generate a new defconfig file that includes your
|
||||
# modifications.
|
||||
#
|
||||
# CONFIG_ARCH_FPU is not set
|
||||
# CONFIG_NSH_ARGCAT is not set
|
||||
# CONFIG_NSH_CMDOPT_HEXDUMP is not set
|
||||
# CONFIG_NSH_CMDPARMS is not set
|
||||
CONFIG_ARCH="arm"
|
||||
CONFIG_ARCH_BOARD="stm32f4discovery"
|
||||
CONFIG_ARCH_BOARD_STM32F4_DISCOVERY=y
|
||||
CONFIG_ARCH_BUTTONS=y
|
||||
CONFIG_ARCH_CHIP="stm32"
|
||||
CONFIG_ARCH_CHIP_STM32=y
|
||||
CONFIG_ARCH_CHIP_STM32F407VG=y
|
||||
CONFIG_ARCH_STACKDUMP=y
|
||||
CONFIG_BOARD_LATE_INITIALIZE=y
|
||||
CONFIG_BOARD_LOOPSPERMSEC=16717
|
||||
CONFIG_BUILTIN=y
|
||||
CONFIG_EXAMPLES_HELLO=y
|
||||
CONFIG_FS_PROCFS=y
|
||||
CONFIG_HAVE_CXX=y
|
||||
CONFIG_HAVE_CXXINITIALIZE=y
|
||||
CONFIG_INTELHEX_BINARY=y
|
||||
CONFIG_LWL_CONSOLE=y
|
||||
CONFIG_MAX_TASKS=16
|
||||
CONFIG_MM_REGIONS=2
|
||||
CONFIG_NSH_BUILTIN_APPS=y
|
||||
CONFIG_NSH_FILEIOSIZE=512
|
||||
CONFIG_NSH_LINELEN=64
|
||||
CONFIG_NSH_READLINE=y
|
||||
CONFIG_PREALLOC_TIMERS=4
|
||||
CONFIG_RAM_SIZE=114688
|
||||
CONFIG_RAM_START=0x20000000
|
||||
CONFIG_RAW_BINARY=y
|
||||
CONFIG_RR_INTERVAL=200
|
||||
CONFIG_SCHED_WAITPID=y
|
||||
CONFIG_SDCLONE_DISABLE=y
|
||||
CONFIG_STANDARD_SERIAL=y
|
||||
CONFIG_START_DAY=6
|
||||
CONFIG_START_MONTH=12
|
||||
CONFIG_START_YEAR=2011
|
||||
CONFIG_STM32_JTAG_SW_ENABLE=y
|
||||
CONFIG_STM32_PWR=y
|
||||
CONFIG_STM32_SPI1=y
|
||||
CONFIG_SYSTEM_NSH=y
|
||||
CONFIG_USER_ENTRYPOINT="nsh_main"
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue