Merge pull request #1 from RT-Thread/master

test
This commit is contained in:
yangjie11
2018-11-28 19:02:11 +08:00
committed by GitHub
2698 changed files with 823932 additions and 230864 deletions
+8
View File
@@ -26,3 +26,11 @@ tools/kconfig-frontends/kconfig-mconf
packages
cconfig.h
GPUCache
#cscope files
cscope.*
ncscope.*
#ctag files
tags
+7 -2
View File
@@ -12,7 +12,7 @@ before_script:
# - "[ $RTT_TOOL_CHAIN = 'sourcery-arm' ] && export RTT_EXEC_PATH=/usr/bin && arm-none-eabi-gcc --version || true"
# - "[ $RTT_TOOL_CHAIN = 'sourcery-arm' ] && curl -s https://sourcery.mentor.com/public/gnu_toolchain/arm-none-eabi/arm-2014.05-28-arm-none-eabi-i686-pc-linux-gnu.tar.bz2 | sudo tar xjf - -C /opt && export RTT_EXEC_PATH=/opt/arm-2014.05/bin && /opt/arm-2014.05/bin/arm-none-eabi-gcc --version || true"
- "[ $RTT_TOOL_CHAIN = 'sourcery-arm' ] && wget -q https://github.com/RT-Thread/toolchains-ci/releases/download/arm-2017q2-v6/gcc-arm-none-eabi-6-2017-q2-update-linux.tar.bz2 && sudo tar xjf gcc-arm-none-eabi-6-2017-q2-update-linux.tar.bz2 -C /opt && export RTT_EXEC_PATH=/opt/gcc-arm-none-eabi-6-2017-q2-update/bin && /opt/gcc-arm-none-eabi-6-2017-q2-update/bin/arm-none-eabi-gcc --version || true"
- "[ $RTT_TOOL_CHAIN = 'sourcery-mips' ] && curl -s https://sourcery.mentor.com/public/gnu_toolchain/mips-sde-elf/mips-2012.09-98-mips-sde-elf-i686-pc-linux-gnu.tar.bz2 | sudo tar xjf - -C /opt && export RTT_EXEC_PATH=/opt/mips-2012.09/bin && /opt/mips-2012.09/bin/mips-sde-elf-gcc --version || true"
- "[ $RTT_TOOL_CHAIN = 'sourcery-mips' ] && curl -s https://sourcery.mentor.com/public/gnu_toolchain/mips-sde-elf/mips-2016.05-7-mips-sde-elf-i686-pc-linux-gnu.tar.bz2 | sudo tar xjf - -C /opt && export RTT_EXEC_PATH=/opt/mips-2016.05/bin && /opt/mips-2016.05/bin/mips-sde-elf-gcc --version || true"
# - "[ $RTT_TOOL_CHAIN = 'sourcery-ppc' ] && curl -s https://sourcery.mentor.com/public/gnu_toolchain/powerpc-eabi/freescale-2011.03-39-powerpc-eabi-i686-pc-linux-gnu.tar.bz2 | sudo tar xjf - -C /opt && export RTT_EXEC_PATH=/opt/freescale-2011.03/bin && /opt/freescale-2011.03/bin/powerpc-eabi-gcc --version || true"
# - "[ $RTT_TOOL_CHAIN = 'atmel-avr32' ] && curl -s http://www.atmel.com/images/avr32-gnu-toolchain-3.4.1.348-linux.any.x86.tar.gz | sudo tar xzf - -C /opt && export RTT_EXEC_PATH=/opt/avr32-gnu-toolchain-linux_x86/bin && /opt/avr32-gnu-toolchain-linux_x86/bin/avr32-gcc --version && curl -sO http://www.atmel.com/images/avr-headers-3.2.3.970.zip && unzip -qq avr-headers-3.2.3.970.zip -d bsp/$RTT_BSP || true"
- export RTT_ROOT=`pwd`
@@ -24,7 +24,7 @@ script:
env:
# - RTT_BSP='simulator' RTT_CC='clang-analyze' RTT_EXEC_PATH=/usr/share/clang/scan-build
- RTT_BSP='CME_M7' RTT_TOOL_CHAIN='sourcery-arm'
# - RTT_BSP='apollo2' RTT_TOOL_CHAIN='sourcery-arm'
- RTT_BSP='apollo2' RTT_TOOL_CHAIN='sourcery-arm'
- RTT_BSP='asm9260t' RTT_TOOL_CHAIN='sourcery-arm'
- RTT_BSP='at91sam9260' RTT_TOOL_CHAIN='sourcery-arm'
- RTT_BSP='allwinner_tina' RTT_TOOL_CHAIN='sourcery-arm'
@@ -33,6 +33,7 @@ env:
# - RTT_BSP='bf533' # no scons
- RTT_BSP='efm32' RTT_TOOL_CHAIN='sourcery-arm'
# - RTT_BSP='gd32450z-eval' RTT_TOOL_CHAIN='sourcery-arm'
- RTT_BSP='gkipc' RTT_TOOL_CHAIN='sourcery-arm'
- RTT_BSP='lm3s8962' RTT_TOOL_CHAIN='sourcery-arm'
- RTT_BSP='lm3s9b9x' RTT_TOOL_CHAIN='sourcery-arm'
- RTT_BSP='lm4f232' RTT_TOOL_CHAIN='sourcery-arm'
@@ -58,8 +59,11 @@ env:
- RTT_BSP='mini2440' RTT_TOOL_CHAIN='sourcery-arm'
# - RTT_BSP='mini4020' # no scons
# - RTT_BSP='nios_ii' # no scons
- RTT_BSP='nuvoton_nuc472' RTT_TOOL_CHAIN='sourcery-arm'
- RTT_BSP='nuvoton_m05x' RTT_TOOL_CHAIN='sourcery-arm'
# - RTT_BSP='pic32ethernet' # no scons
- RTT_BSP='qemu-vexpress-a9' RTT_TOOL_CHAIN='sourcery-arm'
- RTT_BSP='qemu-vexpress-gemini' RTT_TOOL_CHAIN='sourcery-arm'
- RTT_BSP='sam7x' RTT_TOOL_CHAIN='sourcery-arm'
# - RTT_BSP='simulator' # x86
- RTT_BSP='stm32f0x' RTT_TOOL_CHAIN='sourcery-arm'
@@ -76,6 +80,7 @@ env:
- RTT_BSP='stm32f429-disco' RTT_TOOL_CHAIN='sourcery-arm'
- RTT_BSP='stm32l475-iot-disco' RTT_TOOL_CHAIN='sourcery-arm'
- RTT_BSP='stm32l476-nucleo' RTT_TOOL_CHAIN='sourcery-arm'
- RTT_BSP='stm32h743-nucleo' RTT_TOOL_CHAIN='sourcery-arm'
# - RTT_BSP='taihu' RTT_TOOL_CHAIN='sourcery-ppc'
# - RTT_BSP='upd70f3454' # iar
# - RTT_BSP='x86' # x86
-9
View File
@@ -1,9 +0,0 @@
{
"C_Cpp.dimInactiveRegions": false,
"files.exclude": {
"**/.git": true,
"**/build": true,
"bsp" : true,
},
"editor.renderWhitespace": "all"
}
-340
View File
@@ -1,340 +0,0 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Library General
Public License instead of this License.
+130
View File
@@ -1,3 +1,133 @@
# RT-Thread v3.1.1 Change Log
## Kernel
* Support the configuration of the upward growth stack which is defined by the `ARCH_CPU_STACK_GROWS_UPWARD` macro. Because there are fewer ARCH for stacks growing upward, this configuration item does not display directly in menuconfig. When a CPU ARCH needs stacks growing upward, the configuration of `ARCH_CPU_STACK_GROWS_UPWARD` can be selected by BSP Kconfig file in default.
* Support for ARMCC V6 and later compiler (LLVM-based Compiler); currently it's mainly used in Keil MDK IDE. Please notes that the "Warnings" needs to use `Moderate Warnings` in project configuration in C/C++ (AC6) TAB; After using ARMCC v6, RT-Thread will add an additional `CLANG_ARM` macro definition; (liruncong, nongxiaoming, bernard)
* The `RT_USING_IDLE_HOOK` configuration in Kconfig becomes a separate configuration item, not limited to `RT_USING_HOOK`; (geniusgogo)
## Components
* Improve the PWM driver framework and add more interfaces.
* Fix the F_SETFL handling in ioctrl function; Fix the return value issue of fcntl function which is always 0 value.
* Fix the memheap object type issue when creating a ramfs object.
* Add power management framework for low power applications.
* Add multi-segment support for read and write operations in MC/SDIO driver framework (for stm32, you can choose a separate stm32_sdio package); (weety)
* Add ringblk_buf component for the block mode but in ringbuffer applications;
* Improve WLAN management framework with unified interfaces, management, commands, to provide more friendly support to developers and users;
* Add the conditional macro in the finsh when the MSH component is not enabled, even if the code files are compiled.
* Remove gdbstub and move to rt-thread packages.
* Upgrade and improve SAL and AT components: (linuxhan, eddylin83, slyant, luofanlu, Hubert Xie, Lawlieta, zhaojuntao, armink)
* Fix the none cleared issue when closing socket in SAL, which lead to the socket is always holding.
* Fix the `select()` issue for UDP communication in AT component. Add the receiving data handling to complete the clearing of received event;
* Add the errno value when receive data timeout in at_recvfrom function in the AT component.
* Add the receive data timeout handling in at_client_recv function in the AT component.
* Fix a possible issue in fputc function implementation when using microlib;
* Add gmtime_r implementation for ARMCC, IAR tool chain;
* Improve time function support in IAR and support 64bit time; (hichard)
* DHCPD's support for IPv6;
* Remove lwIP-1.3.2 porting and add lwIP-2.1.0 porting; lwIP-2.0.2 is still the default version.
* Add a lightweight ulog component and automatically replace the debug macro of the original rtdbg.h when it's enable.
* USB stack update
* HOST, optimize the USB HOST timeout mechanism; fix the un-alignment visit issue in F4xx-HAL USB host driver;
* Device: Add the check when class drivers are illegally registered; Fix the un-aligned access issue in some platforms; optimize CDC VCOM classes, add the timeout mechanism and ID definition.
## BSP
* Upgrade the wlan adaptor to the new version of Wi-Fi management framework in amebaz BSP.
* Add airkiss wifi configuration code to amebaz BSP.
* Update Apollo2 BSP with ADC, GPIO, I2C, PDM, SPI, UART and other drivers; (Haleyl)
* BeagleBone BSP is changed to main function mode, and adds Kconfig configuration file.
* DM365 BSP adds Kconfig configuration file;
* Update HiFive1 BSP and add more documentation.
* Update imx6sx BSP to main function mode, and add Kconfig configuration file.
* Change the old imxrt1052-evk BSP. The imxrt1052-related BSPs are classified into the `bsp/imxrt` directory; A touch framework is added to `bsp/imxrt`, and later will be moved into `components/drivers` directory;
* Improve stm32f4xx-HAL BSP with PWM, I2C, USB Host driver; (XuanZe, xuzhuoyi)
* Improve stm32f10x BSP with CAN driver and increase I2C driver; (wuhanstudio, AubrCool)
* Improve stm32f10x-HAL BSP with I2C, IWG, PWM, RTC and other drivers, improve UART driver; (XuanZe)
* Improve stm32f429-disco BSP and add I2C, LCD, Touch driver; (xuzhuoyi)
* Improve x86 BSP, support dlmodule function; (SASANO Takayoshi, parai)
## Tool
* Modify the building script to support Python 3; <Python 3 patches have been submitted to scons and need to wait for next scons releasemaybe scons-3.0.2> (Arda)
* Add `scons --pyconfig` mode, which has a TK UI configurator; (weety)
* Support for GNU GCC 7/8 version toolchains (The `-std=c99` is not added into C-compiler flags), but please note: PThreads component failed in 2.5 and new version of newlib.
# RT-Thread 3.1.0 Change Log
## Kernel
* The main thread priority can be configured by Kconfig;
* Add the checking of kernel object type, which can effectively avoid the problem of continuing to use kernel objects after they are destroyed.
* Add the idle hook list to mount multiple idle hook, and can be configured by Kconfig.
* Add the device_ops operation set to reduce the footprint of device object.
* Remove the special memory operation in application module when using SLAB memory management algorithm.
* Move application module from the kernel to `libc/libdl`.
* Enhance the debug information output of `rtdbg.h` file.
* In Keil/IAR tool chain, the `RT_USED` is used to keep symbols and avoid to add more argument or section in link phrase.
## Components
* Remove all of external codes, which will be moved to packages in the future.
* Add initialization flag for shell, file system, network protocol stack etc to prevent repeated initialization;
* Enable the long file name feature of ELM FatFs in default.
* Change DFS FD to dynamic allocation mode. The maximum number of allocation is still DFS_FD_MAX.
* Add dfs_fdtable_get() function to get different fdtable;
* Add more DFS error messages, and provide easy to understand log when abnormal.
* Fix the disk format issue of FatFs file system when multiple FatFs file systems are mounted.
* Remove the folder enter feature in msh when input a folder name;
* Add `int finsh_set_prompt (const char * prompt);` routine for setting a custom prompt for msh;
* Add the VBUS configuration in Kconfig.
* Move the application module from kernel to `libc/libdl` component;
* Rewrite most of the management code for application module: replace the original object container with the object list; split the symbol resolution code into different processor architecture etc.
* Update the application module chapter in the programming guide, and change it into dynamic module chapter.
* Overwrite the exit() function of newlib to take over the processing of exit for a dlmodule.
* Add SAL (Socket Abstraction Layer) component for adapting different protocol stacks and network implementations, and update the relevant sections of the programming guide;
* Add AT component, including AT client, AT server and AT Socket function;
* Remove the poll/select API of DFS_NET and move them to SAL component.
* Remove the strong dependence of lwIP component for DFS_NET and replace it with Kconfig configuration in SAL.
* Add the DHCP server function with lwIP raw API;
* Fix the wait queue none-initialization issue in socket allocation of lwIP.
* When a thread is about to block on a wait queue, fix the wake up issue for `rt_wqueue_wakeup' is executed to wake up that thread;
* Add the PWM driver framework;
* Fix the sdio_irq_wakeup release issue in the MMC/SD framework.
* Fix the problem of DMA handling in the serial driver framework.
* Update SFUD to v1.0.6 version;
## BSP
* Fix the SP issue when hard fault occurs for ARM Cortex-M arch;
* Add C-Sky CK802 architecture porting;
* Add Realtek amebaz WiFi SOC (rtl8710bn) BSP;
* Update imxrt1052-evk firmware SDK to support B model chip.
* Fix the copying packets issue in the Godson 1C BSP when sending message.
* The Nuvoton m05x/m451 BSP are changed into the main() entry mode, and supports GCC compilation;
* Fix the inconsistency issue between touch range and LCD resolution in qemu-vexpress-a9.
* Add qemu-vexpress-gemini BSP for dual core A9 (RT-Thread + Linux) arch;
* Add the basic porting for Raspberry Pi 2B ;
* Add CAN and PWM drivers in stm32f4xx-HAL BSP;
* Optimize the GPIO driver in stm32f4xx-HAL BSP;
* Add UART3 driver in stm32f4xx-HAL BSP;
* Fix the I2C1 driver clock in stm32f10x BSP and WDG control interface.
* Add rt_hw_us_delay interface in stm32f10x-HAL BSP;
* Optimize the GPIO driver in stm32f10x-HAL BSP;
* Add GPIO driver and RTC driver in stm32f107 BSP;
## Tool
* ENV update to v1.0.0 final version.
* ENV added the China mirror for software package, which can speed up the software package download, update etc.
* Fix the ENV known bugs and enhance the interaction with users.
* Add building script to detect the version of GCC & newlib;
* Add building script to detect the version of armcc;
* Add `scons --dist` function to make distribution for a BSP.
* Add `scons - dist - strip' function to make a minimal files of distribution for a BSP.
* Add `ASFLAGS/LOCAL_ASFLAGS' parameters for defined a group and pass them to assembler;
* Fix some errors in building script under the Linux environment.
* Add the C-Sky CDK IDE project generation.
* Add `scons --target=vsc -s` to generate friendly configuration files for VSCode;
# RT-Thread 3.0.4 Change Log
## Kernel
+201
View File
@@ -0,0 +1,201 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
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.
+20 -9
View File
@@ -2,6 +2,7 @@
[中文页](README_zh.md) |
[![GitHub](https://img.shields.io/github/license/RT-Thread/rt-thread.svg)](https://github.com/RT-Thread/rt-thread/blob/master/LICENSE)
[![GitHub release](https://img.shields.io/github/release/RT-Thread/rt-thread.svg)](https://github.com/RT-Thread/rt-thread/releases)
[![Build Status](https://travis-ci.org/RT-Thread/rt-thread.svg)](https://travis-ci.org/RT-Thread/rt-thread)
[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/RT-Thread/rt-thread?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
@@ -16,13 +17,13 @@ RT-Thread RTOS like a traditional real-time operating system. The kernel has rea
* Device Driver;
* Component;
* Application Module
* Dyanmic Module
The device driver is more like a driver framework, UART, IIC, SPI, SDIO, USB device/host, EMAC, MTD NAND etc. The developer can easily add low level driver and board configuration, then combined with the upper framework, he/she can use lots of features.
The Component is a software concept upon RT-Thread kernel, for example a shell (finsh/msh shell), virtual file system (FAT, YAFFS, UFFS, ROM/RAM file system etc), TCP/IP protocol stack (lwIP), POSIX (thread) interface etc. One component must be a directory under RT-Thread/Components and one component can be descripted by a SConscript file (then be compiled and linked into the system).
The Appliation Module, or User Applicaion (UA) is a dyanmic loaded module, it can be compiled standalone without Kernel. Each UA has its own object container to manage thread/semaphore/kernel object which was created or initialized inside this UA. More information about UA, please visit another [git repo](https://github.com/RT-Thread/rtthread-apps).
The Dyanmic Module, formerly named as User Applicaion (UA) is a dyanmic loaded module or library, it can be compiled standalone without Kernel. Each Dyanmic Module has its own object list to manage thread/semaphore/kernel object which was created or initialized inside this UA. More information about UA, please visit another [git repo](https://github.com/RT-Thread/rtthread-apps).
## Board Support Package ##
@@ -42,9 +43,19 @@ RT-Thread RTOS can support many architectures:
## License ##
RT-Thread RTOS is free software; you can redistribute it and/or modify it under terms of the GNU General Public License version 2 as published by the Free Software Foundation. RT-Thread RTOS 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 RT-Thread; see file COPYING. If not, write to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
RT-Thread is Open Source software under the Apache License 2.0 since RT-Thread v3.1.1. License and copyright information can be found within the code.
As a special exception, including RT-Thread RTOS header files in a file, instantiating RT-Thread RTOS generics or templates, or linking other files with RT-Thread RTOS objects to produce an executable application, does not by itself cause the resulting executable application to be covered by the GNU General Public License. This exception does not however invalidate any other reasons why the executable file might be covered by the GNU Public License.
/*
* Copyright (c) 2006-2018, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*/
Since 9th of September 2018, PRs submitted by the community may be merged into the main line only after signing the Contributor License Agreement(CLA).
NOTE:
RT-Thread using the Apache license v2.0 is only launched after the release of v3.1.1, and is still in preparation right now.
## Usage ##
@@ -60,18 +71,18 @@ In SConstruct file:
When you set these variables correctly, you can use command:
scons
scons
under BSP directory to simplely compile RT-Thread RTOS.
If you want to generate the IDE's project file, you can use command:
scons --target=mdk/mdk4/mdk5/iar/cb -s
scons --target=mdk/mdk4/mdk5/iar/cb -s
to generate the project file.
to generate the project file.
NOTE: RT-Thread scons building system will tailor the system according to your rtconfig.h configuration header file. For example, if you disable the lwIP in the rtconfig.h by commenting the ```#define RT_USING_LWIP```, the generated project file should have no lwIP related files.
NOTE: RT-Thread scons building system will tailor the system according to your rtconfig.h configuration header file. For example, if you disable the lwIP in the rtconfig.h by commenting the ```#define RT_USING_LWIP```, the generated project file should have no lwIP related files.
## Contribution ##
Please refer the contributors in the github. Thank all of RT-Thread Developers.
Please refer the contributors in the github. Thank all of RT-Thread Developers.
+12 -4
View File
@@ -31,7 +31,7 @@ RT-Thread包含了一个自有的、传统的硬实时内核:可抢占的多
更多的IoT软件包则以package方式被添加到RT-Thread系统中。
应用模块,或者说用户应用(User Application,UA)是一个可动态加载的模块:它可以独立于RT-Thread固件而单独编译。一般的,每个UA都包含一个main函数入口;一个它自己的对象容器,用于管理这个应用的任务/信号量/消息队列等内核对象,创建、初始化、销毁等。更多关于UA的信息,请访问另外一个 [git 仓库](https://github.com/RT-Thread/rtthread-apps) 了解。
应用模块,或者说用户应用(User Application,UA)是一个可动态加载的模块:它可以独立于RT-Thread固件而单独编译。一般的,每个UA都包含一个main函数入口;一个它自己的对象链表,用于管理这个应用的任务/信号量/消息队列等内核对象,创建、初始化、销毁等。更多关于UA的信息,请访问另外一个 [git 仓库](https://github.com/RT-Thread/rtthread-apps) 了解。
## 支持的芯片架构 ##
@@ -51,11 +51,19 @@ RT-Thread支持数种芯片体系架构,已经覆盖当前应用中的主流
## 许可证 ##
RT-Thread is free software; you can redistribute it and/or modify it under terms of the GNU General Public License version 2 as published by the Free Software Foundation. RT-Thread RTOS 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 RT-Thread; see file COPYING. If not, write to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
RT-Thread从v3.1.1版本开始,是一个以Apache许可证2.0版本授权的开源软件,许可证信息以及版权信息一般的可以在代码首部看到:
As a special exception, including RT-Thread RTOS header files in a file, instantiating RT-Thread RTOS generics or templates, or linking other files with RT-Thread RTOS objects to produce an executable application, does not by itself cause the resulting executable application to be covered by the GNU General Public License. This exception does not however invalidate any other reasons why the executable file might be covered by the GNU Public License.
/*
* Copyright (c) 2006-2018, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*/
RT-Thread始终以开源的方式发展,所有发布的代码都遵循GPLv2+许可证。注意,GPLv2+的意思是,它是GPLv2的一个修改版本,添加了一定的例外。简单的来说,当使用RT-Thread时,除了RT-Thread发布的源代码以外的代码,可以不用遵循GPLv2的方式开源代码
从2018/09/09开始,开发者提交PR需要签署贡献者许可协议(CLA)
注意:
以Apache许可协议v2.0版本授权仅在RT-Thread v3.1.1正式版发布之后才正式实施,当前依然在准备阶段(准备所有原有开发者签署CLA协议)。
## 编译 ##
+23 -23
View File
@@ -53,7 +53,7 @@ int gpio_set_func(enum gpio_port port, enum gpio_pin pin, rt_uint8_t func)
if (func & 0x8)
{
dbg_log(DBG_WARNING, "[line]:%d There is a warning with parameter input\n", __LINE__);
LOG_W("[line]:%d There is a warning with parameter input", __LINE__);
return RT_EINVAL;
}
@@ -65,7 +65,7 @@ int gpio_set_func(enum gpio_port port, enum gpio_pin pin, rt_uint8_t func)
data |= func << offset;
writel(data, addr);
dbg_log(DBG_LOG, "[line]:%d offset:%d addr:%08x data:%08x\n", __LINE__, offset, addr, *((rt_uint32_t *)addr));
LOG_D("[line]:%d offset:%d addr:%08x data:%08x", __LINE__, offset, addr, *((rt_uint32_t *)addr));
return RT_EOK;
}
@@ -80,7 +80,7 @@ int gpio_set_value(enum gpio_port port, enum gpio_pin pin, rt_uint8_t value)
if (value & 0xE)
{
dbg_log(DBG_WARNING, "[line]:%d There is a warning with parameter input\n", __LINE__);
LOG_W("[line]:%d There is a warning with parameter input", __LINE__);
return RT_EINVAL;
}
@@ -92,7 +92,7 @@ int gpio_set_value(enum gpio_port port, enum gpio_pin pin, rt_uint8_t value)
data |= value << offset;
writel(data, addr);
dbg_log(DBG_LOG, "[line]:%d offset:%d addr:%08x data:%08x\n", __LINE__, offset, addr, *((rt_uint32_t *)addr));
LOG_D("[line]:%d offset:%d addr:%08x data:%08x", __LINE__, offset, addr, *((rt_uint32_t *)addr));
return RT_EOK;
}
@@ -110,7 +110,7 @@ int gpio_get_value(enum gpio_port port, enum gpio_pin pin)
data = readl(addr);
dbg_log(DBG_LOG, "[line]:%d offset:%d addr:%08x data:%08x\n", __LINE__, offset, addr, *((rt_uint32_t *)addr));
LOG_D("[line]:%d offset:%d addr:%08x data:%08x", __LINE__, offset, addr, *((rt_uint32_t *)addr));
return (data >> offset) & 0x01;
}
@@ -125,7 +125,7 @@ int gpio_set_pull_mode(enum gpio_port port, enum gpio_pin pin, enum gpio_pull p
if (pull & 0xC)
{
dbg_log(DBG_WARNING, "[line]:%d There is a warning with parameter input\n", __LINE__);
LOG_W("[line]:%d There is a warning with parameter input", __LINE__);
return RT_EINVAL;
}
@@ -138,7 +138,7 @@ int gpio_set_pull_mode(enum gpio_port port, enum gpio_pin pin, enum gpio_pull p
data |= pull << offset;
writel(data, addr);
dbg_log(DBG_LOG, "[line]:%d offset:%d addr:%08x data:%08x\n", __LINE__, offset, addr, *((rt_uint32_t *)addr));
LOG_D("[line]:%d offset:%d addr:%08x data:%08x", __LINE__, offset, addr, *((rt_uint32_t *)addr));
return RT_EOK;
}
@@ -153,7 +153,7 @@ int gpio_set_drive_level(enum gpio_port port, enum gpio_pin pin, enum gpio_drv_l
if (level & 0xC)
{
dbg_log(DBG_WARNING, "[line]:%d There is a warning with parameter input\n", __LINE__);
LOG_W("[line]:%d There is a warning with parameter input", __LINE__);
return RT_EINVAL;
}
@@ -166,7 +166,7 @@ int gpio_set_drive_level(enum gpio_port port, enum gpio_pin pin, enum gpio_drv_l
data |= level << offset;
writel(data, addr);
dbg_log(DBG_LOG, "[line]:%d offset:%d addr:%08x data:%08x\n", __LINE__, offset, addr, *((rt_uint32_t *)addr));
LOG_D("[line]:%d offset:%d addr:%08x data:%08x", __LINE__, offset, addr, *((rt_uint32_t *)addr));
return RT_EOK;
}
@@ -187,7 +187,7 @@ void gpio_direction_input(enum gpio_port port, enum gpio_pin pin)
data |= IO_INPUT << offset;
writel(data, addr);
dbg_log(DBG_LOG, "[line]:%d offset:%d addr:%08x data:%08x\n", __LINE__, offset, addr, *((rt_uint32_t *)addr));
LOG_D("[line]:%d offset:%d addr:%08x data:%08x", __LINE__, offset, addr, *((rt_uint32_t *)addr));
}
void gpio_direction_output(enum gpio_port port, enum gpio_pin pin, int value)
@@ -208,7 +208,7 @@ void gpio_direction_output(enum gpio_port port, enum gpio_pin pin, int value)
data |= IO_OUTPUT << offset;
writel(data, addr);
dbg_log(DBG_LOG, "[line]:%d offset:%d addr:%08x data:%08x\n", __LINE__, offset, addr, *((rt_uint32_t *)addr));
LOG_D("[line]:%d offset:%d addr:%08x data:%08x", __LINE__, offset, addr, *((rt_uint32_t *)addr));
}
/*********************************************************
** IRQ
@@ -237,7 +237,7 @@ void gpio_select_irq_clock(enum gpio_port port, enum gpio_irq_clock clock)
data &= ~0x01;
data |= clock;
writel(data, addr);
dbg_log(DBG_LOG, "[line]:%d addr:%08x data:%08x\n", __LINE__, addr, *((rt_uint32_t *)addr));
LOG_D("[line]:%d addr:%08x data:%08x", __LINE__, addr, *((rt_uint32_t *)addr));
}
void gpio_set_debounce(enum gpio_port port, enum gpio_direction_type prescaler)
@@ -253,7 +253,7 @@ void gpio_set_debounce(enum gpio_port port, enum gpio_direction_type prescaler)
data &= ~(0x07 << 4);
data |= prescaler << 4;
writel(data, addr);
dbg_log(DBG_LOG, "[line]:%d addr:%08x data:%08x\n", __LINE__, addr, *((rt_uint32_t *)addr));
LOG_D("[line]:%d addr:%08x data:%08x", __LINE__, addr, *((rt_uint32_t *)addr));
}
void gpio_irq_enable(enum gpio_port port, enum gpio_pin pin)
@@ -272,7 +272,7 @@ void gpio_irq_enable(enum gpio_port port, enum gpio_pin pin)
data |= 0x1 << offset;
writel(data, addr);
gpio_select_irq_clock(port, GPIO_IRQ_HOSC_24MHZ);
dbg_log(DBG_LOG, "[line]:%d offset:%d addr:%08x data:%08x\n", __LINE__, offset, addr, *((rt_uint32_t *)addr));
LOG_D("[line]:%d offset:%d addr:%08x data:%08x", __LINE__, offset, addr, *((rt_uint32_t *)addr));
}
void gpio_irq_disable(enum gpio_port port, enum gpio_pin pin)
@@ -292,7 +292,7 @@ void gpio_irq_disable(enum gpio_port port, enum gpio_pin pin)
data &= ~(0x1 << offset);
writel(data, addr);
dbg_log(DBG_LOG, "[line]:%d offset:%d addr:%08x data:%08x\n", __LINE__, offset, addr, *((rt_uint32_t *)addr));
LOG_D("[line]:%d offset:%d addr:%08x data:%08x", __LINE__, offset, addr, *((rt_uint32_t *)addr));
}
void gpio_set_irq_type(enum gpio_port port, enum gpio_pin pin, enum gpio_irq_type irq_type)
@@ -312,7 +312,7 @@ void gpio_set_irq_type(enum gpio_port port, enum gpio_pin pin, enum gpio_irq_ty
data |= irq_type << offset;
writel(data, addr);
dbg_log(DBG_LOG, "[line]:%d offset:%d addr:%08x data:%08x\n", __LINE__, offset, addr, *((rt_uint32_t *)addr));
LOG_D("[line]:%d offset:%d addr:%08x data:%08x", __LINE__, offset, addr, *((rt_uint32_t *)addr));
}
static struct gpio_irq_def _g_gpio_irq_tbl[GPIO_PORT_NUM];
@@ -353,7 +353,7 @@ static void gpio_irq_handler(int irq, void *param)
{
if ((pend & 0x1) && (irq_def->irq_cb[pin] != RT_NULL))
{
dbg_log(DBG_LOG, "do irq callback...\n", port, pin);
LOG_D("do irq callback...", port, pin);
irq_def->irq_cb[pin](irq_def->irq_arg[pin]);
}
pin++;
@@ -452,7 +452,7 @@ static void pin_mode(struct rt_device *dev, rt_base_t pin, rt_base_t mode)
{
if ((pin > PIN_NUM(pin_index)) || (pin_index[pin].magic != PIN_MAGIC))
{
dbg_log(DBG_ERROR, "pin:%d value wrongful\n", pin);
LOG_E("pin:%d value wrongful", pin);
return;
}
@@ -463,7 +463,7 @@ static void pin_write(struct rt_device *dev, rt_base_t pin, rt_base_t value)
{
if ((pin > PIN_NUM(pin_index)) || (pin_index[pin].magic != PIN_MAGIC))
{
dbg_log(DBG_ERROR, "pin:%d value wrongful\n", pin);
LOG_E("pin:%d value wrongful", pin);
return;
}
@@ -474,7 +474,7 @@ static int pin_read(struct rt_device *device, rt_base_t pin)
{
if ((pin > PIN_NUM(pin_index)) || (pin_index[pin].magic != PIN_MAGIC))
{
dbg_log(DBG_ERROR, "pin:%d value wrongful\n", pin);
LOG_E("pin:%d value wrongful", pin);
return 0;
}
@@ -485,7 +485,7 @@ static rt_err_t pin_attach_irq(struct rt_device *device, rt_int32_t pin, rt_uint
{
if ((pin > PIN_NUM(pin_index)) || (pin_index[pin].magic != PIN_MAGIC))
{
dbg_log(DBG_ERROR, "pin:%d value wrongful\n", pin);
LOG_E("pin:%d value wrongful", pin);
return RT_ERROR;
}
@@ -497,7 +497,7 @@ static rt_err_t pin_detach_irq(struct rt_device *device, rt_int32_t pin)
{
if ((pin > PIN_NUM(pin_index)) || (pin_index[pin].magic != PIN_MAGIC))
{
dbg_log(DBG_ERROR, "pin:%d value wrongful\n", pin);
LOG_E("pin:%d value wrongful", pin);
return RT_ERROR;
}
@@ -510,7 +510,7 @@ rt_err_t pin_irq_enable(struct rt_device *device, rt_base_t pin, rt_uint32_t ena
{
if ((pin > PIN_NUM(pin_index)) || (pin_index[pin].magic != PIN_MAGIC))
{
dbg_log(DBG_ERROR, "pin:%d value wrongful\n", pin);
LOG_E("pin:%d value wrongful", pin);
return RT_ERROR;
}
+22 -22
View File
@@ -99,7 +99,7 @@ static void mmc_delay_us(int us)
static void mmc_dump_errinfo(unsigned int err)
{
dbg_log(DBG_ERROR, "[err]:0x%08x, %s%s%s%s%s%s%s%s%s%s%s\n",
LOG_E("[err]:0x%08x, %s%s%s%s%s%s%s%s%s%s%s",
err,
err & SDXC_RespErr ? " RE" : "",
err & SDXC_RespCRCErr ? " RCE" : "",
@@ -130,7 +130,7 @@ static int mmc_update_clk(tina_mmc_t mmc)
}
if (!timeout)
{
dbg_log(DBG_ERROR, "mmc update clk failed\n");
LOG_E("mmc update clk failed");
return -RT_ERROR;
}
/* clean interrupt */
@@ -189,8 +189,8 @@ static rt_err_t mmc_trans_data_by_dma(tina_mmc_t mmc, struct mmc_xfe_des *xfe)
pdes[des_idx].buf_addr_ptr2 = (unsigned long)&pdes[des_idx+1];
}
dbg_log(DBG_LOG, "frag %d, remain %d, des[%d](%08x): " \
"[0] = %08x, [1] = %08x, [2] = %08x, [3] = %08x\n", \
LOG_D("frag %d, remain %d, des[%d](%08x): " \
"[0] = %08x, [1] = %08x, [2] = %08x, [3] = %08x", \
i, remain, des_idx, (unsigned int)&pdes[des_idx],
(unsigned int)((unsigned int*)&pdes[des_idx])[0], (unsigned int)((unsigned int*)&pdes[des_idx])[1],
(unsigned int)((unsigned int*)&pdes[des_idx])[2], (unsigned int)((unsigned int*)&pdes[des_idx])[3]);
@@ -243,7 +243,7 @@ static rt_err_t mmc_trans_data_by_cpu(tina_mmc_t mmc, struct mmc_xfe_des *xfe)
if (timeout <= 0)
{
dbg_log(DBG_ERROR, "write data by cpu failed status:0x%08x\n", mmc->star_reg);
LOG_E("write data by cpu failed status:0x%08x", mmc->star_reg);
return -RT_ERROR;
}
mmc->fifo_reg = buff[i];
@@ -258,7 +258,7 @@ static rt_err_t mmc_trans_data_by_cpu(tina_mmc_t mmc, struct mmc_xfe_des *xfe)
if (timeout <= 0)
{
dbg_log(DBG_ERROR, "read data by cpu failed status:0x%08x\n", mmc->star_reg);
LOG_E("read data by cpu failed status:0x%08x", mmc->star_reg);
return -RT_ERROR;
}
buff[i] = mmc->fifo_reg;
@@ -279,7 +279,7 @@ static rt_err_t mmc_config_clock(tina_mmc_t mmc, int clk)
mmc->ckcr_reg = rval;
if (mmc_update_clk(mmc) != RT_EOK)
{
dbg_log(DBG_ERROR, "clk update fail line:%d\n", __LINE__);
LOG_E("clk update fail line:%d", __LINE__);
return -RT_ERROR;
}
@@ -298,7 +298,7 @@ static rt_err_t mmc_config_clock(tina_mmc_t mmc, int clk)
mmc->ckcr_reg = rval;
if(mmc_update_clk(mmc) != RT_EOK)
{
dbg_log(DBG_ERROR, "clk update fail line:%d\n", __LINE__);
LOG_E("clk update fail line:%d", __LINE__);
return -RT_ERROR;
}
@@ -307,12 +307,12 @@ static rt_err_t mmc_config_clock(tina_mmc_t mmc, int clk)
static rt_err_t mmc_set_ios(tina_mmc_t mmc, int clk, int bus_width)
{
dbg_log(DBG_LOG, "mmc set io bus width:%d clock:%d\n", \
LOG_D("mmc set io bus width:%d clock:%d", \
(bus_width == MMCSD_BUS_WIDTH_8 ? 8 : (bus_width == MMCSD_BUS_WIDTH_4 ? 4 : 1)), clk);
/* change clock */
if (clk && (mmc_config_clock(mmc, clk) != RT_EOK))
{
dbg_log(DBG_ERROR, "update clock failed\n");
LOG_E("update clock failed");
return -RT_ERROR;
}
@@ -349,13 +349,13 @@ static int mmc_send_cmd(struct rt_mmcsd_host *host, struct rt_mmcsd_cmd *cmd)
status = mmc->star_reg;
while (status & (1 << 9))
{
dbg_log(DBG_LOG, "note: check card busy\n");
LOG_D("note: check card busy");
status = mmc->star_reg;
if (!timeout--)
{
err = -1;
dbg_log(DBG_ERROR, "mmc cmd12 busy timeout data:0x%08x\n", status);
LOG_E("mmc cmd12 busy timeout data:0x%08x", status);
return err;
}
mmc_delay_us(1);
@@ -397,7 +397,7 @@ static int mmc_send_cmd(struct rt_mmcsd_host *host, struct rt_mmcsd_cmd *cmd)
mmc->bycr_reg = bytecnt;
}
dbg_log(DBG_LOG, "cmd %d(0x%08x), arg 0x%08x\n", cmd->cmd_code, cmdval | cmd->cmd_code, cmd->arg);
LOG_D("cmd %d(0x%08x), arg 0x%08x", cmd->cmd_code, cmdval | cmd->cmd_code, cmd->arg);
mmc->cagr_reg = cmd->arg;
if (!data)
{
@@ -412,7 +412,7 @@ static int mmc_send_cmd(struct rt_mmcsd_host *host, struct rt_mmcsd_cmd *cmd)
*/
if (data)
{
dbg_log(DBG_LOG, "mmc trans data %d bytes addr:0x%08x\n", bytecnt, data);
LOG_D("mmc trans data %d bytes addr:0x%08x", bytecnt, data);
#ifdef CONFIG_MMC_USE_DMA
if (bytecnt > 64)
{
@@ -478,13 +478,13 @@ static int mmc_send_cmd(struct rt_mmcsd_host *host, struct rt_mmcsd_cmd *cmd)
cmd->resp[2] = mmc->resp1_reg;
cmd->resp[1] = mmc->resp2_reg;
cmd->resp[0] = mmc->resp3_reg;
dbg_log(DBG_LOG, "mmc resp 0x%08x 0x%08x 0x%08x 0x%08x\n",
LOG_D("mmc resp 0x%08x 0x%08x 0x%08x 0x%08x",
cmd->resp[0], cmd->resp[1], cmd->resp[2], cmd->resp[3]);
}
else
{
cmd->resp[0] = mmc->resp0_reg;
dbg_log(DBG_LOG, "mmc resp 0x%08x\n", cmd->resp[0]);
LOG_D("mmc resp 0x%08x", cmd->resp[0]);
}
out:
@@ -516,16 +516,16 @@ out:
mmc->gctl_reg = mmc->gctl_reg | 0x80000000;
mmc->dbgc_reg = 0xdeb;
timeout = 1000;
dbg_log(DBG_LOG, "Read remain data\n");
LOG_D("Read remain data");
while (mmc->bbcr_reg < 512)
{
unsigned int tmp = mmc->fifo_reg;
tmp = tmp;
dbg_log(DBG_LOG, "Read data 0x%08x, bbcr 0x%04x\n", tmp, mmc->bbcr_reg);
LOG_D("Read data 0x%08x, bbcr 0x%04x", tmp, mmc->bbcr_reg);
mmc_delay_us(1);
if (!(timeout--))
{
dbg_log(DBG_ERROR, "Read remain data timeout\n");
LOG_E("Read remain data timeout");
break;
}
}
@@ -536,7 +536,7 @@ out:
mmc_update_clk(mmc);
cmd->err = -RT_ETIMEOUT;
dbg_log(DBG_ERROR, "mmc cmd %d err\n", cmd->cmd_code);
LOG_E("mmc cmd %d err", cmd->cmd_code);
}
mmc->gctl_reg &= ~(0x1 << 4);
@@ -744,13 +744,13 @@ int tina_sdio_init(void)
host = mmcsd_alloc_host();
if (!host)
{
dbg_log(DBG_ERROR, "alloc host failed\n");
LOG_E("alloc host failed");
goto err;
}
if (rt_sem_init(&_sdio_drv.rt_sem, "sdio_sem", RT_NULL, RT_IPC_FLAG_FIFO))
{
dbg_log(DBG_ERROR, "sem init failed\n");
LOG_E("sem init failed");
goto err;
}
_sdio_drv.mmc_des = (tina_mmc_t)MMC0_BASE_ADDR;
+68 -71
View File
@@ -33,25 +33,22 @@
#define SPI_BUS_MAX_CLK (30 * 1000 * 1000)
//#define DEBUG
#define DBG_ENABLE
#define DBG_SECTION_NAME "SPI"
#ifdef DEBUG
#define DBG_LEVEL DBG_LOG
#else
#define DBG_LEVEL DBG_WARNING
#endif /* DEBUG */
#define DBG_COLOR
#include <rtdbg.h>
#ifdef RT_USING_SPI
//#define DEBUG
#define ARR_LEN(__N) (sizeof(__N) / sizeof(__N[0]))
#ifdef DEBUG
#define DEBUG_PRINTF(...) rt_kprintf(__VA_ARGS__)
#else
#define DEBUG_PRINTF(...)
#endif
#define __SPI_STATIC_INLINE__ rt_inline
/*
@@ -296,7 +293,7 @@ void SPI_DMA(SPI_T *spi, bool txEn, bool rxEn)
* @brief
*/
__SPI_STATIC_INLINE__
void SPI_SetTxFifoThreshold(SPI_T *spi, uint8_t threshold)
void SPI_SetTxFifoThreshold(SPI_T *spi, rt_uint8_t threshold)
{
HAL_MODIFY_REG(spi->FCTL, SPI_FCTL_TX_TRIG_LEVEL_MASK, threshold << SPI_FCTL_TX_TRIG_LEVEL_SHIFT);
}
@@ -305,7 +302,7 @@ void SPI_SetTxFifoThreshold(SPI_T *spi, uint8_t threshold)
* @brief
*/
__SPI_STATIC_INLINE__
void SPI_SetRxFifoThreshold(SPI_T *spi, uint8_t threshold)
void SPI_SetRxFifoThreshold(SPI_T *spi, rt_uint8_t threshold)
{
HAL_MODIFY_REG(spi->FCTL, SPI_FCTL_RX_TRIG_LEVEL_MASK, threshold << SPI_FCTL_RX_TRIG_LEVEL_SHIFT);
}
@@ -314,18 +311,18 @@ void SPI_SetRxFifoThreshold(SPI_T *spi, uint8_t threshold)
* @brief
*/
__SPI_STATIC_INLINE__
uint8_t SPI_GetTxFifoCounter(SPI_T *spi)
rt_uint8_t SPI_GetTxFifoCounter(SPI_T *spi)
{
return (uint8_t)((spi->FST & SPI_FST_TF_CNT_MASK) >> SPI_FST_TF_CNT_SHIFT);
return (rt_uint8_t)((spi->FST & SPI_FST_TF_CNT_MASK) >> SPI_FST_TF_CNT_SHIFT);
}
/*
* @brief
*/
__SPI_STATIC_INLINE__
uint8_t SPI_GetRxFifoCounter(SPI_T *spi)
rt_uint8_t SPI_GetRxFifoCounter(SPI_T *spi)
{
return (uint8_t)((spi->FST & SPI_FST_RF_CNT_MASK) >> SPI_FST_RF_CNT_SHIFT);
return (rt_uint8_t)((spi->FST & SPI_FST_RF_CNT_MASK) >> SPI_FST_RF_CNT_SHIFT);
}
/*
@@ -350,7 +347,7 @@ void SPI_DisableDualMode(SPI_T *spi)
* @brief
*/
__SPI_STATIC_INLINE__
void SPI_SetInterval(SPI_T *spi, uint16_t nSCLK)
void SPI_SetInterval(SPI_T *spi, rt_uint16_t nSCLK)
{
HAL_MODIFY_REG(spi->WAIT, SPI_WAIT_WCC_MASK, nSCLK << SPI_WAIT_WCC_SHIFT);
}
@@ -358,9 +355,9 @@ void SPI_SetInterval(SPI_T *spi, uint16_t nSCLK)
/*
* @brief
*/
static void SPI_SetClkDiv(SPI_T *spi, uint16_t div)
static void SPI_SetClkDiv(SPI_T *spi, rt_uint16_t div)
{
uint8_t n = 0;
rt_uint8_t n = 0;
if (div < 1)
{
return;
@@ -401,7 +398,7 @@ void SPI_SetDataSize(SPI_T *spi, rt_uint32_t data_size, rt_uint32_t dummy_size)
* @brief
*/
__SPI_STATIC_INLINE__
void SPI_Write(SPI_T *spi, uint8_t *data)
void SPI_Write(SPI_T *spi, rt_uint8_t *data)
{
HAL_REG_8BIT(&spi->TXD) = *data;
}
@@ -410,7 +407,7 @@ void SPI_Write(SPI_T *spi, uint8_t *data)
* @brief
*/
__SPI_STATIC_INLINE__
void SPI_Read(SPI_T *spi, uint8_t *data)
void SPI_Read(SPI_T *spi, rt_uint8_t *data)
{
*data = HAL_REG_8BIT(&spi->RXD);
}
@@ -419,18 +416,18 @@ void SPI_Read(SPI_T *spi, uint8_t *data)
* @brief
*/
__SPI_STATIC_INLINE__
uint8_t *SPI_TxAddress(SPI_T *spi)
rt_uint8_t *SPI_TxAddress(SPI_T *spi)
{
return (uint8_t *)&spi->TXD;
return (rt_uint8_t *)&spi->TXD;
}
/*
* @brief
*/
__SPI_STATIC_INLINE__
uint8_t *SPI_RxAddress(SPI_T *spi)
rt_uint8_t *SPI_RxAddress(SPI_T *spi)
{
return (uint8_t *)&spi->RXD;
return (rt_uint8_t *)&spi->RXD;
}
/* private rt-thread spi ops function */
@@ -451,30 +448,30 @@ static rt_err_t configure(struct rt_spi_device *device,
struct tina_spi *_spi_info = (struct tina_spi *)spi_bus->parent.user_data;
SPI_T *spi = _spi_info->spi;
DEBUG_PRINTF("%s -> %d\n", __FUNCTION__, __LINE__);
LOG_D("%s -> %d", __FUNCTION__, __LINE__);
RT_ASSERT(device != RT_NULL);
RT_ASSERT(configuration != RT_NULL);
DEBUG_PRINTF("%s -> %d\n", __FUNCTION__, __LINE__);
LOG_D("%s -> %d", __FUNCTION__, __LINE__);
DEBUG_PRINTF("spi address: %08X\n", (rt_uint32_t)spi);
LOG_D("spi address: %08X", (rt_uint32_t)spi);
SPI_Disable(spi);
SPI_Reset(spi);
SPI_ResetRxFifo(spi);
SPI_ResetTxFifo(spi);
DEBUG_PRINTF("%s -> %d\n", __FUNCTION__, __LINE__);
LOG_D("%s -> %d", __FUNCTION__, __LINE__);
/* data_width */
if (configuration->data_width != 8)
{
DEBUG_PRINTF("error: data_width is %d\n", configuration->data_width);
LOG_D("error: data_width is %d", configuration->data_width);
return RT_EIO;
}
DEBUG_PRINTF("%s -> %d\n", __FUNCTION__, __LINE__);
LOG_D("%s -> %d", __FUNCTION__, __LINE__);
SPI_SetDuplex(spi, SPI_TCTRL_DHB_FULL_DUPLEX);
SPI_SetMode(spi, SPI_CTRL_MODE_MASTER);
@@ -510,7 +507,7 @@ static rt_err_t configure(struct rt_spi_device *device,
rt_uint32_t max_hz;
rt_uint32_t div;
DEBUG_PRINTF("%s -> %d\n", __FUNCTION__, __LINE__);
LOG_D("%s -> %d", __FUNCTION__, __LINE__);
max_hz = configuration->max_hz;
@@ -520,14 +517,14 @@ static rt_err_t configure(struct rt_spi_device *device,
}
spi_clock = ahb_get_clk();
DEBUG_PRINTF("%s -> %d\n", __FUNCTION__, __LINE__);
LOG_D("%s -> %d", __FUNCTION__, __LINE__);
div = (spi_clock + max_hz - 1) / max_hz;
dbg_log(DBG_LOG, "configuration->max_hz: %d\n", configuration->max_hz);
dbg_log(DBG_LOG, "max freq: %d\n", max_hz);
dbg_log(DBG_LOG, "spi_clock: %d\n", spi_clock);
dbg_log(DBG_LOG, "div: %d\n", div);
LOG_D("configuration->max_hz: %d", configuration->max_hz);
LOG_D("max freq: %d", max_hz);
LOG_D("spi_clock: %d", spi_clock);
LOG_D("div: %d", div);
SPI_SetClkDiv(spi, div / 2);
} /* baudrate */
@@ -536,7 +533,7 @@ static rt_err_t configure(struct rt_spi_device *device,
SPI_SetDataSize(spi, 0, 0);
SPI_Enable(spi);
DEBUG_PRINTF("%s -> %d\n", __FUNCTION__, __LINE__);
LOG_D("%s -> %d", __FUNCTION__, __LINE__);
return RT_EOK;
};
@@ -552,19 +549,19 @@ static rt_uint32_t xfer(struct rt_spi_device *device, struct rt_spi_message *mes
RT_ASSERT(device != NULL);
RT_ASSERT(message != NULL);
DEBUG_PRINTF("%s -> %d\n", __FUNCTION__, __LINE__);
DEBUG_PRINTF("spi_info: %08X\n", (rt_uint32_t)_spi_info);
DEBUG_PRINTF("spi address: %08X\n", (rt_uint32_t)spi);
LOG_D("%s -> %d", __FUNCTION__, __LINE__);
LOG_D("spi_info: %08X", (rt_uint32_t)_spi_info);
LOG_D("spi address: %08X", (rt_uint32_t)spi);
/* take CS */
if (message->cs_take)
{
SPI_ManualChipSelect(spi, tina_spi_cs->cs);
SPI_SetCsLevel(spi, false);
DEBUG_PRINTF("spi take cs\n");
LOG_D("spi take cs");
}
DEBUG_PRINTF("%s -> %d\n", __FUNCTION__, __LINE__);
LOG_D("%s -> %d", __FUNCTION__, __LINE__);
{
if ((config->data_width <= 8) && (message->length > 0))
@@ -574,7 +571,7 @@ static rt_uint32_t xfer(struct rt_spi_device *device, struct rt_spi_message *mes
rt_uint32_t tx_size = message->length;
rt_uint32_t rx_size = message->length;
DEBUG_PRINTF("spi poll transfer start: %d\n", tx_size);
LOG_D("spi poll transfer start: %d", tx_size);
SPI_ResetTxFifo(spi);
SPI_ResetRxFifo(spi);
@@ -582,12 +579,12 @@ static rt_uint32_t xfer(struct rt_spi_device *device, struct rt_spi_message *mes
SPI_StartTransmit(spi);
DEBUG_PRINTF("%s -> %d\n", __FUNCTION__, __LINE__);
LOG_D("%s -> %d", __FUNCTION__, __LINE__);
while (tx_size > 0 || rx_size > 0)
{
uint8_t tx_data = 0xFF;
uint8_t rx_data = 0xFF;
rt_uint8_t tx_data = 0xFF;
rt_uint8_t rx_data = 0xFF;
while ((SPI_GetTxFifoCounter(spi) < SPI_FIFO_SIZE) && (tx_size > 0))
{
@@ -611,25 +608,25 @@ static rt_uint32_t xfer(struct rt_spi_device *device, struct rt_spi_message *mes
}
}
DEBUG_PRINTF("%s -> %d\n", __FUNCTION__, __LINE__);
LOG_D("%s -> %d", __FUNCTION__, __LINE__);
if ((tx_size != 0) || (rx_size != 0))
{
DEBUG_PRINTF("spi_tx_rx error with tx count = %d, rx count = %d.\n", tx_size, rx_size);
LOG_D("spi_tx_rx error with tx count = %d, rx count = %d.", tx_size, rx_size);
return 0;
}
DEBUG_PRINTF("%s -> %d\n", __FUNCTION__, __LINE__);
LOG_D("%s -> %d", __FUNCTION__, __LINE__);
while (SPI_IntState(spi, SPI_INT_TRANSFER_COMPLETE) == 0);
SPI_ClearInt(spi, SPI_INT_TRANSFER_COMPLETE);
DEBUG_PRINTF("spi poll transfer finsh\n");
LOG_D("spi poll transfer finsh");
}
else if (config->data_width > 8)
{
DEBUG_PRINTF("data width: %d\n", config->data_width);
LOG_D("data width: %d", config->data_width);
RT_ASSERT(NULL);
}
}
@@ -638,7 +635,7 @@ static rt_uint32_t xfer(struct rt_spi_device *device, struct rt_spi_message *mes
if (message->cs_release)
{
SPI_SetCsLevel(spi, true);
DEBUG_PRINTF("spi release cs\n");
LOG_D("spi release cs");
}
return message->length;
@@ -676,7 +673,7 @@ rt_err_t tina_spi_bus_register(SPI_T *spi, const char *spi_bus_name)
{
int i;
DEBUG_PRINTF("%s -> %d\n", __FUNCTION__, __LINE__);
LOG_D("%s -> %d", __FUNCTION__, __LINE__);
RT_ASSERT(spi_bus_name != RT_NULL);
@@ -688,67 +685,67 @@ rt_err_t tina_spi_bus_register(SPI_T *spi, const char *spi_bus_name)
bus_gate_clk_enalbe(spis[i].spi_gate);
spis[i].spi_bus->parent.user_data = (void *)&spis[i];
DEBUG_PRINTF("bus addr: %08X\n", (rt_uint32_t)spis[i].spi_bus);
DEBUG_PRINTF("user_data: %08X\n", (rt_uint32_t)spis[i].spi_bus->parent.user_data);
DEBUG_PRINTF("%s -> %d\n", __FUNCTION__, __LINE__);
LOG_D("bus addr: %08X", (rt_uint32_t)spis[i].spi_bus);
LOG_D("user_data: %08X", (rt_uint32_t)spis[i].spi_bus->parent.user_data);
LOG_D("%s -> %d", __FUNCTION__, __LINE__);
rt_spi_bus_register(spis[i].spi_bus, spi_bus_name, &tina_spi_ops);
DEBUG_PRINTF("%s -> %d\n", __FUNCTION__, __LINE__);
LOG_D("%s -> %d", __FUNCTION__, __LINE__);
return RT_EOK;
}
}
DEBUG_PRINTF("%s -> %d\n", __FUNCTION__, __LINE__);
LOG_D("%s -> %d", __FUNCTION__, __LINE__);
return RT_ERROR;
}
int rt_hw_spi_init(void)
{
DEBUG_PRINTF("register spi bus\n");
LOG_D("register spi bus");
#ifdef TINA_USING_SPI0
/* register spi bus */
{
rt_err_t result;
DEBUG_PRINTF("%s -> %d\n", __FUNCTION__, __LINE__);
LOG_D("%s -> %d", __FUNCTION__, __LINE__);
gpio_set_func(GPIO_PORT_C, GPIO_PIN_0, IO_FUN_1);
gpio_set_func(GPIO_PORT_C, GPIO_PIN_2, IO_FUN_1);
gpio_set_func(GPIO_PORT_C, GPIO_PIN_3, IO_FUN_1);
DEBUG_PRINTF("%s -> %d\n", __FUNCTION__, __LINE__);
LOG_D("%s -> %d", __FUNCTION__, __LINE__);
result = tina_spi_bus_register((SPI_T *)SPI0_BASE_ADDR, "spi0");
if (result != RT_EOK)
{
DEBUG_PRINTF("%s -> %d\n", __FUNCTION__, __LINE__);
LOG_D("%s -> %d", __FUNCTION__, __LINE__);
return result;
}
}
DEBUG_PRINTF("%s -> %d\n", __FUNCTION__, __LINE__);
LOG_D("%s -> %d", __FUNCTION__, __LINE__);
/* attach cs */
{
static struct rt_spi_device spi_device;
static struct tina_spi_cs spi_cs;
rt_err_t result;
DEBUG_PRINTF("%s -> %d\n", __FUNCTION__, __LINE__);
LOG_D("%s -> %d", __FUNCTION__, __LINE__);
spi_cs.cs = SPI_TCTRL_SS_SEL_SS0;
DEBUG_PRINTF("%s -> %d\n", __FUNCTION__, __LINE__);
LOG_D("%s -> %d", __FUNCTION__, __LINE__);
gpio_set_func(GPIO_PORT_C, GPIO_PIN_1, IO_FUN_1);
DEBUG_PRINTF("%s -> %d\n", __FUNCTION__, __LINE__);
LOG_D("%s -> %d", __FUNCTION__, __LINE__);
result = rt_spi_bus_attach_device(&spi_device, "spi00", "spi0", (void *)&spi_cs);
if (result != RT_EOK)
{
DEBUG_PRINTF("%s -> %d\n", __FUNCTION__, __LINE__);
LOG_D("%s -> %d", __FUNCTION__, __LINE__);
return result;
}
}
DEBUG_PRINTF("%s -> %d\n", __FUNCTION__, __LINE__);
LOG_D("%s -> %d", __FUNCTION__, __LINE__);
#endif
#ifdef TINA_USING_SPI1
@@ -763,12 +760,12 @@ int rt_hw_spi_init(void)
result = tina_spi_bus_register((SPI_T *)SPI1_BASE_ADDR, "spi1");
if (result != RT_EOK)
{
DEBUG_PRINTF("register spi bus faild: %d\n", result);
LOG_D("register spi bus faild: %d", result);
return result;
}
}
DEBUG_PRINTF("attach cs\n");
LOG_D("attach cs");
/* attach cs */
{
static struct rt_spi_device spi_device;
@@ -781,7 +778,7 @@ int rt_hw_spi_init(void)
result = rt_spi_bus_attach_device(&spi_device, "spi10", "spi1", (void *)&spi_cs);
if (result != RT_EOK)
{
DEBUG_PRINTF("attach cs faild: %d\n", result);
LOG_D("attach cs faild: %d", result);
return result;
}
}
+129 -23
View File
@@ -13,15 +13,24 @@ CONFIG_RT_THREAD_PRIORITY_32=y
# CONFIG_RT_THREAD_PRIORITY_256 is not set
CONFIG_RT_THREAD_PRIORITY_MAX=32
CONFIG_RT_TICK_PER_SECOND=1000
CONFIG_RT_DEBUG=y
CONFIG_RT_USING_OVERFLOW_CHECK=y
CONFIG_RT_DEBUG_INIT=0
CONFIG_RT_DEBUG_THREAD=0
CONFIG_RT_USING_HOOK=y
CONFIG_RT_IDEL_HOOK_LIST_SIZE=4
CONFIG_IDLE_THREAD_STACK_SIZE=256
CONFIG_RT_USING_TIMER_SOFT=y
CONFIG_RT_TIMER_THREAD_PRIO=4
CONFIG_RT_TIMER_THREAD_STACK_SIZE=512
CONFIG_RT_TIMER_THREAD_STACK_SIZE=1024
CONFIG_RT_DEBUG=y
# CONFIG_RT_DEBUG_INIT_CONFIG is not set
# CONFIG_RT_DEBUG_THREAD_CONFIG is not set
# CONFIG_RT_DEBUG_SCHEDULER_CONFIG is not set
# CONFIG_RT_DEBUG_IPC_CONFIG is not set
# CONFIG_RT_DEBUG_TIMER_CONFIG is not set
# CONFIG_RT_DEBUG_IRQ_CONFIG is not set
# CONFIG_RT_DEBUG_MEM_CONFIG is not set
# CONFIG_RT_DEBUG_SLAB_CONFIG is not set
# CONFIG_RT_DEBUG_MEMHEAP_CONFIG is not set
# CONFIG_RT_DEBUG_MODULE_CONFIG is not set
#
# Inter-Thread communication
@@ -53,13 +62,14 @@ CONFIG_RT_USING_DEVICE=y
CONFIG_RT_USING_CONSOLE=y
CONFIG_RT_CONSOLEBUF_SIZE=128
CONFIG_RT_CONSOLE_DEVICE_NAME="dbg"
# CONFIG_RT_USING_MODULE is not set
#
# RT-Thread Components
#
CONFIG_RT_USING_COMPONENTS_INIT=y
# CONFIG_RT_USING_USER_MAIN is not set
CONFIG_RT_USING_USER_MAIN=y
CONFIG_RT_MAIN_THREAD_STACK_SIZE=2048
CONFIG_RT_MAIN_THREAD_PRIORITY=10
#
# C++ features
@@ -82,7 +92,7 @@ CONFIG_FINSH_CMD_SIZE=80
# CONFIG_FINSH_USING_AUTH is not set
CONFIG_FINSH_USING_MSH=y
CONFIG_FINSH_USING_MSH_DEFAULT=y
# CONFIG_FINSH_USING_MSH_ONLY is not set
CONFIG_FINSH_USING_MSH_ONLY=y
CONFIG_FINSH_ARG_MAX=10
#
@@ -94,26 +104,49 @@ CONFIG_FINSH_ARG_MAX=10
# Device Drivers
#
CONFIG_RT_USING_DEVICE_IPC=y
CONFIG_RT_PIPE_BUFSZ=512
CONFIG_RT_USING_SERIAL=y
# CONFIG_RT_USING_CAN is not set
# CONFIG_RT_USING_HWTIMER is not set
# CONFIG_RT_USING_CPUTIME is not set
# CONFIG_RT_USING_I2C is not set
CONFIG_RT_USING_PIN=y
# CONFIG_RT_USING_PIN is not set
# CONFIG_RT_USING_PWM is not set
# CONFIG_RT_USING_MTD_NOR is not set
# CONFIG_RT_USING_MTD_NAND is not set
# CONFIG_RT_USING_MTD is not set
# CONFIG_RT_USING_RTC is not set
# CONFIG_RT_USING_SDIO is not set
# CONFIG_RT_USING_SPI is not set
# CONFIG_RT_USING_WDT is not set
CONFIG_RT_USING_WIFI=y
CONFIG_RT_USING_WLAN_STA=y
CONFIG_RT_USING_WLAN_AP=y
CONFIG_WIFI_DEVICE_STA_NAME="w0"
CONFIG_WIFI_DEVICE_AP_NAME="ap"
# CONFIG_RT_USING_AUDIO is not set
#
# Using WiFi
#
CONFIG_RT_USING_WIFI=y
CONFIG_RT_WLAN_DEVICE_STA_NAME="wlan0"
CONFIG_RT_WLAN_DEVICE_AP_NAME="wlan1"
CONFIG_RT_WLAN_DEFAULT_PROT="lwip"
CONFIG_RT_WLAN_SCAN_WAIT_MS=10000
CONFIG_RT_WLAN_CONNECT_WAIT_MS=10000
CONFIG_RT_WLAN_SSID_MAX_LENGTH=32
CONFIG_RT_WLAN_PASSWORD_MAX_LENGTH=32
CONFIG_RT_WLAN_SCAN_SORT=y
CONFIG_RT_WLAN_CFG_INFO_MAX=3
CONFIG_RT_WLAN_WORKQUEUE_THREAD_NAME="wlan_job"
CONFIG_RT_WLAN_WORKQUEUE_THREAD_SIZE=2048
CONFIG_RT_WLAN_WORKQUEUE_THREAD_PRIO=22
CONFIG_RT_WLAN_DEV_EVENT_NUM=2
# CONFIG_RT_WLAN_PROT_LWIP_PBUF_FORCE is not set
CONFIG_RT_WLAN_DEBUG=y
CONFIG_RT_WLAN_CMD_DEBUG=y
# CONFIG_RT_WLAN_MGNT_DEBUG is not set
# CONFIG_RT_WLAN_DEV_DEBUG is not set
# CONFIG_RT_WLAN_PROT_DEBUG is not set
# CONFIG_RT_WLAN_CFG_DEBUG is not set
# CONFIG_RT_WLAN_LWIP_DEBUG is not set
#
# Using USB
#
@@ -127,15 +160,21 @@ CONFIG_RT_USING_LIBC=y
# CONFIG_RT_USING_PTHREADS is not set
#
# Network stack
# Network
#
#
# Socket abstraction layer
#
# CONFIG_RT_USING_SAL is not set
#
# light weight TCP/IP stack
#
CONFIG_RT_USING_LWIP=y
CONFIG_RT_USING_LWIP141=y
# CONFIG_RT_USING_LWIP202 is not set
# CONFIG_RT_USING_LWIP141 is not set
CONFIG_RT_USING_LWIP202=y
# CONFIG_RT_USING_LWIP_IPV6 is not set
CONFIG_RT_LWIP_IGMP=y
CONFIG_RT_LWIP_ICMP=y
# CONFIG_RT_LWIP_SNMP is not set
@@ -178,12 +217,22 @@ CONFIG_LWIP_SO_SNDTIMEO=1
CONFIG_LWIP_SO_RCVBUF=1
# CONFIG_RT_LWIP_NETIF_LOOPBACK is not set
CONFIG_LWIP_NETIF_LOOPBACK=0
# CONFIG_RT_LWIP_STATS is not set
# CONFIG_RT_LWIP_DEBUG is not set
#
# Modbus master and slave stack
#
# CONFIG_RT_USING_MODBUS is not set
# CONFIG_LWIP_USING_DHCPD is not set
#
# AT commands
#
# CONFIG_RT_USING_AT is not set
CONFIG_LWIP_USING_DHCPD=y
CONFIG_DHCPD_SERVER_IP="192.168.169.1"
CONFIG_DHCPD_USING_ROUTER=y
# CONFIG_LWIP_USING_CUSTOMER_DNS_SERVER is not set
#
# VBUS(Virtual Software BUS)
@@ -212,7 +261,6 @@ CONFIG_LWIP_NETIF_LOOPBACK=0
# CONFIG_PKG_USING_LJSON is not set
# CONFIG_PKG_USING_EZXML is not set
# CONFIG_PKG_USING_NANOPB is not set
# CONFIG_PKG_USING_GAGENT_CLOUD is not set
#
# Wi-Fi
@@ -230,7 +278,16 @@ CONFIG_LWIP_NETIF_LOOPBACK=0
# CONFIG_PKG_USING_COAP is not set
# CONFIG_PKG_USING_NOPOLL is not set
# CONFIG_PKG_USING_NETUTILS is not set
# CONFIG_PKG_USING_AT_DEVICE is not set
# CONFIG_PKG_USING_WIZNET is not set
#
# IoT Cloud
#
# CONFIG_PKG_USING_ONENET is not set
# CONFIG_PKG_USING_GAGENT_CLOUD is not set
# CONFIG_PKG_USING_ALI_IOTKIT is not set
# CONFIG_PKG_USING_AZURE is not set
#
# security packages
@@ -242,6 +299,7 @@ CONFIG_LWIP_NETIF_LOOPBACK=0
#
# language packages
#
# CONFIG_PKG_USING_LUA is not set
# CONFIG_PKG_USING_JERRYSCRIPT is not set
# CONFIG_PKG_USING_MICROPYTHON is not set
@@ -258,6 +316,7 @@ CONFIG_LWIP_NETIF_LOOPBACK=0
# CONFIG_PKG_USING_EASYFLASH is not set
# CONFIG_PKG_USING_EASYLOGGER is not set
# CONFIG_PKG_USING_SYSTEMVIEW is not set
# CONFIG_PKG_USING_RDB is not set
#
# system packages
@@ -271,22 +330,29 @@ CONFIG_LWIP_NETIF_LOOPBACK=0
# CONFIG_PKG_USING_SQLITE is not set
# CONFIG_PKG_USING_RTI is not set
# CONFIG_PKG_USING_LITTLEVGL2RTT is not set
# CONFIG_PKG_USING_CMSIS is not set
# CONFIG_PKG_USING_DFS_YAFFS is not set
#
# peripheral libraries and drivers
#
# CONFIG_PKG_USING_STM32F4_HAL is not set
# CONFIG_PKG_USING_STM32F4_DRIVERS is not set
CONFIG_PKG_USING_REALTEK_AMEBA=y
CONFIG_PKG_REALTEK_AMEBA_PATH="/packages/peripherals/realtek_ameba"
CONFIG_PKG_USING_REALTEK_AMEBA_LATEST_VERSION=y
# CONFIG_PKG_USING_REALTEK_AMEBA_V100 is not set
CONFIG_PKG_REALTEK_AMEBA_VER="latest"
# CONFIG_PKG_USING_CC3200_SDK is not set
# CONFIG_PKG_USING_SHT2X is not set
# CONFIG_PKG_USING_AHT10 is not set
# CONFIG_PKG_USING_AP3216C is not set
# CONFIG_PKG_USING_STM32_SDIO is not set
# CONFIG_PKG_USING_ICM20608 is not set
# CONFIG_PKG_USING_U8G2 is not set
#
# miscellaneous packages
#
# CONFIG_PKG_USING_LIBCSV is not set
# CONFIG_PKG_USING_OPTPARSE is not set
# CONFIG_PKG_USING_FASTLZ is not set
# CONFIG_PKG_USING_MINILZO is not set
# CONFIG_PKG_USING_QUICKLZ is not set
@@ -298,17 +364,57 @@ CONFIG_PKG_REALTEK_AMEBA_VER="latest"
#
# sample package
#
# CONFIG_PKG_USING_SAMPLES is not set
#
# samples: kernel and components samples
#
# CONFIG_PKG_USING_KERNEL_SAMPLES is not set
# CONFIG_PKG_USING_FILESYSTEM_SAMPLES is not set
# CONFIG_PKG_USING_NETWORK_SAMPLES is not set
# CONFIG_PKG_USING_PERIPHERAL_SAMPLES is not set
#
# example package: hello
#
# CONFIG_PKG_USING_HELLO is not set
#
# Privated Packages of RealThread
#
# CONFIG_PKG_USING_CODEC is not set
# CONFIG_PKG_USING_PLAYER is not set
# CONFIG_PKG_USING_PERSIMMON_SRC is not set
#
# Network Utilities
#
# CONFIG_PKG_USING_MDNS is not set
# CONFIG_PKG_USING_UPNP is not set
# CONFIG_PKG_USING_WICED is not set
# CONFIG_PKG_USING_CLOUDSDK is not set
# CONFIG_PKG_USING_COREMARK is not set
# CONFIG_PKG_USING_POWER_MANAGER is not set
# CONFIG_PKG_USING_RT_OTA is not set
# CONFIG_PKG_USING_RDBD_SRC is not set
# CONFIG_PKG_USING_RTINSIGHT is not set
# CONFIG_PKG_USING_SMARTCONFIG is not set
#
# Test Packages of RealThread
#
# CONFIG_PKG_USING_JERRYSCRIPT_WIN32 is not set
# CONFIG_PKG_USING_JS_PERSIMMON is not set
#
# Env config
#
# CONFIG_SYS_AUTO_UPDATE_PKGS is not set
# CONFIG_SYS_CREATE_MDK_IAR_PROJECT is not set
# CONFIG_SYS_PKGS_DOWNLOAD_ACCELERATE is not set
CONFIG_RT_USING_UART0=y
#
# External Libraries
#
CONFIG_RT_USING_SMARTCONFIG_LIB=y
# CONFIG_BSP_USING_UART0 is not set
CONFIG_BSP_USING_WIFI=y
+2 -5
View File
@@ -26,10 +26,7 @@ config $ENV_DIR
source "$RTT_DIR/Kconfig"
source "$PKGS_DIR/Kconfig"
source "$ENV_DIR/tools/scripts/cmds/Kconfig"
config RT_USING_UART0
bool "Using RT_USING_UART0"
default y
source "$BSP_DIR/libraries/Kconfig"
source "$BSP_DIR/drivers/Kconfig"
select PKG_USING_REALTEK_AMEBA
+184 -56
View File
@@ -1,9 +1,8 @@
# amebaz on RT-Thread
## 1. 简介
## 1 简介
amebaz 是由Realtek推出的Cortex-M4内核的WiFi SOC芯片rtl8710b系列
包括如下硬件特性:
amebaz 是由Realtek推出的Cortex-M4内核的WiFi SOC芯片,属于rtl8710b系列。硬件特性如下:
| 硬件 | 描述 |
| -- | -- |
@@ -11,25 +10,42 @@ amebaz 是由Realtek推出的Cortex-M4内核的WiFi SOC芯片rtl8710b系列
|CPU| Cortex-M4 |
|主频| 125MHz |
## 2. 编译说明
## 2 编译说明
| 环境 | 说明 |
| ------------ | ------------------------------------------------------------ |
| PC操作系统 | Linux/MacOS/Windows |
| 编译器 | arm-none-eabi-gcc version 6.3.1 20170620 (release)/iar |
| 构建工具 | scons/iar |
| 编译器 | arm-none-eabi-gcc version 6.3.1 20170620 (release) |
| 构建工具 | scons |
| 依赖软件环境 | Env工具/(IAR或arm-none-eabi-gcc)/git/调试器驱动 |
1) 下载源码
## 3 下载源码
```bash
git clone https://github.com/RT-Thread/rt-thread.git
```
2) 配置工程并准备env
## 4 环境准备
Linux/Mac
### 4.1 Windows 环境准备
Windows环境下有两种开发环境,`GCC toolchain``IAR IDE`,根据不同的需求自行选择。
#### 4.1.1 IAR 发开环境
IAR 开发环境需要开发者自己安装软件,安装过程这里就不特别说明了。amebaz工程当前仅支持 `IAR 7.X` 的版本。
#### 4.4.2 GCC 开发环境
GCC开发使用 RT-Thread 官方提供的 env 工具,该工具集成 GCC 工具链,还具有编译构建环境、图形化系统配置及软件包管理功能。
下载地址:[点击下载env工具](https://www.rt-thread.org/page/download.html)
第一次使用env工具的开发者可以去这里查看教程:[RT-Thread env 工具用户手册](https://www.rt-thread.org/document/site/rtthread-development-guide/rtthread-tool-manual/env/env-user-manual/)。
### 4.2 Linux/Mac 环境准备
Linux/Mac 仅支持 GCC 工具链。
```bash
cd rt-thread/bsp/amebaz
@@ -38,11 +54,17 @@ amebaz 是由Realtek推出的Cortex-M4内核的WiFi SOC芯片rtl8710b系列
pkgs --upgrade
```
Windows
## 5 配置工程(可选
>在[RT-Thread官网][1]下载ENV工具包
### 5.1 Windows 配置工程
3) 配置芯片型号
配置工程,需要在相应的工程目录下使用 `menuconfig` 命令打开图形界面,开发者根据自己的需求开关功能组件。
```bash
menuconfig
```
### 5.2 Linux/Mac 配置工程
Linux/Mac
@@ -50,56 +72,44 @@ amebaz 是由Realtek推出的Cortex-M4内核的WiFi SOC芯片rtl8710b系列
scons --menuconfig
```
Windows(ENV环境中)
## 6 更新软件包
```bash
menuconfig
```
在menuconfig页面配置并选择对应的芯片型号,若开发环境为IAR,则需要生成工程
4) 下载package
amebaz配套的驱动库以package形式提供,故需先下载对应的package(realtek-ameba),请使用env下载package
amebaz 配套的驱动库以 package 形式提供,故需先下载对应的 package(realtek-ameba),在工程目录下,使用下面命令下载软件包。
```bash
pkgs --update
```
5) 生成工程(Mac/Linux下请跳过此步骤)
## 7 编译
Windows IAR
### 7.1 Windows 编译工程
#### 7.1.1 IAR 编译工程
先打开工程目录下的IAR工程(project.eww),然后单击 Project 选项卡,单击 Rebuild All 选项,进行编译
![ ](figures/iar_build.png)
#### 7.1.2 GCC 编译工程
可以使用env编译工程,无需设置GCC工具链路径,直接在 rt-thread/bsp/amebaz 工程目录下输入 `scons` 编译即可。编译完成后,在工程目录下生成 `image2_all_ota1.bin` 文件。
```bash
SET RTT_CC=iar
scons --target=iar -s
scons
```
*该板级支持包不支持生成mdk的工程
### 7.2 Linux/Mac 编译工程
6) 编译
使用IAR请参见对应教程
Windows arm-none-eabi-gcc
使用以下指令设置gcc路径
```bash
SET RTT_EXEC_PATH=[GCC路径]
```
Linux/Mac arm-none-eabi-gcc
使用以下指令设置gcc路径
如果没有配置GCC路径的环境变量,则需要使用以下指令设置gcc路径。
```bash
export RTT_EXEC_PATH=[GCC路径]
```
编译(WindowsLinux/Mac arm-none-eabi-gcc
设置 GCC 路径后,使用 `scons` 编译工程。
```bash
scons -j4
scons
```
出现下列信息即为编译成功
@@ -128,35 +138,153 @@ Done...
scons: done building targets.
```
如果编译正确无误,会产生image2_all_ota1.bin文件。
如果编译正确无误,会在工程目录下生成 image2_all_ota1.bin 文件。
## 3. 烧写及执行
## 8 烧写及执行
烧写可以使用仿真器 串口等多种方式 此处不再赘述
### 8.1 IAR下载
### 3.1 运行结果
下载程序分为两部分:
如果编译 & 烧写无误,会在专用日志串口*上看到RT-Thread的启动logo信息:
(a)先使用jlink工具正确连接A14(CLK),A15(TMS),GND,VCC引脚
(b)打开 IAR 工程并完成编译后,单击 Project 选项卡下 Download 选项,选择 Download active application 下载程序。
![IAR下载程序](figures/iar_download.png)
(c)短按复位按钮,连接串口查看调试信息
### 8.2 串口下载
串口下载分为三个步骤
a)板子进入下载模式
板子使用 `micros usb` 上电,然后按住 `FLASH` 键不放手,短按 `RST` 键,松开 `RST``FLASH` 键进入下载模式。
b)配置下载工具
打开 Image Tool 下载工具配置使用,选择 `micros usb` 所对应的串口端口,选择波特率,默认波特率 1.5Mbps,然后打开串口端口,如下载工具图“①”所示
![串口下载程序](figures/image-tool_v2.2.0.png)
boot选择工程提供的 `boot_all.bin`, OTA1 选择生成的 image2_all_ota1.bin 文件(通常在工程目录下),并且注意在这两个选项前面打勾确认,其他默认即可,如下载工具图“②”。
c)下载程序
按下 Download(如下载工具图 “③”),即可开始下载程序,并且可以从日志窗口查看到下载信息。
## 9 运行
下载程序后,连接串口(默认使用板子上 `micro usb`),打开串口工具,配置串口波特率 115200,数据位 8 位,停止位 1 位,无校验,无流控;短按 `RST` 键复位,串口将输出调试信息,如下所示:
```bash
\ | /
- RT - Thread Operating System
/ | \ 3.0.4 build May 15 2018
/ | \ 3.1.1 build Oct 25 2018
2006 - 2018 Copyright by rt-thread team
msh />
lwIP-2.0.2 initialized!
Initializing WIFI ...
LDO Mode, BD_Info: 0
LDO Mode, BD_Info: 0
WIFI initialized
[I/WIFI] amebaz_wifi_start success
build time: Oct 25 2018 10:52:02
Hello RT-Thread!
[I/WLAN.dev] wlan init success
[I/WLAN.lwip] eth device init ok name:w0
msh >
```
*默认串口
## 10 WIFI简单使用
### wifi扫描命令
## 4. 驱动支持情况及计划
wifi 扫描命令格式如下
```bash
wifi scan
```
命令说明
| 字段 | 描述 |
| ---- | ------------------------ |
| wifi | 有关wifi命令都以wifi开头 |
| scan | wifi执行扫描动作 |
在调试工具中输入该命令,即可进行 wifi 命令扫描,调试信息如下
```bash
scan ap down
SSID MAC security rssi chn Mbps
------------------------------- ----------------- -------------- ---- --- ----
NEO-shanghai-ap2 58:66:ba:a1:ee:71 WPA2_TKIP_PSK -74 11 0
WQ1 88:25:93:94:51:54 WPA2_AES_PSK -76 13 0
shyc1 a0:40:a0:a3:e8:c9 WPA2_AES_PSK -77 13 0
KVIP 70:65:82:3b:71:43 WPA2_AES_PSK -83 11 0
YST2016 88:25:93:c6:67:d1 WPA2_TKIP_PSK -84 4 0
```
> 注:wifi 有关的命令,均以wifi开头。
### wifi 接入
接入 wifi 之前,先介绍一下其接入的命令 ,如下
```bash
wifi join ssid 123456789
```
命令说明
| 字段 | 描述 |
| --------- | ---------------------------------- |
| wifi | 有关wifi命令都以wifi开头 |
| join | wifi执行连接动作 |
| ssid | 热点的名字 |
| 123456789 | 热点的密码,没有密码可不输入这一项 |
了解上述命令,并且成功完成前面步骤,在串口中输入 `wifi w0 join realthread_VIP 123456789` ,如下日志表示连接成功
```bash
WIFI wlan0 Setting:
==============================
MODE => STATION
SSID => realthread_VIP
CHANNEL => 6
SECURITY => AES
PASSWORD => 123456789
[I/WLAN.mgnt] wifi connect success ssid:realthread_VIP
```
另外,提供一个简单的测试使用命令,查询设备IP地址命令:ifconfig。
```bash
network interface: w0 (Default)
MTU: 1500
MAC: 00 e0 4c d5 ac 46
FLAGS: UP LINK_UP ETHARP BROADCAST
ip address: 172.16.200.110
gw address: 172.16.200.1
net mask : 255.255.255.0
dns server #0: 172.16.200.1
dns server #1: 223.5.5.5
```
## 驱动支持情况及计划
| 驱动 | 支持情况 | 备注 |
| ---------- | :------: | :--------------------------: |
| UART | 支持 | UART0 |
| UART | 支持 | UART0 |
| WLAN | 部分支持 | 仅支持STA模式 |
## 5. 联系人信息
## 联系人信息
维护人:
[flyingcys][4] < [flyingcys@163.com][5] >
+2 -9
View File
@@ -15,19 +15,12 @@
#include <rthw.h>
#include <rtthread.h>
/**
* @addtogroup ameba
*/
/*@{*/
#include <rtdevice.h>
int main(void)
{
rt_kprintf("build time: %s %s\n", __DATE__, __TIME__);
rt_kprintf("Hello RT-Thread!\n");
rt_wlan_set_mode(RT_WLAN_DEVICE_STA_NAME, RT_WLAN_STATION);
return 0;
}
/*@}*/
+146
View File
@@ -0,0 +1,146 @@
/*
* File : smartconfig_demo.c
* This file is part of RT-Thread RTOS
* 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.
*
* Change Logs:
* Date Author Notes
* 2018-09-13 Bernard the first version
*/
#include <rtthread.h>
#include <rtdevice.h>
#ifdef RT_USING_SMARTCONFIG_LIB
#include <sys/socket.h>
#include "smartconfig.h"
#define NET_READY_TIME_OUT (rt_tick_from_millisecond(30 * 1000))
static int rt_wlan_device_connetct(char *ssid, char *passwd)
{
int result = RT_EOK;
rt_uint8_t time_cnt = 0;
result = rt_wlan_connect(ssid, passwd);
if (result != RT_EOK)
{
rt_kprintf("\nconnect ssid %s error:%d!\n", ssid, result);
return result;
};
do
{
rt_thread_mdelay(1000);
time_cnt ++;
if (rt_wlan_is_ready())
{
break;
}
}
while (time_cnt <= (NET_READY_TIME_OUT / 1000));
if (time_cnt <= (NET_READY_TIME_OUT / 1000))
{
rt_kprintf("networking ready!\n");
}
else
{
rt_kprintf("wait ip got timeout!\n");
result = -RT_ETIMEOUT;
}
return result;
}
static void airkiss_send_notification(uint8_t random)
{
int sock = -1;
int udpbufsize = 2;
struct sockaddr_in UDPBCAddr, UDPBCServerAddr;
sock = socket(AF_INET, SOCK_DGRAM, 0);
if (sock < 0)
{
rt_kprintf("notify create socket error!\n");
goto _exit;
}
UDPBCAddr.sin_family = AF_INET;
UDPBCAddr.sin_port = htons(10000);
UDPBCAddr.sin_addr.s_addr = htonl(0xffffffff);
rt_memset(&(UDPBCAddr.sin_zero), 0, sizeof(UDPBCAddr.sin_zero));
UDPBCServerAddr.sin_family = AF_INET;
UDPBCServerAddr.sin_port = htons(10000);
UDPBCServerAddr.sin_addr.s_addr = htonl(INADDR_ANY);
rt_memset(&(UDPBCServerAddr.sin_zero), 0, sizeof(UDPBCServerAddr.sin_zero));
if (setsockopt(sock, SOL_SOCKET, SO_BROADCAST, &udpbufsize, sizeof(int)) != 0)
{
rt_kprintf("notify socket setsockopt error\n");
goto _exit;
}
if (bind(sock, (struct sockaddr *)&UDPBCServerAddr, sizeof(UDPBCServerAddr)) != 0)
{
rt_kprintf("notify socket bind error\n");
goto _exit;
}
for (int i = 0; i <= 20; i++)
{
int ret = sendto(sock, (char *)&random, 1, 0, (struct sockaddr *)&UDPBCAddr, sizeof(UDPBCAddr));
rt_thread_delay(10);
}
rt_kprintf("airkiss notification thread exit!\n");
_exit:
if (sock >= 0)
{
closesocket(sock);
}
}
static int smartconfig_result(rt_smartconfig_type result_type, char *ssid, char *passwd, void *userdata, rt_uint8_t userdata_len)
{
rt_uint8_t random = *(rt_uint8_t *)userdata;
rt_kprintf("type:%d\n", result_type);
rt_kprintf("ssid:%s\n", ssid);
rt_kprintf("passwd:%s\n", passwd);
rt_kprintf("user_data:0x%02x\n", random);
if (rt_wlan_device_connetct(ssid, passwd) == RT_EOK)
{
airkiss_send_notification(random);
}
return 0;
}
void smartconfig_demo(void)
{
rt_smartconfig_start(SMARTCONFIG_TYPE_AIRKISS, SMARTCONFIG_ENCRYPT_NONE, RT_NULL, smartconfig_result);
}
#ifdef RT_USING_FINSH
#include "finsh.h"
MSH_CMD_EXPORT(smartconfig_demo, smartconfig demo);
#endif
#endif
+9
View File
@@ -0,0 +1,9 @@
config BSP_USING_UART0
bool "Using UART0"
select RT_USING_SERIAL
default y
config BSP_USING_WIFI
bool "Using WIFI"
select RT_USING_WIFI
default y
+3 -8
View File
@@ -5,14 +5,9 @@ list = os.listdir(cwd)
objs = []
src = Split('''
board.c
drv_uart.c
''')
if GetDepend(['RT_USING_LWIP']):
src += Split('''
drv_wifi.c
''')
board.c
drv_uart.c
''')
CPPPATH = [cwd]
+2 -4
View File
@@ -12,10 +12,8 @@
* 2009-01-05 Bernard first implementation
* 2018-03-15 flyingcys add amebaz
*/
#include <rtl8710b.h>
#include <stdint.h>
#include <rthw.h>
#include <rtthread.h>
#include "board.h"
#include "drv_uart.h"
@@ -87,7 +85,7 @@ void rt_hw_board_init(void)
{
extern uint32_t SystemCoreClock;
SysTick_Config(SystemCoreClock/RT_TICK_PER_SECOND);
#ifdef RT_USING_HEAP
rt_system_heap_init((void*)HEAP_BEGIN, (void*)HEAP_END);
#endif
+11 -1
View File
@@ -17,7 +17,17 @@
#ifndef __BOARD_H__
#define __BOARD_H__
#include "rtl8710b.h"
#ifdef _LITTLE_ENDIAN
#undef _LITTLE_ENDIAN
#endif
#ifdef SECTION
#undef SECTION
#endif
#include <rthw.h>
#include <rtthread.h>
#include <rtdevice.h>
void rt_hw_board_init(void);
+8 -10
View File
@@ -22,11 +22,8 @@
* 2017-05-30 Bernard the first version
* 2018-03-15 flyingcys add amebaz
*/
#include <rthw.h>
#include <rtthread.h>
#include <rtdevice.h>
#include <rtl8710b.h>
#include <serial_api.h>
#include "board.h"
#include "drv_uart.h"
@@ -37,7 +34,9 @@ struct device_uart
rt_uint32_t irqno;
};
#ifdef RT_USING_UART0
extern int LOGUART_SetBaud(u32 BaudRate);
#ifdef BSP_USING_UART0
static struct rt_serial_device serial0;
static struct device_uart uart0;
#endif
@@ -64,7 +63,6 @@ const struct rt_uart_ops _uart_ops =
*/
static rt_err_t ameba_uart_configure (struct rt_serial_device *serial, struct serial_configure *cfg)
{
rt_uint32_t baud_div;
struct device_uart * uart;
RT_ASSERT(serial != RT_NULL);
@@ -230,16 +228,16 @@ int rt_hw_uart_init(void)
struct rt_serial_device *serial;
struct serial_configure config = RT_SERIAL_CONFIG_DEFAULT;
#ifdef RT_USING_UART0
#ifdef BSP_USING_UART0
{
struct device_uart *uart;
serial = &serial0;
uart = &uart0;
/* Init UART Hardware */
serial_init(&uart->serial, UART_TX, UART_RX);
serial->ops = &_uart_ops;
serial->config = config;
serial->config.baud_rate = 115200;
-3
View File
@@ -26,9 +26,6 @@
#ifndef __DRV_UART_H__
#define __DRV_UART_H__
#include "ameba_soc.h"
#include "serial_api.h"
#if defined(CONFIG_PLATFORM_8711B)
// 8710B
#define UART_TX PA_23
-453
View File
@@ -1,453 +0,0 @@
/*
* File : drv_wifi.c
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2017, 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.
*
* Change Logs:
* Date Author Notes
* 2017-5-30 Bernard the first version
* 2018-5-30 flyingcys add amebaz wifi driver
*/
#include <rtthread.h>
#include <wlan_dev.h>
#include <skbuff.h>
#include "amebaz_wlan.h"
//#define ETH_RX_DUMP
//#define ETH_TX_DUMP
//#define MINI_DUMP
struct sk_buff * rltk_wlan_get_recv_skb(int idx);
struct sk_buff * rltk_wlan_alloc_skb(unsigned int total_len);
#define MAX_ADDR_LEN 6
struct ameba_wifi
{
struct rt_wlan_device parent;
rt_uint8_t dev_addr[MAX_ADDR_LEN];
int idx;
int connected;
};
#ifdef RT_USING_WLAN_STA
static struct ameba_wifi wifi_sta;
#endif
#ifdef RT_USING_WLAN_AP
static struct ameba_wifi wifi_ap;
#endif
#if defined(ETH_RX_DUMP) || defined(ETH_TX_DUMP)
static void packet_dump(const char *msg, const struct pbuf *p)
{
const struct pbuf *q;
rt_uint32_t i, j;
rt_uint8_t *ptr;
rt_kprintf("%s %d byte\n", msg, p->tot_len);
#ifdef MINI_DUMP
return;
#endif
i = 0;
for (q = p; q != RT_NULL; q = q->next)
{
ptr = q->payload;
for (j = 0; j < q->len; j++)
{
if ((i % 8) == 0)
{
rt_kprintf(" ");
}
if ((i % 16) == 0)
{
rt_kprintf("\r\n");
}
rt_kprintf("%02x ", *ptr);
i++;
ptr++;
}
}
rt_kprintf("\n\n");
}
#endif /* dump */
#define netifapi_netif_set_link_up(n) netifapi_netif_common(n, netif_set_link_up, NULL)
#define netifapi_netif_set_link_down(n) netifapi_netif_common(n, netif_set_link_down, NULL)
void netif_set_connected(int connected)
{
wifi_sta.connected = connected;
if (connected)
{
netifapi_netif_set_link_up(wifi_sta.parent.parent.netif);
}
else
{
netifapi_netif_set_link_down(wifi_sta.parent.parent.netif);
}
}
void rltk_wlan_set_netif_info(int idx_wlan, void * dev, unsigned char * dev_addr)
{
struct ameba_wifi *wifi;
if(idx_wlan == 0)
wifi = &wifi_sta;
rtw_memcpy(wifi->dev_addr, dev_addr, 6);
rt_hw_wifi_init();
}
void netif_rx(int idx, unsigned int len)
{
struct ameba_wifi *wifi;
struct pbuf *p, *q;
int sg_len = 0;
struct sk_buff *skb = RT_NULL;
if(idx == 0)
wifi = &wifi_sta;
#if CONFIG_WLAN
if(!wifi->connected || !rltk_wlan_running(idx))
return;
#endif
skb = rltk_wlan_get_recv_skb(idx);
if(!skb)
{
rt_kprintf("netif_rx rltk_wlan_get_recv_skb NULL.\n");
return;
}
p = pbuf_alloc(PBUF_RAW, len, PBUF_POOL);
if (p != RT_NULL)
{
pbuf_take(p, skb->data, len);
skb_pull(skb, len);
#ifdef ETH_RX_DUMP
packet_dump("RX dump", p);
#endif /* ETH_RX_DUMP */
if(wifi->parent.parent.netif->input(p, wifi->parent.parent.netif) != ERR_OK)
{
pbuf_free(p);
}
}
else
{
rt_kprintf("pbuf_alloc NULL for wifi RX.\n");
}
}
int netif_is_valid_IP(int idx, unsigned char *ip_dest)
{
struct netif * pnetif;
struct ip_addr addr = { 0 };
u32_t *ip_dest_addr = (u32_t*)ip_dest;
if(idx == 0)
pnetif = wifi_sta.parent.parent.netif;
addr.addr = *ip_dest_addr;
if(pnetif == RT_NULL)
return 0;
if(pnetif->ip_addr.addr == 0)
return 1;
if(ip_addr_ismulticast(&addr) || ip_addr_isbroadcast(&addr,pnetif))
{
return 1;
}
if(ip_addr_cmp(&(pnetif->ip_addr), &addr))
return 1;
return 0;
}
void netif_post_sleep_processing(void)
{
}
void netif_pre_sleep_processing(void)
{
}
unsigned char *rltk_wlan_get_ip(int idx)
{
struct ameba_wifi *wifi;
if(idx == 0)
wifi = &wifi_sta;
return (unsigned char *)&(wifi->parent.parent.netif->ip_addr);
}
struct netif *rltk_wlan_get_netif(int idx)
{
struct netif *netif;
if(idx == 0)
netif = wifi_sta.parent.parent.netif;
else if(idx == 1)
netif = wifi_ap.parent.parent.netif;
return netif;
}
rt_err_t rt_ameba_wifi_init(rt_device_t dev)
{
return RT_EOK;
}
rt_err_t rt_ameba_wifi_open(rt_device_t dev, rt_uint16_t oflag)
{
return RT_EOK;
}
rt_err_t rt_ameba_wifi_close(rt_device_t dev)
{
return RT_EOK;
}
rt_size_t rt_ameba_wifi_read(rt_device_t dev, rt_off_t pos, void *buffer, rt_size_t size)
{
rt_set_errno(-RT_ENOSYS);
return 0;
}
rt_size_t rt_ameba_wifi_write(rt_device_t dev, rt_off_t pos, const void *buffer, rt_size_t size)
{
rt_set_errno(-RT_ENOSYS);
return 0;
}
rt_err_t rt_ameba_wifi_control(rt_device_t dev, int cmd, void *args)
{
switch(cmd)
{
case NIOCTL_GADDR:
{
struct ameba_wifi *wifi = (struct ameba_wifi *)dev;
if(args)
memcpy(args, wifi->dev_addr, MAX_ADDR_LEN);
else
return -RT_ERROR;
}
break;
case WIFI_INIT:
{
rt_wlan_mode_t mode = *(rt_wlan_mode_t *)args;
rt_kprintf("mode:%d\n", mode);
}
break;
case WIFI_SCAN:
{
struct rt_wlan_scan_result *dst = RT_NULL;
dst = (struct rt_wlan_scan_result *)rt_malloc(sizeof(struct rt_wlan_scan_result));
if(dst == RT_NULL)
{
rt_kprintf("rt_malloc for scan result failed!\n");
return -RT_ENOMEM;
}
memset(dst, 0, sizeof(struct rt_wlan_scan_result));
if(amebaz_wifi_scan(dst) != RT_EOK)
{
rt_kprintf("amebaz_wifi_scan failed...\n");
return -RT_ERROR;
}
*(struct rt_wlan_scan_result **)args = dst;
}
break;
case WIFI_JOIN:
break;
case WIFI_EASYJOIN:
{
struct rt_wlan_device *wlan = (struct rt_wlan_device *)dev;
if(amebaz_wifi_connect(wlan->info->ssid, (char *)args) != RT_EOK)
{
rt_kprintf("amebaz_wifi_connect failed...\n");
return -RT_ERROR;
}
}
break;
case WIFI_SOFTAP:
{
struct rt_wlan_device *wlan = (struct rt_wlan_device *)dev;
if(amebaz_wifi_ap_start(wlan->info->ssid, (char *)args, wlan->info->channel) != RT_EOK)
{
rt_kprintf("amebaz_wifi_ap_start failed...\n");
return -RT_ERROR;
}
}
break;
case WIFI_DISCONNECT:
if(amebaz_wifi_disconnect() != RT_EOK)
{
rt_kprintf("amebaz_wifi_disconnect failed...\n");
return -RT_ERROR;
}
break;
case WIFI_GET_RSSI:
{
int *rssi = (int *)args;
*rssi = amebaz_wifi_get_rssi();
}
break;
case WIFI_ENTER_POWERSAVE:
break;
case WIFI_CFG_MONITOR:
break;
case WIFI_SET_CHANNEL:
{
int channel = *(int *)args;
amebaz_wifi_set_channel(channel);
}
break;
case WIFI_GET_CHANNEL:
{
int *channel = (int *)args;
*channel = amebaz_wifi_get_channel();
}
break;
case WIFI_SET_MONITOR_CALLBACK:
break;
}
return RT_EOK;
}
rt_err_t rt_ameba_wifi_tx(rt_device_t dev, struct pbuf* p)
{
rt_err_t result = RT_EOK;
struct ameba_wifi *wifi = (struct ameba_wifi *)dev;
int idx;
rt_base_t level;
struct sk_buff *skb = RT_NULL;
idx = wifi->idx;
level = rt_hw_interrupt_disable();
if(wifi->connected && rltk_wlan_check_isup(idx))
rltk_wlan_tx_inc(idx);
else
{
rt_hw_interrupt_enable(level);
// rt_kprintf("is not: connected && rltk_wlan_check_isup(idx)\n");
result = -RT_ERROR;
goto _exit;
}
rt_hw_interrupt_enable(level);
#ifdef ETH_TX_DUMP
packet_dump("TX dump", p);
#endif /* ETH_TX_DUMP */
skb = rltk_wlan_alloc_skb(p->tot_len);
if(skb != RT_NULL)
{
/* copy pbuf to a whole ETH frame */
pbuf_copy_partial(p, skb->tail, p->tot_len, 0);
skb_put(skb, p->tot_len);
rltk_wlan_send_skb(idx, skb);
}
else
{
rt_kprintf("rltk_wlan_alloc_skb NULL for WIFI TX.\n");
result = -RT_ENOMEM;
}
_exit:
level = rt_hw_interrupt_disable();
rltk_wlan_tx_dec(idx);
rt_hw_interrupt_enable(level);
return result;
}
int rt_hw_wifi_init(void)
{
rt_kprintf("%s %d\n", __FUNCTION__, __LINE__);
#ifdef RT_USING_WLAN_STA
wifi_sta.parent.parent.parent.init = rt_ameba_wifi_init;
wifi_sta.parent.parent.parent.open = rt_ameba_wifi_open;
wifi_sta.parent.parent.parent.close = rt_ameba_wifi_close;
wifi_sta.parent.parent.parent.read = rt_ameba_wifi_read;
wifi_sta.parent.parent.parent.write = rt_ameba_wifi_write;
wifi_sta.parent.parent.parent.control = rt_ameba_wifi_control;
wifi_sta.parent.parent.parent.user_data = RT_NULL;
//
wifi_sta.idx = 0;
//
wifi_sta.parent.parent.eth_rx = RT_NULL;
wifi_sta.parent.parent.eth_tx = rt_ameba_wifi_tx;
/* register wifi device */
eth_device_init(&wifi_sta.parent.parent, WIFI_DEVICE_STA_NAME);
#endif
#ifdef RT_USING_WLAN_AP
#endif
return RT_EOK;
}
+5 -4
View File
@@ -6,10 +6,11 @@ CPPPATH = [cwd, str(Dir('#'))]
src = []
if GetDepend(['RT_USING_LWIP']):
src += Split('''
amebaz_wlan.c
''')
src += Split('''
drv_wifi.c
drv_wlan.c
''')
group = DefineGroup('amebaz_wlan', src, depend = [''], CPPPATH = CPPPATH)
group = DefineGroup('Drivers', src, depend = [''], CPPPATH = CPPPATH)
Return('group')
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -25,7 +25,7 @@
#ifndef __DRV_WIFI_H__
#define __DRV_WIFI_H__
int rt_hw_wifi_init(void);
int rthw_wifi_low_init(void);
#endif /* __DRV_WIFI_H__ */
+366
View File
@@ -0,0 +1,366 @@
/*
* File : drv_wlan.c
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2017, 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.
*
* Change Logs:
* Date Author Notes
* 2018-7-10 tyx the first version
*/
#include "wifi_structures.h"
#include "wifi_constants.h"
#include <wifi/wifi_util.h>
#include <wifi/wifi_conf.h>
#include "board.h"
#include "drv_wlan.h"
// #define SCAN_WAIT_TIME (10000)
struct scan_user_data
{
struct rt_completion done;
scan_callback_fn fun;
void *data;
};
extern rthw_mode_t wifi_mode;
rthw_mode_t rthw_wifi_mode_get(void)
{
return wifi_mode;
}
int rthw_wifi_stop(void)
{
return wifi_off();
}
int rthw_wifi_start(rthw_mode_t mode)
{
if(wifi_on(mode) < 0)
{
rt_kprintf("ERROR: wifi_on failed\n");
return -1;
}
return 0;
}
int rthw_wifi_connect(char *ssid, int ssid_len, char *password, int pass_len, rthw_security_t security_type)
{
int mode;
rtw_wifi_setting_t setting;
mode = rthw_wifi_mode_get();
if ((mode != RTHW_MODE_STA) && (mode != RTHW_MODE_STA_AP))
{
return -1;
}
if(wext_get_mode(WLAN0_NAME, &mode) < 0)
{
rt_kprintf("L:%d wifi get mode err\n", __LINE__);
return -1;
}
if(wifi_connect(ssid, security_type, password, ssid_len, pass_len, -1, NULL) != RTW_SUCCESS)
{
rt_kprintf("wifi connect fail\n");
return -1;
}
rt_kprintf("wifi connect success\n");
rt_kprintf("Show Wi-Fi information\n");
wifi_get_setting(WLAN0_NAME,&setting);
wifi_show_setting(WLAN0_NAME,&setting);
return 0;
}
int rthw_wifi_connect_bssid(char *bssid, char *ssid, int ssid_len, char *password, int pass_len, rthw_security_t security_type)
{
int mode;
rtw_wifi_setting_t setting;
mode = rthw_wifi_mode_get();
if ((mode != RTHW_MODE_STA) && (mode != RTHW_MODE_STA_AP))
{
return -1;
}
if(wext_get_mode(WLAN0_NAME, &mode) < 0)
{
rt_kprintf("L:%d wifi get mode err\n", __LINE__);
return -1;
}
if(wifi_connect_bssid(bssid, ssid, security_type, password, 6, ssid_len, pass_len, -1, NULL) != RTW_SUCCESS)
{
rt_kprintf("wifi connect fail\n");
return -1;
}
rt_kprintf("wifi connect success\n");
rt_kprintf("Show Wi-Fi information\n");
wifi_get_setting(WLAN0_NAME,&setting);
wifi_show_setting(WLAN0_NAME,&setting);
return 0;
}
int rthw_wifi_ap_start(char *ssid, char *password, int channel)
{
int mode = 0, timeout = 20;
rtw_security_t security_type = RTW_SECURITY_WPA2_AES_PSK;
char *name = RT_NULL;
mode = rthw_wifi_mode_get();
if (mode == RTHW_MODE_AP)
{
name = WLAN0_NAME;
}
else if (mode == RTHW_MODE_STA_AP)
{
name = WLAN1_NAME;
}
else
{
return -1;
}
if(wext_get_mode(name, &mode) < 0)
{
rt_kprintf("L:%d wifi get mode err\n", __LINE__);
return -1;
}
if (password == RT_NULL)
{
security_type = RTW_SECURITY_OPEN;
}
if(wifi_start_ap(ssid, security_type, password, rt_strlen(ssid), rt_strlen(password), 6) != 0)
{
rt_kprintf("ERROR: wifi_start_ap failed\n");
return -1;
}
while(1)
{
char essid[33];
if(wext_get_ssid(name, (unsigned char *) essid) > 0)
{
if(strcmp((const char *) essid, (const char *)ssid) == 0)
{
rt_kprintf("%s started\n", ssid);
break;
}
}
if(timeout == 0)
{
rt_kprintf("Start AP timeout\n");
return -1;
}
rt_thread_delay(1 * RT_TICK_PER_SECOND);
timeout --;
}
return 0;
}
static int rthw_wifi_disconnect(char *name)
{
char essid[33];
int timeout = 20;
const rt_uint8_t null_bssid[ETH_ALEN + 2] = {0, 0, 0, 0, 0, 1, 0, 0};
if (name == RT_NULL)
return -1;
if (wext_get_ssid(name, (unsigned char *) essid) < 0)
{
rt_kprintf("\nWIFI disconnected!\n");
return -1;
}
if (wext_set_bssid(name, null_bssid) < 0)
{
rt_kprintf("Failed to set bogus BSSID to disconnect");
return -1;
}
while (1)
{
if(wext_get_ssid(name, (unsigned char *) essid) < 0)
{
rt_kprintf("WIFI disconnected!\n");
break;
}
if(timeout == 0)
{
rt_kprintf("ERROR: Deassoc timeout!\n");
return -1;
}
rt_thread_delay(10);
timeout --;
}
return 0;
}
int rthw_wifi_sta_disconnect(void)
{
int mode = 0;
char *name = RT_NULL;
mode = rthw_wifi_mode_get();
if (mode == RTHW_MODE_STA)
{
name = WLAN0_NAME;
}
else if (mode == RTHW_MODE_STA_AP)
{
name = WLAN0_NAME;
}
else
{
return -1;
}
return rthw_wifi_disconnect(name);
}
int rthw_wifi_ap_disconnect(void)
{
int mode = 0;
char *name = RT_NULL;
mode = rthw_wifi_mode_get();
if (mode == RTHW_MODE_AP)
{
name = WLAN0_NAME;
}
else if (mode == RTHW_MODE_STA_AP)
{
name = WLAN1_NAME;
}
else
{
return -1;
}
return rthw_wifi_disconnect(name);
}
int rthw_wifi_rssi_get(void)
{
int rssi = 0;
wifi_get_rssi(&rssi);
return rssi;
}
void rthw_wifi_channel_set(int channel)
{
wifi_set_channel(channel);
}
int rthw_wifi_channel_get(void)
{
int channel;
wifi_get_channel(&channel);
return channel;
}
static rtw_result_t rthw_wifi_scan_result_handler( rtw_scan_handler_result_t* malloced_scan_result)
{
struct scan_user_data* user_data = malloced_scan_result->user_data;
struct rthw_wlan_info info = { 0 };
if (malloced_scan_result->scan_complete != RTW_TRUE)
{
rtw_scan_result_t* record = &malloced_scan_result->ap_details;
if (user_data->fun != RT_NULL)
{
record->SSID.val[record->SSID.len] = 0; /* Ensure the SSID is null terminated */
info.ssid = record->SSID.val;
info.bssid = record->BSSID.octet;
info.band = record->band;
info.datarate = 0;
info.channel = record->channel;
info.rssi = record->signal_strength;
info.security = record->security;
user_data->fun(&info, user_data->data);
}
}
else
{
user_data->fun(RT_NULL, user_data->data);
rt_free(user_data);
rt_kprintf("scan ap down\n");
}
return RTW_SUCCESS;
}
int rthw_wifi_scan(scan_callback_fn fun, void *data)
{
struct scan_user_data *user_data;
if (fun == RT_NULL)
{
rt_kprintf("scan callback fun is null\n");
return -1;
}
user_data = rt_malloc(sizeof(struct scan_user_data));
if (user_data == RT_NULL)
{
rt_kprintf("wifi scan malloc fail\n");
return -1;
}
user_data->fun = fun;
user_data->data = data;
if (wifi_scan_networks(rthw_wifi_scan_result_handler, user_data) != RTW_SUCCESS)
{
rt_kprintf("ERROR: wifi scan failed\n\r");
return -1;
}
return 0;
}
static rthw_wlan_monitor_callback_t monitor_callback;
static void rthw_wifi_promisc_callback(unsigned char *buf, unsigned int len, void* userdata)
{
if (monitor_callback)
{
monitor_callback(userdata, len, RT_NULL);
}
}
void rthw_wifi_monitor_callback_set(rthw_wlan_monitor_callback_t callback)
{
monitor_callback = callback;
}
void rthw_wifi_monitor_enable(int enable)
{
if (enable)
{
wifi_enter_promisc_mode();
wifi_set_promisc(RTW_PROMISC_ENABLE, rthw_wifi_promisc_callback, 1);
rt_kprintf("%s run \n", __FUNCTION__);
}
else
{
wifi_set_promisc(RTW_PROMISC_DISABLE, RT_NULL, 0);
rthw_wifi_stop();
}
}
+119
View File
@@ -0,0 +1,119 @@
/*
* File : drv_wlan.h
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2017, 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.
*
* Change Logs:
* Date Author Notes
* 2018-7-10 tyx the first version
*/
#ifndef __DRV_WLAN_H__
#define __DRV_WLAN_H__
typedef enum
{
RTHW_MODE_NONE = 0,
RTHW_MODE_STA,
RTHW_MODE_AP,
RTHW_MODE_STA_AP,
RTHW_MODE_PROMISC,
RTHW_MODE_P2P
}rthw_mode_t;
#define SHARED_ENABLED 0x00008000
#define WPA_SECURITY 0x00200000
#define WPA2_SECURITY 0x00400000
#define WPS_ENABLED 0x10000000
#define WEP_ENABLED 0x0001
#define TKIP_ENABLED 0x0002
#define AES_ENABLED 0x0004
#define WSEC_SWFLAG 0x0008
typedef enum {
RTHW_SECURITY_OPEN = 0, /**< Open security */
RTHW_SECURITY_WEP_PSK = WEP_ENABLED, /**< WEP Security with open authentication */
RTHW_SECURITY_WEP_SHARED = ( WEP_ENABLED | SHARED_ENABLED ), /**< WEP Security with shared authentication */
RTHW_SECURITY_WPA_TKIP_PSK = ( WPA_SECURITY | TKIP_ENABLED ), /**< WPA Security with TKIP */
RTHW_SECURITY_WPA_AES_PSK = ( WPA_SECURITY | AES_ENABLED ), /**< WPA Security with AES */
RTHW_SECURITY_WPA2_AES_PSK = ( WPA2_SECURITY | AES_ENABLED ), /**< WPA2 Security with AES */
RTHW_SECURITY_WPA2_TKIP_PSK = ( WPA2_SECURITY | TKIP_ENABLED ), /**< WPA2 Security with TKIP */
RTHW_SECURITY_WPA2_MIXED_PSK = ( WPA2_SECURITY | AES_ENABLED | TKIP_ENABLED ), /**< WPA2 Security with AES & TKIP */
RTHW_SECURITY_WPA_WPA2_MIXED = ( WPA_SECURITY | WPA2_SECURITY ), /**< WPA/WPA2 Security */
RTHW_SECURITY_WPS_OPEN = WPS_ENABLED, /**< WPS with open security */
RTHW_SECURITY_WPS_SECURE = (WPS_ENABLED | AES_ENABLED), /**< WPS with AES security */
RTHW_SECURITY_UNKNOWN = -1, /**< May be returned by scan function if security is unknown. Do not pass this to the join function! */
RTHW_SECURITY_FORCE_32_BIT = 0x7fffffff /**< Exists only to force rtw_security_t type to 32 bits */
} rthw_security_t;
typedef enum {
RTHW_WIFI_EVENT_CONNECT = 0,
RTHW_WIFI_EVENT_DISCONNECT = 1,
RTHW_WIFI_EVENT_FOURWAY_HANDSHAKE_DONE = 2,
RTHW_WIFI_EVENT_SCAN_RESULT_REPORT = 3,
RTHW_WIFI_EVENT_SCAN_DONE = 4,
RTHW_WIFI_EVENT_RECONNECTION_FAIL = 5,
RTHW_WIFI_EVENT_SEND_ACTION_DONE = 6,
RTHW_WIFI_EVENT_RX_MGNT = 7,
RTHW_WIFI_EVENT_STA_ASSOC = 8,
RTHW_WIFI_EVENT_STA_DISASSOC = 9,
RTHW_WIFI_EVENT_STA_WPS_START = 10,
RTHW_WIFI_EVENT_WPS_FINISH = 11,
RTHW_WIFI_EVENT_EAPOL_START = 12,
RTHW_WIFI_EVENT_EAPOL_RECVD = 13,
RTHW_WIFI_EVENT_NO_NETWORK = 14,
RTHW_WIFI_EVENT_BEACON_AFTER_DHCP = 15,
RTHW_WIFI_EVENT_MAX,
}rthw_event_indicate_t;
typedef enum {
RTHW_802_11_BAND_5GHZ = 0, /**< Denotes 5GHz radio band */
RTHW_802_11_BAND_2_4GHZ = 1 /**< Denotes 2.4GHz radio band */
} rthw_802_11_band_t;
struct rthw_wlan_info
{
char *ssid;
rt_uint8_t *bssid;
rthw_802_11_band_t band;
rt_uint32_t datarate;
rt_uint16_t channel;
rt_int16_t rssi;
rthw_security_t security;
};
typedef void (*scan_callback_fn)(struct rthw_wlan_info *info, void *user_data);
typedef void (*rthw_wlan_monitor_callback_t)(rt_uint8_t *data, int len, void *user_data);
rthw_mode_t rthw_wifi_mode_get(void);
int rthw_wifi_stop(void);
int rthw_wifi_start(rthw_mode_t mode);
int rthw_wifi_connect(char *ssid, int ssid_len, char *password, int pass_len, rthw_security_t security_type);
int rthw_wifi_connect_bssid(char *bssid, char *ssid, int ssid_len, char *password, int pass_len, rthw_security_t security_type);
int rthw_wifi_ap_start(char *ssid, char *password, int channel);
int rthw_wifi_rssi_get(void);
void rthw_wifi_channel_set(int channel);
int rthw_wifi_channel_get(void);
int rthw_wifi_sta_disconnect(void);
int rthw_wifi_ap_disconnect(void);
int rthw_wifi_scan(scan_callback_fn fun, void *data);
void rthw_wifi_monitor_enable(int enable);
void rthw_wifi_monitor_callback_set(rthw_wlan_monitor_callback_t callback);
#endif
Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 135 KiB

+7
View File
@@ -0,0 +1,7 @@
menu "External Libraries"
config RT_USING_SMARTCONFIG_LIB
bool "Using RT-Thrad SmartConfig Library"
default n
endmenu
+12
View File
@@ -0,0 +1,12 @@
import os
from building import *
objs = []
cwd = GetCurrentDir()
list = os.listdir(cwd)
for item in list:
if os.path.isfile(os.path.join(cwd, item, 'SConscript')):
objs = objs + SConscript(os.path.join(item, 'SConscript'))
Return('objs')
@@ -0,0 +1,18 @@
Import('rtconfig')
from building import *
cwd = GetCurrentDir()
src = []
path = [cwd + '/inc']
libs = ['']
libpath = [cwd + '/libs']
if rtconfig.CROSS_TOOL == 'gcc':
libs += ['libsmartconfig_armcm4_gcc']
elif rtconfig.CROSS_TOOL == 'iar':
libs += ['libsmartconfig_armcm4_iar']
group = DefineGroup('smartconfig', src, depend = ['RT_USING_SMARTCONFIG_LIB'], CPPPATH = path, LIBS = libs, LIBPATH = libpath)
Return('group')
@@ -0,0 +1,62 @@
/*
* File : smartconfig.h
* This file is part of RT-Thread RTOS
* 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.
*
* Change Logs:
* Date Author Notes
* 2018-09-13 Bernard the first version
*/
#ifndef __SMARTCONFIG_H__
#define __SMARTCONFIG_H__
#define SMARTCONFIG_EVENT_CHANGE_CHANNEL (1 << 0)
#define SMARTCONFIG_EVENT_LOCKED_CHANNEL (1 << 1)
#define SMARTCONFIG_EVENT_COMPLETE (1 << 2)
#define SMARTCONFIG_EVENT_RESTART (1 << 3)
#define SMARTCONFIG_EVENT_STOP (1 << 4)
typedef enum
{
SMARTCONFIG_TYPE_AIRKISS = 0,
SMARTCONFIG_TYPE_JDSMART = 1,
SMARTCONFIG_TYPE_ESPTOUCH,
SMARTCONFIG_TYPE_REALTOUCH,
SMARTCONFIG_TYPE_ALL,
SMARTCONFIG_TYPE_MAX,
} rt_smartconfig_type;
typedef enum
{
SMARTCONFIG_ENCRYPT_NONE,
SMARTCONFIG_ENCRYPT_AES,
} rt_smartconfig_encrypt_type;
typedef int (*rt_smartconfig_result_cb)(rt_smartconfig_type result_type, char *ssid, char *passwd, \
void *userdata, rt_uint8_t userdata_len);
typedef void (*rt_smartconfig_event_handle)(rt_uint32_t event, void *userdata);
int rt_smartconfig_start(rt_smartconfig_type config_type, rt_smartconfig_encrypt_type encrypt_type, char *encrypt, \
rt_smartconfig_result_cb result_cb);
int rt_smartconfig_stop(void);
void rt_smartconfig_set_event_handle(rt_smartconfig_event_handle handle, void *userdata);
char *rt_smartconfig_version(void);
#endif
File diff suppressed because it is too large Load Diff
+157 -189
View File
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+56 -12
View File
@@ -11,15 +11,14 @@
#define RT_THREAD_PRIORITY_32
#define RT_THREAD_PRIORITY_MAX 32
#define RT_TICK_PER_SECOND 1000
#define RT_DEBUG
#define RT_USING_OVERFLOW_CHECK
#define RT_DEBUG_INIT 0
#define RT_DEBUG_THREAD 0
#define RT_USING_HOOK
#define RT_IDEL_HOOK_LIST_SIZE 4
#define IDLE_THREAD_STACK_SIZE 256
#define RT_USING_TIMER_SOFT
#define RT_TIMER_THREAD_PRIO 4
#define RT_TIMER_THREAD_STACK_SIZE 512
#define RT_TIMER_THREAD_STACK_SIZE 1024
#define RT_DEBUG
/* Inter-Thread communication */
@@ -45,6 +44,9 @@
/* RT-Thread Components */
#define RT_USING_COMPONENTS_INIT
#define RT_USING_USER_MAIN
#define RT_MAIN_THREAD_STACK_SIZE 2048
#define RT_MAIN_THREAD_PRIORITY 10
/* C++ features */
@@ -62,6 +64,7 @@
#define FINSH_CMD_SIZE 80
#define FINSH_USING_MSH
#define FINSH_USING_MSH_DEFAULT
#define FINSH_USING_MSH_ONLY
#define FINSH_ARG_MAX 10
/* Device virtual file system */
@@ -70,13 +73,27 @@
/* Device Drivers */
#define RT_USING_DEVICE_IPC
#define RT_PIPE_BUFSZ 512
#define RT_USING_SERIAL
#define RT_USING_PIN
/* Using WiFi */
#define RT_USING_WIFI
#define RT_USING_WLAN_STA
#define RT_USING_WLAN_AP
#define WIFI_DEVICE_STA_NAME "w0"
#define WIFI_DEVICE_AP_NAME "ap"
#define RT_WLAN_DEVICE_STA_NAME "wlan0"
#define RT_WLAN_DEVICE_AP_NAME "wlan1"
#define RT_WLAN_DEFAULT_PROT "lwip"
#define RT_WLAN_SCAN_WAIT_MS 10000
#define RT_WLAN_CONNECT_WAIT_MS 10000
#define RT_WLAN_SSID_MAX_LENGTH 32
#define RT_WLAN_PASSWORD_MAX_LENGTH 32
#define RT_WLAN_SCAN_SORT
#define RT_WLAN_CFG_INFO_MAX 3
#define RT_WLAN_WORKQUEUE_THREAD_NAME "wlan_job"
#define RT_WLAN_WORKQUEUE_THREAD_SIZE 2048
#define RT_WLAN_WORKQUEUE_THREAD_PRIO 22
#define RT_WLAN_DEV_EVENT_NUM 2
#define RT_WLAN_DEBUG
#define RT_WLAN_CMD_DEBUG
/* Using USB */
@@ -85,12 +102,15 @@
#define RT_USING_LIBC
/* Network stack */
/* Network */
/* Socket abstraction layer */
/* light weight TCP/IP stack */
#define RT_USING_LWIP
#define RT_USING_LWIP141
#define RT_USING_LWIP202
#define RT_LWIP_IGMP
#define RT_LWIP_ICMP
#define RT_LWIP_DNS
@@ -129,6 +149,12 @@
/* Modbus master and slave stack */
/* AT commands */
#define LWIP_USING_DHCPD
#define DHCPD_SERVER_IP "192.168.169.1"
#define DHCPD_USING_ROUTER
/* VBUS(Virtual Software BUS) */
@@ -148,6 +174,9 @@
/* Wiced WiFi */
/* IoT Cloud */
/* security packages */
@@ -173,12 +202,27 @@
/* sample package */
/* samples: kernel and components samples */
/* example package: hello */
/* Privated Packages of RealThread */
/* Network Utilities */
/* Test Packages of RealThread */
/* Env config */
#define RT_USING_UART0
/* External Libraries */
#define RT_USING_SMARTCONFIG_LIB
#define BSP_USING_WIFI
#endif
+20 -36
View File
@@ -9,12 +9,17 @@ if os.getenv('RTT_CC'):
CROSS_TOOL = os.getenv('RTT_CC')
if os.getenv('RTT_ROOT'):
RTT_ROOT = os.getenv('RTT_ROOT')
else:
RTT_ROOT = os.path.join(os.path.normpath(os.getcwd()), 'rt-thread')
# cross_tool provides the cross compiler
# EXEC_PATH is the compiler execute path, for example, CodeSourcery, Keil MDK, IAR
if CROSS_TOOL == 'gcc':
PLATFORM = 'gcc'
EXEC_PATH = r'/opt/gcc-arm-none-eabi-5_4-2016q3/bin'
EXEC_PATH = 'C:/work/env/tools/gnu_gcc/arm_gcc/mingw/bin'
elif CROSS_TOOL == 'iar':
PLATFORM = 'iar'
EXEC_PATH = 'C:/Program Files (x86)/IAR Systems/Embedded Workbench 7.0'
else:
print 'Please make sure your toolchains is GNU GCC!'
exit(0)
@@ -39,7 +44,7 @@ if PLATFORM == 'gcc':
NM = PREFIX + 'nm'
DEVICE = ' -DM3 -mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=hard -ffunction-sections -fdata-sections'
CFLAGS = DEVICE + ' -g2 -w -O2 -Wno-pointer-sign -fno-common -fmessage-length=0 -ffunction-sections -fdata-sections -fomit-frame-pointer -fno-short-enums -DF_CPU=166000000L -std=gnu99 -fsigned-char'
CFLAGS = DEVICE + ' -g2 -Wall -Wno-pointer-sign -fno-common -fmessage-length=0 -ffunction-sections -fdata-sections -fomit-frame-pointer -fno-short-enums -DF_CPU=166000000L -std=gnu99 -fsigned-char'
AFLAGS = ' -c' + DEVICE + ' -x assembler-with-cpp -Wa,-mimplicit-it=thumb '
LFLAGS = DEVICE + ' -lm -lgcc -lc' + ' -g --specs=nano.specs -nostartfiles -Wl,-Map=rtthread.map -Os -Wl,--gc-sections -Wl,--cref -Wl,--entry=Reset_Handler -Wl,--no-enum-size-warning -Wl,--no-wchar-size-warning -T./rlx8711B-symbol-v02-img2_xip1.ld'
LFLAGS += ' -Wl,-wrap,rtl_printf'
@@ -48,7 +53,7 @@ if PLATFORM == 'gcc':
LPATH = ''
if BUILD == 'debug':
CFLAGS += ' -O0 -gdwarf-2'
CFLAGS += ' -Os -gdwarf-2'
AFLAGS += ' -gdwarf-2'
else:
CFLAGS += ' -O2'
@@ -61,32 +66,6 @@ if PLATFORM == 'gcc':
M_CFLAGS = CFLAGS + ' -mlong-calls -Dsourcerygxx -O0 -fPIC '
M_LFLAGS = DEVICE + ' -Wl,-z,max-page-size=0x4 -shared -fPIC -e main -nostdlib'
elif PLATFORM == 'armcc':
# toolchains
CC = 'armcc'
AS = 'armasm'
AR = 'armar'
LINK = 'armlink'
TARGET_EXT = 'axf'
DEVICE = ' --cpu=cortex-m4.fp'
CFLAGS = DEVICE + ' --apcs=interwork -DSTM32F429_439xx'
AFLAGS = DEVICE
LFLAGS = DEVICE + ' --info sizes --info totals --info unused --info veneers --list rtthread-stm32.map --scatter stm32f429_flash.sct'
CFLAGS += ' -I' + EXEC_PATH + '/ARM/RV31/INC'
LFLAGS += ' --libpath ' + EXEC_PATH + '/ARM/RV31/LIB'
EXEC_PATH += '/arm/bin40/'
if BUILD == 'debug':
CFLAGS += ' -g -O0'
AFLAGS += ' -g'
else:
CFLAGS += ' -O2'
POST_ACTION = 'fromelf --bin $TARGET --output rtthread.bin \nfromelf -z $TARGET'
elif PLATFORM == 'iar':
# toolchains
@@ -96,7 +75,7 @@ elif PLATFORM == 'iar':
LINK = 'ilinkarm'
TARGET_EXT = 'out'
DEVICE = ' -D USE_STDPERIPH_DRIVER' + ' -D STM32F10X_HD'
DEVICE = '-Dewarm'
CFLAGS = DEVICE
CFLAGS += ' --diag_suppress Pa050'
@@ -107,26 +86,31 @@ elif PLATFORM == 'iar':
CFLAGS += ' --no_tbaa'
CFLAGS += ' --no_clustering'
CFLAGS += ' --no_scheduling'
CFLAGS += ' --debug'
CFLAGS += ' --endian=little'
CFLAGS += ' --cpu=Cortex-M4'
CFLAGS += ' -e'
CFLAGS += ' --fpu=None'
CFLAGS += ' --dlib_config "' + EXEC_PATH + '/arm/INC/c/DLib_Config_Normal.h"'
CFLAGS += ' -Ol'
CFLAGS += ' --use_c++_inline'
CFLAGS += ' --silent'
AFLAGS = ''
AFLAGS = DEVICE
AFLAGS += ' -s+'
AFLAGS += ' -w+'
AFLAGS += ' -r'
AFLAGS += ' --cpu Cortex-M4'
AFLAGS += ' --fpu None'
AFLAGS += ' -S'
LFLAGS = ' --config stm32f429_flash.icf'
if BUILD == 'debug':
CFLAGS += ' --debug'
CFLAGS += ' -On'
else:
CFLAGS += ' -Oh'
LFLAGS = ' --config rom_symbol_v01_iar.icf'
LFLAGS += ' --redirect _Printf=_PrintfTiny'
LFLAGS += ' --redirect _Scanf=_ScanfSmall'
LFLAGS += ' --entry __iar_program_start'
EXEC_PATH = EXEC_PATH + '/arm/bin/'
POST_ACTION = ''
POST_ACTION = 'ielftool --bin $TARGET rt-thread.bin'
+21 -265
View File
@@ -45,7 +45,7 @@
</option>
<option>
<name>MemFile</name>
<state>$PROJ_DIR$\packages\realtek_ameba-latest\sdk-ameba-v4.0b_without_NDA_GCC_V1.0.0\component\soc\realtek\8711b\misc\iar_utility\common\8710b.ddf</state>
<state>$PROJ_DIR$\packages\realtek_ameba-latest\sdk-ameba-v4.0b_without_NDA_GCC_V1.0.0\component\soc\realtek\8711b\misc\iar_utility\common\preload.mac</state>
</option>
<option>
<name>RunToEnable</name>
@@ -81,7 +81,7 @@
</option>
<option>
<name>OCProductVersion</name>
<state>7.40.3.8937</state>
<state>7.30.4.8186</state>
</option>
<option>
<name>OCDynDriverList</name>
@@ -89,7 +89,7 @@
</option>
<option>
<name>OCLastSavedByProductVersion</name>
<state>7.40.3.8937</state>
<state>7.30.4.8186</state>
</option>
<option>
<name>OCDownloadAttachToProgram</name>
@@ -520,7 +520,7 @@
<name>IJET_ID</name>
<archiveVersion>2</archiveVersion>
<data>
<version>6</version>
<version>5</version>
<wantNonLocal>1</wantNonLocal>
<debug>1</debug>
<option>
@@ -603,7 +603,7 @@
</option>
<option>
<name>IjetCpuClockEdit</name>
<state></state>
<state>72.0</state>
</option>
<option>
<name>IjetSwoPrescalerList</name>
@@ -732,10 +732,6 @@
<version>0</version>
<state>2</state>
</option>
<option>
<name>FlashBoardPathSlave</name>
<state>0</state>
</option>
</data>
</settings>
<settings>
@@ -844,7 +840,7 @@
</option>
<option>
<name>CCJLinkInterfaceRadio</name>
<state>0</state>
<state>1</state>
</option>
<option>
<name>OCJLinkAttachSlave</name>
@@ -1256,7 +1252,7 @@
<name>XDS100_ID</name>
<archiveVersion>2</archiveVersion>
<data>
<version>4</version>
<version>2</version>
<wantNonLocal>1</wantNonLocal>
<debug>1</debug>
<option>
@@ -1275,6 +1271,11 @@
<name>TIPackage</name>
<state></state>
</option>
<option>
<name>CCXds100InterfaceList</name>
<version>2</version>
<state>0</state>
</option>
<option>
<name>BoardFile</name>
<state></state>
@@ -1287,129 +1288,6 @@
<name>LogFile</name>
<state>$PROJ_DIR$\cspycomm.log</state>
</option>
<option>
<name>CCXds100BreakpointRadio</name>
<state>0</state>
</option>
<option>
<name>CCXds100DoUpdateBreakpoints</name>
<state>0</state>
</option>
<option>
<name>CCXds100UpdateBreakpoints</name>
<state>_call_main</state>
</option>
<option>
<name>CCXds100CatchReset</name>
<state>0</state>
</option>
<option>
<name>CCXds100CatchUndef</name>
<state>0</state>
</option>
<option>
<name>CCXds100CatchSWI</name>
<state>0</state>
</option>
<option>
<name>CCXds100CatchData</name>
<state>0</state>
</option>
<option>
<name>CCXds100CatchPrefetch</name>
<state>0</state>
</option>
<option>
<name>CCXds100CatchIRQ</name>
<state>0</state>
</option>
<option>
<name>CCXds100CatchFIQ</name>
<state>0</state>
</option>
<option>
<name>CCXds100CatchCORERESET</name>
<state>0</state>
</option>
<option>
<name>CCXds100CatchMMERR</name>
<state>0</state>
</option>
<option>
<name>CCXds100CatchNOCPERR</name>
<state>0</state>
</option>
<option>
<name>CCXds100CatchCHRERR</name>
<state>0</state>
</option>
<option>
<name>CCXds100CatchSTATERR</name>
<state>0</state>
</option>
<option>
<name>CCXds100CatchBUSERR</name>
<state>0</state>
</option>
<option>
<name>CCXds100CatchINTERR</name>
<state>0</state>
</option>
<option>
<name>CCXds100CatchHARDERR</name>
<state>0</state>
</option>
<option>
<name>CCXds100CatchDummy</name>
<state>0</state>
</option>
<option>
<name>CCXds100CpuClockEdit</name>
<state>72.0</state>
</option>
<option>
<name>CCXds100SwoClockAuto</name>
<state>0</state>
</option>
<option>
<name>CCXds100SwoClockEdit</name>
<state>1000</state>
</option>
<option>
<name>CCXds100HWResetDelay</name>
<state>0</state>
</option>
<option>
<name>CCXds100ResetList</name>
<version>0</version>
<state>0</state>
</option>
<option>
<name>CCXds100UsbSerialNo</name>
<state></state>
</option>
<option>
<name>CCXds100UsbSerialNoSelect</name>
<state>0</state>
</option>
<option>
<name>CCXds100JtagSpeedList</name>
<version>0</version>
<state>0</state>
</option>
<option>
<name>CCXds100InterfaceRadio</name>
<state>2</state>
</option>
<option>
<name>CCXds100InterfaceCmdLine</name>
<state>0</state>
</option>
<option>
<name>CCXds100ProbeList</name>
<version>0</version>
<state>0</state>
</option>
</data>
</settings>
<debuggerPlugins>
@@ -1566,7 +1444,7 @@
</option>
<option>
<name>OCProductVersion</name>
<state>7.40.3.8937</state>
<state>7.30.4.8186</state>
</option>
<option>
<name>OCDynDriverList</name>
@@ -1670,7 +1548,7 @@
</option>
<option>
<name>OCMulticoreNrOfCores</name>
<state></state>
<state>1</state>
</option>
<option>
<name>OCMulticoreMaster</name>
@@ -2005,7 +1883,7 @@
<name>IJET_ID</name>
<archiveVersion>2</archiveVersion>
<data>
<version>6</version>
<version>5</version>
<wantNonLocal>1</wantNonLocal>
<debug>0</debug>
<option>
@@ -2217,10 +2095,6 @@
<version>0</version>
<state>2</state>
</option>
<option>
<name>FlashBoardPathSlave</name>
<state>0</state>
</option>
</data>
</settings>
<settings>
@@ -2741,7 +2615,7 @@
<name>XDS100_ID</name>
<archiveVersion>2</archiveVersion>
<data>
<version>4</version>
<version>2</version>
<wantNonLocal>1</wantNonLocal>
<debug>0</debug>
<option>
@@ -2760,6 +2634,11 @@
<name>TIPackage</name>
<state></state>
</option>
<option>
<name>CCXds100InterfaceList</name>
<version>2</version>
<state>0</state>
</option>
<option>
<name>BoardFile</name>
<state></state>
@@ -2772,129 +2651,6 @@
<name>LogFile</name>
<state>$PROJ_DIR$\cspycomm.log</state>
</option>
<option>
<name>CCXds100BreakpointRadio</name>
<state>0</state>
</option>
<option>
<name>CCXds100DoUpdateBreakpoints</name>
<state>0</state>
</option>
<option>
<name>CCXds100UpdateBreakpoints</name>
<state>_call_main</state>
</option>
<option>
<name>CCXds100CatchReset</name>
<state>0</state>
</option>
<option>
<name>CCXds100CatchUndef</name>
<state>0</state>
</option>
<option>
<name>CCXds100CatchSWI</name>
<state>0</state>
</option>
<option>
<name>CCXds100CatchData</name>
<state>0</state>
</option>
<option>
<name>CCXds100CatchPrefetch</name>
<state>0</state>
</option>
<option>
<name>CCXds100CatchIRQ</name>
<state>0</state>
</option>
<option>
<name>CCXds100CatchFIQ</name>
<state>0</state>
</option>
<option>
<name>CCXds100CatchCORERESET</name>
<state>0</state>
</option>
<option>
<name>CCXds100CatchMMERR</name>
<state>0</state>
</option>
<option>
<name>CCXds100CatchNOCPERR</name>
<state>0</state>
</option>
<option>
<name>CCXds100CatchCHRERR</name>
<state>0</state>
</option>
<option>
<name>CCXds100CatchSTATERR</name>
<state>0</state>
</option>
<option>
<name>CCXds100CatchBUSERR</name>
<state>0</state>
</option>
<option>
<name>CCXds100CatchINTERR</name>
<state>0</state>
</option>
<option>
<name>CCXds100CatchHARDERR</name>
<state>0</state>
</option>
<option>
<name>CCXds100CatchDummy</name>
<state>0</state>
</option>
<option>
<name>CCXds100CpuClockEdit</name>
<state>72.0</state>
</option>
<option>
<name>CCXds100SwoClockAuto</name>
<state>0</state>
</option>
<option>
<name>CCXds100SwoClockEdit</name>
<state>1000</state>
</option>
<option>
<name>CCXds100HWResetDelay</name>
<state>0</state>
</option>
<option>
<name>CCXds100ResetList</name>
<version>0</version>
<state>0</state>
</option>
<option>
<name>CCXds100UsbSerialNo</name>
<state></state>
</option>
<option>
<name>CCXds100UsbSerialNoSelect</name>
<state>0</state>
</option>
<option>
<name>CCXds100JtagSpeedList</name>
<version>0</version>
<state>0</state>
</option>
<option>
<name>CCXds100InterfaceRadio</name>
<state>2</state>
</option>
<option>
<name>CCXds100InterfaceCmdLine</name>
<state>0</state>
</option>
<option>
<name>CCXds100ProbeList</name>
<version>0</version>
<state>0</state>
</option>
</data>
</settings>
<debuggerPlugins>
+57 -76
View File
@@ -12,7 +12,7 @@
<name>General</name>
<archiveVersion>3</archiveVersion>
<data>
<version>24</version>
<version>22</version>
<wantNonLocal>1</wantNonLocal>
<debug>1</debug>
<option>
@@ -27,6 +27,11 @@
<name>ListPath</name>
<state>Debug\List</state>
</option>
<option>
<name>Variant</name>
<version>21</version>
<state>39</state>
</option>
<option>
<name>GEndianMode</name>
<state>0</state>
@@ -34,25 +39,30 @@
<option>
<name>Input variant</name>
<version>3</version>
<state>7</state>
<state>0</state>
</option>
<option>
<name>Input description</name>
<state>No specifier n, no float nor long long, no scan set, no assignment suppressing, without multibyte support.</state>
<state>Automatic choice of formatter.</state>
</option>
<option>
<name>Output variant</name>
<version>2</version>
<state>7</state>
<state>0</state>
</option>
<option>
<name>Output description</name>
<state>No specifier a, A, no specifier n, no float nor long long, no flags.</state>
<state>Automatic choice of formatter.</state>
</option>
<option>
<name>GOutputBinary</name>
<state>0</state>
</option>
<option>
<name>FPU</name>
<version>3</version>
<state>5</state>
</option>
<option>
<name>OGCoreOrChip</name>
<state>0</state>
@@ -73,11 +83,11 @@
</option>
<option>
<name>OGProductVersion</name>
<state>6.10.1.52170</state>
<state>7.30.4.8186</state>
</option>
<option>
<name>OGLastSavedByProductVersion</name>
<state>7.40.3.8937</state>
<state>7.30.4.8186</state>
</option>
<option>
<name>GeneralEnableMisra</name>
@@ -89,11 +99,11 @@
</option>
<option>
<name>OGChipSelectEditMenu</name>
<state>STM32F107xC ST STM32F107xC</state>
<state>Default None</state>
</option>
<option>
<name>GenLowLevelInterface</name>
<state>0</state>
<state>1</state>
</option>
<option>
<name>GEndianModeBE</name>
@@ -125,9 +135,14 @@
<name>RTConfigPath2</name>
<state>$TOOLKIT_DIR$\INC\c\DLib_Config_Normal.h</state>
</option>
<option>
<name>GFPUCoreSlave</name>
<version>21</version>
<state>39</state>
</option>
<option>
<name>GBECoreSlave</name>
<version>22</version>
<version>21</version>
<state>39</state>
</option>
<option>
@@ -142,34 +157,6 @@
<name>GRuntimeLibThreads</name>
<state>0</state>
</option>
<option>
<name>CoreVariant</name>
<version>22</version>
<state>39</state>
</option>
<option>
<name>GFPUDeviceSlave</name>
<state>STM32F107xC ST STM32F107xC</state>
</option>
<option>
<name>FPU2</name>
<version>0</version>
<state>4</state>
</option>
<option>
<name>NrRegs</name>
<version>0</version>
<state>1</state>
</option>
<option>
<name>NEON</name>
<state>0</state>
</option>
<option>
<name>GFPUCoreSlave2</name>
<version>22</version>
<state>39</state>
</option>
</data>
</settings>
<settings>
@@ -182,6 +169,13 @@
<option>
<name>CCDefines</name>
<state></state>
<state>CONFIG_PLATFORM_8711B</state>
<state>CONFIG_BUILD_ROM</state>
<state>PLATFORM_RTTHREAD</state>
<state>__IEEE_LITTLE_ENDIAN</state>
<state>RT_USING_DLIBC</state>
<state>_DLIB_FILE_DESCRIPTOR</state>
<state>_DLIB_THREAD_SUPPORT</state>
</option>
<option>
<name>CCPreprocFile</name>
@@ -597,7 +591,7 @@
<debug>1</debug>
<option>
<name>OOCOutputFormat</name>
<version>3</version>
<version>2</version>
<state>0</state>
</option>
<option>
@@ -967,7 +961,7 @@
<name>General</name>
<archiveVersion>3</archiveVersion>
<data>
<version>24</version>
<version>22</version>
<wantNonLocal>1</wantNonLocal>
<debug>0</debug>
<option>
@@ -982,6 +976,11 @@
<name>ListPath</name>
<state>Release\List</state>
</option>
<option>
<name>Variant</name>
<version>21</version>
<state>0</state>
</option>
<option>
<name>GEndianMode</name>
<state>0</state>
@@ -989,7 +988,7 @@
<option>
<name>Input variant</name>
<version>3</version>
<state>1</state>
<state>0</state>
</option>
<option>
<name>Input description</name>
@@ -998,7 +997,7 @@
<option>
<name>Output variant</name>
<version>2</version>
<state>1</state>
<state>0</state>
</option>
<option>
<name>Output description</name>
@@ -1008,6 +1007,11 @@
<name>GOutputBinary</name>
<state>0</state>
</option>
<option>
<name>FPU</name>
<version>3</version>
<state>0</state>
</option>
<option>
<name>OGCoreOrChip</name>
<state>0</state>
@@ -1028,11 +1032,11 @@
</option>
<option>
<name>OGProductVersion</name>
<state>6.10.1.52170</state>
<state>7.30.4.8186</state>
</option>
<option>
<name>OGLastSavedByProductVersion</name>
<state>7.40.3.8937</state>
<state></state>
</option>
<option>
<name>GeneralEnableMisra</name>
@@ -1044,7 +1048,7 @@
</option>
<option>
<name>OGChipSelectEditMenu</name>
<state>Default None</state>
<state></state>
</option>
<option>
<name>GenLowLevelInterface</name>
@@ -1080,10 +1084,15 @@
<name>RTConfigPath2</name>
<state></state>
</option>
<option>
<name>GFPUCoreSlave</name>
<version>21</version>
<state>1</state>
</option>
<option>
<name>GBECoreSlave</name>
<version>22</version>
<state>0</state>
<version>21</version>
<state>1</state>
</option>
<option>
<name>OGUseCmsis</name>
@@ -1097,34 +1106,6 @@
<name>GRuntimeLibThreads</name>
<state>0</state>
</option>
<option>
<name>CoreVariant</name>
<version>22</version>
<state>0</state>
</option>
<option>
<name>GFPUDeviceSlave</name>
<state>Default None</state>
</option>
<option>
<name>FPU2</name>
<version>0</version>
<state>0</state>
</option>
<option>
<name>NrRegs</name>
<version>0</version>
<state>0</state>
</option>
<option>
<name>NEON</name>
<state>0</state>
</option>
<option>
<name>GFPUCoreSlave2</name>
<version>22</version>
<state>0</state>
</option>
</data>
</settings>
<settings>
@@ -1552,7 +1533,7 @@
<debug>0</debug>
<option>
<name>OOCOutputFormat</name>
<version>3</version>
<version>2</version>
<state>0</state>
</option>
<option>
+1788 -1789
View File
File diff suppressed because it is too large Load Diff
+2 -2
View File
@@ -12,10 +12,10 @@
<abs_offset>0xb020</abs_offset>
</pass>
<pass>
<range>CODE 0x10005000 0x10005A6B</range>
<range>CODE 0x10005000 0x10005A9B</range>
<loader>$PROJ_DIR$\packages\realtek_ameba-latest\sdk-ameba-v4.0b_without_NDA_GCC_V1.0.0\component\soc\realtek\8711b\misc\iar_utility\common\flashloader\FlashRTL8195aMP.flash</loader>
<abs_offset>0xb000</abs_offset>
<args>--concat</args>
</pass>
<ignore>CODE 0x10005a6c 0x1003dfff</ignore>
<ignore>CODE 0x10005a9c 0x1003dfff</ignore>
</flash_board>
+55 -32
View File
@@ -19,46 +19,57 @@
*
* Change Logs:
* Date Author Notes
* 2017-12-04 Haley the first version
* 2017-09-18 Haley the first version
*/
#include <rtthread.h>
#include <rtdevice.h>
#include "am_mcu_apollo.h"
#include "board.h"
#ifdef RT_USING_ADC
/* sem define */
rt_sem_t adcsem = RT_NULL;
/* messagequeue define */
struct rt_messagequeue adcbat_mq;
#define BATTERY_GPIO 29 /* Battery */
#define BATTERY_ADC_PIN AM_HAL_PIN_29_ADCSE1
#define BATTERY_ADC_CHANNEL AM_HAL_ADC_SLOT_CHSEL_SE1 /* BATTERY ADC采集通道 */
#define BATTERY_ADC_CHANNELNUM 1 /* BATTERY ADC采集通道号 */
#define BATTERY_GPIO 35 /* Battery */
#define BATTERY_ADC_PIN AM_HAL_PIN_35_ADCSE7
#define BATTERY_ADC_CHANNEL AM_HAL_ADC_SLOT_CHSEL_SE7 /* BATTERY ADC采集通道 */
#define BATTERY_ADC_CHANNELNUM 7 /* BATTERY ADC采集通道号 */
#define ADC_CTIMER_NUM 3 /* ADC使用定时器 */
#define ADC_CTIMER_COUNT (2048/512 - 1)
#define ADC_CHANNEL_NUM 1 /* ADC采集通道个数 */
#define ADC_SAMPLE_NUM 8 /* ADC采样个数, NE_OF_OUTPUT */
#define ADC_SAMPLE_NUM 8 /* ADC采样个数 */
rt_uint8_t bat_adc_cnt = (ADC_CHANNEL_NUM + 1)*ADC_SAMPLE_NUM;
rt_int16_t am_adc_buffer_pool[64];
rt_uint8_t bat_adc_cnt = 0;
static rt_uint8_t am_adcbat_buffer_pool[256];
static rt_int16_t am_adcbat_buffertemp[32];
rt_uint8_t am_adc_data_get(rt_int16_t *buff, rt_uint16_t size)
rt_uint8_t am_adc_data_get(rt_uint8_t channel, rt_int16_t *buff, rt_uint16_t size)
{
/* wait adc interrupt release sem forever */
rt_sem_take(adcsem, RT_WAITING_FOREVER);
rt_uint8_t adc_bufftemp[32];
if (channel == BATTERY_ADC_CHANNELNUM)
{
/* wait adc message forever */
rt_mq_recv(&adcbat_mq, adc_bufftemp, 32, RT_WAITING_FOREVER);
}
/* copy the data */
rt_memcpy(buff, am_adc_buffer_pool, size*sizeof(rt_int16_t));
rt_memcpy(buff, adc_bufftemp, size*sizeof(rt_int16_t));
return 0;
}
void am_adc_start(void)
void am_adc_start(rt_uint8_t channel)
{
/* adcsem create */
adcsem = rt_sem_create("adcsem", 0, RT_IPC_FLAG_FIFO);
/* messagequeue init */
rt_mq_init(&adcbat_mq, "mq_adcbat",
&am_adcbat_buffer_pool[0],
32 - sizeof(void*),
sizeof(am_adcbat_buffer_pool),
RT_IPC_FLAG_FIFO);
/* Start the ctimer */
am_hal_ctimer_start(ADC_CTIMER_NUM, AM_HAL_CTIMER_TIMERA);
@@ -67,13 +78,16 @@ void am_adc_start(void)
am_hal_adc_trigger();
}
void am_adc_stop(void)
void am_adc_stop(rt_uint8_t channel)
{
/* Stop the ctimer */
am_hal_ctimer_stop(ADC_CTIMER_NUM, AM_HAL_CTIMER_TIMERA);
/* adcsem delete */
rt_sem_delete(adcsem);
/* messagequeue delete */
rt_mq_delete(&adceeg_mq);
/* messagequeue delete */
rt_mq_delete(&adcbat_mq);
}
/**
@@ -87,6 +101,9 @@ void am_adc_isr(void)
{
uint32_t ui32Status, ui32FifoData;
/* enter interrupt */
rt_interrupt_enter();
/* Read the interrupt status */
ui32Status = am_hal_adc_int_status_get(true);
@@ -101,20 +118,23 @@ void am_adc_isr(void)
/* Read the value from the FIFO into the circular buffer */
ui32FifoData = am_hal_adc_fifo_pop();
if(AM_HAL_ADC_FIFO_SLOT(ui32FifoData) == BATTERY_ADC_CHANNELNUM)
am_adc_buffer_pool[bat_adc_cnt++] = AM_HAL_ADC_FIFO_SAMPLE(ui32FifoData);
if(bat_adc_cnt > (ADC_CHANNEL_NUM + 1)*ADC_SAMPLE_NUM - 1)
if (AM_HAL_ADC_FIFO_SLOT(ui32FifoData) == BATTERY_ADC_CHANNELNUM)
{
/* shift data */
rt_memmove(am_adc_buffer_pool, am_adc_buffer_pool + ADC_CHANNEL_NUM*ADC_SAMPLE_NUM, ADC_CHANNEL_NUM*ADC_SAMPLE_NUM*sizeof(rt_int16_t));
bat_adc_cnt = (ADC_CHANNEL_NUM + 1)*ADC_SAMPLE_NUM;
am_adcbat_buffertemp[bat_adc_cnt++] = AM_HAL_ADC_FIFO_SAMPLE(ui32FifoData);
}
/* release adcsem */
rt_sem_release(adcsem);
if ((bat_adc_cnt > ADC_SAMPLE_NUM + 2 - 1))
{
bat_adc_cnt = 0;
/* send the message */
rt_mq_send(&adcbat_mq, am_adcbat_buffertemp, ADC_SAMPLE_NUM*sizeof(rt_int16_t));
}
} while (AM_HAL_ADC_FIFO_COUNT(ui32FifoData) > 0);
}
/* leave interrupt */
rt_interrupt_leave();
}
static void timerA3_for_adc_init(void)
@@ -129,7 +149,7 @@ static void timerA3_for_adc_init(void)
am_hal_ctimer_int_enable(AM_HAL_CTIMER_INT_TIMERA3);
/* Set 512 sample rate */
am_hal_ctimer_period_set(ADC_CTIMER_NUM, AM_HAL_CTIMER_TIMERA, 3, 1);
am_hal_ctimer_period_set(ADC_CTIMER_NUM, AM_HAL_CTIMER_TIMERA, ADC_CTIMER_COUNT, 1);
/* Enable the timer A3 to trigger the ADC directly */
am_hal_ctimer_adc_trigger_enable();
@@ -184,7 +204,10 @@ int rt_hw_adc_init(void)
/* Enable the ADC */
am_hal_adc_enable();
rt_kprintf("adc_init!\n");
/* Trigger the ADC once */
//am_hal_adc_trigger();
//rt_kprintf("adc_init!\n");
return 0;
}
+3 -3
View File
@@ -32,8 +32,8 @@
*
*/
int rt_hw_adc_init(void);
rt_uint8_t am_adc_data_get(rt_int16_t *buff, rt_uint16_t size);
void am_adc_start(void);
void am_adc_stop(void);
rt_uint8_t am_adc_data_get(rt_uint8_t channel, rt_int16_t *buff, rt_uint16_t size);
void am_adc_start(rt_uint8_t channel);
void am_adc_stop(rt_uint8_t channel);
#endif // __ADC_H_

Some files were not shown because too many files have changed in this diff Show More