diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..0246bf4 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,36 @@ + + +## Description + + +## Motivation and Context + + +- Fixes/Closes/Resolves nanoFramework/Home#NNNN + +## How Has This Been Tested? + + + + +## Screenshots + +## Types of changes + +- [ ] Improvement (non-breaking change that improves a feature, code or algorithm) +- [ ] Bug fix (non-breaking change which fixes an issue) +- [ ] New feature (non-breaking change which adds functionality) +- [ ] Breaking change (fix or feature that would cause existing functionality to change) + +## Checklist: + + +- [ ] My code follows the code style of this project. +- [ ] My change requires a change to the documentation. +- [ ] I have updated the documentation accordingly. +- [ ] I have read the **CONTRIBUTING** document. +- [ ] I have added tests to cover my changes. +- [ ] All new and existing tests passed. + + +Signed-off-by: GITHUB_USER diff --git a/.github_changelog_generator b/.github_changelog_generator new file mode 100644 index 0000000..e128ed6 --- /dev/null +++ b/.github_changelog_generator @@ -0,0 +1,14 @@ +user=nanoframework +project=lib-nanoFramework.Hardware.Esp32 +issues=true +add_issues_wo_labels=false +add_pr_wo_labels=false +add_issues_wo_labels=false +filter_issues_by_milestone=false +exclude_labels=Area: Config-and-Build,Area: Infrastructure-and-Organization,reverted +enhancement_labels=Type: enhancement +bug_labels=Type: bug +merge_prefix=**Documentation and other chores:** +unreleased_label=**Changes available only in 'Preview' NuGet packages:** +issue_line_labels=Breaking-Change,documentation +author=false diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f1e3d20 --- /dev/null +++ b/.gitignore @@ -0,0 +1,252 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. + +# User-specific files +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ + +# Visual Studio 2015 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUNIT +*.VisualState.xml +TestResult.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# DNX +project.lock.json +artifacts/ + +*_i.c +*_p.c +*_i.h +*.ilk +*.meta +*.obj +*.pch +*.pdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# JustCode is a .NET coding add-in +.JustCode + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# TODO: Comment the next line if you want to checkin your web deploy settings +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# The packages folder can be ignored because of Package Restore +**/packages/* +# except build/, which is used as an MSBuild target. +!**/packages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/packages/repositories.config +# NuGet v3's project.json files produces more ignoreable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.pfx +*.publishsettings +node_modules/ +orleans.codegen.cs + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm + +# SQL Server files +*.mdf +*.ldf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# JetBrains Rider +.idea/ +*.sln.iml diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..0dcec85 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,26 @@ +# Change Log + +## [v1.0.0](https://github.com/nanoframework/lib-nanoFramework.Hardware.Esp32/tree/v1.0.0) (2018-10-17) +**Implemented enhancements:** + +- Update strong name key to match mscorlib [\#12](https://github.com/nanoframework/lib-nanoFramework.Hardware.Esp32/pull/12) + +**Fixed bugs:** + +- Fix typo in WakeupByTimer method name [\#4](https://github.com/nanoframework/lib-nanoFramework.Hardware.Esp32/pull/4) + +**Documentation and other chores:** + +- Update 3 NuGet dependencies [\#25](https://github.com/nanoframework/lib-nanoFramework.Hardware.Esp32/pull/25) +- Bumps nanoFramework.Windows.Devices.Gpio from 1.0.0-preview226 to 1.0.0-preview228 [\#24](https://github.com/nanoframework/lib-nanoFramework.Hardware.Esp32/pull/24) +- Update 3 NuGet dependencies [\#23](https://github.com/nanoframework/lib-nanoFramework.Hardware.Esp32/pull/23) +- Update 3 NuGet dependencies [\#22](https://github.com/nanoframework/lib-nanoFramework.Hardware.Esp32/pull/22) +- Update 3 NuGet dependencies [\#21](https://github.com/nanoframework/lib-nanoFramework.Hardware.Esp32/pull/21) +- Add High res timer class [\#15](https://github.com/nanoframework/lib-nanoFramework.Hardware.Esp32/pull/15) +- Bump nanoFramework.Runtime.Events from 1.0.0-preview188 to 1.0.0-preview191 in /source [\#14](https://github.com/nanoframework/lib-nanoFramework.Hardware.Esp32/pull/14) +- Bump nanoFramework.Windows.Devices.Gpio from 1.0.0-preview197 to 1.0.0-preview199 in /source [\#13](https://github.com/nanoframework/lib-nanoFramework.Hardware.Esp32/pull/13) +- Bump nanoFramework.CoreLibrary, Devices.Gpio and Runtime.Events in /source [\#9](https://github.com/nanoframework/lib-nanoFramework.Hardware.Esp32/pull/9) + + + +\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)* \ No newline at end of file diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..7feff0a --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,3 @@ +# Contributor Code of Conduct + +Please refer to the contributor Code of Conduct at the Home repository [here](https://github.com/nanoframework/Home/blob/master/CODE_OF_CONDUCT.md. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..5a6a6c1 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,3 @@ +# Contributing to **nanoFramework** + +Please refer to the contribution guidelines at the Home repository [here](https://github.com/nanoframework/Home/blob/master/CONTRIBUTING.md). diff --git a/GitVersion.yml b/GitVersion.yml new file mode 100644 index 0000000..a9712f5 --- /dev/null +++ b/GitVersion.yml @@ -0,0 +1,38 @@ +next-version: 1.0.0 +assembly-versioning-scheme: MajorMinorPatch +assembly-file-versioning-scheme: MajorMinorPatch +assembly-informational-format: '{LegacySemVerPadded}' +build-metadata-padding: 3 +legacy-semver-padding: 3 +major-version-bump-message: '\+semver:\s?(breaking|major)' +minor-version-bump-message: '\+semver:\s?(feature|minor)' +patch-version-bump-message: '\+semver:\s?(fix|patch)' +branches: + master: + mode: ContinuousDelivery + tag: + increment: Patch + prevent-increment-of-merged-branch-version: true + track-merge-target: false + develop: + regex: dev(elop)?(ment)?$ + mode: ContinuousDeployment + tag: preview + increment: Patch + prevent-increment-of-merged-branch-version: false + track-merge-target: true + tracks-release-branches: true + is-release-branch: false + release: + tag: rc + pull-request: + regex: (pull|pull\-requests|pr)[/-] + tag: alpha + mode: ContinuousDelivery + increment: Inherit + prevent-increment-of-merged-branch-version: false + track-merge-target: false + tracks-release-branches: false + is-release-branch: false +ignore: + sha: [] diff --git a/README.md b/README.md index 24984e9..c2df2e3 100644 --- a/README.md +++ b/README.md @@ -1 +1,37 @@ -# lib-nanoFramework.Hardware.ESP32 \ No newline at end of file +[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://github.com/nanoframework/Home/blob/master/LICENSE) [![NuGet](https://img.shields.io/nuget/dt/nanoFramework.Hardware.Esp32.svg)]() [![#yourfirstpr](https://img.shields.io/badge/first--timers--only-friendly-blue.svg)](https://github.com/nanoframework/Home/blob/master/CONTRIBUTING.md) [![Discord](https://img.shields.io/discord/478725473862549535.svg)](https://discord.gg/gCyBu8T) + + +![nanoFramework logo](https://github.com/nanoframework/Home/blob/master/resources/logo/nanoFramework-repo-logo.png) + +----- + +### Welcome to the **nanoFramework** nanoFramework.Hardware.Esp32 Library repository! + + +## Build status + +| Component | Build Status | NuGet Package | +|:-|---|---| +| nanoFramework.Hardware.Esp32 | [![Build status](https://ci.appveyor.com/api/projects/status/2qjp0dkdv00uxst8/branch/master?svg=true)](https://ci.appveyor.com/project/nfbot/lib-nanoframework-hardware-esp32/branch/master) | [![NuGet](https://img.shields.io/nuget/vpre/nanoFramework.Hardware.Esp32.svg)](https://www.nuget.org/packages/nanoFramework.Hardware.Esp32/) | +| nanoFramework.Hardware.Esp32 (preview) | [![Build status](https://ci.appveyor.com/api/projects/status/2qjp0dkdv00uxst8/branch/develop?svg=true)](https://ci.appveyor.com/project/nfbot/lib-nanoframework-hardware-esp32/branch/develop) | [![MyGet Pre Release](https://img.shields.io/myget/nanoframework-dev/vpre/nanoFramework.Hardware.Esp32.svg)](https://www.myget.org/feed/nanoframework-dev/package/nuget/nanoFramework.Hardware.Esp32) | + +## Feedback and documentation + +For documentation, providing feedback, issues and finding out how to contribute please refer to the [Home repo](https://github.com/nanoframework/Home). + +Join our Discord community [here](https://discord.gg/gCyBu8T). + + +## Credits + +The list of contributors to this project can be found at [CONTRIBUTORS](https://github.com/nanoframework/Home/blob/master/CONTRIBUTORS.md). + + +## License + +The **nanoFramework** Class Libraries are licensed under the [Apache 2.0 license](http://www.apache.org/licenses/LICENSE-2.0). + + +## Code of Conduct +This project has adopted the code of conduct defined by the [Contributor Covenant](http://contributor-covenant.org/) +to clarify expected behavior in our community. diff --git a/appveyor-discord.ps1 b/appveyor-discord.ps1 new file mode 100644 index 0000000..a1ce8b9 --- /dev/null +++ b/appveyor-discord.ps1 @@ -0,0 +1,82 @@ +# Copyright (c) 2017 The nanoFramework project contributors +# Portions Copyright (c) Sankarsan Kampa (a.k.a. k3rn31p4nic). All rights reserved. +# See LICENSE file in the project root for full license information. + +$STATUS=$args[0] +$WEBHOOK_URL=$args[1] + +Write-Output "[Webhook]: Sending webhook to Discord..." + +Switch ($STATUS) { + "success" { + $EMBED_COLOR=3066993 + $STATUS_MESSAGE="Passed" + Break + } + "failure" { + $EMBED_COLOR=15158332 + $STATUS_MESSAGE="Failed" + Break + } + default { + Write-Output "Default!" + Break + } +} + +if (!$env:APPVEYOR_REPO_COMMIT) { + $env:APPVEYOR_REPO_COMMIT="$(git log -1 --pretty="%H")" +} + +$AUTHOR_NAME="$(git log -1 "$env:APPVEYOR_REPO_COMMIT" --pretty="%aN")" +$COMMITTER_NAME="$(git log -1 "$env:APPVEYOR_REPO_COMMIT" --pretty="%cN")" +$COMMIT_SUBJECT="$(git log -1 "$env:APPVEYOR_REPO_COMMIT" --pretty="%s")" +$COMMIT_MESSAGE="$(git log -1 "$env:APPVEYOR_REPO_COMMIT" --pretty="%b")" + +if ($AUTHOR_NAME -eq $COMMITTER_NAME) { + $CREDITS = "$AUTHOR_NAME authored & committed" +} +else { + $CREDITS = "$AUTHOR_NAME authored & $COMMITTER_NAME committed" +} + +if ($env:APPVEYOR_PULL_REQUEST_NUMBER) { + $URL="https://github.com/$env:APPVEYOR_REPO_NAME/pull/$env:APPVEYOR_PULL_REQUEST_NUMBER" +} +else { + $URL="" +} + +$BUILD_VERSION = [uri]::EscapeDataString($env:APPVEYOR_BUILD_VERSION) + +$WEBHOOK_DATA="{ + ""embeds"": [ { + ""color"": $EMBED_COLOR, + ""author"": { + ""name"": ""Job #$env:APPVEYOR_JOB_NUMBER (Build #$env:APPVEYOR_BUILD_NUMBER) $STATUS_MESSAGE - $env:APPVEYOR_REPO_NAME"", + ""url"": ""https://ci.appveyor.com/project/$env:APPVEYOR_ACCOUNT_NAME/$env:APPVEYOR_PROJECT_SLUG/build/$BUILD_VERSION"", + ""icon_url"": ""$AVATAR"" + }, + ""title"": ""$COMMIT_SUBJECT"", + ""url"": ""$URL"", + ""description"": ""$COMMIT_MESSAGE $CREDITS"", + ""fields"": [ + { + ""name"": ""Commit"", + ""value"": ""[``$($env:APPVEYOR_REPO_COMMIT.substring(0, 7))``](https://github.com/$env:APPVEYOR_REPO_NAME/commit/$env:APPVEYOR_REPO_COMMIT)"", + ""inline"": true + }, + { + ""name"": ""Branch/Tag"", + ""value"": ""[``$env:APPVEYOR_REPO_BRANCH``](https://github.com/$env:APPVEYOR_REPO_NAME/tree/$env:APPVEYOR_REPO_BRANCH)"", + ""inline"": true + } + ] + } ], + ""content"" : """", + ""file"": """" +}" + +Invoke-RestMethod -Uri $WEBHOOK_URL -Method POST -UserAgent AppVeyor-Webhook -ContentType 'application/json' -Body $WEBHOOK_DATA + +Write-Output "[Webhook]: Successfully sent the webhook." diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 0000000..18ba695 --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,168 @@ +# configuration for all branches + +image: Visual Studio 2017 + +skip_tags: false + +skip_branch_with_pr: true + +test: off + +pull_requests: + do_not_increment_build_number: true + +# Skipping commits affecting specific files +skip_commits: + files: + - '**\AssemblyInfo*.*' + - '**/*.md' + - 'LICENSE' + - dir/* + - '.gitignore' + +build: + verbosity: minimal + +environment: + APPVEYOR_SAVE_CACHE_ON_ERROR: true + matrix: + - RUBY_VERSION: 24 + GitHubUserName: + secure: 7OBtVAMTodMWK20wg6pGnQ== + GitHubUserEmail: + secure: /NpmL1KqwHyHFnF0GlUovA586wDIt8Hg/Q8Dro6kUpk= + GitHubToken: + secure: i/2hGsqVMwzdM5yIS4rxOIeG3ftx7su7klWYN80s/fHvgk7A5H2fF3oUTNLcyTbw + GitRestAuth: + secure: E3bCMe4LtDdAhHSYRcLp0N6DixJe1m8TNxhYeJW/GnqM3WXdRqsgkHSbwootPjJQtOQJrps4twmzTVzofLSVgPgbzU8PxU0AkJV7zwkyVOE= + +init: +- git config --global core.autocrlf true +- git config --global credential.helper store +- ps: Add-Content "$env:USERPROFILE\.git-credentials" "https://$($env:GitHubToken):x-oauth-basic@github.com`n" +- git config --global user.email "%GitHubUserEmail%" +- git config --global user.name "%GitHubUserName%" +- ps: "$headers = if($env:APPVEYOR_PULL_REQUEST_NUMBER){\n @{\n \"Authorization\" = \"Basic $env:GitRestAuth\"\n \"Content-type\" = \"application/json\"\n}\n\n$pr = Invoke-RestMethod -Uri \"https://api.github.com/repos/$env:APPVEYOR_REPO_NAME/pulls/$env:APPVEYOR_PULL_REQUEST_NUMBER\" -Headers $headers -Method GET\n\nif($pr.user.login -eq \"nfbot\" -and $pr.body -match \"*[version update]*\")\n{\n # commit was from nfbot AND it's taged as a [version update]\n # OK to skip AppVeyor build \n \"Version update only. Skipping build.\" | Write-Host -BackgroundColor White -ForegroundColor Blue\n Exit-AppveyorBuild\n} }\n" +- ps: "if($env:APPVEYOR_PULL_REQUEST_NUMBER -eq \"\")\n{\n \n if($env:APPVEYOR_REPO_COMMIT_AUTHOR -eq \"nfbot\" -and $env:APPVEYOR_REPO_COMMIT_MESSAGE_EXTENDED -like \"*[version update]*\")\n {\n # commit was from nfbot AND it's taged as a [version update]\n # OK to skip AppVeyor build \n \"Version update only. Skipping build.\" | Write-Host -BackgroundColor White -ForegroundColor Blue\n Exit-AppveyorBuild\n }\n}" + +install: + - set PATH=C:\Ruby%RUBY_VERSION%\bin;%PATH% + - bundle config --local path vendor/bundle + - gem install bundler --quiet --no-ri --no-rdoc + - gem install github_changelog_generator --quiet --no-ri --no-rdoc + - choco install gitversion.portable -pre -y + - ps: .\install-vsix-appveyor.ps1 + +before_build: +- ps: >- + + nuget sources add -name MyGet -Source https://www.myget.org/F/nanoframework-dev + + nuget restore source\nanoFramework.Hardware.Esp32.sln + + C:\ProgramData\chocolatey\lib\GitVersion.Portable\tools\GitVersion.exe /l console /output buildserver /updateAssemblyInfo "source\nanoFramework.Hardware.Esp32\Properties\AssemblyInfo.cs" + +build_script: +- ps: >- + + msbuild source\nanoFramework.Hardware.Esp32.sln /p:Configuration=Release /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" + +artifacts: +- path: '**\bin\Release\*.nupkg' + name: Nuget_Packages + +before_deploy: + - ps: >- + .\commit-assemblyinfo-changes.ps1 + + .\generate-change-log.ps1 + + Push-AppveyorArtifact $env:APPVEYOR_BUILD_FOLDER\source\Nuget.nanoFramework.Hardware.Esp32\bin\Release\nanoFramework.Hardware.Esp32.$env:GitVersion_NuGetVersionV2.nupkg + +after_deploy: +# for this environment variable to work here it has to be set in AppVeyor UI +- nuget push source\Nuget.nanoFramework.Hardware.Esp32\bin\Release\nanoFramework.Hardware.Esp32.%GitVersion_NuGetVersionV2%.nupkg %MyGetToken% -Source https://www.myget.org/F/nanoframework-dev/api/v2/package +- nuget push source\Nuget.nanoFramework.Hardware.Esp32.DELIVERABLES\bin\Release\nanoFramework.Hardware.Esp32.DELIVERABLES.%GitVersion_NuGetVersionV2%.nupkg %MyGetToken% -Source https://www.myget.org/F/nanoframework-dev/api/v2/package + +# requires APPVEYOR_DISCORD_WEBHOOK_URL enviroment variable set with Discord webhook URL +on_failure: + - ps: | + + & $env:APPVEYOR_BUILD_FOLDER\appveyor-discord.ps1 failure $env:APPVEYOR_DISCORD_WEBHOOK_URL + +cache: + - source\packages -> **source\packages.config + - C:\ProgramData\chocolatey\bin -> appveyor.yml + - C:\ProgramData\chocolatey\lib -> appveyor.yml + +################################################ +# override configuration for specific branches +for: + +- + branches: + only: + - master + - /v.*/ + + deploy: + - provider: NuGet + api_key: $(NuGetToken) + skip_symbols: true + on: + appveyor_repo_tag: true + - provider: GitHub + tag: v$(GitVersion_NuGetVersionV2) + release: nanoFramework.Hardware.Esp32 Library v$(gitversion_semver) + description: 'Check the [changelog](https://github.com/nanoframework/lib-nanoFramework.Hardware.Esp32/blob/master/CHANGELOG.md)\n\n## Install from NuGet\n\nThe following NuGet packages are available for download from this release\n\n:package: [.NET](https://www.nuget.org/packages/nanoFramework.Hardware.Esp32/$(GitVersion_NuGetVersionV2)) v$(GitVersion_NuGetVersionV2)' + auth_token: + secure: DNixoFFE+pGlwyhj7McfZoln42vOmj0iY1iNV9zXEr3y0NpXlOIgL8k5ehzlFM1S + artifact: Nuget_Packages + draft: true + prerelease: false + force_update: true + on: + appveyor_repo_tag: false + +- + branches: + only: + - /dev.*/ + + deploy: + - provider: GitHub + tag: v$(GitVersion_NuGetVersionV2) + release: nanoFramework.Hardware.Esp32 Library v$(gitversion_semver) + description: 'Check the [changelog](https://github.com/nanoframework/lib-nanoFramework.Hardware.Esp32/blob/$(appveyor_repo_branch)/CHANGELOG.md)\n\n## Install from nanoFramework MyGet development feed\n\nThe following NuGet packages are available for download from this release\n\npackage: [.NET](https://www.myget.org/feed/nanoframework-dev/package/nuget/nanoFramework.Hardware.Esp32/$(GitVersion_NuGetVersionV2)) v$(GitVersion_NuGetVersionV2)' + auth_token: + secure: DNixoFFE+pGlwyhj7McfZoln42vOmj0iY1iNV9zXEr3y0NpXlOIgL8k5ehzlFM1S + artifact: Nuget_Packages + draft: true + prerelease: true + force_update: true + on: + appveyor_repo_tag: false + +- + branches: + only: + - /release.*/ + + deploy: + - provider: NuGet + api_key: $(NuGetToken) + skip_symbols: true + on: + appveyor_repo_tag: true + - provider: GitHub + tag: v$(GitVersion_NuGetVersionV2) + release: nanoFramework.Hardware.Esp32 Library v$(gitversion_semver) + description: 'Check the [changelog](https://github.com/nanoframework/lib-nanoFramework.Hardware.Esp32/blob/$(appveyor_repo_branch)/CHANGELOG.md)\n\n## Install from NuGet\n\nThe following NuGet packages are available for download from this release\n\n:package: [.NET](https://www.nuget.org/packages/nanoFramework.Hardware.Esp32/$(GitVersion_NuGetVersionV2)) v$(GitVersion_NuGetVersionV2)' + auth_token: + secure: DNixoFFE+pGlwyhj7McfZoln42vOmj0iY1iNV9zXEr3y0NpXlOIgL8k5ehzlFM1S + artifact: Nuget_Packages + draft: true + prerelease: true + force_update: true + on: + appveyor_repo_tag: false diff --git a/commit-assemblyinfo-changes.ps1 b/commit-assemblyinfo-changes.ps1 new file mode 100644 index 0000000..8ea52c5 --- /dev/null +++ b/commit-assemblyinfo-changes.ps1 @@ -0,0 +1,94 @@ +# Copyright (c) 2018 The nanoFramework project contributors +# See LICENSE file in the project root for full license information. + +# skip updating assembly info changes if build is a pull-request or not a tag (master OR release) +if ($env:appveyor_pull_request_number -or + ($env:APPVEYOR_REPO_BRANCH -eq "master" -and $env:APPVEYOR_REPO_TAG -eq 'true') -or + ($env:APPVEYOR_REPO_BRANCH -match "^release*" -and $env:APPVEYOR_REPO_TAG -eq 'true') -or + $env:APPVEYOR_REPO_TAG -eq "true") +{ + 'Skip committing assembly info changes...' | Write-Host -ForegroundColor White +} +else +{ + # updated assembly info files + git add "source\nanoFramework.Hardware.Esp32\Properties\AssemblyInfo.cs" + git commit -m "Update assembly info file for v$env:GitVersion_NuGetVersionV2 [skip ci]" -m"[version update]" + git push origin --porcelain -q > $null + + 'Updated assembly info...' | Write-Host -ForegroundColor White -NoNewline + 'OK' | Write-Host -ForegroundColor Green +} + +# update assembly info in nf-interpreter if we are in development branch or if this is tag (master OR release) +if ($env:APPVEYOR_REPO_BRANCH -match "^dev*" -or $env:APPVEYOR_REPO_TAG -eq "true") +{ + 'Updating assembly version in nf-interpreter...' | Write-Host -ForegroundColor White -NoNewline + + # clone nf-interpreter repo (only a shallow clone with last commit) + git clone https://github.com/nanoframework/nf-interpreter -b develop --depth 1 -q + cd nf-interpreter + + # new branch name + $newBranch = "$env:APPVEYOR_REPO_BRANCH-nfbot/update-version/nanoFramework.Hardware.Esp32/$env:GitVersion_NuGetVersionV2" + + # create branch to perform updates + git checkout -b "$newBranch" develop -q + + # replace version in assembly declaration + $newVersion = $env:GitVersion_AssemblySemFileVer -replace "\." , ", " + $newVersion = "{ $newVersion }" + + $versionRegex = "\{\s*\d+\,\s*\d+\,\s*\d+\,\s*\d+\s*}" + $assemblyFiles = (Get-ChildItem -Path ".\*" -Include "nanoFramework_hardware_esp32_native.cpp" -Recurse) + + foreach($file in $assemblyFiles) + { + $filecontent = Get-Content($file) + attrib $file -r + $filecontent -replace $versionRegex, $newVersion | Out-File $file -Encoding utf8 + } + + # check if anything was changed + $repoStatus = "$(git status --short --porcelain)" + + if ($repoStatus -eq "") + { + # nothing changed + & cd .. > $null + } + else + { + $commitMessage = "Update nanoFramework.Hardware.Esp32 version to $env:GitVersion_NuGetVersionV2" + + # commit changes + git add -A 2>&1 + git commit -m"$commitMessage [skip ci]" -m"[version update]" -q + git push --set-upstream origin "$newBranch" --porcelain -q > $null + + # start PR + $prRequestBody = @{title="$commitMessage";body="$commitMessage`nStarted with https://github.com/$env:APPVEYOR_REPO_NAME/commit/$env:APPVEYOR_REPO_COMMIT`n[version update]";head="$newBranch";base="develop"} | ConvertTo-Json + $githubApiEndpoint = "https://api.github.com/repos/nanoframework/nf-interpreter/pulls" + [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 + + try + { + $result = Invoke-RestMethod -Method Post -UserAgent [Microsoft.PowerShell.Commands.PSUserAgent]::InternetExplorer -Uri $githubApiEndpoint -Header @{"Authorization"="Basic $env:GitRestAuth"} -ContentType "application/json" -Body $prRequestBody + 'Started PR with version update...' | Write-Host -ForegroundColor White -NoNewline + 'OK' | Write-Host -ForegroundColor Green + } + catch + { + $result = $_.Exception.Response.GetResponseStream() + $reader = New-Object System.IO.StreamReader($result) + $reader.BaseStream.Position = 0 + $reader.DiscardBufferedData() + $responseBody = $reader.ReadToEnd(); + + "Error starting PR: $responseBody" | Write-Host -ForegroundColor Red + } + + # move back to home folder + & cd .. > $null + } +} diff --git a/generate-change-log.ps1 b/generate-change-log.ps1 new file mode 100644 index 0000000..a9d3395 --- /dev/null +++ b/generate-change-log.ps1 @@ -0,0 +1,33 @@ +# Copyright (c) 2018 The nanoFramework project contributors +# See LICENSE file in the project root for full license information. + +# generate change log when build is NOT a pull-request or not a tag (master OR release) +if ($env:appveyor_pull_request_number -or + ($env:APPVEYOR_REPO_BRANCH -eq "master" -and $env:APPVEYOR_REPO_TAG -eq 'true') -or + ($env:APPVEYOR_REPO_BRANCH -match "^release*" -and $env:APPVEYOR_REPO_TAG -eq 'true') -or + $env:APPVEYOR_REPO_TAG -eq "true") +{ + 'Skip change log processing...' | Write-Host -ForegroundColor White +} +else +{ + # need this to keep ruby happy + md c:\tmp + + if ($env:APPVEYOR_REPO_BRANCH -eq "master" -or $env:APPVEYOR_REPO_BRANCH -match "^release*") + { + # generate change log including future version + bundle exec github_changelog_generator --token $env:GitHubToken --future-release "v$env:GitVersion_MajorMinorPatch" + } + else + { + # generate change log + # version includes commits + bundle exec github_changelog_generator --token $env:GitHubToken + } + + # updated changelog and the updated assembly info files + git add CHANGELOG.md + git commit -m "Update CHANGELOG for v$env:GitVersion_NuGetVersionV2" + git push origin --porcelain -q > $null +} diff --git a/install-vsix-appveyor.ps1 b/install-vsix-appveyor.ps1 new file mode 100644 index 0000000..31d841e --- /dev/null +++ b/install-vsix-appveyor.ps1 @@ -0,0 +1,4 @@ +$vsixPath = "$($env:USERPROFILE)\nanoFramework.Tools.VS2017.Extension.vsix" +(New-Object Net.WebClient).DownloadFile('https://marketplace.visualstudio.com/_apis/public/gallery/publishers/vs-publisher-1470366/vsextensions/nanoFrameworkVS2017Extension/0/vspackage', $vsixPath) +"`"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\VSIXInstaller.exe`" /q /a $vsixPath" | out-file ".\install-vsix.cmd" -Encoding ASCII +& .\install-vsix.cmd diff --git a/source/NuGet.Config b/source/NuGet.Config new file mode 100644 index 0000000..efc7d1b --- /dev/null +++ b/source/NuGet.Config @@ -0,0 +1,6 @@ + + + + + + diff --git a/source/Nuget.nanoFramework.Hardware.Esp32.DELIVERABLES/Nuget.nanoFramework.Hardware.Esp32.DELIVERABLES.nuproj b/source/Nuget.nanoFramework.Hardware.Esp32.DELIVERABLES/Nuget.nanoFramework.Hardware.Esp32.DELIVERABLES.nuproj new file mode 100644 index 0000000..fcbe669 --- /dev/null +++ b/source/Nuget.nanoFramework.Hardware.Esp32.DELIVERABLES/Nuget.nanoFramework.Hardware.Esp32.DELIVERABLES.nuproj @@ -0,0 +1,81 @@ + + + + + Debug + AnyCPU + + + Release + AnyCPU + + + + 1.0.0-preview001 + + + + + + + content\Stubs\%(RecursiveDir)%(Filename)%(Extension) + + + content\txt\%(RecursiveDir)%(Filename)%(Extension) + + + content\dump\%(RecursiveDir)%(Filename)%(Extension) + + + content\dump\%(RecursiveDir)%(Filename)%(Extension) + + + content\resources\%(RecursiveDir)%(Filename)%(Extension) + + + content\disasm\%(RecursiveDir)%(Filename)%(Extension) + + + + + [1.0.4] + + + + + [1.0.0] + + + + + [1.0.0] + + + + 19E72838-7849-4917-92C2-5E84A5BB8A0D + + + ..\packages\NuProj.0.20.4-beta\tools\ + + + + nanoFramework.Hardware.Esp32.DELIVERABLES + $(GitVersion_NuGetVersionV2) + nanoFramework.Hardware.Esp32.DELIVERABLES + nanoFramework project contributors + nanoFramework project contributors + nanoFramework.Hardware.Esp32.DELIVERABLES is not meant for development. + ** DON'T REFERENCE THIS PACKAGE ** Not meant for development. This package includes the deliverable artifacts of the Hardware.Esp32 assembly for nanoFramework. These are for testing purposes and for updating the native code base of the core library. + + + https://github.com/nanoframework/lib-nanoFramework.Hardware.Esp32 + + + Copyright (c) 2017 The nanoFramework project contributors + + + https://secure.gravatar.com/avatar/97d0e092247f0716db6d4b47b7d1d1ad + false + + + \ No newline at end of file diff --git a/source/Nuget.nanoFramework.Hardware.Esp32/Nuget.nanoFramework.Hardware.Esp32.nuproj b/source/Nuget.nanoFramework.Hardware.Esp32/Nuget.nanoFramework.Hardware.Esp32.nuproj new file mode 100644 index 0000000..cdb4fb9 --- /dev/null +++ b/source/Nuget.nanoFramework.Hardware.Esp32/Nuget.nanoFramework.Hardware.Esp32.nuproj @@ -0,0 +1,77 @@ + + + + + Debug + AnyCPU + + + Release + AnyCPU + + + + 1.0.0-preview001 + + + + lib\nanoFramework.Hardware.Esp32.dll + + + lib\nanoFramework.Hardware.Esp32.pdb + + + lib\nanoFramework.Hardware.Esp32.pdbx + + + lib\nanoFramework.Hardware.Esp32.pe + + + lib\nanoFramework.Hardware.Esp32.xml + + + + + + + + [1.0.4] + + + + + [1.0.0] + + + + + [1.0.0] + + + + 04FF2AEC-F12E-4685-9E2D-D8CF0C958C0F + + + ..\packages\NuProj.0.20.4-beta\tools\ + + + + nanoFramework.Hardware.Esp32 + $(GitVersion_NuGetVersionV2) + nanoFramework.Hardware.Esp32 + nanoFramework project contributors + nanoFramework project contributors + nanoFramework.Hardware.Esp32 assembly for nanoFramework C# projects + This package includes the nanoFramework.Hardware.Esp32 assembly for nanoFramework C# projects. The nanoFramework.Hardware.Esp32 assembly contains functions specific to the ESP32 device. + + + https://github.com/nanoframework/lib-nanoFramework.Hardware.Esp32 + + + Copyright (c) 2017 The nanoFramework project contributors + nanoFramework C# csharp netmf netnf nanoFramework.Hardware.Esp32 + https://secure.gravatar.com/avatar/97d0e092247f0716db6d4b47b7d1d1ad + false + + + \ No newline at end of file diff --git a/source/README.md b/source/README.md new file mode 100644 index 0000000..68ec17a --- /dev/null +++ b/source/README.md @@ -0,0 +1,3 @@ +There is packaging tool for Visual Studio 2017 that must be installed before you should open the solution. + +Please visit the [NuGetizer-3000 repository](https://github.com/NuGet/NuGet.Build.Packaging) and follow the instructions. diff --git a/source/key.snk b/source/key.snk new file mode 100644 index 0000000..67c9bb0 Binary files /dev/null and b/source/key.snk differ diff --git a/source/nanoFramework.Hardware.Esp32.sln b/source/nanoFramework.Hardware.Esp32.sln new file mode 100644 index 0000000..b80ec7c --- /dev/null +++ b/source/nanoFramework.Hardware.Esp32.sln @@ -0,0 +1,44 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.27130.2027 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{11A8DD76-328B-46DF-9F39-F559912D0360}") = "nanoFramework.Hardware.Esp32", "nanoFramework.Hardware.Esp32\nanoFramework.Hardware.Esp32.nfproj", "{7ED93745-27D9-4E63-9033-C39642D323A0}" +EndProject +Project("{FF286327-C783-4F7A-AB73-9BCBAD0D4460}") = "Nuget.nanoFramework.Hardware.Esp32.DELIVERABLES", "Nuget.nanoFramework.Hardware.Esp32.DELIVERABLES\Nuget.nanoFramework.Hardware.Esp32.DELIVERABLES.nuproj", "{19E72838-7849-4917-92C2-5E84A5BB8A0D}" + ProjectSection(ProjectDependencies) = postProject + {7ED93745-27D9-4E63-9033-C39642D323A0} = {7ED93745-27D9-4E63-9033-C39642D323A0} + EndProjectSection +EndProject +Project("{FF286327-C783-4F7A-AB73-9BCBAD0D4460}") = "Nuget.nanoFramework.Hardware.Esp32", "Nuget.nanoFramework.Hardware.Esp32\Nuget.nanoFramework.Hardware.Esp32.nuproj", "{04FF2AEC-F12E-4685-9E2D-D8CF0C958C0F}" + ProjectSection(ProjectDependencies) = postProject + {7ED93745-27D9-4E63-9033-C39642D323A0} = {7ED93745-27D9-4E63-9033-C39642D323A0} + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {7ED93745-27D9-4E63-9033-C39642D323A0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7ED93745-27D9-4E63-9033-C39642D323A0}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7ED93745-27D9-4E63-9033-C39642D323A0}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7ED93745-27D9-4E63-9033-C39642D323A0}.Release|Any CPU.Build.0 = Release|Any CPU + {7ED93745-27D9-4E63-9033-C39642D323A0}.Release|Any CPU.Deploy.0 = Release|Any CPU + {19E72838-7849-4917-92C2-5E84A5BB8A0D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {19E72838-7849-4917-92C2-5E84A5BB8A0D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {19E72838-7849-4917-92C2-5E84A5BB8A0D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {19E72838-7849-4917-92C2-5E84A5BB8A0D}.Release|Any CPU.Build.0 = Release|Any CPU + {04FF2AEC-F12E-4685-9E2D-D8CF0C958C0F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {04FF2AEC-F12E-4685-9E2D-D8CF0C958C0F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {04FF2AEC-F12E-4685-9E2D-D8CF0C958C0F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {04FF2AEC-F12E-4685-9E2D-D8CF0C958C0F}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {3B82DF2A-43BA-4894-8908-CFBD148F5B20} + EndGlobalSection +EndGlobal diff --git a/source/nanoFramework.Hardware.Esp32/Configuration.cs b/source/nanoFramework.Hardware.Esp32/Configuration.cs new file mode 100644 index 0000000..bf58cad --- /dev/null +++ b/source/nanoFramework.Hardware.Esp32/Configuration.cs @@ -0,0 +1,32 @@ +// +// Copyright (c) 2018 The nanoFramework project contributors +// See LICENSE file in the project root for full license information. +// + +using System; +using Windows.Devices.Gpio; + +namespace nanoFramework.Hardware.Esp32 +{ + /// + /// Change Configuration + /// + public class Configuration + { + /// + /// Set the default function for a GPIO pin + /// + /// + /// Allows gpio pins to be assigned a device function. + /// For example setting the I2C1 data pin to use GPIO pin 17. + /// + /// + /// + public static void SetPinFunction(int pin, DeviceFunction value) + { + GpioPin gpioPin = GpioController.GetDefault().OpenPin(pin); + gpioPin.SetAlternateFunction((int)value); + gpioPin.Dispose(); + } + } +} diff --git a/source/nanoFramework.Hardware.Esp32/DeviceTypePins.cs b/source/nanoFramework.Hardware.Esp32/DeviceTypePins.cs new file mode 100644 index 0000000..c51cdd5 --- /dev/null +++ b/source/nanoFramework.Hardware.Esp32/DeviceTypePins.cs @@ -0,0 +1,210 @@ +// +// Copyright (c) 2018 The nanoFramework project contributors +// See LICENSE file in the project root for full license information. +// + +using System; + +namespace nanoFramework.Hardware.Esp32 +{ + internal enum ValueTypes + { + Index = 0, + DeviceIndex = 0x00000100, + DeviceType = 0x00010000, + } + + /// + /// Device Types + /// + public enum DeviceTypes + { + /// + /// GPIO Device type + /// + GPIO = 0 * ValueTypes.DeviceType, + /// + /// SPI Device type + /// + SPI = 1 * ValueTypes.DeviceType, + /// + /// I2C Device type + /// + I2C = 2 * ValueTypes.DeviceType, + /// + /// SERIAL Device type + /// + SERIAL = 3 * ValueTypes.DeviceType, + /// + /// PWM Device type + /// + PWM = 4 * ValueTypes.DeviceType, + }; + + /// + /// Defines values used to change pin configuration via the GPIO alternate + /// drivemode interface. + /// + public enum DeviceFunction + { + /// + /// Device function MOSI for SPI1 + /// + SPI1_MOSI = DeviceTypes.SPI + (1 * ValueTypes.DeviceIndex) + 0, + /// + /// Device function MISI for SPI1 + /// + SPI1_MISI = DeviceTypes.SPI + (1 * ValueTypes.DeviceIndex) + 1, + /// + /// Device function CLOCK for SPI1 + /// + SPI1_CLOCK = DeviceTypes.SPI + (1 * ValueTypes.DeviceIndex) + 2, + + /// + /// Device function MOSI for SPI2 + /// + SPI2_MOSI = DeviceTypes.SPI + (2 * ValueTypes.DeviceIndex) + 0, + /// + /// Device function MISI for SPI2 + /// + SPI2_MISI = DeviceTypes.SPI + (2 * ValueTypes.DeviceIndex) + 1, + /// + /// Device function CLOCK for SPI2 + /// + SPI2_CLOCK = DeviceTypes.SPI + (2 * ValueTypes.DeviceIndex) + 2, + + /// + /// Device function DATA for I2C1 + /// + I2C1_DATA = DeviceTypes.I2C + (1 * ValueTypes.DeviceIndex) + 0, + /// + /// Device function CLOCK for I2C1 + /// + I2C1_CLOCK = DeviceTypes.I2C + (1 * ValueTypes.DeviceIndex) + 1, + + /// + /// Device function DATA for I2C2 + /// + I2C2_DATA = DeviceTypes.I2C + (2 * ValueTypes.DeviceIndex) + 0, + /// + /// Device function CLOCK for I2C2 + /// + I2C2_CLOCK = DeviceTypes.I2C + (2 * ValueTypes.DeviceIndex) + 1, + + /// + /// Device function TX data for COM1 + /// + COM1_TX = DeviceTypes.SERIAL + (1 * ValueTypes.DeviceIndex) + 0, + /// + /// Device function RX data for COM1 + /// + COM1_RX = DeviceTypes.SERIAL + (1 * ValueTypes.DeviceIndex) + 1, + /// + /// Device function Request to Send(RTS) for COM1 + /// + COM1_RTS = DeviceTypes.SERIAL + (1 * ValueTypes.DeviceIndex) + 2, + /// + /// Device function Clear to Send(CTS) for COM1 + /// + COM1_CTS = DeviceTypes.SERIAL + (1 * ValueTypes.DeviceIndex) + 3, + + /// + /// Device function TX data for COM2 + /// + COM2_TX = DeviceTypes.SERIAL + (2 * ValueTypes.DeviceIndex) + 0, + /// + /// Device function RX data for COM2 + /// + COM2_RX = DeviceTypes.SERIAL + (2 * ValueTypes.DeviceIndex) + 1, + /// + /// Device function Request to Send(RTS) for COM2 + /// + COM2_RTS = DeviceTypes.SERIAL + (2 * ValueTypes.DeviceIndex) + 2, + /// + /// Device function Clear to Send(CTS) for COM2 + /// + COM2_CTS = DeviceTypes.SERIAL + (2 * ValueTypes.DeviceIndex) + 3, + + /// + /// Device function TX data for COM3 + /// + COM3_TX = DeviceTypes.SERIAL + (3 * ValueTypes.DeviceIndex) + 0, + /// + /// Device function RX data for COM3 + /// + COM3_RX = DeviceTypes.SERIAL + (3 * ValueTypes.DeviceIndex) + 1, + /// + /// Device function Request to Send(RTS) for COM3 + /// + COM3_RTS = DeviceTypes.SERIAL + (3 * ValueTypes.DeviceIndex) + 2, + /// + /// Device function Clear to Send(CTS) for COM3 + /// + COM3_CTS = DeviceTypes.SERIAL + (3 * ValueTypes.DeviceIndex) + 3, + + /// + /// Device function PWM1 + /// + PWM1 = DeviceTypes.PWM + (1 * ValueTypes.DeviceIndex) + 0, + /// + /// Device function PWM2 + /// + PWM2 = DeviceTypes.PWM + (2 * ValueTypes.DeviceIndex) + 0, + /// + /// Device function PWM3 + /// + PWM3 = DeviceTypes.PWM + (3 * ValueTypes.DeviceIndex) + 0, + /// + /// Device function PWM4 + /// + PWM4 = DeviceTypes.PWM + (4 * ValueTypes.DeviceIndex) + 0, + /// + /// Device function PWM5 + /// + PWM5 = DeviceTypes.PWM + (5 * ValueTypes.DeviceIndex) + 0, + /// + /// Device function PWM6 + /// + PWM6 = DeviceTypes.PWM + (6 * ValueTypes.DeviceIndex) + 0, + /// + /// Device function PWM7 + /// + PWM7 = DeviceTypes.PWM + (7 * ValueTypes.DeviceIndex) + 0, + /// + /// Device function PWM8 + /// + PWM8 = DeviceTypes.PWM + (8 * ValueTypes.DeviceIndex) + 0, + /// + /// Device function PWM9 + /// + PWM9 = DeviceTypes.PWM + (9 * ValueTypes.DeviceIndex) + 0, + /// + /// Device function PWM10 + /// + PWM10 = DeviceTypes.PWM + (10 * ValueTypes.DeviceIndex) + 0, + /// + /// Device function PWM11 + /// + PWM11 = DeviceTypes.PWM + (11 * ValueTypes.DeviceIndex) + 0, + /// + /// Device function PWM12 + /// + PWM12 = DeviceTypes.PWM + (12 * ValueTypes.DeviceIndex) + 0, + /// + /// Device function PWM13 + /// + PWM13 = DeviceTypes.PWM + (13 * ValueTypes.DeviceIndex) + 0, + /// + /// Device function PWM14 + /// + PWM14 = DeviceTypes.PWM + (14 * ValueTypes.DeviceIndex) + 0, + /// + /// Device function PWM15 + /// + PWM15 = DeviceTypes.PWM + (15 * ValueTypes.DeviceIndex) + 0, + /// + /// Device function PWM16 + /// + PWM16 = DeviceTypes.PWM + (16 * ValueTypes.DeviceIndex) + 0, + }; + } diff --git a/source/nanoFramework.Hardware.Esp32/Errors.cs b/source/nanoFramework.Hardware.Esp32/Errors.cs new file mode 100644 index 0000000..ab17b76 --- /dev/null +++ b/source/nanoFramework.Hardware.Esp32/Errors.cs @@ -0,0 +1,84 @@ +// +// Copyright (c) 2018 The nanoFramework project contributors +// See LICENSE file in the project root for full license information. +// + +using System; + +namespace nanoFramework.Hardware.Esp32 +{ + /// + /// Encapsulates the ESP32 native errors + /// + public enum EspNativeError : Int32 + { + /// + /// No error + /// + OK = 0, + /// + /// The function failed + /// + FAIL = -1, + + /// + /// Memory allocation failed error + /// + NO_MEM = 0x101, + + /// + /// Invalid argument error + /// + INVALID_ARG = 0x102, + + /// + /// Invalid state error + /// + INVALID_STATE = 0x103, + + /// + /// Invalid size error + /// + INVALID_SIZE = 0x104, + + /// + /// The function failed + /// + NOT_FOUND = 0x105, + + /// + /// Function not supported error + /// + NOT_SUPPORTED = 0x106, + + /// + /// Timeout error + /// + TIMEOUT = 0x107, + + /// + /// Invalid response + /// + INVALID_RESPONSE = 0x108, + + /// + /// CRC error + /// + INVALID_CRC = 0x109, + + /// + /// Invalid version + /// + INVALID_VERSION = 0x10A, + + /// + /// Invalid MAC address + /// + INVALID_MAC = 0x10B, + + /// + /// Base of WiFi errors + /// + WIFI_BASE = 0x3000 + } +} diff --git a/source/nanoFramework.Hardware.Esp32/HighResEventListener.cs b/source/nanoFramework.Hardware.Esp32/HighResEventListener.cs new file mode 100644 index 0000000..9418500 --- /dev/null +++ b/source/nanoFramework.Hardware.Esp32/HighResEventListener.cs @@ -0,0 +1,83 @@ +// +// Copyright (c) 2018 The nanoFramework project contributors +// See LICENSE file in the project root for full license information. +// + +using System; +using System.Collections; +using nanoFramework.Runtime.Events; + +namespace nanoFramework.Hardware.Esp32 +{ + internal class HighResEventListener : IEventProcessor, IEventListener + { + System.Collections.ArrayList HighResTimers = new ArrayList(); + + + public HighResEventListener() + { + EventSink.AddEventProcessor(EventCategory.Custom, this); + EventSink.AddEventListener(EventCategory.Custom, this); + } + + public void InitializeForEventSource() + { + } + + /// + /// Fire event on correct timer + /// + /// + /// + public bool OnEvent(BaseEvent ev) + { + if ( ev is HighResTimerEvent) + { + foreach (object obj in HighResTimers) + { + HighResTimer timer = obj as HighResTimer; + if (timer._timerHandle == ((HighResTimerEvent)ev).TimerHandle) + { + timer.OnHighResTimerExpiredInternal((HighResTimerEvent)ev); + break; + } + } + return true; + } + return false; + } + + /// + /// Process an event + /// + /// + /// + /// + /// + public BaseEvent ProcessEvent(uint data1, uint data2, DateTime time) + { + HighResTimerEventType eventType = (HighResTimerEventType)(data1 & 0xFF); + + if (eventType >= HighResTimerEventType.TimerExpired) + { + HighResTimerEvent timerEvent = new HighResTimerEvent(); + timerEvent.EventType = eventType; + timerEvent.TimerHandle = data2; + + return timerEvent; + } + return null; + } + + + internal void AddHighResTimer(HighResTimer timer) + { + HighResTimers.Add(timer); + } + + internal void RemoveHighResTimer(HighResTimer timer) + { + HighResTimers.Remove(timer); + } + } +} diff --git a/source/nanoFramework.Hardware.Esp32/HighResTimer.cs b/source/nanoFramework.Hardware.Esp32/HighResTimer.cs new file mode 100644 index 0000000..202a342 --- /dev/null +++ b/source/nanoFramework.Hardware.Esp32/HighResTimer.cs @@ -0,0 +1,168 @@ +// +// Copyright (c) 2018 The nanoFramework project contributors +// See LICENSE file in the project root for full license information. +// + +using System; +using System.Runtime.CompilerServices; +using nanoFramework.Runtime.Events; + +namespace nanoFramework.Hardware.Esp32 +{ + /// + /// Event raised when a High res timer expires. + /// + public delegate void HighResTimerExpiredEventHandler( + HighResTimer sender, + Object e); + + + /// + /// The class encapsulates the ESP32 High Resolution Timer API. + /// + public class HighResTimer : IDisposable + { + internal Int32 _timerHandle; + internal bool _disposedValue = false; // To detect redundant calls + + + private static HighResEventListener s_eventListener = new HighResEventListener(); + + // This is used as the lock object + // a lock is required because multiple threads can access the HighResTimer + private object _syncLock = new object(); + + /// + /// Event raised when a HighRes timer expires. + /// + public event HighResTimerExpiredEventHandler OnHighResTimerExpired; + + + internal void OnHighResTimerExpiredInternal(object e) + { + HighResTimerExpiredEventHandler callbacks = null; + + lock (_syncLock) + { + if (!_disposedValue) + { + callbacks = OnHighResTimerExpired; + } + } + + callbacks?.Invoke(this, new EventArgs()); + } + + /// + /// Returns the number of micro seconds since boot + /// + /// + public static UInt64 GetCurrent() + { + return NativeGetCurrent(); + } + + /// + /// Create a High Resolution Timer. A maximum of 10 timers can be created. + /// + public HighResTimer() + { + _timerHandle = NativeEspTimerCreate(); + s_eventListener.AddHighResTimer(this); + } + + + /// + /// Stop the Timer. + /// + public void Stop() + { + NativeStop(); + } + + /// + /// Start a one shot timer. + /// Once the timer has expired the timer event will be fired. + /// + /// Timeout in mirco seconds + public void StartOneShot(UInt64 timeout_us) + { + NativeStartOneShot(timeout_us); + } + + /// + /// Start a periodic timer. + /// + /// Period between firing timer events. + /// + public void StartOnePeriodic(UInt64 period_us) + { + NativeStartPeriodic(period_us); + } + + #region IDisposable Support + + /// + /// Dispose(bool disposing) + /// + /// + protected virtual void Dispose(bool disposing) + { + if (!_disposedValue) + { + if (disposing) + { + // TODO: dispose managed state (managed objects). + } + + s_eventListener.RemoveHighResTimer(this); + + NativeEspTimerDispose(); + + _disposedValue = true; + } + } + + /// + /// Finalizer + /// + ~HighResTimer() + { + // Do not change this code. Put cleanup code in Dispose(bool disposing) above. + Dispose(false); + } + + /// + /// Dispose HighResTimer + /// + public void Dispose() + { + Dispose(true); + + GC.SuppressFinalize(this); + } + #endregion + + #region Native Calls + [MethodImpl(MethodImplOptions.InternalCall)] + private extern Int32 NativeEspTimerCreate(); + + [MethodImpl(MethodImplOptions.InternalCall)] + private extern void NativeEspTimerDispose(); + + [MethodImpl(MethodImplOptions.InternalCall)] + private static extern UInt64 NativeGetCurrent(); + + [MethodImpl(MethodImplOptions.InternalCall)] + private extern void NativeStop(); + + [MethodImpl(MethodImplOptions.InternalCall)] + private extern void NativeStartOneShot(UInt64 timeout); + + [MethodImpl(MethodImplOptions.InternalCall)] + private extern void NativeStartPeriodic(UInt64 period); + + #endregion + } + +} diff --git a/source/nanoFramework.Hardware.Esp32/HighResTimerEvent.cs b/source/nanoFramework.Hardware.Esp32/HighResTimerEvent.cs new file mode 100644 index 0000000..a051871 --- /dev/null +++ b/source/nanoFramework.Hardware.Esp32/HighResTimerEvent.cs @@ -0,0 +1,24 @@ +// +// Copyright (c) 2018 The nanoFramework project contributors +// See LICENSE file in the project root for full license information. +// + +using System; +using nanoFramework.Runtime.Events; + + +namespace nanoFramework.Hardware.Esp32 +{ + [Flags] + internal enum HighResTimerEventType : byte + { + TimerExpired = 101 // HighRes Timer expired event + } + + internal class HighResTimerEvent : BaseEvent + { + public HighResTimerEventType EventType; + public uint TimerHandle; + + } +} diff --git a/source/nanoFramework.Hardware.Esp32/Logging.cs b/source/nanoFramework.Hardware.Esp32/Logging.cs new file mode 100644 index 0000000..b0201ef --- /dev/null +++ b/source/nanoFramework.Hardware.Esp32/Logging.cs @@ -0,0 +1,75 @@ +// +// Copyright (c) 2018 The nanoFramework project contributors +// See LICENSE file in the project root for full license information. +// + +using System; +using System.Runtime.CompilerServices; + +namespace nanoFramework.Hardware.Esp32 +{ + /// + /// Controls the logging output. + /// By default the logging is LOG_LEVEL_NONE as the same port is used for the Visual Studio debug connection when connected via serial port. + /// + class Logging + { + /// + /// Enumeration of Log levels + /// + public enum LogLevel + { + /// + /// No log output + /// + LOG_LEVEL_NONE, + /// + /// Critical errors, software module can not recover on its own + /// + LOG_LEVEL_ERROR, + /// + /// Error conditions from which recovery measures have been taken + /// + LOG_LEVEL_WARN, + /// + /// Information messages which describe normal flow of events + /// + LOG_LEVEL_INFO, + /// + /// Extra information which is not necessary for normal use (values, pointers, sizes, etc). + /// + LOG_LEVEL_DEBUG, + /// + /// Bigger chunks of debugging information, or frequent messages which can potentially flood the output. + /// + LOG_LEVEL_VERBOSE + } + + /// + /// Set overall logging level. + /// + /// + public static void SetLogLevel(LogLevel level) + { + SetLogLevel( "*", level); + } + + /// + /// Set overall logging level for specific tag, tag "*" equals all tags. + /// + /// + /// + public static void SetLogLevel(string tag, LogLevel level) + { + NativeSetLogLevel(tag, (int)level); + } + + #region native calls + + [MethodImpl(MethodImplOptions.InternalCall)] + private static extern void NativeSetLogLevel(string tag, int level); + + #endregion + + } +} diff --git a/source/nanoFramework.Hardware.Esp32/Properties/AssemblyInfo.cs b/source/nanoFramework.Hardware.Esp32/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..90393f9 --- /dev/null +++ b/source/nanoFramework.Hardware.Esp32/Properties/AssemblyInfo.cs @@ -0,0 +1,30 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("nanoFramework.Hardware.Esp32")] +[assembly: AssemblyCompany("nanoFramework Contributors")] +[assembly: AssemblyProduct("nanoFramework.Hardware.Esp32")] +[assembly: AssemblyCopyright("Copyright © nanoFramework Contributors 2018")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] +[assembly: AssemblyInformationalVersion("1.0.0-rc001")] diff --git a/source/nanoFramework.Hardware.Esp32/Sleep.cs b/source/nanoFramework.Hardware.Esp32/Sleep.cs new file mode 100644 index 0000000..6b02e2d --- /dev/null +++ b/source/nanoFramework.Hardware.Esp32/Sleep.cs @@ -0,0 +1,327 @@ +// +// Copyright (c) 2018 The nanoFramework project contributors +// See LICENSE file in the project root for full license information. +// + +using System; +using System.Runtime.CompilerServices; + +namespace nanoFramework.Hardware.Esp32 +{ + /// + /// Encapsulates ESP32 sleep functions + /// + public class Sleep + { + /// + /// Wakeup mode used by EnableWakeupByMultiPins + /// + public enum WakeupMode + { + /// + /// Wakeup when all pins are low + /// + AllLow = 0, + + /// + /// Wakeup when any pin is high + /// + AnyHigh = 1 + }; + + /// + /// Sleep wakeup cause + /// + public enum WakeupCause + { + /// + /// Wakeup not caused from exit from sleep + /// + Undefined = 0, + /// + /// Wakeup caused by external signal using RTC_IO + /// + Ext0, + /// + /// Wakeup caused by external signal using RTC_CNTL + /// + Ext1, + /// + /// Wakeup caused by timer + /// + Timer, + /// + /// Wakeup caused by touchpad + /// + TouchPad, + /// + /// Wakeup caused by ULP program + /// + Ulp + }; + + + /// + /// Gpio pins that can be used for wakeup + /// + [Flags] + public enum WakeupGpioPin : UInt64 + { + /// + /// No wake up pin + /// + None = 0, + /// + /// Gpio Pin 1 used for wakeup + /// + Pin0 = 1, + /// + /// Gpio Pin 2 used for wakeup + /// + Pin2 = 1 << 2, + /// + /// Gpio Pin 4 used for wakeup + /// + Pin4 = 1 << 4, + /// + /// Gpio Pin 12 used for wakeup + /// + Pin12 = 1 << 12, + /// + /// Gpio Pin 13 used for wakeup + /// + Pin13 = 1 << 13, + /// + /// Gpio Pin 14 used for wakeup + /// + Pin14 = 1 << 14, + /// + /// Gpio Pin 15 used for wakeup + /// + Pin15 = 1 << 15, + /// + /// Gpio Pin 25 used for wakeup + /// + Pin25 = 1 << 25, + /// + /// Gpio Pin 26 used for wakeup + /// + Pin26 = 1 << 26, + /// + /// Gpio Pin 27 used for wakeup + /// + Pin27 = 1 << 27, + /// + /// Gpio Pin 32 used for wakeup + /// + Pin32 = 1 << 32, + /// + /// Gpio Pin 33 used for wakeup + /// + Pin33 = 1 << 33, + /// + /// Gpio Pin 34 used for wakeup + /// + Pin34 = 1 << 34, + /// + /// Gpio Pin 35 used for wakeup + /// + Pin35 = 1 << 35, + /// + /// Gpio Pin 36 used for wakeup + /// + Pin36 = 1 << 36, + /// + /// Gpio Pin 37 used for wakeup + /// + Pin37 = 1 << 37, + /// + /// Gpio Pin 38 used for wakeup + /// + Pin38 = 1 << 38, + /// + /// Gpio Pin 39 used for wakeup + /// + Pin39 = 1 << 39 + }; + + /// + /// Enumeration of Touch pad numbers + /// + public enum TouchPad + { + /// + /// Touch pad channel 0 is GPIO4 + /// + Num0 = 0, + /// + /// Touch pad channel 1 is GPIO0 + /// + Num1, + /// + /// Touch pad channel 2 is GPIO2 + /// + Num2, + /// + /// Touch pad channel 3 is GPIO15 + /// + Num3, + /// + /// Touch pad channel 4 is GPIO13 + /// + Num4, + /// + /// Touch pad channel 5 is GPIO12 + /// + Num5, + /// + /// Touch pad channel 6 is GPIO14 + /// + Num6, + /// + /// Touch pad channel 7 is GPIO27 + /// + Num7, + /// + /// Touch pad channel 8 is GPIO33 + /// + Num8, + /// + /// Touch pad channel 9 is GPIO32 + /// + Num9, + /// + /// Number returned when no touch pad used on wakeup + /// + None + }; + + /// + /// Enable Wakeup by Timer + /// + /// + /// + public static EspNativeError EnableWakeupByTimer(TimeSpan time) + { + UInt64 time_us = (UInt64)time.Ticks / 10; + + return (EspNativeError)NativeEnableWakeupByTimer(time_us); + } + + /// + /// Enable wakeup using a gpio pin + /// + /// GPIO number used as wakeup source. Only pins that have RTC functionality can be used. + /// 0,2,4,12->15,25->27,32->39 + /// + /// + public static EspNativeError EnableWakeupByPin(WakeupGpioPin pin, int level) + { + return NativeEnableWakeupByPin(pin, level); + } + + /// + /// Enable Wkaup using multiple pins. + /// + /// + /// Only pins that are RTC connected. + /// + /// + /// + /// + public static EspNativeError EnableWakeupByMultiPins(WakeupGpioPin pins, WakeupMode mode) + { + return NativeEnableWakeupByMultiPins( pins, mode); + } + + + /// + /// Enable wakeup by Touchpad + /// + /// + public static EspNativeError EnableWakeupByTouchPad() + { + return NativeEnableWakeupByTouchPad(); + } + + /// + /// Enter light sleep with the configured wakeup options. + /// + /// Return ESP_ERR_INVALID_STATE if Wifi or BT not stopped. + public static EspNativeError StartLightSleep() + { + return NativeStartLightSleep(); + } + + /// + /// Enter deep sleep using configured wakeup sources. + /// + /// + /// If no sources configured then it will be a indefinate sleep. + /// ESP_OK if ok + public static EspNativeError StartDeepSleep() + { + return NativeStartDeepSleep(); + } + + /// + /// Get the cause for waking up + /// + /// Return the Wakeup cause. + public static WakeupCause GetWakeupCause() + { + return NativeGetWakeupCause(); + } + + /// + /// Returns a bit mask of pins taht caused the wakeup + /// + /// + public static WakeupGpioPin GetWakeupGpioPin() + { + return NativeGetWakeupGpioPin(); + } + + /// + /// Get the touch pad which caused wakeup. + /// + /// Return TouchPad number or None + public static TouchPad GetWakeupTouchpad() + { + + return NativeGetWakeupTouchpad(); + } + + #region extenal calls to native implementations + + [MethodImpl(MethodImplOptions.InternalCall)] + private static extern EspNativeError NativeEnableWakeupByTimer(UInt64 time_us); + + [MethodImpl(MethodImplOptions.InternalCall)] + private static extern EspNativeError NativeEnableWakeupByPin(WakeupGpioPin pin, int level); + + [MethodImpl(MethodImplOptions.InternalCall)] + private static extern EspNativeError NativeEnableWakeupByMultiPins(WakeupGpioPin pins, WakeupMode mode); + + [MethodImpl(MethodImplOptions.InternalCall)] + private static extern EspNativeError NativeEnableWakeupByTouchPad(); + + [MethodImpl(MethodImplOptions.InternalCall)] + private static extern EspNativeError NativeStartLightSleep(); + + [MethodImpl(MethodImplOptions.InternalCall)] + private static extern EspNativeError NativeStartDeepSleep(); + + [MethodImpl(MethodImplOptions.InternalCall)] + private static extern WakeupCause NativeGetWakeupCause(); + + [MethodImpl(MethodImplOptions.InternalCall)] + private static extern WakeupGpioPin NativeGetWakeupGpioPin(); + + [MethodImpl(MethodImplOptions.InternalCall)] + private static extern TouchPad NativeGetWakeupTouchpad(); + + #endregion + + } +} diff --git a/source/nanoFramework.Hardware.Esp32/app.config b/source/nanoFramework.Hardware.Esp32/app.config new file mode 100644 index 0000000..dae1033 --- /dev/null +++ b/source/nanoFramework.Hardware.Esp32/app.config @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/source/nanoFramework.Hardware.Esp32/nanoFramework.Hardware.Esp32.nfproj b/source/nanoFramework.Hardware.Esp32/nanoFramework.Hardware.Esp32.nfproj new file mode 100644 index 0000000..bb5c9a2 --- /dev/null +++ b/source/nanoFramework.Hardware.Esp32/nanoFramework.Hardware.Esp32.nfproj @@ -0,0 +1,95 @@ + + + + $(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\ + + + + Debug + AnyCPU + {11A8DD76-328B-46DF-9F39-F559912D0360};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 7ed93745-27d9-4e63-9033-c39642d323a0 + Library + 512 + + + nanoFramework.Hardware.Esp32 + v1.0 + True + bin\$(Configuration)\nanoFramework.Hardware.Esp32.xml + + + true + + + ..\key.snk + + + false + + + + + false + true + true + + false + true + + true + true + Stubs\nanoFramework_hardware_esp32_native + hardware_esp32 + false + nanoFramework.Hardware.Esp32 + + + + false + + + false + + + false + + + + + + + + + + + + + + + + + + + + + + ..\packages\nanoFramework.CoreLibrary.1.0.4\lib\mscorlib.dll + True + + + ..\packages\nanoFramework.Runtime.Events.1.0.0\lib\nanoFramework.Runtime.Events.dll + True + + + ..\packages\nanoFramework.Windows.Devices.Gpio.1.0.0\lib\Windows.Devices.Gpio.dll + True + + + + + + + + + diff --git a/source/nanoFramework.Hardware.Esp32/packages.config b/source/nanoFramework.Hardware.Esp32/packages.config new file mode 100644 index 0000000..4bab53e --- /dev/null +++ b/source/nanoFramework.Hardware.Esp32/packages.config @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file