Squashed 'tmk_core/' changes from 7967731..b9e0ea0

b9e0ea0 Merge commit '7fa9d8bdea3773d1195b04d98fcf27cf48ddd81d' as 'tool/mbed/mbed-sdk'
7fa9d8b Squashed 'tool/mbed/mbed-sdk/' content from commit 7c21ce5

git-subtree-dir: tmk_core
git-subtree-split: b9e0ea08cb940de20b3610ecdda18e9d8cd7c552
This commit is contained in:
Jun Wako
2015-04-24 16:26:14 +09:00
parent a20ef7052c
commit 1fe4406f37
4198 changed files with 2016457 additions and 0 deletions

15
tool/mbed/mbed-sdk/.gitattributes vendored Normal file
View File

@ -0,0 +1,15 @@
*.c text
*.cpp text
*.h text
*.s text
*.sct text
*.ld text
*.txt text
*.xml text
*.py text
*.md text
*.json text
*.tmpl text
*.dia binary
*.elf binary
*.bin binary

75
tool/mbed/mbed-sdk/.gitignore vendored Normal file
View File

@ -0,0 +1,75 @@
*.py[cod]
# Distribution dir
dist
# MANIFEST file
MANIFEST
# Private settings
private_settings.py
# Default Build Directory
build/
# Eclipse Project Files
.cproject
.project
.pydevproject
# C extensions
*.so
# Packages
*.egg
*.egg-info
dist
build
eggs
parts
bin
var
sdist
develop-eggs
.installed.cfg
lib
lib64
# Installer logs
pip-log.txt
# Unit test / coverage reports
.coverage
.tox
nosetests.xml
# Translations
*.mo
# Mr Developer
.mr.developer.cfg
output.txt
uVision Project/
# Sublime Text Project Files
*.sublime*
*.bak
debug.log
# Ignore OS X Desktop Services Store files
.DS_Store
# Orig diff files
*.orig
# PyCharm
*.idea
# Cscope
cscope.*
# vim swap files
*.swp

View File

@ -0,0 +1,9 @@
---
python:
- "2.7"
script: "python workspace_tools/build_travis.py"
install:
- "sudo $TRAVIS_BUILD_DIR/travis/install_dependencies.sh > /dev/null"
- sudo pip install colorama
- sudo pip install prettytable
- sudo pip install jinja2

View File

@ -0,0 +1,45 @@
# Description
This document is cheat sheet for everyone who wants to contribute to mbedmicro/mbed GitHub repository at GitHub.
All changes in code base should originate from GitHub Issues and take advantage of existing GitHub flows. Goal is to attract contributors and allow them contribute to code and documentation at the same time.
Guidelines from this document are created to help new and existing contributors understand process workflow and align to project rules before pull request is submitted. It explains how a participant should do things like format code, test fixes, and submit patches.
## Where to get more information?
You can for example read more in our ```docs``` section in [mbedmicro/mbed/doc](https://github.com/PrzemekWirkus/mbed/tree/docs/docs) directory.
# How to contribute
We really appreciate your contributions! We are Open Source project and we need your help. We want to keep it as easy as possible to contribute changes that get things working in your environment. There are a few guidelines that we need contributors to follow so that we can have a chance of keeping on top of things.
Before a pull request will be merged, the [mbed Contributor Agreement](http://developer.mbed.org/contributor_agreement/) must be signed.
You can pick up existing [mbed GitHub Issue](https://github.com/mbedmicro/mbed/issues) and solve it or implement new feature you find important, attractive or just necessary. We will review your proposal via pull request mechanism, give you comments and merge your changes if we decide your contribution satisfy criteria such as quality.
# Enhancements vs Bugs
Enhancements are:
* New features implementation.
* Code refactoring.
* Coding rules, coding styles improvements.
* Code comments improvement.
* Documentation work.
Bugs are:
* Issues rose internally or externally by mbedmicro/mbed users.
* Internally (within mbed team) created issues from Continuous Integration pipeline and build servers.
* Issues detected using automation tools such as compilers, sanitizers, static code analysis tools etc.
# Gate Keeper role
Gate Keeper is a person responsible for GitHub process workflow execution and is responsible for repository / project code base. Gate Keeper is also responsible for code (pull request) quality stamp and approves or rejects code changes in projects code base.
Gate Keepers will review your pull request code, give you comments in pull request comment section and in the end if everything goes well merge your pull request to one of our branches (most probably default ```master``` branch).
Please be patient, digest Gate Keeper's feedback and respond promptly :)
# mbed SDK porting
* For more information regarding mbed SDK porting please refer to [mbed SDK porting](http://developer.mbed.org/handbook/mbed-SDK-porting) handbook.
* Before starting the mbed SDK porting, you might want to familiarize with the [mbed SDK library internals](http://developer.mbed.org/handbook/mbed-library-internals) first.
# Glossary
* Gate Keeper persons responsible for overall code-base quality of mbedmicro/mbed project.
* Enhancement New feature deployment, code refactoring actions or existing code improvements.
* Bugfix Issues originated from GitHub Issues pool, raised internally within mbed classic team or issues from automated code validators like linters, static code analysis tools etc.
* Mbed classic mbed SDK 2.0 located in GitHub at mbedmicro/mbed.

165
tool/mbed/mbed-sdk/LICENSE Normal file
View File

@ -0,0 +1,165 @@
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:
You must give any other recipients of the Work or Derivative Works a copy of
this License; and
You must cause any modified files to carry prominent notices stating that You
changed the files; and
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
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.

View File

@ -0,0 +1,3 @@
graft workspace_tools
recursive-exclude workspace_tools *.pyc
include LICENSE

View File

@ -0,0 +1,115 @@
mbed SDK
========
[![Build Status](https://travis-ci.org/mbedmicro/mbed.png)](https://travis-ci.org/mbedmicro/mbed/builds)
The mbed Software Development Kit (SDK) is a C/C++ microcontroller software platform relied upon by tens of thousands of
developers to build projects fast.
The SDK is licensed under the permissive Apache 2.0 licence, so you can use it in both commercial and personal projects
with confidence.
The mbed SDK has been designed to provide enough hardware abstraction to be intuitive and concise, yet powerful enough
to build complex projects. It is built on the low-level ARM CMSIS APIs, allowing you to code down to the metal if needed.
In addition to RTOS, USB and Networking libraries, a cookbook of hundreds of reusable peripheral and module libraries
have been built on top of the SDK by the mbed Developer Community.
Documentation
-------------
* [Tools](http://developer.mbed.org/handbook/mbed-tools): how to setup and use the build system.
* [mbed library internals](http://developer.mbed.org/handbook/mbed-library-internals)
* [Adding a new target microcontroller](http://developer.mbed.org/handbook/mbed-SDK-porting)
Supported Microcontrollers and Boards
-------------------------------------
View all on the [mbed Platforms](https://developer.mbed.org/platforms/) page.
NXP:
* [mbed LPC1768](http://developer.mbed.org/platforms/mbed-LPC1768/) (Cortex-M3)
* [u-blox C027 LPC1768](http://developer.mbed.org/platforms/u-blox-C027/) (Cortex-M3)
* [mbed LPC11U24](http://developer.mbed.org/platforms/mbed-LPC11U24/) (Cortex-M0)
* [EA LPC11U35](http://developer.mbed.org/platforms/EA-LPC11U35/) (Cortex-M0)
* mbed LPC2368 (ARM7TDMI-S)
* LPC810 (Cortex-M0+)
* [LPC812](http://developer.mbed.org/platforms/NXP-LPC800-MAX/) (Cortex-M0+)
* [EA LPC4088](http://developer.mbed.org/platforms/EA-LPC4088/) (Cortex-M4F)
* [EA LPC4088 DM](http://developer.mbed.org/platforms/EA-LPC4088-Display-Module/) (Cortex-M4F)
* LPC4330 (Cortex-M4F + Cortex-M0)
* [LPC1347](http://developer.mbed.org/platforms/DipCortex-M3/) (Cortex-M3)
* [LPC1114](http://developer.mbed.org/platforms/LPC1114FN28/) (Cortex-M0)
* LPC11C24 (Cortex-M0)
* [LPC1549](https://developer.mbed.org/platforms/LPCXpresso1549/) (Cortex-M3)
* [LPC800-MAX](https://developer.mbed.org/platforms/NXP-LPC800-MAX/) (Cortex-M0+)
* [DipCortex-M0](https://developer.mbed.org/platforms/DipCortex-M0/) (Cortex-M0)
* [DipCortex-M3](https://developer.mbed.org/platforms/DipCortex-M3/) (Cortex-M3)
* [BlueBoard-LPC11U24](https://developer.mbed.org/platforms/BlueBoard-LPC11U24/) (Cortex-M0)
* LPCCAPPUCCINO (Cortex-M0)
* [Arch](https://developer.mbed.org/platforms/Seeeduino-Arch/) (Cortex-M0)
* [Arch GPRS](https://developer.mbed.org/platforms/Seeed-Arch-GPRS/) (Cortex-M0)
* [Arch Pro](https://developer.mbed.org/platforms/Seeeduino-Arch-Pro/) (Cortex-M3)
Freescale:
* [FRDM-KL05Z](https://developer.mbed.org/platforms/FRDM-KL05Z/) (Cortex-M0+)
* [FRDM-KL25Z](http://developer.mbed.org/platforms/KL25Z/) (Cortex-M0+)
* FRDM-KL43Z (Cortex-M0+)
* [FRDM-KL46Z](https://developer.mbed.org/platforms/FRDM-KL46Z/) (Cortex-M0+)
* [FRDM-K20D50M](https://developer.mbed.org/platforms/FRDM-K20D50M/) (Cortex-M4)
* [FRDM-K22F](https://developer.mbed.org/platforms/FRDM-K22F/) (Cortex-M4F)
* [FRDM-K64F](https://developer.mbed.org/platforms/FRDM-K64F/) (Cortex-M4F)
STMicroelectronics:
* [Nucleo-F030R8](https://developer.mbed.org/platforms/ST-Nucleo-F030R8/) (Cortex-M0)
* [Nucleo-F072RB](https://developer.mbed.org/platforms/ST-Nucleo-F072RB/) (Cortex-M0)
* [Nucleo-L053R8](https://developer.mbed.org/platforms/ST-Nucleo-L053R8/) (Cortex-M0+)
* [Nucleo-F103RB](https://developer.mbed.org/platforms/ST-Nucleo-F103RB/) (Cortex-M3)
* [Nucleo-L152RE](https://developer.mbed.org/platforms/ST-Nucleo-L152RE/) (Cortex-M3)
* [Nucleo-F302R8](https://developer.mbed.org/platforms/ST-Nucleo-F302R8/) (Cortex-M4F)
* [Nucleo-F334R8](https://developer.mbed.org/platforms/ST-Nucleo-F334R8/) (Cortex-M4F)
* [Nucleo-F401RE](https://developer.mbed.org/platforms/ST-Nucleo-F401RE/) (Cortex-M4F)
* [Nucleo-F411RE](https://developer.mbed.org/platforms/ST-Nucleo-F411RE/) (Cortex-M4F)
* STM32F4XX (Cortex-M4F)
* STM32F3XX (Cortex-M4F)
* STM32F0-Discovery (Cortex-M0)
* STM32VL-Discovery (Cortex-M3)
* STM32F3-Discovery (Cortex-M4F)
* STM32F4-Discovery (Cortex-M4F)
* STM32F429-Discovery (Cortex-M4F)
* STM32L0-Discovery (Cortex-M0+)
* [Arch Max](https://developer.mbed.org/platforms/Seeed-Arch-Max/) (Cortex-M4F)
Nordic:
* [nRF51822-mKIT](https://developer.mbed.org/platforms/Nordic-nRF51822/) (Cortex-M0)
* [Arch BLE](https://developer.mbed.org/platforms/Seeed-Arch-BLE/) (Cortex-M0)
Renesas:
* [RZ-A1H](http://developer.mbed.org/platforms/Renesas-GR-PEACH/) (Cortex-A9)
Supported Toolchains and IDEs
-----------------------------
* GCC ARM: [GNU Tools for ARM Embedded Processors](https://launchpad.net/gcc-arm-embedded/4.7/4.7-2012-q4-major)
* ARMCC (standard library and MicroLib): [uVision](http://www.keil.com/uvision/)
* IAR: [IAR Embedded Workbench](http://www.iar.com/en/Products/IAR-Embedded-Workbench/ARM/)
* GCC code_red: [Red Suite](http://www.code-red-tech.com/)
* GCC CodeSourcery: [Sourcery CodeBench](http://www.mentor.com/embedded-software/codesourcery)
* GCC ARM: [Em::Blocks](http://www.emblocks.org/web/)
* GCC ARM: [CooCox CoIDE](http://www.coocox.org/)
API Documentation
-----------------
* [RTOS API](http://developer.mbed.org/handbook/RTOS)
* [TCP/IP Socket API](http://developer.mbed.org/handbook/Socket) (Transports: Ethernet, WiFi, 3G)
* [USB Device API](http://developer.mbed.org/handbook/USBDevice)
* [USB Host API](http://developer.mbed.org/handbook/USBHost)
* [DSP API](http://developer.mbed.org/users/mbed_official/code/mbed-dsp/docs/tip/)
* Flash File Systems: [SD](http://developer.mbed.org/handbook/SDFileSystem), [USB MSD](http://developer.mbed.org/handbook/USBHostMSD), [semihosted](http://developer.mbed.org/handbook/LocalFileSystem)
* [Peripheral Drivers API](http://developer.mbed.org/handbook/Homepage)
Community
---------
For discussing the development of the mbed SDK itself (Addition/support of microcontrollers/toolchains, build and test system, Hardware Abstraction Layer API, etc) please join our [mbed-devel mailing list](https://groups.google.com/forum/?fromgroups#!forum/mbed-devel).
For every topic regarding the use of the mbed SDK, rather than its development, please post on the [mbed.org forum](http://mbed.org/forum/), or the [mbed.org Q&A](http://mbed.org/questions/).
For reporting issues in the mbed libraries please open a ticket on the issue tracker of the relevant [mbed official library](http://mbed.org/users/mbed_official/code/).

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,269 @@
# Committing changes to mbedmicro/mbed
* Our current branching model is very simple. We are using ```master``` branch to merge all pull requests.
* Based on stable ```SHA``` version of ```master``` branch we decide to release and att he same time ```tag``` our build release.
* Our current release versioning follows simple integer version: ```94```, ```95```, ```96``` etc.
# Committer Guide
## How to decide what release(s) should be patched
This section provides a guide to help a committer decide the specific base branch that a change set should be merged into.
Currently our default branch is ```master``` branch. All pull requests should be created against ```master``` branch.
mbed SDK is released currently on master branch under certain tag name (see [Git tagging basics]( http://git-scm.com/book/en/v2/Git-Basics-Tagging)). You can see mbed SDK tags and switch between them to for example go back to previous mbed SDK release.
```
$ git tag
```
Please note: mebd SDK ```master``` branch's ```HEAD``` is our latest code and may not be as stable as you expect. We are putting our best effort to run regression testing (in-house) against pull requests and latest code.
Each commit to ```master``` will trigger [GitHub's Travis Continuous Integration](https://travis-ci.org/mbedmicro/mbed/builds).
### Pull request
Please send pull requests with changes which are:
* Complete (your code will compile and perform as expected).
* Tested on hardware.
* You can use included mbed SDK test suite to perform testing. See TESTING.md.
* If your change, feature do not have a test case included please add one (or more) to cover new functionality.
* If you can't test your functionality describe why.
* Documented source code:
* New, modified functions have descriptive comments.
* You follow coding rules and styles provided by mbed SDK project.
* Documented pull request description:
* Description of changes is added - explain your change / enhancement.
* References to existing issues, other pull requests or forum discussions are included.
* Test results are added.
After you send us your pull request our Gate Keeper will change the state of pull request to:
• ``` enhancement``` or ```bug``` when pull request creates new improvement or fixed issue.
Than we will set for you labels:
• ```review``` to let you know your pull request is under review and you can expect review related comments from us.
• ```in progress``` when you pull request requires some additional change which will for now block this pull request from merging.
At the end we will remove ```review``` label and merge your change if everything goes well.
## C++ coding rules & coding guidelines
### Rules
* The mbed SDK code follows K&R style (Reference: [K&R style](http://en.wikipedia.org/wiki/Indent_style#K.26R_style)) with at least 2 exceptions which can be found in the list below the code snippet:
```c++
static const PinMap PinMap_ADC[] = {
{PTC2, ADC0_SE4b, 0},
{NC , NC , 0}
};
uint32_t adc_function(analogin_t *obj, uint32_t options)
{
uint32_t instance = obj->adc >> ADC_INSTANCE_SHIFT;
switch (options) {
case 1:
timeout = 6;
break;
default:
timeout = 10;
break;
}
while (!adc_hal_is_conversion_completed(instance, 0)) {
if (timeout == 0) {
break;
} else {
timeout--;
}
}
if (obj->adc == ADC_CHANNEL0) {
adc_measure_channel(instance);
adc_stop_channel(instance);
} else {
error("channel not available");
}
#if DEBUG
for (uint32_t i = 0; i < 10; i++) {
printf("Loop : %d", i);
}
#endif
return adc_hal_get_conversion_value(instance, 0);
}
```
* Indentation - 4 spaces. Please do not use tabs!
* Braces - K&R, except for functions where the opening brace is on the new line.
* 1 TBS - use braces for statements ```if```, ```else```, ```while```, ```for``` (exception from K&R) Reference: [1TBS](http://en.wikipedia.org/wiki/Indent_style#Variant:_1TBS)).
* One line per statement.
* Preprocessor macro starts at the beginning of a new line, the code inside is indented accordingly the code above it.
* Cases within switch are indented (exception from K&R).
* Space after statements if, while, for, switch, same applies to binary and ternary operators.
* Each line has preferably at most 120 characters.
* For pointers, ```*``` is adjacent to a name (analogin_t *obj).
* Don't leave trailing spaces at the end of lines.
* Empty lines should have no trailing spaces.
* Unix line endings are default option for files.
* Use capital letters for macros.
* A file should have an empty line at the end.
and:
* We are not using C++11 yet so do not write code compliant to this standard.
* We are not using libraries like ```BOOST``` so please so not include any ```BOOST``` headers to your code.
* C++ & templates: please take under consideration templates are not fully supported by cross-compilers. You may have difficulties compiling template code few cross-compilers so make sure your template code compilers for more than one compiler.
### Naming conventions
Classes:
* Begins with a capital letter, and each word in it begins also with a capital letter (```AnalogIn```, ```BusInOut```).
* Methods contain small letters, distinct words separated by underscore.
* Private members starts with an underscore.
User defined types (typedef):
* Structures - suffix ```_t``` - to denote it is user defined type
* Enumeration - the type name and values name - same naming convention as classes (e.g ```MyNewEnum```)
Functions:
* Contain lower case letters (as methods within classes)
* Distinct words separated by underscore (```wait_ms```, ```read_u16```)
* Please make sure that in your module all functions have unique prefix so when your module is compiled with other modules function names (and e.g. extern global variable names) are not in naming conflict.
Example code look&feel:
```c++
#define ADC_INSTANCE_SHIFT 8
class AnalogIn {
public:
/** Create an AnalogIn, connected to the specified pin
*
* @param pin AnalogIn pin to connect to
* @param name (optional) A string to identify the object
*/
AnalogIn(PinName pin) {
analogin_init(&_adc, pin);
}
/** Read the input voltage, represented as a float in the range [0.0, 1.0]
*
* @returns
* A floating-point value representing the current input voltage, measured as a percentage
*/
uint32_t read() {
return analogin_read(&_adc, operation);
}
protected:
analogin_t _adc;
};
typedef enum {
ADC0_SE0 = (0 << ADC_INSTANCE_SHIFT) | 0,
} ADCName;
struct analogin_s {
ADCName adc;
};
typedef struct analogin_s analogin_t;
```
### Doxygen documentation
All functions / methods should contain a documentation using doxygen javadoc in a header file. More information regarding writing API Documentation, follow [this](https://mbed.org/handbook/API-Documentation) link.
Example of well documentet code:
```c++
#ifndef ADC_H
#define ADC_H
#ifdef __cplusplus
extern "C" {
#endif
/** ADC Measurement method
*
* @param obj Pointer to the analogin object.
* @param options Options to be enabled by ADC peripheral.
*
* @returns
* Measurement value on defined ADC channel.
*/
uint32_t adc_function(analogin_t *obj, uint32_t options)
#ifdef __cplusplus
}
#endif
#endif
```
### C/C++ Source code indenter
In Mbed project you can use AStyle (Reference: [Artistic Style](http://astyle.sourceforge.net/)) source code indenter to help you auto format your source code. It will for sure not correct all your coding styles but for sure will eliminate most of them. You can download AStyle from this location.
Official Mbed SDK styles include below AStyle styles (defined by command line switched):
```
--style=kr --indent=spaces=4 --indent-switches
```
To format your file you can execute below command. Just replace ```$(FULL_CURRENT_PATH)``` with path to your source file.
```
$ astyle.exe --style=kr --indent=spaces=4 --indent-switches $(FULL_CURRENT_PATH)
```
## Python coding rules & coding guidelines
Some of our tools in workspace_tools are written in ```Python 2.7```. In case of developing tools for python we prefer to keep similar code styles across all Python source code. Please note that not all rules must be enforced. For example we do not limit you to 80 characters per line, just be sure your code can fit to widescreen display.
Please stay compatible with ```Python 2.7``` but nothing stops you to write your code so in the future it will by Python 3 friendly.
Please check our Python source code (especially ```test_api.py``` and ```singletest.py```) to get notion of how your new code should look like). We know our code is not perfect but please try to fit the same coding style to existing code so source looks consistent and is not series of different flavors.
Some general guidelines:
* Use Python idioms, please refer to one of many on-line guidelines how to write Pythonic code: [Code Like a Pythonista: Idiomatic Python](http://python.net/~goodger/projects/pycon/2007/idiomatic/handout.html).
* Please do not use TABs. Please use 4 spaces instead for indentations.
* Please put space character between operators, after comma etc.
* Please document your code, write comments and ```doc``` sections for each function or class you implement.
### Static Code Analizers for Python
If you are old-school developer for sure you remember tools like lint. "lint was the name originally given to a particular program that flagged some suspicious and non-portable constructs (likely to be bugs) in C language source code." Now lint-like programs are used to check similar code issues for multiple languages, also for Python. Please do use them if you want to commit new code to workspace_tools and other mbed SDK Python tooling.
Below is the list Python lint tools you may want to use:
* [pyflakes](https://pypi.python.org/pypi/pyflakes) - Please scan your code with pyflakes and remove all issues reported by it. If you are unsure if something should be modified or not you can skip lint report related fix and report this issue as possible additional commit in your pull request description.
* [pylint](http://www.pylint.org/) - Please scan your code with pylint and check if there are any issues which can be resolved and are obvious "to fix" bugs. For example you may forgot to add 'self' as first parameter in class method parameter list or you are calling unknown functions / functions from not imported modules.
* [pychecker](http://pychecker.sourceforge.net/) - optional, but more the merrier ;)
Example Python look&feel:
```python
class HostRegistry:
""" Class stores registry with host tests and objects representing them
"""
HOST_TESTS = {} # host_test_name -> host_test_ojbect
def register_host_test(self, ht_name, ht_object):
""" Registers (removes) host test by name from HOST_TESTS registry
if host test is not already registered (check by name).
"""
if ht_name not in self.HOST_TESTS:
self.HOST_TESTS[ht_name] = ht_object
def unregister_host_test(self):
""" Unregisters (removes) host test by name from HOST_TESTS registry.
"""
if ht_name in HOST_TESTS:
self.HOST_TESTS[ht_name] = None
def get_host_test(self, ht_name):
""" Returns HOST_TEST if host name is valid.
In case no host test is available return None
"""
return self.HOST_TESTS[ht_name] if ht_name in self.HOST_TESTS else None
def is_host_test(self, ht_name):
""" Function returns True if host name is valid (is in HOST_TESTS)
"""
return ht_name in self.HOST_TESTS
```
## Testing
Please refer to TESTING.md document for detais regarding mbed SDK test suite and build scripts included in ```mbed/workspace_tools/```.
## Before pull request checklist
* Your pull request description section contains:
* Rationale tell us why you submitted this pull request. This is your change to write us summary of your change.
* Description describe changes youve made and tell us which new features / functionalities were implemented.
* Manual / Cookbook / Handbook you can put here manual, cookbook or handbook related to your change / enhancement. Your documentation can stay with pull request.
* Test results (if applicable).
* Make sure you followed project's coding rules and styles.
* No dependencies are created to external C/C++ libraries which are not included already in our repository.
* Please make sure that in your module all functions have unique prefix (no name space collisions).
* You reused existing functionality, please do not add or rewrite existing code. E.g. use mbeds ```FunctionPointer``` if possible to store your function pointers. Do not write another wrapper for it. We already got one. If some functionality is missing, just add it! Extend our APIs wisely!
* Were you consistent? Please continue using style / code formatting, variables naming etc. in file they are modifying.
* Your code compiles and links. Also doesnt generate additional compilation warnings.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,287 @@
/* Copyright (c) 2010-2011 mbed.org, MIT License
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software
* and associated documentation files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or
* substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
* BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef USBAudio_H
#define USBAudio_H
/* These headers are included for child class. */
#include "USBEndpoints.h"
#include "USBDescriptor.h"
#include "USBDevice_Types.h"
#include "USBDevice.h"
/**
* USBAudio example
*
* @code
* #include "mbed.h"
* #include "USBAudio.h"
*
* Serial pc(USBTX, USBRX);
*
* // frequency: 48 kHz
* #define FREQ 48000
*
* // 1 channel: mono
* #define NB_CHA 1
*
* // length of an audio packet: each ms, we receive 48 * 16bits ->48 * 2 bytes. as there is one channel, the length will be 48 * 2 * 1
* #define AUDIO_LENGTH_PACKET 48 * 2 * 1
*
* // USBAudio
* USBAudio audio(FREQ, NB_CHA);
*
* int main() {
* int16_t buf[AUDIO_LENGTH_PACKET/2];
*
* while (1) {
* // read an audio packet
* audio.read((uint8_t *)buf);
*
*
* // print packet received
* pc.printf("recv: ");
* for(int i = 0; i < AUDIO_LENGTH_PACKET/2; i++) {
* pc.printf("%d ", buf[i]);
* }
* pc.printf("\r\n");
* }
* }
* @endcode
*/
class USBAudio: public USBDevice {
public:
/**
* Constructor
*
* @param frequency_in frequency in Hz (default: 48000)
* @param channel_nb_in channel number (1 or 2) (default: 1)
* @param frequency_out frequency in Hz (default: 8000)
* @param channel_nb_out_in channel number (1 or 2) (default: 1)
* @param vendor_id Your vendor_id
* @param product_id Your product_id
* @param product_release Your preoduct_release
*/
USBAudio(uint32_t frequency_in = 48000, uint8_t channel_nb_in = 1, uint32_t frequency_out = 8000, uint8_t channel_nb_out = 1, uint16_t vendor_id = 0x7bb8, uint16_t product_id = 0x1111, uint16_t product_release = 0x0100);
/**
* Get current volume between 0.0 and 1.0
*
* @returns volume
*/
float getVolume();
/**
* Read an audio packet. During a frame, only a single reading (you can't write and read an audio packet during the same frame)can be done using this method. Warning: Blocking
*
* @param buf pointer on a buffer which will be filled with an audio packet
*
* @returns true if successfull
*/
bool read(uint8_t * buf);
/**
* Try to read an audio packet. During a frame, only a single reading (you can't write and read an audio packet during the same frame)can be done using this method. Warning: Non Blocking
*
* @param buf pointer on a buffer which will be filled if an audio packet is available
*
* @returns true if successfull
*/
bool readNB(uint8_t * buf);
/**
* Write an audio packet. During a frame, only a single writing (you can't write and read an audio packet during the same frame)can be done using this method.
*
* @param buf pointer on the audio packet which will be sent
* @returns true if successful
*/
bool write(uint8_t * buf);
/**
* Write and read an audio packet at the same time (on the same frame)
*
* @param buf_read pointer on a buffer which will be filled with an audio packet
* @param buf_write pointer on the audio packet which will be sent
* @returns true if successful
*/
bool readWrite(uint8_t * buf_read, uint8_t * buf_write);
/** attach a handler to update the volume
*
* @param function Function to attach
*
*/
void attach(void(*fptr)(void)) {
updateVol.attach(fptr);
}
/** Attach a nonstatic void/void member function to update the volume
*
* @param tptr Object pointer
* @param mptr Member function pointer
*
*/
template<typename T>
void attach(T *tptr, void(T::*mptr)(void)) {
updateVol.attach(tptr, mptr);
}
protected:
/*
* Called by USBDevice layer. Set configuration of the device.
* For instance, you can add all endpoints that you need on this function.
*
* @param configuration Number of the configuration
* @returns true if class handles this request
*/
virtual bool USBCallback_setConfiguration(uint8_t configuration);
/*
* Called by USBDevice on Endpoint0 request. Warning: Called in ISR context
* This is used to handle extensions to standard requests
* and class specific requests
*
* @returns true if class handles this request
*/
virtual bool USBCallback_request();
/*
* Get string product descriptor
*
* @returns pointer to the string product descriptor
*/
virtual uint8_t * stringIproductDesc();
/*
* Get string interface descriptor
*
* @returns pointer to the string interface descriptor
*/
virtual uint8_t * stringIinterfaceDesc();
/*
* Get configuration descriptor
*
* @returns pointer to the configuration descriptor
*/
virtual uint8_t * configurationDesc();
/*
* Called by USBDevice layer. Set interface/alternate of the device.
*
* @param interface Number of the interface to be configured
* @param alternate Number of the alternate to be configured
* @returns true if class handles this request
*/
virtual bool USBCallback_setInterface(uint16_t interface, uint8_t alternate);
/*
* Called by USBDevice on Endpoint0 request completion
* if the 'notify' flag has been set to true. Warning: Called in ISR context
*
* In this case it is used to indicate that a HID report has
* been received from the host on endpoint 0
*
* @param buf buffer received on endpoint 0
* @param length length of this buffer
*/
virtual void USBCallback_requestCompleted(uint8_t * buf, uint32_t length);
/*
* Callback called on each Start of Frame event
*/
virtual void SOF(int frameNumber);
/*
* Callback called when a packet is received
*/
virtual bool EPISO_OUT_callback();
/*
* Callback called when a packet has been sent
*/
virtual bool EPISO_IN_callback();
private:
// stream available ?
volatile bool available;
// interrupt OUT has been received
volatile bool interruptOUT;
// interrupt IN has been received
volatile bool interruptIN;
// audio packet has been written
volatile bool writeIN;
// FREQ
uint32_t FREQ_OUT;
uint32_t FREQ_IN;
// size of the maximum packet for the isochronous endpoint
uint32_t PACKET_SIZE_ISO_IN;
uint32_t PACKET_SIZE_ISO_OUT;
// mono, stereo,...
uint8_t channel_nb_in;
uint8_t channel_nb_out;
// channel config: master, left, right
uint8_t channel_config_in;
uint8_t channel_config_out;
// mute state
uint8_t mute;
// Volume Current Value
uint16_t volCur;
// Volume Minimum Value
uint16_t volMin;
// Volume Maximum Value
uint16_t volMax;
// Volume Resolution
uint16_t volRes;
// Buffer containing one audio packet (to be read)
volatile uint8_t * buf_stream_in;
// Buffer containing one audio packet (to be written)
volatile uint8_t * buf_stream_out;
// callback to update volume
FunctionPointer updateVol;
// boolean showing that the SOF handler has been called. Useful for readNB.
volatile bool SOF_handler;
volatile float volume;
};
#endif

View File

@ -0,0 +1,97 @@
/* Copyright (c) 2010-2011 mbed.org, MIT License
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software
* and associated documentation files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or
* substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
* BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef USBAUDIO_TYPES_H
#define USBAUDIO_TYPES_H
#define DEFAULT_CONFIGURATION (1)
// Audio Request Codes
#define REQUEST_SET_CUR 0x01
#define REQUEST_GET_CUR 0x81
#define REQUEST_SET_MIN 0x02
#define REQUEST_GET_MIN 0x82
#define REQUEST_SET_MAX 0x03
#define REQUEST_GET_MAX 0x83
#define REQUEST_SET_RES 0x04
#define REQUEST_GET_RES 0x84
#define MUTE_CONTROL 0x01
#define VOLUME_CONTROL 0x02
// Audio Descriptor Sizes
#define CONTROL_INTERFACE_DESCRIPTOR_LENGTH 0x09
#define STREAMING_INTERFACE_DESCRIPTOR_LENGTH 0x07
#define INPUT_TERMINAL_DESCRIPTOR_LENGTH 0x0C
#define OUTPUT_TERMINAL_DESCRIPTOR_LENGTH 0x09
#define FEATURE_UNIT_DESCRIPTOR_LENGTH 0x09
#define STREAMING_ENDPOINT_DESCRIPTOR_LENGTH 0x07
// Audio Format Type Descriptor Sizes
#define FORMAT_TYPE_I_DESCRIPTOR_LENGTH 0x0b
#define AUDIO_CLASS 0x01
#define SUBCLASS_AUDIOCONTROL 0x01
#define SUBCLASS_AUDIOSTREAMING 0x02
// Audio Descriptor Types
#define INTERFACE_DESCRIPTOR_TYPE 0x24
#define ENDPOINT_DESCRIPTOR_TYPE 0x25
// Audio Control Interface Descriptor Subtypes
#define CONTROL_HEADER 0x01
#define CONTROL_INPUT_TERMINAL 0x02
#define CONTROL_OUTPUT_TERMINAL 0x03
#define CONTROL_FEATURE_UNIT 0x06
// USB Terminal Types
#define TERMINAL_USB_STREAMING 0x0101
// Predefined Audio Channel Configuration Bits
// Mono
#define CHANNEL_M 0x0000
#define CHANNEL_L 0x0001 /* Left Front */
#define CHANNEL_R 0x0002 /* Right Front */
// Feature Unit Control Bits
#define CONTROL_MUTE 0x0001
#define CONTROL_VOLUME 0x0002
// Input Terminal Types
#define TERMINAL_MICROPHONE 0x0201
// Output Terminal Types
#define TERMINAL_SPEAKER 0x0301
#define TERMINAL_HEADPHONES 0x0302
// Audio Streaming Interface Descriptor Subtypes
#define STREAMING_GENERAL 0x01
#define STREAMING_FORMAT_TYPE 0x02
// Audio Data Format Type I Codes
#define FORMAT_PCM 0x0001
// Audio Format Types
#define FORMAT_TYPE_I 0x01
// Audio Endpoint Descriptor Subtypes
#define ENDPOINT_GENERAL 0x01
#endif

View File

@ -0,0 +1,143 @@
/*******************************************************************************
* DISCLAIMER
* This software is supplied by Renesas Electronics Corporation and is only
* intended for use with Renesas products. No other uses are authorized. This
* software is owned by Renesas Electronics Corporation and is protected under
* all applicable laws, including copyright laws.
* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING
* THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT
* LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
* AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.
* TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS
* ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE
* FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR
* ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE
* BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
* Renesas reserves the right, without notice, to make changes to this software
* and to discontinue the availability of this software. By using this software,
* you agree to the additional terms and conditions found by accessing the
* following link:
* http://www.renesas.com/disclaimer
* Copyright (C) 2012 - 2014 Renesas Electronics Corporation. All rights reserved.
*******************************************************************************/
/*******************************************************************************
* File Name : usb_function.h
* $Rev: 1116 $
* $Date:: 2014-07-09 16:29:19 +0900#$
* Description : RZ/A1H R7S72100 USB Sample Program
*******************************************************************************/
#ifndef USB_FUNCTION_H
#define USB_FUNCTION_H
/*******************************************************************************
Includes <System Includes> , "Project Includes"
*******************************************************************************/
#include "r_typedefs.h"
#include "iodefine.h"
#include "rza_io_regrw.h"
/*******************************************************************************
Macro definitions
*******************************************************************************/
#define USB_FUNCTION_ALT_NO (255)
#define USB_FUNCTION_ALT_SET (0xff)
#define USB_FUNCTION_BITUPLLE (0x0002u)
#define USB_FUNCTION_BITUCKSEL (0x0004u)
#define USB_FUNCTION_BITBWAIT (0x003fu)
#define USB_FUNCTION_BUSWAIT_02 (0x0000u)
#define USB_FUNCTION_BUSWAIT_03 (0x0001u)
#define USB_FUNCTION_BUSWAIT_04 (0x0002u)
#define USB_FUNCTION_BUSWAIT_05 (0x0003u)
#define USB_FUNCTION_BUSWAIT_06 (0x0004u)
#define USB_FUNCTION_BUSWAIT_07 (0x0005u)
#define USB_FUNCTION_BUSWAIT_08 (0x0006u)
#define USB_FUNCTION_BUSWAIT_09 (0x0007u)
#define USB_FUNCTION_BUSWAIT_10 (0x0008u)
#define USB_FUNCTION_BUSWAIT_11 (0x0009u)
#define USB_FUNCTION_BUSWAIT_12 (0x000au)
#define USB_FUNCTION_BUSWAIT_13 (0x000bu)
#define USB_FUNCTION_BUSWAIT_14 (0x000cu)
#define USB_FUNCTION_BUSWAIT_15 (0x000du)
#define USB_FUNCTION_BUSWAIT_16 (0x000eu)
#define USB_FUNCTION_BUSWAIT_17 (0x000fu)
#define USB_FUNCTION_BITRESUME (0x0020u)
#define USB_FUNCTION_BITUACT (0x0010u)
#define USB_FUNCTION_HSPROC (0x0004u)
#define USB_FUNCTION_HSMODE (0x0003u)
#define USB_FUNCTION_FSMODE (0x0002u)
#define USB_FUNCTION_LSMODE (0x0001u)
#define USB_FUNCTION_UNDECID (0x0000u)
#define USB_FUNCTION_BITRCNT (0x8000u)
#define USB_FUNCTION_BITDREQE (0x1000u)
#define USB_FUNCTION_BITMBW (0x0c00u)
#define USB_FUNCTION_BITMBW_8 (0x0000u)
#define USB_FUNCTION_BITMBW_16 (0x0400u)
#define USB_FUNCTION_BITMBW_32 (0x0800u)
#define USB_FUNCTION_BITBYTE_LITTLE (0x0000u)
#define USB_FUNCTION_BITBYTE_BIG (0x0100u)
#define USB_FUNCTION_BITISEL (0x0020u)
#define USB_FUNCTION_BITCURPIPE (0x000fu)
#define USB_FUNCTION_CFIFO_READ (0x0000u)
#define USB_FUNCTION_CFIFO_WRITE (0x0020u)
#define USB_FUNCTION_BITBVAL (0x8000u)
#define USB_FUNCTION_BITBCLR (0x4000u)
#define USB_FUNCTION_BITFRDY (0x2000u)
#define USB_FUNCTION_BITDTLN (0x0fffu)
#define USB_FUNCTION_BITVBSE (0x8000u)
#define USB_FUNCTION_BITRSME (0x4000u)
#define USB_FUNCTION_BITSOFE (0x2000u)
#define USB_FUNCTION_BITDVSE (0x1000u)
#define USB_FUNCTION_BITCTRE (0x0800u)
#define USB_FUNCTION_BITVBINT (0x8000u)
#define USB_FUNCTION_BITRESM (0x4000u)
#define USB_FUNCTION_BITSOFR (0x2000u)
#define USB_FUNCTION_BITDVST (0x1000u)
#define USB_FUNCTION_BITCTRT (0x0800u)
#define USB_FUNCTION_BITBEMPE (0x0400u)
#define USB_FUNCTION_BITNRDYE (0x0200u)
#define USB_FUNCTION_BITBRDYE (0x0100u)
#define USB_FUNCTION_BITBEMP (0x0400u)
#define USB_FUNCTION_BITNRDY (0x0200u)
#define USB_FUNCTION_BITBRDY (0x0100u)
#define USB_FUNCTION_BITDVSQ (0x0070u)
#define USB_FUNCTION_BITDVSQS (0x0030u)
#define USB_FUNCTION_DS_SPD_CNFG (0x0070u)
#define USB_FUNCTION_DS_SPD_ADDR (0x0060u)
#define USB_FUNCTION_DS_SPD_DFLT (0x0050u)
#define USB_FUNCTION_DS_SPD_POWR (0x0040u)
#define USB_FUNCTION_DS_CNFG (0x0030u)
#define USB_FUNCTION_DS_ADDS (0x0020u)
#define USB_FUNCTION_DS_DFLT (0x0010u)
#define USB_FUNCTION_DS_POWR (0x0000u)
#define USB_FUNCTION_BITVALID (0x0008u)
#define USB_FUNCTION_BITCTSQ (0x0007u)
#define USB_FUNCTION_CS_SQER (0x0006u)
#define USB_FUNCTION_CS_WRND (0x0005u)
#define USB_FUNCTION_CS_WRSS (0x0004u)
#define USB_FUNCTION_CS_WRDS (0x0003u)
#define USB_FUNCTION_CS_RDSS (0x0002u)
#define USB_FUNCTION_CS_RDDS (0x0001u)
#define USB_FUNCTION_CS_IDST (0x0000u)
#define USB_FUNCTION_PIPExBUF (64u)
#define USB_FUNCTION_D0FIFO (0)
#define USB_FUNCTION_D1FIFO (1)
#define USB_FUNCTION_DMA_READY (0)
#define USB_FUNCTION_DMA_BUSY (1)
#define USB_FUNCTION_DMA_BUSYEND (2)
#define USB_FUNCTION_FIFO_USE (0x7000)
#endif /* USB_FUNCTION_FUNCTION_H */
/* End of File */

View File

@ -0,0 +1,32 @@
/*******************************************************************************
* DISCLAIMER
* This software is supplied by Renesas Electronics Corporation and is only
* intended for use with Renesas products. No other uses are authorized. This
* software is owned by Renesas Electronics Corporation and is protected under
* all applicable laws, including copyright laws.
* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING
* THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT
* LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
* AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.
* TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS
* ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE
* FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR
* ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE
* BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
* Renesas reserves the right, without notice, to make changes to this software
* and to discontinue the availability of this software. By using this software,
* you agree to the additional terms and conditions found by accessing the
* following link:
* http://www.renesas.com/disclaimer
* Copyright (C) 2012 - 2014 Renesas Electronics Corporation. All rights reserved.
*******************************************************************************/
/*******************************************************************************
* File Name : usb_function_version.h
* $Rev: 1116 $
* $Date:: 2014-07-09 16:29:19 +0900#$
* Description : RZ/A1H R7S72100 USB Sample Program
*******************************************************************************/
#define USB_FUNCTION_LOCAL_Rev "VER080_140709"
/* End of File */

View File

@ -0,0 +1,171 @@
/*******************************************************************************
* DISCLAIMER
* This software is supplied by Renesas Electronics Corporation and is only
* intended for use with Renesas products. No other uses are authorized. This
* software is owned by Renesas Electronics Corporation and is protected under
* all applicable laws, including copyright laws.
* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING
* THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT
* LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
* AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.
* TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS
* ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE
* FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR
* ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE
* BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
* Renesas reserves the right, without notice, to make changes to this software
* and to discontinue the availability of this software. By using this software,
* you agree to the additional terms and conditions found by accessing the
* following link:
* http://www.renesas.com/disclaimer
* Copyright (C) 2012 - 2014 Renesas Electronics Corporation. All rights reserved.
*******************************************************************************/
/*******************************************************************************
* File Name : usb0_function.h
* $Rev: 1116 $
* $Date:: 2014-07-09 16:29:19 +0900#$
* Description : RZ/A1H R7S72100 USB Sample Program
*******************************************************************************/
#ifndef USB0_FUNCTION_H
#define USB0_FUNCTION_H
/*******************************************************************************
Includes <System Includes> , "Project Includes"
*******************************************************************************/
#include "devdrv_usb_function_api.h"
#include "usb_function.h"
#ifdef __cplusplus
extern "C" {
#endif
/*******************************************************************************
Typedef definitions
*******************************************************************************/
/*******************************************************************************
Macro definitions
*******************************************************************************/
/*******************************************************************************
Imported global variables and functions (from other files)
*******************************************************************************/
extern const uint16_t g_usb0_function_bit_set[];
extern uint32_t g_usb0_function_data_count[USB_FUNCTION_MAX_PIPE_NO + 1];
extern uint8_t *g_usb0_function_data_pointer[USB_FUNCTION_MAX_PIPE_NO + 1];
extern uint16_t g_usb0_function_PipeIgnore[];
extern uint16_t g_usb0_function_PipeTbl[];
extern uint16_t g_usb0_function_pipe_status[];
extern uint32_t g_usb0_function_PipeDataSize[];
extern USB_FUNCTION_DMA_t g_usb0_function_DmaInfo[];
extern uint16_t g_usb0_function_DmaPipe[];
extern uint16_t g_usb0_function_DmaBval[];
extern uint16_t g_usb0_function_DmaStatus[];
extern uint16_t g_usb0_function_CtrZeroLengthFlag;
extern uint16_t g_usb0_function_ConfigNum;
extern uint16_t g_usb0_function_Alternate[USB_FUNCTION_ALT_NO];
extern uint16_t g_usb0_function_RemoteWakeupFlag;
extern uint16_t g_usb0_function_TestModeFlag;
extern uint16_t g_usb0_function_TestModeSelectors;
extern uint16_t g_usb0_function_ReqType;
extern uint16_t g_usb0_function_ReqTypeType;
extern uint16_t g_usb0_function_ReqTypeRecip;
extern uint16_t g_usb0_function_ReqRequest;
extern uint16_t g_usb0_function_ReqValue;
extern uint16_t g_usb0_function_ReqIndex;
extern uint16_t g_usb0_function_ReqLength;
extern uint16_t g_usb0_function_EPTableIndex[USB_FUNCTION_MAX_EP_NO + 1];
extern uint16_t g_usb0_function_pipecfg[USB_FUNCTION_MAX_PIPE_NO + 1];
extern uint16_t g_usb0_function_pipebuf[USB_FUNCTION_MAX_PIPE_NO + 1];
extern uint16_t g_usb0_function_pipemaxp[USB_FUNCTION_MAX_PIPE_NO + 1];
extern uint16_t g_usb0_function_pipeperi[USB_FUNCTION_MAX_PIPE_NO + 1];
/*******************************************************************************
Exported global variables and functions (to be accessed by other files)
*******************************************************************************/
/* ==== common ==== */
void usb0_function_dma_stop_d0(uint16_t pipe, uint32_t remain);
void usb0_function_dma_stop_d1(uint16_t pipe, uint32_t remain);
uint16_t usb0_function_is_hispeed(void);
uint16_t usb0_function_is_hispeed_enable(void);
uint16_t usb0_function_start_send_transfer(uint16_t pipe, uint32_t size, uint8_t *data);
uint16_t usb0_function_write_buffer(uint16_t pipe);
uint16_t usb0_function_write_buffer_c(uint16_t pipe);
uint16_t usb0_function_write_buffer_d0(uint16_t pipe);
uint16_t usb0_function_write_buffer_d1(uint16_t pipe);
void usb0_function_start_receive_transfer(uint16_t pipe, uint32_t size, uint8_t *data);
uint16_t usb0_function_read_buffer(uint16_t pipe);
uint16_t usb0_function_read_buffer_c(uint16_t pipe);
uint16_t usb0_function_read_buffer_d0(uint16_t pipe);
uint16_t usb0_function_read_buffer_d1(uint16_t pipe);
uint16_t usb0_function_change_fifo_port(uint16_t pipe, uint16_t fifosel, uint16_t isel, uint16_t mbw);
void usb0_function_set_curpipe(uint16_t pipe, uint16_t fifosel, uint16_t isel, uint16_t mbw);
void usb0_function_set_curpipe2(uint16_t pipe, uint16_t fifosel, uint16_t isel, uint16_t mbw, uint16_t dfacc);
uint16_t usb0_function_get_mbw(uint32_t trncount, uint32_t dtptr);
uint16_t usb0_function_read_dma(uint16_t pipe);
void usb0_function_brdy_int(uint16_t status, uint16_t int_enb);
void usb0_function_nrdy_int(uint16_t status, uint16_t int_enb);
void usb0_function_bemp_int(uint16_t status, uint16_t int_enb);
void usb0_function_setting_interrupt(uint8_t level);
void usb0_function_reset_module(uint16_t clockmode);
uint16_t usb0_function_get_buf_size(uint16_t pipe);
uint16_t usb0_function_get_mxps(uint16_t pipe);
void usb0_function_clear_brdy_sts(uint16_t pipe);
void usb0_function_clear_bemp_sts(uint16_t pipe);
void usb0_function_clear_nrdy_sts(uint16_t pipe);
void usb0_function_set_pid_buf(uint16_t pipe);
void usb0_function_set_pid_nak(uint16_t pipe);
void usb0_function_set_pid_stall(uint16_t pipe);
void usb0_function_clear_pid_stall(uint16_t pipe);
uint16_t usb0_function_get_pid(uint16_t pipe);
void usb0_function_set_sqclr(uint16_t pipe);
void usb0_function_set_sqset(uint16_t pipe);
void usb0_function_set_csclr(uint16_t pipe);
void usb0_function_aclrm(uint16_t pipe);
void usb0_function_set_aclrm(uint16_t pipe);
void usb0_function_clr_aclrm(uint16_t pipe);
uint16_t usb0_function_get_sqmon(uint16_t pipe);
uint16_t usb0_function_get_inbuf(uint16_t pipe);
/* ==== function ==== */
void usb0_function_init_status(void);
void usb0_function_InitModule(uint16_t mode);
uint16_t usb0_function_CheckVBUStaus(void);
void usb0_function_USB_FUNCTION_Attach(void);
void usb0_function_USB_FUNCTION_Detach(void);
void usb0_function_USB_FUNCTION_BusReset(void);
void usb0_function_USB_FUNCTION_Resume(void);
void usb0_function_USB_FUNCTION_Suspend(void);
void usb0_function_USB_FUNCTION_TestMode(void);
void usb0_function_ResetDCP(void);
void usb0_function_ResetEP(uint16_t num);
uint16_t usb0_function_EpToPipe(uint16_t ep);
void usb0_function_InitEPTable(uint16_t Con_Num, uint16_t Int_Num, uint16_t Alt_Num);
uint16_t usb0_function_GetConfigNum(void);
uint16_t usb0_function_GetAltNum(uint16_t Con_Num, uint16_t Int_Num);
uint16_t usb0_function_CheckRemoteWakeup(void);
void usb0_function_clear_alt(void);
void usb0_function_clear_pipe_tbl(void);
void usb0_function_clear_ep_table_index(void);
uint16_t usb0_function_GetInterfaceNum(uint16_t num);
#ifdef __cplusplus
}
#endif
#endif /* USB0_FUNCTION_H */
/* End of File */

View File

@ -0,0 +1,104 @@
/*******************************************************************************
* DISCLAIMER
* This software is supplied by Renesas Electronics Corporation and is only
* intended for use with Renesas products. No other uses are authorized. This
* software is owned by Renesas Electronics Corporation and is protected under
* all applicable laws, including copyright laws.
* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING
* THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT
* LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
* AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.
* TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS
* ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE
* FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR
* ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE
* BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
* Renesas reserves the right, without notice, to make changes to this software
* and to discontinue the availability of this software. By using this software,
* you agree to the additional terms and conditions found by accessing the
* following link:
* http://www.renesas.com/disclaimer
* Copyright (C) 2012 - 2014 Renesas Electronics Corporation. All rights reserved.
*******************************************************************************/
/*******************************************************************************
* File Name : usb0_function_api.h
* $Rev: 1116 $
* $Date:: 2014-07-09 16:29:19 +0900#$
* Description : RZ/A1H R7S72100 USB Sample Program
*******************************************************************************/
#ifndef USB0_FUNCTION_API_H
#define USB0_FUNCTION_API_H
#ifdef __cplusplus
extern "C" {
#endif
/*******************************************************************************
Includes <System Includes> , "Project Includes"
*******************************************************************************/
/*******************************************************************************
Typedef definitions
*******************************************************************************/
/*******************************************************************************
Macro definitions
*******************************************************************************/
/*******************************************************************************
Variable Externs
*******************************************************************************/
/*******************************************************************************
Exported global variables and functions (to be accessed by other files)
*******************************************************************************/
void usb0_api_function_init(uint8_t int_level, uint16_t mode, uint16_t clockmode);
uint16_t usb0_api_function_IsConfigured(void);
uint16_t usb0_function_GetDeviceState(void);
uint16_t usb0_api_function_CtrlReadStart(uint32_t size, uint8_t *data);
void usb0_api_function_CtrlWriteStart(uint32_t size, uint8_t *data);
uint16_t usb0_api_function_start_send_transfer(uint16_t pipe, uint32_t size, uint8_t *data);
uint16_t usb0_api_function_check_pipe_status(uint16_t pipe, uint32_t *size);
void usb0_api_function_clear_pipe_status(uint16_t pipe);
void usb0_api_function_start_receive_transfer(uint16_t pipe, uint32_t size, uint8_t *data);
void usb0_api_function_set_pid_buf(uint16_t pipe);
void usb0_api_function_set_pid_nak(uint16_t pipe);
void usb0_api_function_set_pid_stall(uint16_t pipe);
void usb0_api_function_clear_pid_stall(uint16_t pipe);
uint16_t usb0_api_function_get_pid(uint16_t pipe);
int32_t usb0_api_function_check_stall(uint16_t pipe);
void usb0_api_function_set_sqclr(uint16_t pipe);
void usb0_api_function_set_sqset(uint16_t pipe);
void usb0_api_function_set_csclr(uint16_t pipe);
void usb0_api_function_set_curpipe(uint16_t pipe, uint16_t fifosel, uint16_t isel, uint16_t mbw);
void usb0_api_function_clear_brdy_sts(uint16_t pipe);
void usb0_api_function_clear_bemp_sts(uint16_t pipe);
void usb0_api_function_clear_nrdy_sts(uint16_t pipe);
void usb0_function_ClearFeature(uint16_t type, uint16_t value, uint16_t index, uint16_t length);
void usb0_function_SetFeature(uint16_t type, uint16_t value, uint16_t index, uint16_t length);
void usb0_function_SetAddress(uint16_t type, uint16_t value, uint16_t index, uint16_t length);
void usb0_function_SetDescriptor(uint16_t type, uint16_t value, uint16_t index, uint16_t length);
void usb0_function_SetConfiguration(uint16_t type, uint16_t value, uint16_t index, uint16_t length);
void usb0_function_SetInterface(uint16_t type, uint16_t value, uint16_t index, uint16_t length);
void usb0_function_SynchFrame(uint16_t type, uint16_t value, uint16_t index, uint16_t length);
void usb0_function_GetStatus(uint16_t type, uint16_t value, uint16_t index, uint16_t length);
void usb0_function_GetDescriptor(uint16_t type, uint16_t value, uint16_t index, uint16_t length);
void usb0_function_GetConfiguration(uint16_t type, uint16_t value, uint16_t index, uint16_t length);
void usb0_function_GetInterface(uint16_t type, uint16_t value, uint16_t index, uint16_t length);
void usb0_function_Resrv_0(uint16_t type, uint16_t value, uint16_t index, uint16_t length);
void usb0_function_Resrv_123(uint16_t type, uint16_t value, uint16_t index, uint16_t length);
void usb0_function_Resrv_4(uint16_t type, uint16_t value, uint16_t index, uint16_t length);
void usb0_function_Resrv_5(uint16_t type, uint16_t value, uint16_t index, uint16_t length);
#ifdef __cplusplus
}
#endif
#endif /* USB0_FUNCTION_API_H */
/* End of File */

View File

@ -0,0 +1,142 @@
/*******************************************************************************
* DISCLAIMER
* This software is supplied by Renesas Electronics Corporation and is only
* intended for use with Renesas products. No other uses are authorized. This
* software is owned by Renesas Electronics Corporation and is protected under
* all applicable laws, including copyright laws.
* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING
* THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT
* LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
* AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.
* TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS
* ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE
* FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR
* ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE
* BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
* Renesas reserves the right, without notice, to make changes to this software
* and to discontinue the availability of this software. By using this software,
* you agree to the additional terms and conditions found by accessing the
* following link:
* http://www.renesas.com/disclaimer
* Copyright (C) 2012 - 2014 Renesas Electronics Corporation. All rights reserved.
*******************************************************************************/
/*******************************************************************************
* File Name : usb0_function_dmacdrv.h
* $Rev: 1116 $
* $Date:: 2014-07-09 16:29:19 +0900#$
* Description : RZ/A1H R7S72100 USB Sample Program
*******************************************************************************/
#ifndef USB0_FUNCTION_DMACDRV_H
#define USB0_FUNCTION_DMACDRV_H
/*******************************************************************************
Includes <System Includes> , "Project Includes"
*******************************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
/*******************************************************************************
Typedef definitions
*******************************************************************************/
typedef struct dmac_transinfo
{
uint32_t src_addr; /* Transfer source address */
uint32_t dst_addr; /* Transfer destination address */
uint32_t count; /* Transfer byte count */
uint32_t src_size; /* Transfer source data size */
uint32_t dst_size; /* Transfer destination data size */
uint32_t saddr_dir; /* Transfer source address direction */
uint32_t daddr_dir; /* Transfer destination address direction */
} dmac_transinfo_t;
/*******************************************************************************
Macro definitions
*******************************************************************************/
/* ==== Transfer specification of the sample program ==== */
#define DMAC_SAMPLE_SINGLE (0) /* Single transfer */
#define DMAC_SAMPLE_CONTINUATION (1) /* Continuous transfer (use REN bit) */
/* ==== DMA modes ==== */
#define DMAC_MODE_REGISTER (0) /* Register mode */
#define DMAC_MODE_LINK (1) /* Link mode */
/* ==== Transfer requests ==== */
#define DMAC_REQ_MODE_EXT (0) /* External request */
#define DMAC_REQ_MODE_PERI (1) /* On-chip peripheral module request */
#define DMAC_REQ_MODE_SOFT (2) /* Auto-request (request by software) */
/* ==== DMAC transfer sizes ==== */
#define DMAC_TRANS_SIZE_8 (0) /* 8 bits */
#define DMAC_TRANS_SIZE_16 (1) /* 16 bits */
#define DMAC_TRANS_SIZE_32 (2) /* 32 bits */
#define DMAC_TRANS_SIZE_64 (3) /* 64 bits */
#define DMAC_TRANS_SIZE_128 (4) /* 128 bits */
#define DMAC_TRANS_SIZE_256 (5) /* 256 bits */
#define DMAC_TRANS_SIZE_512 (6) /* 512 bits */
#define DMAC_TRANS_SIZE_1024 (7) /* 1024 bits */
/* ==== Address increment for transferring ==== */
#define DMAC_TRANS_ADR_NO_INC (1) /* Not increment */
#define DMAC_TRANS_ADR_INC (0) /* Increment */
/* ==== Method for detecting DMA request ==== */
#define DMAC_REQ_DET_FALL (0) /* Falling edge detection */
#define DMAC_REQ_DET_RISE (1) /* Rising edge detection */
#define DMAC_REQ_DET_LOW (2) /* Low level detection */
#define DMAC_REQ_DET_HIGH (3) /* High level detection */
/* ==== Request Direction ==== */
#define DMAC_REQ_DIR_SRC (0) /* DMAREQ is the source/ DMAACK is active when reading */
#define DMAC_REQ_DIR_DST (1) /* DMAREQ is the destination/ DMAACK is active when writing */
/* ==== Descriptors ==== */
#define DMAC_DESC_HEADER (0) /* Header */
#define DMAC_DESC_SRC_ADDR (1) /* Source Address */
#define DMAC_DESC_DST_ADDR (2) /* Destination Address */
#define DMAC_DESC_COUNT (3) /* Transaction Byte */
#define DMAC_DESC_CHCFG (4) /* Channel Confg */
#define DMAC_DESC_CHITVL (5) /* Channel Interval */
#define DMAC_DESC_CHEXT (6) /* Channel Extension */
#define DMAC_DESC_LINK_ADDR (7) /* Link Address */
/* ==== On-chip peripheral module requests ===== */
typedef enum dmac_request_factor
{
DMAC_REQ_USB0_DMA0_TX, /* USB_0 channel 0 transmit FIFO empty */
DMAC_REQ_USB0_DMA0_RX, /* USB_0 channel 0 receive FIFO full */
DMAC_REQ_USB0_DMA1_TX, /* USB_0 channel 1 transmit FIFO empty */
DMAC_REQ_USB0_DMA1_RX, /* USB_0 channel 1 receive FIFO full */
DMAC_REQ_USB1_DMA0_TX, /* USB_1 channel 0 transmit FIFO empty */
DMAC_REQ_USB1_DMA0_RX, /* USB_1 channel 0 receive FIFO full */
DMAC_REQ_USB1_DMA1_TX, /* USB_1 channel 1 transmit FIFO empty */
DMAC_REQ_USB1_DMA1_RX, /* USB_1 channel 1 receive FIFO full */
} dmac_request_factor_t;
/*******************************************************************************
Exported global variables and functions (to be accessed by other files)
*******************************************************************************/
void usb0_function_DMAC1_PeriReqInit(const dmac_transinfo_t *trans_info, uint32_t dmamode, uint32_t continuation,
uint32_t request_factor, uint32_t req_direction);
int32_t usb0_function_DMAC1_Open(uint32_t req);
void usb0_function_DMAC1_Close(uint32_t *remain);
void usb0_function_DMAC1_Load_Set(uint32_t src_addr, uint32_t dst_addr, uint32_t count);
void usb0_function_DMAC2_PeriReqInit(const dmac_transinfo_t *trans_info, uint32_t dmamode, uint32_t continuation,
uint32_t request_factor, uint32_t req_direction);
int32_t usb0_function_DMAC2_Open(uint32_t req);
void usb0_function_DMAC2_Close(uint32_t *remain);
void usb0_function_DMAC2_Load_Set(uint32_t src_addr, uint32_t dst_addr, uint32_t count);
#ifdef __cplusplus
}
#endif
#endif /* USB0_FUNCTION_DMACDRV_H */
/* End of File */

View File

@ -0,0 +1,249 @@
/*******************************************************************************
* DISCLAIMER
* This software is supplied by Renesas Electronics Corporation and is only
* intended for use with Renesas products. No other uses are authorized. This
* software is owned by Renesas Electronics Corporation and is protected under
* all applicable laws, including copyright laws.
* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING
* THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT
* LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
* AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.
* TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS
* ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE
* FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR
* ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE
* BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
* Renesas reserves the right, without notice, to make changes to this software
* and to discontinue the availability of this software. By using this software,
* you agree to the additional terms and conditions found by accessing the
* following link:
* http://www.renesas.com/disclaimer
* Copyright (C) 2012 - 2014 Renesas Electronics Corporation. All rights reserved.
*******************************************************************************/
/*******************************************************************************
* File Name : usb0_function_intrn.c
* $Rev: 1116 $
* $Date:: 2014-07-09 16:29:19 +0900#$
* Device(s) : RZ/A1H
* Tool-Chain :
* OS : None
* H/W Platform :
* Description : RZ/A1H R7S72100 USB Sample Program
* Operation :
* Limitations :
*******************************************************************************/
/*******************************************************************************
Includes <System Includes> , "Project Includes"
*******************************************************************************/
#include "usb0_function.h"
/*******************************************************************************
Typedef definitions
*******************************************************************************/
/*******************************************************************************
Macro definitions
*******************************************************************************/
/*******************************************************************************
Imported global variables and functions (from other files)
*******************************************************************************/
/*******************************************************************************
Exported global variables and functions (to be accessed by other files)
*******************************************************************************/
/*******************************************************************************
Private global variables and functions
*******************************************************************************/
/*******************************************************************************
* Function Name: usb0_function_brdy_int
* Description : Executes BRDY interrupt(USB_FUNCTION_PIPE1-9).
* : According to the pipe that interrupt is generated in,
* : reads/writes buffer allocated in the pipe.
* : This function is executed in the BRDY interrupt handler.
* : This function clears BRDY interrupt status and BEMP interrupt
* : status.
* Arguments : uint16_t Status ; BRDYSTS Register Value
* : uint16_t Int_enbl ; BRDYENB Register Value
* Return Value : none
*******************************************************************************/
#if 0
void usb0_function_brdy_int (uint16_t status, uint16_t int_enb)
{
uint32_t int_sense = 0;
uint16_t pipe;
uint16_t pipebit;
for (pipe = USB_FUNCTION_PIPE1; pipe <= USB_FUNCTION_MAX_PIPE_NO; pipe++)
{
pipebit = g_usb0_function_bit_set[pipe];
if ((status & pipebit) && (int_enb & pipebit))
{
USB200.BRDYSTS = (uint16_t)~pipebit;
USB200.BEMPSTS = (uint16_t)~pipebit;
if ((g_usb0_function_PipeTbl[pipe] & USB_FUNCTION_FIFO_USE) == USB_FUNCTION_D0FIFO_DMA)
{
if (g_usb0_function_DmaStatus[USB_FUNCTION_D0FIFO] != USB_FUNCTION_DMA_READY)
{
usb0_function_dma_interrupt_d0fifo(int_sense);
}
if (RZA_IO_RegRead_16(&g_usb0_function_pipecfg[pipe], USB_PIPECFG_BFRE_SHIFT, USB_PIPECFG_BFRE) == 0)
{
usb0_function_read_dma(pipe);
usb0_function_disable_brdy_int(pipe);
}
else
{
USB200.D0FIFOCTR = USB_FUNCTION_BITBCLR;
g_usb0_function_pipe_status[pipe] = DEVDRV_USBF_PIPE_DONE;
}
}
else if ((g_usb0_function_PipeTbl[pipe] & USB_FUNCTION_FIFO_USE) == USB_FUNCTION_D1FIFO_DMA)
{
if (g_usb0_function_DmaStatus[USB_FUNCTION_D1FIFO] != USB_FUNCTION_DMA_READY)
{
usb0_function_dma_interrupt_d1fifo(int_sense);
}
if (RZA_IO_RegRead_16(&g_usb0_function_pipecfg[pipe], USB_PIPECFG_BFRE_SHIFT, USB_PIPECFG_BFRE) == 0)
{
usb0_function_read_dma(pipe);
usb0_function_disable_brdy_int(pipe);
}
else
{
USB200.D1FIFOCTR = USB_FUNCTION_BITBCLR;
g_usb0_function_pipe_status[pipe] = DEVDRV_USBF_PIPE_DONE;
}
}
else
{
if (RZA_IO_RegRead_16(&g_usb0_function_pipecfg[pipe], USB_PIPECFG_DIR_SHIFT, USB_PIPECFG_DIR) == 0)
{
usb0_function_read_buffer(pipe);
}
else
{
usb0_function_write_buffer(pipe);
}
}
}
}
}
#endif
/*******************************************************************************
* Function Name: usb0_function_nrdy_int
* Description : Executes NRDY interrupt(USB_FUNCTION_PIPE1-9).
* : Checks NRDY interrupt cause by PID. When the cause if STALL,
* : regards the pipe state as STALL and ends the processing.
* : Then the cause is not STALL, increments the error count to
* : communicate again. When the error count is 3, determines
* : the pipe state as DEVDRV_USBF_PIPE_NORES and ends the processing.
* : This function is executed in the NRDY interrupt handler.
* : This function clears NRDY interrupt status.
* Arguments : uint16_t status ; NRDYSTS Register Value
* : uint16_t int_enb ; NRDYENB Register Value
* Return Value : none
*******************************************************************************/
void usb0_function_nrdy_int (uint16_t status, uint16_t int_enb)
{
uint16_t pid;
uint16_t pipe;
uint16_t bitcheck;
bitcheck = (uint16_t)(status & int_enb);
USB200.NRDYSTS = (uint16_t)~status;
for (pipe = USB_FUNCTION_PIPE1; pipe <= USB_FUNCTION_MAX_PIPE_NO; pipe++)
{
if ((bitcheck&g_usb0_function_bit_set[pipe]) == g_usb0_function_bit_set[pipe])
{
if (RZA_IO_RegRead_16(&USB200.SYSCFG0, USB_SYSCFG_DCFM_SHIFT, USB_SYSCFG_DCFM) == 1)
{
if (g_usb0_function_pipe_status[pipe] == DEVDRV_USBF_PIPE_WAIT)
{
pid = usb0_function_get_pid(pipe);
if ((pid == DEVDRV_USBF_PID_STALL) || (pid == DEVDRV_USBF_PID_STALL2))
{
g_usb0_function_pipe_status[pipe] = DEVDRV_USBF_PIPE_STALL;
}
else
{
g_usb0_function_PipeIgnore[pipe]++;
if (g_usb0_function_PipeIgnore[pipe] == 3)
{
g_usb0_function_pipe_status[pipe] = DEVDRV_USBF_PIPE_NORES;
}
else
{
usb0_function_set_pid_buf(pipe);
}
}
}
}
else
{
/* USB Function */
}
}
}
}
/*******************************************************************************
* Function Name: usb0_function_bemp_int
* Description : Executes BEMP interrupt(USB_FUNCTION_PIPE1-9).
* Arguments : uint16_t status ; BEMPSTS Register Value
* : uint16_t int_enb ; BEMPENB Register Value
* Return Value : none
*******************************************************************************/
void usb0_function_bemp_int (uint16_t status, uint16_t int_enb)
{
uint16_t pid;
uint16_t pipe;
uint16_t bitcheck;
uint16_t inbuf;
bitcheck = (uint16_t)(status & int_enb);
USB200.BEMPSTS = (uint16_t)~status;
for (pipe = USB_FUNCTION_PIPE1; pipe <= USB_FUNCTION_MAX_PIPE_NO; pipe++)
{
if ((bitcheck&g_usb0_function_bit_set[pipe]) == g_usb0_function_bit_set[pipe])
{
pid = usb0_function_get_pid(pipe);
if ((pid == DEVDRV_USBF_PID_STALL) || (pid == DEVDRV_USBF_PID_STALL2))
{
g_usb0_function_pipe_status[pipe] = DEVDRV_USBF_PIPE_STALL;
}
else
{
inbuf = usb0_function_get_inbuf(pipe);
if (inbuf == 0)
{
usb0_function_disable_bemp_int(pipe);
usb0_function_set_pid_nak(pipe);
g_usb0_function_pipe_status[pipe] = DEVDRV_USBF_PIPE_DONE;
}
}
}
}
}
/* End of File */

View File

@ -0,0 +1,142 @@
/*******************************************************************************
* DISCLAIMER
* This software is supplied by Renesas Electronics Corporation and is only
* intended for use with Renesas products. No other uses are authorized. This
* software is owned by Renesas Electronics Corporation and is protected under
* all applicable laws, including copyright laws.
* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING
* THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT
* LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
* AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.
* TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS
* ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE
* FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR
* ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE
* BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
* Renesas reserves the right, without notice, to make changes to this software
* and to discontinue the availability of this software. By using this software,
* you agree to the additional terms and conditions found by accessing the
* following link:
* http://www.renesas.com/disclaimer
* Copyright (C) 2012 - 2014 Renesas Electronics Corporation. All rights reserved.
*******************************************************************************/
/*******************************************************************************
* File Name : usb0_function_controlrw.c
* $Rev: 1116 $
* $Date:: 2014-07-09 16:29:19 +0900#$
* Device(s) : RZ/A1H
* Tool-Chain :
* OS : None
* H/W Platform :
* Description : RZ/A1H R7S72100 USB Sample Program
* Operation :
* Limitations :
*******************************************************************************/
/*******************************************************************************
Includes <System Includes> , "Project Includes"
*******************************************************************************/
#include "usb0_function.h"
/*******************************************************************************
Typedef definitions
*******************************************************************************/
/*******************************************************************************
Macro definitions
*******************************************************************************/
/*******************************************************************************
Imported global variables and functions (from other files)
*******************************************************************************/
/*******************************************************************************
Exported global variables and functions (to be accessed by other files)
*******************************************************************************/
/*******************************************************************************
Private global variables and functions
*******************************************************************************/
/*******************************************************************************
* Function Name: usb0_api_function_CtrlReadStart
* Description : Executes the USB control read transfer.
* : USB host controller <- USB device
* Arguments : uint16_t size ; Data Size
* : uint8_t *data ; Data Address
* Return Value : DEVDRV_USBF_WRITEEND ; End of data write
* : DEVDRV_USBF_WRITESHRT ; End of short data write
* : DEVDRV_USBF_WRITING ; Continue of data write
* : DEVDRV_USBF_FIFOERROR ; FIFO access error
*******************************************************************************/
uint16_t usb0_api_function_CtrlReadStart (uint32_t size, uint8_t * data)
{
uint16_t status;
uint16_t mbw;
usb0_function_set_pid_nak(USB_FUNCTION_PIPE0);
g_usb0_function_data_count[USB_FUNCTION_PIPE0] = size;
g_usb0_function_data_pointer[USB_FUNCTION_PIPE0] = data;
mbw = usb0_function_get_mbw(g_usb0_function_data_count[USB_FUNCTION_PIPE0],
(uint32_t)g_usb0_function_data_pointer[USB_FUNCTION_PIPE0]);
usb0_function_set_curpipe(USB_FUNCTION_PIPE0, USB_FUNCTION_CUSE, USB_FUNCTION_CFIFO_WRITE, mbw);
USB200.CFIFOCTR = USB_FUNCTION_BITBCLR;
status = usb0_function_write_buffer_c(USB_FUNCTION_PIPE0);
/* Peripheral Control sequence */
switch (status)
{
case DEVDRV_USBF_WRITESHRT: /* End of data write */
case DEVDRV_USBF_WRITEEND: /* End of data write (not null) */
case DEVDRV_USBF_WRITING: /* Continue of data write */
usb0_function_enable_bemp_int(USB_FUNCTION_PIPE0); /* Enable Empty Interrupt */
usb0_function_set_pid_buf(USB_FUNCTION_PIPE0); /* Set BUF */
break;
case DEVDRV_USBF_FIFOERROR: /* FIFO access error */
break;
default:
break;
}
return status; /* End or Err or Continue */
}
/*******************************************************************************
* Function Name: usb0_api_function_CtrlWriteStart
* Description : Executes the USB control write transfer.
* : USB host controller -> USB device
* Arguments : uint16_t size ; Data Size
* : uint8_t *data ; Data Address
* Return Value : none
*******************************************************************************/
void usb0_api_function_CtrlWriteStart (uint32_t size, uint8_t * data)
{
uint16_t mbw;
usb0_function_set_pid_nak(USB_FUNCTION_PIPE0);
g_usb0_function_data_count[USB_FUNCTION_PIPE0] = size;
g_usb0_function_data_pointer[USB_FUNCTION_PIPE0] = data;
mbw = usb0_function_get_mbw(g_usb0_function_data_count[USB_FUNCTION_PIPE0],
(uint32_t)g_usb0_function_data_pointer[USB_FUNCTION_PIPE0]);
usb0_function_set_curpipe(USB_FUNCTION_PIPE0, USB_FUNCTION_CUSE, USB_FUNCTION_CFIFO_WRITE, mbw);
USB200.CFIFOCTR = USB_FUNCTION_BITBCLR;
usb0_function_enable_brdy_int(USB_FUNCTION_PIPE0);
usb0_function_set_pid_buf(USB_FUNCTION_PIPE0);
}
/* End of File */

View File

@ -0,0 +1,144 @@
/*******************************************************************************
* DISCLAIMER
* This software is supplied by Renesas Electronics Corporation and is only
* intended for use with Renesas products. No other uses are authorized. This
* software is owned by Renesas Electronics Corporation and is protected under
* all applicable laws, including copyright laws.
* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING
* THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT
* LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
* AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.
* TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS
* ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE
* FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR
* ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE
* BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
* Renesas reserves the right, without notice, to make changes to this software
* and to discontinue the availability of this software. By using this software,
* you agree to the additional terms and conditions found by accessing the
* following link:
* http://www.renesas.com/disclaimer
* Copyright (C) 2012 - 2014 Renesas Electronics Corporation. All rights reserved.
*******************************************************************************/
/*******************************************************************************
* File Name : usb0_function_global.c
* $Rev: 1116 $
* $Date:: 2014-07-09 16:29:19 +0900#$
* Device(s) : RZ/A1H
* Tool-Chain :
* OS : None
* H/W Platform :
* Description : RZ/A1H R7S72100 USB Sample Program
* Operation :
* Limitations :
*******************************************************************************/
/*******************************************************************************
Includes <System Includes> , "Project Includes"
*******************************************************************************/
#include "usb0_function.h"
/*******************************************************************************
Typedef definitions
*******************************************************************************/
/*******************************************************************************
Macro definitions
*******************************************************************************/
/*******************************************************************************
Imported global variables and functions (from other files)
*******************************************************************************/
/*******************************************************************************
Exported global variables and functions (to be accessed by other files)
*******************************************************************************/
/*******************************************************************************
Private global variables and functions
*******************************************************************************/
const uint16_t g_usb0_function_bit_set[16] =
{
0x0001, 0x0002, 0x0004, 0x0008,
0x0010, 0x0020, 0x0040, 0x0080,
0x0100, 0x0200, 0x0400, 0x0800,
0x1000, 0x2000, 0x4000, 0x8000
};
uint32_t g_usb0_function_data_count[USB_FUNCTION_MAX_PIPE_NO + 1];
uint8_t * g_usb0_function_data_pointer[USB_FUNCTION_MAX_PIPE_NO + 1];
uint16_t g_usb0_function_PipeIgnore[USB_FUNCTION_MAX_PIPE_NO + 1];
uint16_t g_usb0_function_PipeTbl[USB_FUNCTION_MAX_PIPE_NO + 1];
uint16_t g_usb0_function_pipe_status[USB_FUNCTION_MAX_PIPE_NO + 1];
uint32_t g_usb0_function_PipeDataSize[USB_FUNCTION_MAX_PIPE_NO + 1];
USB_FUNCTION_DMA_t g_usb0_function_DmaInfo[2];
uint16_t g_usb0_function_DmaPipe[2];
uint16_t g_usb0_function_DmaBval[2];
uint16_t g_usb0_function_DmaStatus[2];
uint16_t g_usb0_function_CtrZeroLengthFlag;
//uint16_t g_usb0_function_ConfigNum;
//uint16_t g_usb0_function_Alternate[USB_FUNCTION_ALT_NO];
//uint16_t g_usb0_function_RemoteWakeupFlag;
uint16_t g_usb0_function_TestModeFlag;
uint16_t g_usb0_function_TestModeSelectors;
//uint16_t g_usb0_function_ReqType;
//uint16_t g_usb0_function_ReqTypeType;
//uint16_t g_usb0_function_ReqTypeRecip;
//uint16_t g_usb0_function_ReqRequest;
//uint16_t g_usb0_function_ReqValue;
//uint16_t g_usb0_function_ReqIndex;
//uint16_t g_usb0_function_ReqLength;
//uint16_t g_usb0_function_EPTableIndex[USB_FUNCTION_MAX_EP_NO + 1];
uint16_t g_usb0_function_pipecfg[USB_FUNCTION_MAX_PIPE_NO + 1];
uint16_t g_usb0_function_pipebuf[USB_FUNCTION_MAX_PIPE_NO + 1];
uint16_t g_usb0_function_pipemaxp[USB_FUNCTION_MAX_PIPE_NO + 1];
uint16_t g_usb0_function_pipeperi[USB_FUNCTION_MAX_PIPE_NO + 1];
/*******************************************************************************
* Function Name: usb0_function_init_status
* Description : Initialization USB Sample Driver Variable.
* Arguments : none
* Return Value : none
*******************************************************************************/
void usb0_function_init_status (void)
{
uint16_t pipe;
//g_usb0_function_ConfigNum = 0;
//g_usb0_function_RemoteWakeupFlag = DEVDRV_USBF_OFF;
g_usb0_function_TestModeFlag = DEVDRV_USBF_OFF;
g_usb0_function_CtrZeroLengthFlag = 0;
#if 0
usb0_function_clear_alt();
#endif
for (pipe = 0; pipe < (USB_FUNCTION_MAX_PIPE_NO + 1); ++pipe)
{
g_usb0_function_pipe_status[pipe] = DEVDRV_USBF_PIPE_IDLE;
g_usb0_function_PipeDataSize[pipe] = 0;
g_usb0_function_data_count[pipe] = 0;
/* pipe configuration in usb0_function_ResetEP() */
g_usb0_function_pipecfg[pipe] = 0;
g_usb0_function_pipebuf[pipe] = 0;
g_usb0_function_pipemaxp[pipe] = 0;
g_usb0_function_pipeperi[pipe] = 0;
}
}
/* End of File */

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