mirror of
https://github.com/pvvx/RTL00MP3.git
synced 2025-07-31 12:41:06 +00:00
add examples
This commit is contained in:
parent
265d41b6a3
commit
4128624f93
112 changed files with 158017 additions and 0 deletions
19
RTL00_SDKV35a/example_sources/uart_irq/readme.txt
Normal file
19
RTL00_SDKV35a/example_sources/uart_irq/readme.txt
Normal 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:
|
||||
1. The RX data ready interrupt service routine is used to receive characters from the PC, and then loopback them to the PC.
|
||||
2. The TX done interrupt service routine will send a prompt string "8195a$" to the PC.
|
65
RTL00_SDKV35a/example_sources/uart_irq/src/main.c
Normal file
65
RTL00_SDKV35a/example_sources/uart_irq/src/main.c
Normal file
|
@ -0,0 +1,65 @@
|
|||
/*
|
||||
* 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
|
||||
|
||||
volatile char rc=0;
|
||||
|
||||
void uart_send_string(serial_t *sobj, char *pstr)
|
||||
{
|
||||
unsigned int i=0;
|
||||
|
||||
while (*(pstr+i) != 0) {
|
||||
serial_putc(sobj, *(pstr+i));
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
void uart_irq(uint32_t id, SerialIrq event)
|
||||
{
|
||||
serial_t *sobj = (void*)id;
|
||||
|
||||
if(event == RxIrq) {
|
||||
rc = serial_getc(sobj);
|
||||
serial_putc(sobj, rc);
|
||||
}
|
||||
|
||||
if(event == TxIrq && rc!=0){
|
||||
uart_send_string(sobj, "\r\n8195a$");
|
||||
rc = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void main(void)
|
||||
{
|
||||
// sample text
|
||||
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 IRQ API Demo...\r\n");
|
||||
uart_send_string(&sobj, "Hello World!!\n");
|
||||
uart_send_string(&sobj, "\r\n8195a$");
|
||||
serial_irq_handler(&sobj, uart_irq, (uint32_t)&sobj);
|
||||
serial_irq_set(&sobj, RxIrq, 1);
|
||||
serial_irq_set(&sobj, TxIrq, 1);
|
||||
|
||||
while(1);
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue