ATY_LIB V2_102_230218
ATY_LIB for general devices or ALGO
 
Loading...
Searching...
No Matches
uart2_timer2_tx.c
Go to the documentation of this file.
1// Copyright 2021 IOsetting <iosetting(at)outlook.com>
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15/***
16 * Demo: UART2 TX
17 *
18 * Pin connection:
19 * STC8G/STC8H USB2TTL
20 * P10 -> TX
21 * P11 -> RX
22 */
23#include "fw_hal.h"
24
25void main(void)
26{
28 // P10:RX, P11:TX
30 // GPIO Config
32 // UART2, baud 115200, baud source Timer2, 1T mode, no interrupt
35 while(1)
36 {
37 UART2_TxChar('T');
38 UART2_TxHex(0x41);
39 UART2_TxString("U");
40 UART2_TxString(" string\r\n");
41 SYS_Delay(1000);
42 }
43}
@ GPIO_Pin_0
Definition: fw_gpio.h:45
@ GPIO_Pin_1
Definition: fw_gpio.h:46
#define GPIO_P1_SetMode(__PINS__, __MODE__)
Definition: fw_gpio.h:79
@ GPIO_Mode_InOut_QBD
Definition: fw_gpio.h:23
void SYS_SetClock(void)
Definition: fw_sys.c:40
void SYS_Delay(uint16_t t)
Definition: fw_sys.c:65
@ HAL_State_ON
Definition: fw_types.h:71
#define UART2_Set8bitUART()
Definition: fw_uart.h:113
#define UART2_SwitchPort(__ALTER_PORT__)
Definition: fw_uart.h:118
void UART2_TxChar(char dat)
Definition: fw_uart.c:113
void UART2_TxString(uint8_t *str)
Definition: fw_uart.c:126
void UART2_TxHex(uint8_t hex)
Definition: fw_uart.c:120
@ UART2_AlterPort_P10_P11
Definition: fw_uart.h:104
void UART2_Config(HAL_State_t _1TMode, uint32_t baudrate)
Definition: fw_uart.c:102
void main(void)