summaryrefslogtreecommitdiff
path: root/components/drivers/include
diff options
context:
space:
mode:
authorxuzhuoyi <[email protected]>2018-11-16 20:09:46 +0800
committerxuzhuoyi <[email protected]>2018-11-16 20:09:46 +0800
commit37db67d94a269e1a9893d076ab2bb6b9883cfa8c (patch)
treefaaea1c497b8b50e638f768ed6fcc4ec83e6a90f /components/drivers/include
parent305307c90c8723dcdb79663f65a8933b5cb1b934 (diff)
parent63a6f6c4d2540b003296594c4b916cc1ba8d0b16 (diff)
Merge remote-tracking branch 'upstream/master'
# Conflicts: # src/thread.c
Diffstat (limited to 'components/drivers/include')
-rw-r--r--components/drivers/include/drivers/alarm.h18
-rw-r--r--components/drivers/include/drivers/audio.h20
-rw-r--r--components/drivers/include/drivers/can.h18
-rw-r--r--components/drivers/include/drivers/cputime.h18
-rw-r--r--components/drivers/include/drivers/hwtimer.h8
-rw-r--r--components/drivers/include/drivers/i2c-bit-ops.h18
-rw-r--r--components/drivers/include/drivers/i2c.h18
-rw-r--r--components/drivers/include/drivers/i2c_dev.h18
-rw-r--r--components/drivers/include/drivers/mmc.h18
-rw-r--r--components/drivers/include/drivers/mmcsd_card.h18
-rw-r--r--components/drivers/include/drivers/mmcsd_cmd.h18
-rw-r--r--components/drivers/include/drivers/mmcsd_core.h18
-rw-r--r--components/drivers/include/drivers/mmcsd_host.h18
-rw-r--r--components/drivers/include/drivers/mtd.h105
-rw-r--r--components/drivers/include/drivers/mtd_nand.h18
-rw-r--r--components/drivers/include/drivers/mtd_nor.h20
-rw-r--r--components/drivers/include/drivers/mtdnand.h101
-rw-r--r--components/drivers/include/drivers/mtdnor.h35
-rw-r--r--components/drivers/include/drivers/pin.h18
-rw-r--r--components/drivers/include/drivers/pm.h181
-rw-r--r--components/drivers/include/drivers/rt_drv_pwm.h27
-rw-r--r--components/drivers/include/drivers/rtc.h18
-rw-r--r--components/drivers/include/drivers/sd.h18
-rw-r--r--components/drivers/include/drivers/sdio.h18
-rw-r--r--components/drivers/include/drivers/sdio_func_ids.h18
-rw-r--r--components/drivers/include/drivers/serial.h18
-rw-r--r--components/drivers/include/drivers/spi.h18
-rw-r--r--components/drivers/include/drivers/usb_common.h31
-rw-r--r--components/drivers/include/drivers/usb_device.h27
-rw-r--r--components/drivers/include/drivers/usb_host.h18
-rw-r--r--components/drivers/include/drivers/watchdog.h20
-rw-r--r--components/drivers/include/drivers/wlan.h21
-rw-r--r--components/drivers/include/ipc/completion.h8
-rw-r--r--components/drivers/include/ipc/dataqueue.h8
-rw-r--r--components/drivers/include/ipc/pipe.h8
-rw-r--r--components/drivers/include/ipc/poll.h18
-rw-r--r--components/drivers/include/ipc/ringblk_buf.h101
-rw-r--r--components/drivers/include/ipc/ringbuffer.h8
-rw-r--r--components/drivers/include/ipc/waitqueue.h18
-rw-r--r--components/drivers/include/ipc/workqueue.h8
-rw-r--r--components/drivers/include/rtdevice.h34
41 files changed, 699 insertions, 468 deletions
diff --git a/components/drivers/include/drivers/alarm.h b/components/drivers/include/drivers/alarm.h
index 99dd8ef9b8..b5ebbc86d9 100644
--- a/components/drivers/include/drivers/alarm.h
+++ b/components/drivers/include/drivers/alarm.h
@@ -1,21 +1,7 @@
/*
- * File : alarm.h
- * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2006 - 2012, RT-Thread Development Team
+ * Copyright (c) 2006-2018, RT-Thread Development Team
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
diff --git a/components/drivers/include/drivers/audio.h b/components/drivers/include/drivers/audio.h
index 04821c2bc8..7d2cb36728 100644
--- a/components/drivers/include/drivers/audio.h
+++ b/components/drivers/include/drivers/audio.h
@@ -1,21 +1,7 @@
/*
- * File : audio.h
- * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2006 - 2017, RT-Thread Development Team
+ * Copyright (c) 2006-2018, RT-Thread Development Team
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
@@ -94,7 +80,7 @@
/* Support Dsp(input/output) Units controls */
#define AUDIO_DSP_PARAM 0 /* get/set all params */
-#define AUDIO_DSP_SAMPLERATE 1 /* ����Ƶ�� */
+#define AUDIO_DSP_SAMPLERATE 1 /* 采样频率 */
#define AUDIO_DSP_FMT 2
#define AUDIO_DSP_CHANNELS 3
diff --git a/components/drivers/include/drivers/can.h b/components/drivers/include/drivers/can.h
index ecf3b5f51e..c61fb19eaa 100644
--- a/components/drivers/include/drivers/can.h
+++ b/components/drivers/include/drivers/can.h
@@ -1,21 +1,7 @@
/*
- * File : can.h
- * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2015, RT-Thread Development Team
+ * Copyright (c) 2006-2018, RT-Thread Development Team
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
diff --git a/components/drivers/include/drivers/cputime.h b/components/drivers/include/drivers/cputime.h
index c3dd243f11..78c22fc1da 100644
--- a/components/drivers/include/drivers/cputime.h
+++ b/components/drivers/include/drivers/cputime.h
@@ -1,21 +1,7 @@
/*
- * File : cputime.h
- * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2017, RT-Thread Development Team
+ * Copyright (c) 2006-2018, RT-Thread Development Team
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
diff --git a/components/drivers/include/drivers/hwtimer.h b/components/drivers/include/drivers/hwtimer.h
index 24cec74d32..cbfeec2bf8 100644
--- a/components/drivers/include/drivers/hwtimer.h
+++ b/components/drivers/include/drivers/hwtimer.h
@@ -1,3 +1,11 @@
+/*
+ * Copyright (c) 2006-2018, RT-Thread Development Team
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Change Logs:
+ * Date Author Notes
+ */
#ifndef __HWTIMER_H__
#define __HWTIMER_H__
diff --git a/components/drivers/include/drivers/i2c-bit-ops.h b/components/drivers/include/drivers/i2c-bit-ops.h
index 6360b99a92..ddf9a36d73 100644
--- a/components/drivers/include/drivers/i2c-bit-ops.h
+++ b/components/drivers/include/drivers/i2c-bit-ops.h
@@ -1,21 +1,7 @@
/*
- * File : i2c-bit-ops.h
- * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2006 - 2012, RT-Thread Development Team
+ * Copyright (c) 2006-2018, RT-Thread Development Team
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
diff --git a/components/drivers/include/drivers/i2c.h b/components/drivers/include/drivers/i2c.h
index b6f5273722..e2a9e7d0b8 100644
--- a/components/drivers/include/drivers/i2c.h
+++ b/components/drivers/include/drivers/i2c.h
@@ -1,21 +1,7 @@
/*
- * File : i2c.h
- * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2006 - 2012, RT-Thread Development Team
+ * Copyright (c) 2006-2018, RT-Thread Development Team
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
diff --git a/components/drivers/include/drivers/i2c_dev.h b/components/drivers/include/drivers/i2c_dev.h
index 81e9896bcf..5ef9dd1a8c 100644
--- a/components/drivers/include/drivers/i2c_dev.h
+++ b/components/drivers/include/drivers/i2c_dev.h
@@ -1,21 +1,7 @@
/*
- * File : i2c_dev.h
- * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2006 - 2012, RT-Thread Development Team
+ * Copyright (c) 2006-2018, RT-Thread Development Team
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
diff --git a/components/drivers/include/drivers/mmc.h b/components/drivers/include/drivers/mmc.h
index 6800c2a29e..95dce7178a 100644
--- a/components/drivers/include/drivers/mmc.h
+++ b/components/drivers/include/drivers/mmc.h
@@ -1,21 +1,7 @@
/*
- * File : mmc.h
- * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2006, RT-Thread Development Team
+ * Copyright (c) 2006-2018, RT-Thread Development Team
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
diff --git a/components/drivers/include/drivers/mmcsd_card.h b/components/drivers/include/drivers/mmcsd_card.h
index 18470a5ea9..3ee5a20465 100644
--- a/components/drivers/include/drivers/mmcsd_card.h
+++ b/components/drivers/include/drivers/mmcsd_card.h
@@ -1,21 +1,7 @@
/*
- * File : mmcsd_card.h
- * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2006, RT-Thread Development Team
+ * Copyright (c) 2006-2018, RT-Thread Development Team
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
diff --git a/components/drivers/include/drivers/mmcsd_cmd.h b/components/drivers/include/drivers/mmcsd_cmd.h
index 2700771531..7c2f26e892 100644
--- a/components/drivers/include/drivers/mmcsd_cmd.h
+++ b/components/drivers/include/drivers/mmcsd_cmd.h
@@ -1,21 +1,7 @@
/*
- * File : mmcsd_cmd.h
- * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2006, RT-Thread Development Team
+ * Copyright (c) 2006-2018, RT-Thread Development Team
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
diff --git a/components/drivers/include/drivers/mmcsd_core.h b/components/drivers/include/drivers/mmcsd_core.h
index 2be758bf82..05a5af6d79 100644
--- a/components/drivers/include/drivers/mmcsd_core.h
+++ b/components/drivers/include/drivers/mmcsd_core.h
@@ -1,21 +1,7 @@
/*
- * File : mmcsd_core.h
- * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2006, RT-Thread Development Team
+ * Copyright (c) 2006-2018, RT-Thread Development Team
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
diff --git a/components/drivers/include/drivers/mmcsd_host.h b/components/drivers/include/drivers/mmcsd_host.h
index 877a04d8e0..1253062aef 100644
--- a/components/drivers/include/drivers/mmcsd_host.h
+++ b/components/drivers/include/drivers/mmcsd_host.h
@@ -1,21 +1,7 @@
/*
- * File : mmcsd_host.h
- * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2006, RT-Thread Development Team
+ * Copyright (c) 2006-2018, RT-Thread Development Team
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
diff --git a/components/drivers/include/drivers/mtd.h b/components/drivers/include/drivers/mtd.h
new file mode 100644
index 0000000000..fb7ea4389d
--- /dev/null
+++ b/components/drivers/include/drivers/mtd.h
@@ -0,0 +1,105 @@
+/*
+ * Copyright (c) 2006-2018, RT-Thread Development Team
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Change Logs:
+ * Date Author Notes
+ 2018-09-10 heyuanjie87 first version
+
+ */
+
+#ifndef __MTD_H__
+#define __MTD_H__
+
+#include <rtthread.h>
+#include <stddef.h>
+#include <stdint.h>
+
+#define MTD_TYPE_NOR 1
+#define MTD_TYPE_NAND 2
+
+ /**
+ * MTD operation modes
+ *
+ * @MTD_OPM_PLACE_OOB: OOB data are placed at the given offset (default)
+ * @MTD_OPM_AUTO_OOB: OOB data are automatically placed at the free areas
+ * @MTD_OPM_RAW: data are transferred as-is, with no error correction;
+ */
+enum mtd_opm
+{
+ MTD_OPM_PLACE_OOB = 0,
+ MTD_OPM_AUTO_OOB = 1,
+ MTD_OPM_RAW = 2,
+};
+
+#ifndef loff_t
+typedef long loff_t;
+#endif
+
+struct mtd_oob_region
+{
+ uint8_t offset;
+ uint8_t length;
+};
+
+typedef struct mtd_info
+{
+ struct rt_device parent;
+
+ const struct mtd_ops *ops;
+
+ uint16_t oob_size;
+ uint16_t sector_size; /* Minimal writable flash unit size */
+ uint32_t block_size:28; /* Erase size for the device */
+ uint32_t type:4;
+
+ size_t size; /* Total size of the MTD */
+ loff_t offset; /* At which this MTD starts, from the beginning of the MEMORY */
+ struct mtd_info *master;
+
+ void *priv;
+}rt_mtd_t;
+
+struct mtd_io_desc
+{
+ uint8_t mode; /* operation mode(enum mtd_opm) */
+ uint8_t ooblen; /* number of oob bytes to write/read */
+ uint8_t oobretlen; /* number of oob bytes written/read */
+ uint8_t ooboffs; /* offset in the oob area */
+ uint8_t *oobbuf;
+
+ size_t datlen; /* number of data bytes to write/read */
+ size_t datretlen; /* number of data bytes written/read */
+ uint8_t *datbuf; /* if NULL only oob are read/written */
+};
+
+struct mtd_ops
+{
+ int(*erase)(rt_mtd_t *mtd, loff_t addr, size_t len); /* return 0 if success */
+ int(*read) (rt_mtd_t *mtd, loff_t from, struct mtd_io_desc *ops); /* return 0 if success */
+ int(*write) (rt_mtd_t *mtd, loff_t to, struct mtd_io_desc *ops); /* return 0 if success */
+ int(*isbad) (rt_mtd_t *mtd, uint32_t block); /* return 1 if bad, 0 not bad */
+ int(*markbad) (rt_mtd_t *mtd, uint32_t block); /* return 0 if success */
+};
+
+struct mtd_part
+{
+ const char *name; /* name of the MTD partion */
+ loff_t offset; /* start addr of partion */
+ size_t size; /* size of partion */
+};
+
+int rt_mtd_erase(rt_mtd_t *mtd, loff_t addr, size_t size);
+int rt_mtd_block_erase(rt_mtd_t *mtd, uint32_t block);
+int rt_mtd_read_oob(rt_mtd_t *mtd, loff_t from, struct mtd_io_desc *desc);
+int rt_mtd_write_oob(rt_mtd_t *mtd, loff_t to, struct mtd_io_desc *desc);
+int rt_mtd_read(rt_mtd_t *mtd, loff_t from, uint8_t *buf, size_t len);
+int rt_mtd_write(rt_mtd_t *mtd, loff_t to, const uint8_t *buf, size_t len);
+int rt_mtd_block_markbad(rt_mtd_t *mtd, uint32_t block);
+int rt_mtd_block_isbad(rt_mtd_t *mtd, uint32_t block);
+
+rt_mtd_t* rt_mtd_get(const char *name);
+int rt_mtd_register(rt_mtd_t *master, const struct mtd_part *parts, int np);
+
+#endif
diff --git a/components/drivers/include/drivers/mtd_nand.h b/components/drivers/include/drivers/mtd_nand.h
index fb14eb0dcc..8afed000dd 100644
--- a/components/drivers/include/drivers/mtd_nand.h
+++ b/components/drivers/include/drivers/mtd_nand.h
@@ -1,21 +1,7 @@
/*
- * File : mtd_nand.h
- * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2006 - 2012, RT-Thread Development Team
+ * Copyright (c) 2006-2018, RT-Thread Development Team
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
diff --git a/components/drivers/include/drivers/mtd_nor.h b/components/drivers/include/drivers/mtd_nor.h
index c51ce87f41..32a952f374 100644
--- a/components/drivers/include/drivers/mtd_nor.h
+++ b/components/drivers/include/drivers/mtd_nor.h
@@ -1,21 +1,7 @@
/*
- * File : mtd_nor.h
- * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2012, Shanghai Real-Thread Technology Co., Ltd
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * COPYRIGHT (C) 2018, Real-Thread Information Technology Ltd
+ *
+ * SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
diff --git a/components/drivers/include/drivers/mtdnand.h b/components/drivers/include/drivers/mtdnand.h
new file mode 100644
index 0000000000..2e836cb2fb
--- /dev/null
+++ b/components/drivers/include/drivers/mtdnand.h
@@ -0,0 +1,101 @@
+/*
+ * Copyright (c) 2006-2018, RT-Thread Development Team
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Change Logs:
+ * Date Author Notes
+ 2018-09-10 heyuanjie87 first version
+
+ */
+
+#ifndef _MTDNAND_H_
+#define _MTDNAND_H_
+
+#include "mtd.h"
+
+ /* Status bits */
+#define NAND_STATUS_FAIL 0x01
+#define NAND_STATUS_FAIL_N1 0x02
+#define NAND_STATUS_WP 0x80
+
+typedef enum
+{
+ NAND_CMD_PAGE_RD, /* read data to chip's page buffer,do WaitBusy after this cmd in low driver */
+ NAND_CMD_PAGE_WR0, /* write data to chip's page buffer */
+ NAND_CMD_PAGE_WR1, /* do flash programe */
+ NAND_CMD_BLK_ERASE, /* erase block */
+ NAND_CMD_ECC_EN, /* enable gen HWECC */
+ NAND_CMD_ECC_DIS /* disable gen HWECC */
+} nand_cmd_t;
+
+typedef enum
+{
+ NAND_ECCM_NONE,
+ NAND_ECCM_HW,
+} nand_eccmode_t;
+
+struct nand_chip;
+struct nand_ops;
+
+/**
+* struct nand_buffers - buffer structure for read/write
+* @ecccalc: buffer pointer for calculated ECC, size is oobsize.
+* @ecccode: buffer pointer for ECC read from flash, size is oobsize.
+*
+*/
+struct nand_buffers
+{
+ uint8_t *ecccalc;
+ uint8_t *ecccode;
+};
+
+struct nand_ecc
+{
+ uint8_t mode; /* nand_eccmode_t */
+ uint8_t bytes; /* gen ecc bytes per ecc step(usually 3) */
+ uint16_t stepsize:12; /* min 256 */
+ uint16_t _step:4; /* */
+
+ /* driver must set the two interface if HWECC */
+ void (*calculate)(struct nand_chip *chip, const uint8_t *dat, uint8_t *ecc_code);
+ /* return max bit flips if can't correct,return -1 ECC is error(0 success) */
+ int(*correct)(struct nand_chip *chip, uint8_t *dat, uint8_t *read_ecc, uint8_t *calc_ecc);
+ /* ignore if NONECC */
+ const struct mtd_oob_region *layout;
+};
+
+typedef struct nand_chip
+{
+ rt_mtd_t parent;
+
+ /* driver must init these */
+ const struct nand_ops *ops;
+ struct nand_ecc ecc;
+ const struct mtd_oob_region *freelayout;
+
+ /* driver do not touch */
+ struct nand_buffers buffers;
+ uint8_t *oob_poi;
+ uint8_t *pagebuf;
+ uint32_t size;
+ uint16_t oobsize;
+ uint8_t pages_pb;
+ uint16_t page_size;
+ int(*read_page)(struct nand_chip *chip, uint8_t *buf, int oob_required, int page);
+ int(*write_page)(struct nand_chip *chip, const uint8_t *buf, int oob_required, int page);
+}rt_nand_t;
+
+struct nand_ops
+{
+ int(*cmdfunc)(rt_nand_t *nand, int cmd, int page, int offset); /* send nand operation cmd, return Status bits(0 success),
+ if nand is busy please wait in low driver */
+ int(*read_buf)(rt_nand_t *nand, uint8_t *buf, int len); /* read data from nand chip's page buffer */
+ int(*write_buf)(rt_nand_t *nand, const uint8_t *buf, int len);/* write data to nand chip's page buffer */
+ int(*isbad)(rt_nand_t *nand, uint32_t blk); /* if NULL OOB[0] used as bad mark(not 0xff is bad) */
+ int(*markbad)(rt_nand_t *nand, uint32_t blk); /* if NULL OOB[0] used as bad mark(set to 0x00) */
+};
+
+int rt_mtd_nand_init(rt_nand_t *nand, int blk_size, int page_size, int oob_size);
+
+#endif /* MTD_NAND_H_ */
diff --git a/components/drivers/include/drivers/mtdnor.h b/components/drivers/include/drivers/mtdnor.h
new file mode 100644
index 0000000000..ccb7466b4b
--- /dev/null
+++ b/components/drivers/include/drivers/mtdnor.h
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2006-2018, RT-Thread Development Team
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Change Logs:
+ * Date Author Notes
+ 2018-09-10 heyuanjie87 first version
+
+ */
+
+#ifndef __MTDNOR_H__
+#define __MTDNOR_H__
+
+#include <drivers/mtd.h>
+
+struct nor_ops;
+
+typedef struct
+{
+ rt_mtd_t parent;
+
+ const struct nor_ops *ops; /* operations interface */
+}rt_nor_t;
+
+struct nor_ops
+{
+ int (*erase)(rt_nor_t *nor, loff_t addr, size_t len); /* return success erased len or error code */
+ int (*read)(rt_nor_t *nor, loff_t addr, uint8_t *buf, size_t len); /* return success data size or error code */
+ int (*write)(rt_nor_t *nor, loff_t addr, const uint8_t *buf, size_t len); /* return success data size or error code */
+};
+
+int rt_mtd_nor_init(rt_nor_t *nor, int blksize);
+
+#endif
diff --git a/components/drivers/include/drivers/pin.h b/components/drivers/include/drivers/pin.h
index de8fd21acc..ca35407932 100644
--- a/components/drivers/include/drivers/pin.h
+++ b/components/drivers/include/drivers/pin.h
@@ -1,21 +1,7 @@
/*
- * File : pin.h
- * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2015, RT-Thread Development Team
+ * Copyright (c) 2006-2018, RT-Thread Development Team
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
diff --git a/components/drivers/include/drivers/pm.h b/components/drivers/include/drivers/pm.h
new file mode 100644
index 0000000000..94d4c8559b
--- /dev/null
+++ b/components/drivers/include/drivers/pm.h
@@ -0,0 +1,181 @@
+/*
+ * Copyright (c) 2006-2018, RT-Thread Development Team
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Change Logs:
+ * Date Author Notes
+ * 2012-06-02 Bernard the first version
+ * 2018-08-02 Tanek split run and sleep modes, support custom mode
+ */
+
+#ifndef __PM_H__
+#define __PM_H__
+
+#include <rtthread.h>
+
+#ifndef PM_HAS_CUSTOM_CONFIG
+
+/* All modes used for rt_pm_request() adn rt_pm_release() */
+enum
+{
+ /* run modes */
+ PM_RUN_MODE_NORMAL = 0,
+
+ /* sleep modes */
+ PM_SLEEP_MODE_SLEEP,
+ PM_SLEEP_MODE_TIMER,
+ PM_SLEEP_MODE_SHUTDOWN,
+};
+
+/* The name of all modes used in the msh command "pm_dump" */
+#define PM_MODE_NAMES \
+{ \
+ "Running Mode", \
+ \
+ "Sleep Mode", \
+ "Timer Mode", \
+ "Shutdown Mode", \
+}
+
+/* run mode count : 1 */
+#define PM_RUN_MODE_COUNT 1
+/* sleep mode count : 3 */
+#define PM_SLEEP_MODE_COUNT 3
+
+/* support redefining default run mode */
+#ifndef PM_RUN_MODE_DEFAULT
+#define PM_RUN_MODE_DEFAULT 0
+#endif
+
+/* support redefining default sleep mode */
+#ifndef PM_SLEEP_MODE_DEFAULT
+#define PM_SLEEP_MODE_DEFAULT (PM_SLEEP_MODE_START)
+#endif
+
+/* support redefining the minimum tick into sleep mode */
+#ifndef PM_MIN_ENTER_SLEEP_TICK
+#define PM_MIN_ENTER_SLEEP_TICK (1)
+#endif
+
+#else /* PM_HAS_CUSTOM_CONFIG */
+
+#include <pm_cfg.h>
+
+#ifndef PM_RUN_MODE_COUNT
+#error "You must defined PM_RUN_MODE_COUNT on pm_cfg.h"
+#endif
+
+#ifndef PM_SLEEP_MODE_COUNT
+#error "You must defined PM_SLEEP_MODE_COUNT on pm_cfg.h"
+#endif
+
+#ifndef PM_MODE_DEFAULT
+#error "You must defined PM_MODE_DEFAULT on pm_cfg.h"
+#endif
+
+#ifndef PM_MODE_NAMES
+#error "You must defined PM_MODE_NAMES on pm_cfg.h"
+#endif
+
+#ifndef PM_RUN_MODE_DEFAULT
+#error "You must defined PM_RUN_MODE_DEFAULT on pm_cfg.h"
+#endif
+
+/* The default sleep mode(PM_SLEEP_MODE_DEFAULT) are not required.
+ * If the default mode is defined, it is requested once in rt_system_pm_init()
+ */
+
+#endif /* PM_HAS_CUSTOM_CONFIG */
+
+/* run mode must start at 0 */
+#define PM_RUN_MODE_START 0
+/* the values of the run modes and sleep mode must be consecutive */
+#define PM_SLEEP_MODE_START PM_RUN_MODE_COUNT
+/* all mode count */
+#define PM_MODE_COUNT (PM_RUN_MODE_COUNT + PM_SLEEP_MODE_COUNT)
+/* The last mode, will be request in rt_system_pm_init() */
+#define PM_MODE_MAX (PM_RUN_MODE_COUNT + PM_SLEEP_MODE_COUNT - 1)
+
+#if PM_MODE_COUNT > 32
+#error "The number of modes cannot exceed 32"
+#endif
+
+/**
+ * device control flag to request or release power
+ */
+#define RT_PM_DEVICE_CTRL_REQUEST 0x01
+#define RT_PM_DEVICE_CTRL_RELEASE 0x02
+
+struct rt_pm;
+
+/**
+ * low power mode operations
+ */
+struct rt_pm_ops
+{
+ void (*enter)(struct rt_pm *pm);
+ void (*exit)(struct rt_pm *pm);
+
+#if PM_RUN_MODE_COUNT > 1
+ void (*frequency_change)(struct rt_pm *pm, rt_uint32_t frequency);
+#endif
+
+ void (*timer_start)(struct rt_pm *pm, rt_uint32_t timeout);
+ void (*timer_stop)(struct rt_pm *pm);
+ rt_tick_t (*timer_get_tick)(struct rt_pm *pm);
+};
+
+struct rt_device_pm_ops
+{
+#if PM_RUN_MODE_COUNT > 1
+ void (*frequency_change)(const struct rt_device* device);
+#endif
+
+ void (*suspend)(const struct rt_device* device);
+ void (*resume) (const struct rt_device* device);
+};
+
+struct rt_device_pm
+{
+ const struct rt_device* device;
+ const struct rt_device_pm_ops* ops;
+};
+
+/**
+ * power management
+ */
+struct rt_pm
+{
+ struct rt_device parent;
+
+ /* modes */
+ rt_uint8_t modes[PM_MODE_COUNT];
+ rt_uint8_t current_mode; /* current pm mode */
+ rt_uint8_t exit_count;
+
+ /* the list of device, which has PM feature */
+ rt_uint8_t device_pm_number;
+ struct rt_device_pm* device_pm;
+ struct rt_semaphore device_lock;
+
+ /* if the mode has timer, the corresponding bit is 1*/
+ rt_uint32_t timer_mask;
+
+ const struct rt_pm_ops *ops;
+};
+
+void rt_pm_enter(void);
+void rt_pm_exit(void);
+
+void rt_pm_request(rt_ubase_t mode);
+void rt_pm_release(rt_ubase_t mode);
+
+void rt_pm_register_device(struct rt_device* device, const struct rt_device_pm_ops* ops);
+void rt_pm_unregister_device(struct rt_device* device);
+
+void rt_system_pm_init(const struct rt_pm_ops *ops,
+ rt_uint8_t timer_mask,
+ void *user_data);
+
+#endif /* __PM_H__ */
diff --git a/components/drivers/include/drivers/rt_drv_pwm.h b/components/drivers/include/drivers/rt_drv_pwm.h
index ffd08edabb..16de4c6ab8 100644
--- a/components/drivers/include/drivers/rt_drv_pwm.h
+++ b/components/drivers/include/drivers/rt_drv_pwm.h
@@ -1,21 +1,7 @@
/*
- * File : rt_drv_pwm.h
- * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2018, RT-Thread Development Team
+ * Copyright (c) 2006-2018, RT-Thread Development Team
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
@@ -25,6 +11,9 @@
#ifndef __DRV_PWM_H_INCLUDE__
#define __DRV_PWM_H_INCLUDE__
+#include <rtthread.h>
+#include <rtdevice.h>
+
#define PWM_CMD_ENABLE (128 + 0)
#define PWM_CMD_DISABLE (128 + 1)
#define PWM_CMD_SET (128 + 2)
@@ -49,6 +38,10 @@ struct rt_device_pwm
const struct rt_pwm_ops *ops;
};
-extern rt_err_t rt_device_pwm_register(struct rt_device_pwm *device, const char *name, const struct rt_pwm_ops *ops, const void *user_data);
+rt_err_t rt_device_pwm_register(struct rt_device_pwm *device, const char *name, const struct rt_pwm_ops *ops, const void *user_data);
+
+rt_err_t rt_pwm_enable(struct rt_device_pwm *device, int channel);
+rt_err_t rt_pwm_disable(struct rt_device_pwm *device, int channel);
+rt_err_t rt_pwm_set(struct rt_device_pwm *device, int channel, rt_uint32_t period, rt_uint32_t pulse);
#endif /* __DRV_PWM_H_INCLUDE__ */
diff --git a/components/drivers/include/drivers/rtc.h b/components/drivers/include/drivers/rtc.h
index 7e89bd3704..1cd88a7be3 100644
--- a/components/drivers/include/drivers/rtc.h
+++ b/components/drivers/include/drivers/rtc.h
@@ -1,21 +1,7 @@
/*
- * File : rtc.h
- * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2006 - 2012, RT-Thread Development Team
+ * Copyright (c) 2006-2018, RT-Thread Development Team
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
diff --git a/components/drivers/include/drivers/sd.h b/components/drivers/include/drivers/sd.h
index 7d5fcacade..e096df9372 100644
--- a/components/drivers/include/drivers/sd.h
+++ b/components/drivers/include/drivers/sd.h
@@ -1,21 +1,7 @@
/*
- * File : sd.h
- * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2006, RT-Thread Development Team
+ * Copyright (c) 2006-2018, RT-Thread Development Team
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
diff --git a/components/drivers/include/drivers/sdio.h b/components/drivers/include/drivers/sdio.h
index 2cd1c7dfd1..e4bf4a048f 100644
--- a/components/drivers/include/drivers/sdio.h
+++ b/components/drivers/include/drivers/sdio.h
@@ -1,21 +1,7 @@
/*
- * File : sdio.h
- * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2006, RT-Thread Development Team
+ * Copyright (c) 2006-2018, RT-Thread Development Team
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
diff --git a/components/drivers/include/drivers/sdio_func_ids.h b/components/drivers/include/drivers/sdio_func_ids.h
index 9fee7c238a..79085a5933 100644
--- a/components/drivers/include/drivers/sdio_func_ids.h
+++ b/components/drivers/include/drivers/sdio_func_ids.h
@@ -1,21 +1,7 @@
/*
- * File : sdio_func_ids.h
- * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2006, RT-Thread Development Team
+ * Copyright (c) 2006-2018, RT-Thread Development Team
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
diff --git a/components/drivers/include/drivers/serial.h b/components/drivers/include/drivers/serial.h
index 2abf925854..af5d626251 100644
--- a/components/drivers/include/drivers/serial.h
+++ b/components/drivers/include/drivers/serial.h
@@ -1,21 +1,7 @@
/*
- * File : serial.h
- * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2006 - 2012, RT-Thread Development Team
+ * Copyright (c) 2006-2018, RT-Thread Development Team
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
diff --git a/components/drivers/include/drivers/spi.h b/components/drivers/include/drivers/spi.h
index 0fbaabe5dd..84b589ace0 100644
--- a/components/drivers/include/drivers/spi.h
+++ b/components/drivers/include/drivers/spi.h
@@ -1,21 +1,7 @@
/*
- * File : spi.h
- * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2006 - 2012, RT-Thread Development Team
+ * Copyright (c) 2006-2018, RT-Thread Development Team
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
diff --git a/components/drivers/include/drivers/usb_common.h b/components/drivers/include/drivers/usb_common.h
index 922682b1af..c26d83391e 100644
--- a/components/drivers/include/drivers/usb_common.h
+++ b/components/drivers/include/drivers/usb_common.h
@@ -1,21 +1,7 @@
/*
- * File : usb_common.h
- * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2012, RT-Thread Development Team
+ * Copyright (c) 2006-2018, RT-Thread Development Team
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
@@ -230,6 +216,19 @@ extern "C" {
#define HID_REPORT_ID_GENERAL 5
#define HID_REPORT_ID_MOUSE 6
+/*
+ * Time of usb timeout
+ */
+#ifndef USB_TIMEOUT_BASIC
+#define USB_TIMEOUT_BASIC (RT_TICK_PER_SECOND) /* 1s */
+#endif
+#ifndef USB_TIMEOUT_LONG
+#define USB_TIMEOUT_LONG (RT_TICK_PER_SECOND * 5) /* 5s */
+#endif
+#ifndef USB_DEBOUNCE_TIME
+#define USB_DEBOUNCE_TIME (RT_TICK_PER_SECOND / 5) /* 0.2s */
+#endif
+
#define uswap_32(x) \
((((x) & 0xff000000) >> 24) | \
(((x) & 0x00ff0000) >> 8) | \
diff --git a/components/drivers/include/drivers/usb_device.h b/components/drivers/include/drivers/usb_device.h
index 572c7d0dff..26f0c4cf4a 100644
--- a/components/drivers/include/drivers/usb_device.h
+++ b/components/drivers/include/drivers/usb_device.h
@@ -1,21 +1,7 @@
/*
- * File : usb_device.h
- * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2012, RT-Thread Development Team
+ * Copyright (c) 2006-2018, RT-Thread Development Team
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
@@ -31,6 +17,10 @@
#include <rtthread.h>
#include "drivers/usb_common.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/* Vendor ID */
#ifdef USB_VENDOR_ID
#define _VENDOR_ID USB_VENDOR_ID
@@ -467,4 +457,9 @@ rt_inline void usbd_os_proerty_descriptor_send(ufunction_t func, ureq_t setup, u
}
rt_usbd_ep0_write(func->device, data, setup->wLength);
}
+
+#ifdef __cplusplus
+}
+#endif
+
#endif
diff --git a/components/drivers/include/drivers/usb_host.h b/components/drivers/include/drivers/usb_host.h
index 92adaa3d47..2a68f4edb5 100644
--- a/components/drivers/include/drivers/usb_host.h
+++ b/components/drivers/include/drivers/usb_host.h
@@ -1,21 +1,7 @@
/*
- * File : usb_host.h
- * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2011, RT-Thread Development Team
+ * Copyright (c) 2006-2018, RT-Thread Development Team
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
diff --git a/components/drivers/include/drivers/watchdog.h b/components/drivers/include/drivers/watchdog.h
index 5c74dc82be..f80ded58aa 100644
--- a/components/drivers/include/drivers/watchdog.h
+++ b/components/drivers/include/drivers/watchdog.h
@@ -1,21 +1,7 @@
/*
- * File : watchdog.h
- * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2012-2014, Shanghai Real-Thread Electronic Technology Co.,Ltd
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * COPYRIGHT (C) 2018, Real-Thread Information Technology Ltd
+ *
+ * SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
diff --git a/components/drivers/include/drivers/wlan.h b/components/drivers/include/drivers/wlan.h
new file mode 100644
index 0000000000..724e61da78
--- /dev/null
+++ b/components/drivers/include/drivers/wlan.h
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2006-2018, RT-Thread Development Team
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Change Logs:
+ * Date Author Notes
+ * 2018-09-15 tyx the first version
+ */
+
+#ifndef __WLAN_H__
+#define __WLAN_H__
+
+#include <rtthread.h>
+#include <wlan_dev.h>
+#include <wlan_cfg.h>
+#include <wlan_mgnt.h>
+#include <wlan_prot.h>
+#include <wlan_workqueue.h>
+
+#endif
diff --git a/components/drivers/include/ipc/completion.h b/components/drivers/include/ipc/completion.h
index e3e883ba8b..acfcaa3995 100644
--- a/components/drivers/include/ipc/completion.h
+++ b/components/drivers/include/ipc/completion.h
@@ -1,3 +1,11 @@
+/*
+ * Copyright (c) 2006-2018, RT-Thread Development Team
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Change Logs:
+ * Date Author Notes
+ */
#ifndef COMPLETION_H_
#define COMPLETION_H_
diff --git a/components/drivers/include/ipc/dataqueue.h b/components/drivers/include/ipc/dataqueue.h
index 44ffed655e..f584c267bf 100644
--- a/components/drivers/include/ipc/dataqueue.h
+++ b/components/drivers/include/ipc/dataqueue.h
@@ -1,3 +1,11 @@
+/*
+ * Copyright (c) 2006-2018, RT-Thread Development Team
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Change Logs:
+ * Date Author Notes
+ */
#ifndef DATAQUEUE_H__
#define DATAQUEUE_H__
diff --git a/components/drivers/include/ipc/pipe.h b/components/drivers/include/ipc/pipe.h
index ca20c2a453..25b19f540d 100644
--- a/components/drivers/include/ipc/pipe.h
+++ b/components/drivers/include/ipc/pipe.h
@@ -1,3 +1,11 @@
+/*
+ * Copyright (c) 2006-2018, RT-Thread Development Team
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Change Logs:
+ * Date Author Notes
+ */
#ifndef PIPE_H__
#define PIPE_H__
diff --git a/components/drivers/include/ipc/poll.h b/components/drivers/include/ipc/poll.h
index 0279fe3b5d..8c68a96af8 100644
--- a/components/drivers/include/ipc/poll.h
+++ b/components/drivers/include/ipc/poll.h
@@ -1,21 +1,7 @@
/*
- * File : poll.h
- * This file is part of Device File System in RT-Thread RTOS
- * COPYRIGHT (C) 2006-2017, RT-Thread Development Team
+ * Copyright (c) 2006-2018, RT-Thread Development Team
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
diff --git a/components/drivers/include/ipc/ringblk_buf.h b/components/drivers/include/ipc/ringblk_buf.h
new file mode 100644
index 0000000000..653fa2a60b
--- /dev/null
+++ b/components/drivers/include/ipc/ringblk_buf.h
@@ -0,0 +1,101 @@
+/*
+ * Copyright (c) 2006-2018, RT-Thread Development Team
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Change Logs:
+ * Date Author Notes
+ * 2018-08-25 armink the first version
+ */
+
+#ifndef _RINGBLK_BUF_H_
+#define _RINGBLK_BUF_H_
+
+/*
+ * Introduction:
+ * The rbb is the ring buffer which is composed with many blocks. It is different from the ring buffer.
+ * The ring buffer is only composed with chars. The rbb put and get supported zero copies. So the rbb
+ * is very suitable for put block and get block by a certain order. Such as DMA block transmit,
+ * communicate frame send/recv, and so on.
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+enum rt_rbb_status
+{
+ /* unused status when first initialize or after blk_free() */
+ RT_RBB_BLK_UNUSED,
+ /* initialized status after blk_alloc() */
+ RT_RBB_BLK_INITED,
+ /* put status after blk_put() */
+ RT_RBB_BLK_PUT,
+ /* get status after blk_get() */
+ RT_RBB_BLK_GET,
+};
+typedef enum rt_rbb_status rt_rbb_status_t;
+
+/**
+ * the block of rbb
+ */
+struct rt_rbb_blk
+{
+ rt_rbb_status_t status :8;
+ /* less then 2^24 */
+ rt_size_t size :24;
+ rt_uint8_t *buf;
+ rt_slist_t list;
+};
+typedef struct rt_rbb_blk *rt_rbb_blk_t;
+
+/**
+ * Rbb block queue: the blocks (from block1->buf to blockn->buf) memory which on this queue is continuous.
+ */
+struct rt_rbb_blk_queue
+{
+ rt_rbb_blk_t blocks;
+ rt_size_t blk_num;
+};
+typedef struct rt_rbb_blk_queue *rt_rbb_blk_queue_t;
+
+/**
+ * ring block buffer
+ */
+struct rt_rbb
+{
+ rt_uint8_t *buf;
+ rt_size_t buf_size;
+ /* all of blocks */
+ rt_rbb_blk_t blk_set;
+ rt_size_t blk_max_num;
+ /* saved the initialized and put status blocks */
+ rt_slist_t blk_list;
+};
+typedef struct rt_rbb *rt_rbb_t;
+
+/* rbb (ring block buffer) API */
+void rt_rbb_init(rt_rbb_t rbb, rt_uint8_t *buf, rt_size_t buf_size, rt_rbb_blk_t block_set, rt_size_t blk_max_num);
+rt_rbb_t rt_rbb_create(rt_size_t buf_size, rt_size_t blk_max_num);
+void rt_rbb_destroy(rt_rbb_t rbb);
+rt_size_t rt_rbb_get_buf_size(rt_rbb_t rbb);
+
+/* rbb block API */
+rt_rbb_blk_t rt_rbb_blk_alloc(rt_rbb_t rbb, rt_size_t blk_size);
+void rt_rbb_blk_put(rt_rbb_blk_t block);
+rt_rbb_blk_t rt_rbb_blk_get(rt_rbb_t rbb);
+void rt_rbb_blk_free(rt_rbb_t rbb, rt_rbb_blk_t block);
+
+/* rbb block queue API */
+rt_size_t rt_rbb_blk_queue_get(rt_rbb_t rbb, rt_size_t queue_data_len, rt_rbb_blk_queue_t blk_queue);
+rt_size_t rt_rbb_blk_queue_len(rt_rbb_blk_queue_t blk_queue);
+rt_uint8_t *rt_rbb_blk_queue_buf(rt_rbb_blk_queue_t blk_queue);
+void rt_rbb_blk_queue_free(rt_rbb_t rbb, rt_rbb_blk_queue_t blk_queue);
+rt_size_t rt_rbb_next_blk_queue_len(rt_rbb_t rbb);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _RINGBLK_BUF_H_ */
diff --git a/components/drivers/include/ipc/ringbuffer.h b/components/drivers/include/ipc/ringbuffer.h
index 4cfab6d69c..4487d02c47 100644
--- a/components/drivers/include/ipc/ringbuffer.h
+++ b/components/drivers/include/ipc/ringbuffer.h
@@ -1,3 +1,11 @@
+/*
+ * Copyright (c) 2006-2018, RT-Thread Development Team
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Change Logs:
+ * Date Author Notes
+ */
#ifndef RINGBUFFER_H__
#define RINGBUFFER_H__
diff --git a/components/drivers/include/ipc/waitqueue.h b/components/drivers/include/ipc/waitqueue.h
index 8cb0989f73..e26ec1e896 100644
--- a/components/drivers/include/ipc/waitqueue.h
+++ b/components/drivers/include/ipc/waitqueue.h
@@ -1,21 +1,7 @@
/*
- * File : waitqueue.h
- * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2006 - 2018, RT-Thread Development Team
+ * Copyright (c) 2006-2018, RT-Thread Development Team
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
diff --git a/components/drivers/include/ipc/workqueue.h b/components/drivers/include/ipc/workqueue.h
index 0b044b5ad3..9e23e181b1 100644
--- a/components/drivers/include/ipc/workqueue.h
+++ b/components/drivers/include/ipc/workqueue.h
@@ -1,3 +1,11 @@
+/*
+ * Copyright (c) 2006-2018, RT-Thread Development Team
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Change Logs:
+ * Date Author Notes
+ */
#ifndef WORKQUEUE_H__
#define WORKQUEUE_H__
diff --git a/components/drivers/include/rtdevice.h b/components/drivers/include/rtdevice.h
index e3c826fe53..1843432768 100644
--- a/components/drivers/include/rtdevice.h
+++ b/components/drivers/include/rtdevice.h
@@ -1,21 +1,7 @@
/*
- * File : rtdevice.h
- * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2006 - 2012, RT-Thread Development Team
+ * Copyright (c) 2006-2018, RT-Thread Development Team
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
@@ -35,6 +21,7 @@
#include "ipc/waitqueue.h"
#include "ipc/pipe.h"
#include "ipc/poll.h"
+#include "ipc/ringblk_buf.h"
#ifdef __cplusplus
extern "C" {
@@ -116,6 +103,21 @@ extern "C" {
#include "drivers/rt_drv_pwm.h"
#endif
+#ifdef RT_USING_PM
+#include "drivers/pm.h"
+#endif
+
+#ifdef RT_USING_WIFI
+#include "drivers/wlan.h"
+#endif
+
+#ifdef MTD_USING_NOR
+#include "drivers/mtdnor.h"
+#endif
+#ifdef MTD_USING_NAND
+#include "drivers/mtdnand.h"
+#endif
+
#ifdef __cplusplus
}
#endif