add examples

This commit is contained in:
pvvx 2016-12-14 04:21:37 +03:00
parent 265d41b6a3
commit 4128624f93
112 changed files with 158017 additions and 0 deletions

View file

@ -0,0 +1,19 @@
Example Description
This example describes how to use UART to communicate with PC.
Required Components:
USBtoTTL adapter
Connect to PC
- Connect Ground: connect to GND pin via USBtoTTL adapter
- Use UART1
GPIOA_6 as UART1_RX connect to TX of USBtoTTL adapter
GPIOA_7 as UART1_TX connect to RX of USBtoTTL adapter
Open Super terminal or teraterm and
set baud rate to 38400, 1 stopbit, no parity, no flow contorl.
This example shows:
User input will be received by demo board, and demo board will loopback the received character with a prompt string "8195a$".

View file

@ -0,0 +1,46 @@
/*
* Routines to access hardware
*
* Copyright (c) 2013 Realtek Semiconductor Corp.
*
* This module is a confidential and proprietary property of RealTek and
* possession or use of this module requires written permission of RealTek.
*/
#include "device.h"
#include "serial_api.h"
#include "main.h"
#define UART_TX PA_7
#define UART_RX PA_6
void uart_send_string(serial_t *sobj, char *pstr)
{
unsigned int i=0;
while (*(pstr+i) != 0) {
serial_putc(sobj, *(pstr+i));
i++;
}
}
void main(void)
{
// sample text
char rc;
serial_t sobj;
// mbed uart test
serial_init(&sobj,UART_TX,UART_RX);
serial_baud(&sobj,38400);
serial_format(&sobj, 8, ParityNone, 1);
uart_send_string(&sobj, "UART API Demo...\r\n");
uart_send_string(&sobj, "Hello World!!\r\n");
while(1){
uart_send_string(&sobj, "\r\n8195a$");
rc = serial_getc(&sobj);
serial_putc(&sobj, rc);
}
}