Skip to content

Commit e2ddb84

Browse files
authored
Merge pull request #108 from Yuheng-P/iot_link
add driver framework and at framework for iot_link, as well as bearpi target
2 parents baf6ec5 + 2e9e2b3 commit e2ddb84

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+32186
-142
lines changed

iot_link/at/at.c

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@
3636
#include <stdlib.h>
3737
#include <string.h>
3838
#include <driver.h>
39-
39+
#include <sys/fcntl.h>
40+
#include <los_base.h>
4041

4142
//these defines could be moved to the configuration of the at module
4243
#define cn_at_oob_len 6 //only allow 6 oob command monitor here,you could configure it more
@@ -79,9 +80,9 @@ struct at_cb
7980
struct at_cmd cmd; //the at command,only one command could be excuted
8081
struct at_oob oob[cn_at_oob_len]; //storage the out of band dealer
8182
char rcvbuf[cn_at_resp_maxlen]; //used storage one frame,read from the at channel
82-
u32_t passmode:1; //if zero, then use the at mode,else use the pass mode,pass all the data to fnoob
83-
u32_t rxdebugmode:2; //receive debug mode
84-
u32_t txdebugmode:2; //send debug mode
83+
unsigned int passmode:1; //if zero, then use the at mode,else use the pass mode,pass all the data to fnoob
84+
unsigned int rxdebugmode:2; //receive debug mode
85+
unsigned int txdebugmode:2; //send debug mode
8586
};
8687
static struct at_cb g_at_cb; //this is the at controller here
8788

@@ -148,7 +149,7 @@ static int __resp_rcv(char *buf,int buflen,int timeout)
148149
}
149150

150151
//create a command
151-
static bool_t __cmd_create(char *cmdbuf,int cmdlen,const char *index,char *respbuf,int respbuflen,u32_t timeout)
152+
static bool_t __cmd_create(char *cmdbuf,int cmdlen,const char *index,char *respbuf,int respbuflen,unsigned int timeout)
152153
{
153154
bool_t ret = false;
154155
struct at_cmd *cmd;
@@ -317,7 +318,7 @@ instruction :only one command could be dealt at one time, for we use the sempho
317318
response data to the respbuf as much as the respbuflen permit
318319
*******************************************************************************/
319320
int at_command(char *cmd,int cmdlen,const char *index,char *respbuf,\
320-
int respbuflen,int timeout)
321+
int respbuflen,int timeout)
321322
{
322323
int ret = 0;
323324
if((NULL != cmd))//which means no response need
@@ -408,7 +409,7 @@ bool_t at_init(const char *devname)
408409
goto EXIT_CMDLOCK;
409410
}
410411

411-
if(-1 == task_create("at_rcv",__rcv_task_entry,0x800,NULL,NULL,10))
412+
if(-1 == osal_task_create("at_rcv",__rcv_task_entry,0x800,NULL,NULL,10))
412413
{
413414
printf("%s:rcvtask create error\n\r",__FUNCTION__);
414415
goto EXIT_RCVTASK;
@@ -437,8 +438,10 @@ bool_t at_init(const char *devname)
437438
return ret;
438439
}
439440

441+
440442
//////////////////////////////////DEBUG COMMAND FOLLOWING/////////////////////////////////////////
441443
#include <shell.h>
444+
#include <los_sys.ph>
442445
//use this shell command,you could input at command through the terminal
443446
static int shell_at(int argc, const char *argv[])
444447
{
@@ -462,7 +465,7 @@ static int shell_at(int argc, const char *argv[])
462465

463466

464467
memset(respbuf,0,CN_AT_SHELL_LEN);
465-
snprintf((char *)cmdbuf,CN_AT_SHELL_LEN,"%s\r",argv[1]);
468+
snprintf((char *)cmdbuf,CN_AT_SHELL_LEN,"%s\r\n",argv[1]);
466469

467470
ret = at_command(cmdbuf,strlen((const char *)cmdbuf),index,respbuf,CN_AT_SHELL_LEN,LOSCFG_BASE_CORE_TICK_PER_SECOND); //one second
468471
if(ret > 0)

iot_link/at/at.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,13 @@
4141
#include <osal.h>
4242

4343

44-
#define CFG_ATCLIENT_ENABLE 1
44+
#define cfg_at_enable 1
4545

4646
typedef int (*fnoob)(char *data,int datalen);
4747

48-
#if CFG_ATCLIENT_ENABLE
49-
48+
#if cfg_at_enable
5049

50+
#define CN_OBJECT_INVALID 0Xffffffff
5151
bool_t at_init(const char *devname); //install the at frame work,which binded to the device
5252
bool_t at_oobregister(fnoob func,const char *index); //register a out of band data dealer
5353
int at_command(char *cmd, int cmdlen,const char *index,\

iot_link/at/at.mk

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@
44
# make sure driver module is enabled
55
################################################################################
66

7-
AT_MODULE_SRC = ${wildcard $(iot_link_root)/at_skeleton/*.c}
8-
C_SOURCES += $(AT_MODULE_SRC)
7+
ifeq ($(cfg_at_enable),yes)
8+
AT_MODULE_SRC = ${wildcard $(iot_link_root)/at/*.c}
9+
C_SOURCES += $(AT_MODULE_SRC)
910

10-
AT_MODULE_INC = -I $(iot_link_root)/at_skeleton
11-
C_INCLUDES += $(AT_MODULE_INC)
11+
AT_MODULE_INC = -I $(iot_link_root)/at
12+
C_INCLUDES += $(AT_MODULE_INC)
1213

13-
AT_MODULE_DEF = -D CFG_ATCLIENT_ENABLE=1
14-
C_DEFS += $(AT_MODULE_DEF)
14+
AT_MODULE_DEF = -D cfg_at_enable=1
15+
C_DEFS += $(AT_MODULE_DEF)
16+
endif
1517

iot_link/driver/dev_fs_test.c

Lines changed: 31 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -42,60 +42,61 @@
4242
#include <stdio.h>
4343
#include <shell.h>
4444
#include <driver.h>
45-
#include <fs/los_vfs.h>
45+
#include "fs/inc/los_vfs.h"
46+
#include "sys/fcntl.h"
4647

4748
//this file implement some demo to test the device module
4849
#define cn_testdriv_buf_len 256
4950

5051
typedef struct
5152
{
52-
s32_t refers;
53+
int refers;
5354
}testdriv_cb_test_t;
5455
static testdriv_cb_test_t s_testdriv_cb_test;
5556
//cached only one frame here
5657

57-
static bool_t testdriv_open(void *pri,s32_t flag)
58+
static bool_t testdriv_open(void *pri,int flag)
5859
{
59-
printf("TESTDRIV:PRI:0x%08X OPEN\n\r",(u32_t)pri);
60+
printf("TESTDRIV:PRI:0x%08X OPEN\n\r",(unsigned int)pri);
6061

6162
s_testdriv_cb_test.refers++;
6263
return true;
6364
}
6465
static void testdriv_close(void *pri)
6566
{
66-
printf("TESTDRIV:PRI:0x%08X CLOSE\n\r",(u32_t)pri);
67+
printf("TESTDRIV:PRI:0x%08X CLOSE\n\r",(unsigned int)pri);
6768
s_testdriv_cb_test.refers--;
6869
return ;
6970
}
7071

71-
static bool_t testdriv_write(void *pri,u32_t offset,u8_t *buf,s32_t len,u32_t timeout)
72+
static bool_t testdriv_write(void *pri,unsigned int offset,unsigned char *buf,int len,unsigned int timeout)
7273
{
73-
printf("TESTDRIV:PRI:0x%08X WTRITE: buf:0x%08x len:%d timeout:%d\n\r",(u32_t)pri,(u32_t)buf,len,timeout);
74+
printf("TESTDRIV:PRI:0x%08X WTRITE: buf:0x%08x len:%d timeout:%d\n\r",(unsigned int)pri,(unsigned int)buf,len,timeout);
7475
return len;
7576
}
7677

77-
static bool_t testdriv_read(void *pri,u32_t offset,u8_t *buf,s32_t len,u32_t timeout)
78+
static bool_t testdriv_read(void *pri,unsigned int offset,unsigned char *buf,int len,unsigned int timeout)
7879
{
79-
printf("TESTDRIV:PRI:0x%08X READ: buf:0x%08x len:%d timeout:%d\n\r",(u32_t)pri,(u32_t)buf,len,timeout);
80+
printf("TESTDRIV:PRI:0x%08X READ: buf:0x%08x len:%d timeout:%d\n\r",(unsigned int)pri,(unsigned int)buf,len,timeout);
8081
return len;
8182
}
8283

8384

8485
static bool_t testdriv_init(void *pri)
8586
{
86-
printf("TESTDRIV:PRI:0x%08X INIT\n\r",(u32_t)pri);
87+
printf("TESTDRIV:PRI:0x%08X INIT\n\r",(unsigned int)pri);
8788
return true;
8889
}
8990

9091
static void testdriv_deinit(void *pri)
9192
{
92-
printf("TESTDRIV:PRI:0x%08X DEINIT\n\r",(u32_t)pri);
93+
printf("TESTDRIV:PRI:0x%08X DEINIT\n\r",(unsigned int)pri);
9394
return ;
9495
}
9596

96-
static bool_t testdriv_ioctl(void *pri,u32_t cmd, void *para,s32_t paralen)
97+
static bool_t testdriv_ioctl(void *pri,unsigned int cmd, void *para,int paralen)
9798
{
98-
printf("TESTDRIV:PRI:0x%08X IOCTL:cmd:%d para:0x%08x paralen:%d \n\r",(u32_t)pri,cmd,(u32_t)para,paralen);
99+
printf("TESTDRIV:PRI:0x%08X IOCTL:cmd:%d para:0x%08x paralen:%d \n\r",(unsigned int)pri,cmd,(unsigned int)para,paralen);
99100
return true;
100101
}
101102

@@ -117,12 +118,12 @@ OSDRIV_EXPORT(drivpara4,"dev3",(los_driv_op_t *)&s_testdriv,NULL,O_RDWR);
117118
OSDRIV_EXPORT(drivpara5,"dev2",(los_driv_op_t *)&s_testdriv,NULL,O_RDWR);
118119
OSDRIV_EXPORT(drivpara6,"dev1",(los_driv_op_t *)&s_testdriv,NULL,O_RDWR);
119120

120-
static s32_t s_shell_opendev = NULL;
121-
static s32_t __driv_open(s32_t argc,const char *argv[]) //dirvopen drivname flag
121+
static int s_shell_opendev = NULL;
122+
static int __driv_open(int argc,const char *argv[]) //dirvopen drivname flag
122123
{
123124
int dev;
124125
const char *drivname = 0;
125-
u32_t flag = 0;
126+
unsigned int flag = 0;
126127
if(argc != 3 )
127128
{
128129
printf("paraerr");
@@ -165,10 +166,10 @@ static s32_t __driv_open(s32_t argc,const char *argv[]) //dirvopen drivname flag
165166
OSSHELL_EXPORT_CMD(__driv_open,"open","open name flag");
166167

167168

168-
static s32_t __driv_write(s32_t argc,const char *argv[]) //drivewrite string timeout
169+
static int __driv_write(int argc,const char *argv[]) //drivewrite string timeout
169170
{
170-
s32_t ret;
171-
u32_t timeout = 0;
171+
int ret;
172+
unsigned int timeout = 0;
172173

173174
if(argc != 3)
174175
{
@@ -177,7 +178,7 @@ static s32_t __driv_write(s32_t argc,const char *argv[]) //drivewrite string tim
177178
}
178179

179180
timeout = strtoul(argv[2],NULL,0);
180-
ret = write(s_shell_opendev,(u8_t *)argv[1],strlen(argv[1]));
181+
ret = write(s_shell_opendev,(unsigned char *)argv[1],strlen(argv[1]));
181182
printf("write:%d bytes\n\r",ret);
182183

183184
return 0;
@@ -186,12 +187,12 @@ static s32_t __driv_write(s32_t argc,const char *argv[]) //drivewrite string tim
186187
OSSHELL_EXPORT_CMD(__driv_write,"write","write string timeout");
187188

188189

189-
static s32_t __driv_read(s32_t argc,const char *argv[]) //driveread len timeout
190+
static int __driv_read(int argc,const char *argv[]) //driveread len timeout
190191
{
191-
s32_t ret;
192-
u32_t timeout = 0;
193-
s32_t len ;
194-
u8_t *buf;
192+
int ret;
193+
unsigned int timeout = 0;
194+
int len ;
195+
unsigned char *buf;
195196

196197
if(argc != 3)
197198
{
@@ -211,10 +212,10 @@ static s32_t __driv_read(s32_t argc,const char *argv[]) //driveread len timeout
211212

212213
OSSHELL_EXPORT_CMD(__driv_read,"read","read len timeout");
213214

214-
static s32_t __driv_ioctl(s32_t argc,const char *argv[]) //drivioctl cmd cmdpara
215+
static int __driv_ioctl(int argc,const char *argv[]) //drivioctl cmd cmdpara
215216
{
216217
bool_t ret;
217-
u32_t cmd = 0;
218+
unsigned int cmd = 0;
218219

219220
if(argc != 3)
220221
{
@@ -224,7 +225,7 @@ static s32_t __driv_ioctl(s32_t argc,const char *argv[]) //drivioctl cmd cmdpara
224225

225226
cmd = strtoul(argv[1],NULL,0);
226227

227-
ret = ioctl(s_shell_opendev,cmd,(u32_t)argv[2]);
228+
ret = ioctl(s_shell_opendev,cmd,(unsigned int)argv[2]);
228229
if(ret)
229230
{
230231
printf("IOCTL OK\r\n");
@@ -240,9 +241,9 @@ static s32_t __driv_ioctl(s32_t argc,const char *argv[]) //drivioctl cmd cmdpara
240241

241242
OSSHELL_EXPORT_CMD(__driv_ioctl,"ioctl","ioctl cmd cmdpara");
242243

243-
static s32_t __driv_close(s32_t argc,const char *argv[]) //drivclose
244+
static int __driv_close(int argc,const char *argv[]) //drivclose
244245
{
245-
s32_t ret;
246+
int ret;
246247

247248
ret = close(s_shell_opendev);
248249
if(ret)

0 commit comments

Comments
 (0)