From 5192f731832e572d358f20319f9f56019d1dc585 Mon Sep 17 00:00:00 2001 From: Bernhard Guillon Date: Sun, 4 Dec 2016 12:06:35 +0100 Subject: [PATCH] exaples/softuart: add basic example for softuart --- examples/softuart/LICENSE | 23 +++++++++++++++++++++++ examples/softuart/Makefile | 4 ++++ examples/softuart/main.c | 30 ++++++++++++++++++++++++++++++ 3 files changed, 57 insertions(+) create mode 100644 examples/softuart/LICENSE create mode 100644 examples/softuart/Makefile create mode 100644 examples/softuart/main.c diff --git a/examples/softuart/LICENSE b/examples/softuart/LICENSE new file mode 100644 index 0000000..104c838 --- /dev/null +++ b/examples/softuart/LICENSE @@ -0,0 +1,23 @@ +The MIT License (MIT) + +Copyright (C) 2016 Bernhard Guillon +Copyright (c) 2015 plieningerweb + +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. + diff --git a/examples/softuart/Makefile b/examples/softuart/Makefile new file mode 100644 index 0000000..5b3f951 --- /dev/null +++ b/examples/softuart/Makefile @@ -0,0 +1,4 @@ +PROGRAM = softuart +EXTRA_COMPONENTS = extras/softuart +ESPBAUD = 460800 +include ../../common.mk diff --git a/examples/softuart/main.c b/examples/softuart/main.c new file mode 100644 index 0000000..350cde9 --- /dev/null +++ b/examples/softuart/main.c @@ -0,0 +1,30 @@ +/* + * Softuart example + * + * Copyright (C) 2016 Bernhard Guillon + * Copyright (c) 2015 plieningerweb + * + * MIT Licensed as described in the file LICENSE + */ +#include +#include +#include +#include +#include "softuart/softuart.h" + +void user_init(void) +{ + // setup real UART for now + uart_set_baud(0, 115200); + printf("SDK version:%s\n\n", sdk_system_get_sdk_version()); + + // setup software rx to 9600 8n1 + softuart_init(9600); + + while (true) + { + if (!softuart_available()) + continue; + printf("%c",softuart_read()); + } +}