Zynq7020 SDK 初学篇(1) - HelloWorld

发布时间 2023-08-09 19:12:20作者: 掌控命运

一、开发环境  Zynq7020 + Vivado2017.4

二、开发背景:会使用 Vivado 开发工具,不熟悉的可以参考正点原子开发文档

二、功能实现,串口输出 HelloWorld

三、实现步骤:

  1、配置 PS 端 Block Design 串口 0

  

  

   2、导出到 SDK ,编写代码,编译输出即可

#include <stdio.h>
#include "platform.h"
#include "xil_printf.h"

int main()
{
    init_platform();

    print("Hello World\r\n");
    print("Hello Zynq7020\r\n");

    cleanup_platform();
    return 0;
}

  3、关键代码功能说明,下面是关键打印库说明,xil_printf.h提供了多个打印接口,其中:

  (1)xil_printf 基本等同于 C 语言下的 printf;

  (2)print 只能输出固定字符串,不可传参

#ifndef XIL_PRINTF_H
#define XIL_PRINTF_H

#ifdef __cplusplus
extern "C" {
#endif

#include <ctype.h>
#include <string.h>
#include <stdarg.h>
#include "xil_types.h"
#include "xparameters.h"
struct params_s; typedef char8* charptr; typedef s32 (*func_ptr)(int c); void xil_printf( const char8 *ctrl1, ...); void print( const char8 *ptr); extern void outbyte (char8 c); extern char8 inbyte(void); #ifdef __cplusplus } #endif #endif /* end of protection macro */