TC275——05ASCLIN-UART
ASCLIN模块
AscLin 这个词意思是 UART+SPI+LIN,这是三种在汽车里常用的(相对 CAN 简单的通信接口)简单接口。由于有一些可以复用的电路,AURIX 把这三种接口做成了一个模块,可以通过配置选择。
Asynchronous/Synchronous Interface (ASCLIN)
程序
/*********************************************************************************************************************/
/*-----------------------------------------------------Includes------------------------------------------------------*/
/*********************************************************************************************************************/
#include "IfxAsclin_Asc.h"
#include "IfxCpu_Irq.h"
#include "Ifx_Console.h"/*********************************************************************************************************************/
/*------------------------------------------------------Macros-------------------------------------------------------*/
/*********************************************************************************************************************/
#define SERIAL_BAUDRATE 115200 /* Baud rate in bit/s */#define SERIAL_PIN_RX IfxAsclin0_RXA_P14_1_IN /* RX pin of the board */
#define SERIAL_PIN_TX IfxAsclin0_TX_P14_0_OUT /* TX pin of the board */#define INTPRIO_ASCLIN0_TX 19 /* Priority of the ISR */
#define INTPRIO_ASCLIN0_RX 14
#define INTPRIO_ASCLIN0_ER 20#define ASC_TX_BUFFER_SIZE 64 /* Definition of the buffer size */
#define ASC_RX_BUFFER_SIZE 64/*********************************************************************************************************************/
/*-------------------------------------------------Global variables--------------------------------------------------*/
/*********************************************************************************************************************/
static IfxStdIf_DPipe stdio; //使用print必须加上
IfxAsclin_Asc g_asc; /* Declaration of the ASC handle */
uint8 g_ascTxBuffer[ASC_TX_BUFFER_SIZE + sizeof(Ifx_Fifo) + 8];
uint8 g_ascRxBuffer[ASC_RX_BUFFER_SIZE + sizeof(Ifx_Fifo) + 8];/* Declaration of the FIFOs parameters *//*********************************************************************************************************************/
/*---------------------------------------------Function Implementations----------------------------------------------*/
/*********************************************************************************************************************/
IFX_INTERRUPT(asclin0_Tx_ISR, 0, INTPRIO_ASCLIN0_TX); /* Adding the Interrupt Service Routine */void asclin0_Tx_ISR(void)
{IfxAsclin_Asc_isrTransmit(&g_asc);
}void init_UART(void)
{/* Initialize an instance of IfxAsclin_Asc_Config with default values */IfxAsclin_Asc_Config ascConfig;IfxAsclin_Asc_initModuleConfig(&ascConfig, &MODULE_ASCLIN0);//同时配置发送接收//IfxAsclin_Asc_initModuleConfig(&ascConfig, SERIAL_PIN_TX.module);//只配置了发送/* Set the desired baud rate设置波特率 */ascConfig.baudrate.baudrate = SERIAL_BAUDRATE;/* ISR priorities and interrupt target */ascConfig.interrupt.txPriority = INTPRIO_ASCLIN0_TX;ascConfig.interrupt.rxPriority = INTPRIO_ASCLIN0_RX;//加上接收的ascConfig.interrupt.erPriority = INTPRIO_ASCLIN0_ER;//错误ascConfig.interrupt.typeOfService = IfxCpu_Irq_getTos(IfxCpu_getCoreIndex());//使能,使用哪个CPU/* FIFO configuration缓冲区配置 */ascConfig.txBuffer = &g_ascTxBuffer;ascConfig.txBufferSize = ASC_TX_BUFFER_SIZE;ascConfig.rxBuffer = &g_ascRxBuffer;ascConfig.rxBufferSize = ASC_RX_BUFFER_SIZE;/* Port pins configuration 管脚配置*/const IfxAsclin_Asc_Pins pins ={NULL_PTR, IfxPort_InputMode_pullUp, /* CTS pin not used */&SERIAL_PIN_RX, IfxPort_InputMode_pullUp, /* RX pin not used */NULL_PTR, IfxPort_OutputMode_pushPull, /* RTS pin not used */&SERIAL_PIN_TX, IfxPort_OutputMode_pushPull, /* TX pin */IfxPort_PadDriver_cmosAutomotiveSpeed1};ascConfig.pins = &pins;//初始化串口模块 -> 初始化标准输入输出流 -> 初始化标准控制台IfxAsclin_Asc_initModule(&g_asc, &ascConfig); /* Initialize module with above parameters */IfxAsclin_Asc_stdIfDPipeInit(&stdio, &g_asc); //使用print必须加上Ifx_Console_init(&stdio);}void send_UART_message(void)
{uint8 txData[] = "Hello World!"; /* Message to send */Ifx_SizeT count = 12; /* Size of the message */IfxAsclin_Asc_write(&g_asc, txData, &count, TIME_INFINITE); /* Transfer of data */
}
#include "Ifx_Types.h"
#include "IfxCpu.h"
#include "IfxScuWdt.h"
#include "UART_VCOM.h"
#include "Ifx_Console.h"//print用
#include "Bsp.h"//延时用得上IfxCpu_syncEvent g_cpuSyncEvent = 0;
uint32 i = 0;int core0_main(void)
{IfxCpu_enableInterrupts();/* !!WATCHDOG0 AND SAFETY WATCHDOG ARE DISABLED HERE!!* Enable the watchdogs and service them periodically if it is required*/IfxScuWdt_disableCpuWatchdog(IfxScuWdt_getCpuWatchdogPassword());IfxScuWdt_disableSafetyWatchdog(IfxScuWdt_getSafetyWatchdogPassword());/* Wait for CPU sync event */IfxCpu_emitEvent(&g_cpuSyncEvent);IfxCpu_waitEvent(&g_cpuSyncEvent, 1);init_UART(); /* Initialize the module */send_UART_message(); /* Send the message "Hello World!" */while(1){Ifx_Console_print("Hello, world!(%d)\n", i++);//尝试使用Ifx_Console_print的函数,类似于printfwaitTime(IfxStm_getTicksFromMilliseconds(BSP_DEFAULT_TIMER, 500));}return (1);
}
测试结果
TC275——05ASCLIN-UART相关推荐
- uart协议_UART协议简介
1UART UART是异步串口通信协议,英文全称是Universal Asynchronous Receiver /Transmitter 即通用异步收发传输器,它不像SPI和I2C这样的通信协议,但 ...
- linux uart m200平台波特率500kbps乱码问题和输入不响应问题
[问题] linux uart m200平台波特率500kbps乱码问题 [解答] [问题] linux uart m200平台波特率500kbps输入不响应问题 [解答] 转载于:https://w ...
- 串口的偶校验位设置_详解UART串口
通用异步收发传输器(Universal Asynchronous Receiver/Transmitter,通常称作UART) 是一种串行异步收发协议,应用十分广泛.UART工作原理是将数据的二进制位 ...
- c++ 测试串口速率_Raspberry Pi Zero W:串口(UART)的配置和使用
Raspberry Pi Zero W:串口(UART)的配置和使用 开启UART 据官方所言(https://www.raspberrypi.org/documentation/configurat ...
- 通讯波形记录——I2S、I2C、Uart、SPI
SPI波形 设置: UART I2S 扩展: I2S有3个主要信号: 1. SCLK:串行时钟,也叫位时钟(BCLK),即对应数字音频的每一位数据,SCLK都有1个脉冲.SCLK的频率=2×采样频率 ...
- GPIO,I2C,SPI,UART,USART,USB的区别
1.简单区别: 1) GPIO(General Purpose Input Output )为通用输入/输出,通用端口,总线扩展器, 利用工业标准I2C.SMBus™或SPI™接口简化了I/O口的扩展 ...
- RPi 2B UART作为调试口或者普通串口
/*************************************************************************************** RPi 2B UART ...
- 八、mini2440裸机程序之UART(2)UART0与PC串口通信【转】
转自:http://blog.csdn.net/shengnan_wu/article/details/8309417 版权声明:本文为博主原创文章,未经博主允许不得转载. 1.相关原理图 2.相关寄 ...
- uart口图片_认识UART接口
没有仔细研究过,就用了下,总结了点,也搜了点资料: 串口进行通信的方式有两种:同步通信方式和异步通信方式 SPI(Serial Peripheral Interface:串行外设接口); I2C(IN ...
- FPGA基础知识极简教程(6)UART通信与移位寄存器的应用
博文目录 写在前面 正文 关于UART的介绍 UART通信过程 UART.RS232以及TTL之间的关系 UART的使用场合 有关UART的总结 调试UART的技巧 UART的Verilog实现 波特 ...
最新文章
- Mac打包Android的apk,[Mac][React Native][Android] 打包成apk
- linux虚拟单用户数,Linux单用户模式
- Java删除文件及其子文件、文件夹
- mysqlbinlog工具_mysqlbinlog命令详解 Part 1-实验环境准备
- gitlab 修改HTTP连接方式中的IP和端口
- Java跳出多重循环
- python中object是什么数据类型_自学Python2.1-基本数据类型-字符串str(object) 上
- python杨长兴版答案,c++程序设计课后习题答案(杨长兴 ,刘卫国主编)1111
- 记华为综合面试(IT集成类)
- python 内存溢出_python之记录一次内存溢出
- bzoj 3373: [Usaco2004 Mar]Lying Livestock 说谎的牲畜
- 大数据面试3分钟自我介绍_如何在面试时,做好三分钟自我介绍
- 10 个实战与面试【常用 Shell 脚本】编写
- CodeForces - 869A The Artful Expedient
- 多组输入,scanf的与按位取反操作符的运用。
- About Oracle TraceFile
- 国内供应链金融模式梳理及思考
- win10支持8t 硬盘_教你如何解决win10系统识别不了移动硬盘?
- Digital Twin 数字孪生 工业4.0 SCADA 物联网
- 介绍python中几种遍历列表的for循环方法