Softuart (#307)
* extras/softuart: support for multiple UARTs, dynamic RX/TX pins
This commit is contained in:
parent
fda5d0b942
commit
6b0547b963
7 changed files with 463 additions and 0 deletions
23
examples/softuart/LICENSE
Normal file
23
examples/softuart/LICENSE
Normal file
|
@ -0,0 +1,23 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (C) 2016 Bernhard Guillon <Bernhard.Guillon@web.de>
|
||||
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.
|
||||
|
4
examples/softuart/Makefile
Normal file
4
examples/softuart/Makefile
Normal file
|
@ -0,0 +1,4 @@
|
|||
PROGRAM = softuart
|
||||
EXTRA_COMPONENTS = extras/softuart
|
||||
ESPBAUD = 460800
|
||||
include ../../common.mk
|
40
examples/softuart/main.c
Normal file
40
examples/softuart/main.c
Normal file
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* Softuart example
|
||||
*
|
||||
* Copyright (C) 2017 Ruslan V. Uss <unclerus@gmail.com>
|
||||
* Copyright (C) 2016 Bernhard Guillon <Bernhard.Guillon@web.de>
|
||||
* Copyright (c) 2015 plieningerweb
|
||||
*
|
||||
* MIT Licensed as described in the file LICENSE
|
||||
*/
|
||||
#include <esp/gpio.h>
|
||||
#include <esp/uart.h>
|
||||
#include <espressif/esp_common.h>
|
||||
#include <stdio.h>
|
||||
//#include <FreeRTOS.h>
|
||||
//#include <task.h>
|
||||
|
||||
#include <softuart/softuart.h>
|
||||
|
||||
#define RX_PIN 5
|
||||
#define TX_PIN 4
|
||||
|
||||
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 uart to 9600 8n1
|
||||
softuart_open(0, 9600, RX_PIN, TX_PIN);
|
||||
|
||||
while (true)
|
||||
{
|
||||
if (!softuart_available(0))
|
||||
continue;
|
||||
|
||||
char c = softuart_read(0);
|
||||
printf("input: %c, 0x%02x\n", c, c);
|
||||
softuart_puts(0, "start\r\n");
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue