这是一篇来自澳洲的关于测试ATmegaA324A微控制器的C编程技能的编程代写。具体作业要求是您需要修改一个程序以实现附加的特性。该程序是街机游戏“Pong”的基本模板(详细描述见第3页)。AVR ATmega324微控制器运行程序和接收来自多个来源的输入和使用LED矩阵作为游戏显示,额外的信息输出到串行终端和作为这个任务的一部分实现七段显示和其他设备。以下是部分作业内容:
Program Description
The program you will be provided with has several C files which contain groups of related functions.
The files provided are described below. The corresponding .h files (except for project.c) list the functions that are intended to be accessible from other files. You may modify any of the provided files. You must submit ALL files used to build your project, even if you have not modified some provided files. Many files make assumptions about which AVR ports are used to connect to various IO devices. You are encouraged not to change these.
- project.c – this is the main file that contains the game event loop and examples of how time-based events are implemented. You should read and understand this file.
- game.c/.h – this file contains the implementation of the game components and is used to store the state of the game. You should read this file and understand what representation is used for the game state and the ball and paddle positions. You will need to modify this file to add required functionality.
- display.c/.h – this file contains the implementation for displaying the current state of the board. This file contains useful functions for displaying the board to the LED matrix.
- buttons.c/.h – this contains the code which deals with the push buttons. It sets up pin change interrupts on those pins and records rising edges (buttons being pushed).
- ledmatrix.c/.h – this contains functions which give easier access to the services provided by the LED matrix. It makes use of the SPI routines implemented in spi.c.
- pixel_colour.h – this file contains definitions of some useful colours for use with the LED matrix.
- serialio.c/.h – this file is responsible for handling serial input and output using interrupts. It also maps the C standard IO routines (e.g. printf() and fgetc()) to use the serial interface so you are able to use printf() etc for debugging purposes if you wish. You should not need to look in this file, but you may be interested in how it works and the buffer sizes used for input and output (and what happens when the buffers fill up).
- terminalio.c/.h – this encapsulates the sending of various escape sequences which enable some control over terminal appearance and text placement – you can call these functions (declared in terminalio.h) instead of remembering various escape sequences. Additional information about terminal IO will be provided on the course Blackboard site.
- spi.c./h – this file encapsulates all SPI communication. Note that by default, all SPI communication uses busy waiting (i.e. polling) – the “send” routine returns only when the data is sent. If you need the CPU cycles for other activities, you may wish to consider converting this to interrupt based IO, similar to the way that serial IO is handled.
- timer0.c/.h – sets up a timer that is used to generate an interrupt every millisecond and update a global time value that is used to time various game events (such as the Pong ball movement).
This can be useful for implementing any features that require precise timing.
……
程序说明
您将获得的程序有几个包含相关函数组的 C 文件。
提供的文件如下所述。 相应的 .h 文件(project.c 除外)列出了可从其他文件访问的函数。 您可以修改任何提供的文件。 您必须提交用于构建项目的所有文件,即使您没有修改某些提供的文件。 许多文件都假设哪些 AVR 端口用于连接各种 IO 设备。 我们鼓励您不要更改这些。
- project.c – 这是包含游戏事件循环和如何实现基于时间的事件的示例的主文件。 您应该阅读并理解此文件。
- game.c/.h – 该文件包含游戏组件的实现,用于存储游戏状态。 您应该阅读此文件并了解用于游戏状态以及球和球拍位置的表示。 您将需要修改此文件以添加所需的功能。
- display.c/.h——该文件包含显示板当前状态的实现。 此文件包含用于将电路板显示到 LED 矩阵的有用函数。
- buttons.c/.h – 这包含处理按钮的代码。 它在这些引脚上设置引脚更改中断并记录上升沿(按下按钮)。
- ledmatrix.c/.h – 这包含可以更轻松地访问 LED 矩阵提供的服务的函数。 它使用在 spi.c 中实现的 SPI 例程。
- pixel_colour.h——该文件包含一些用于 LED 矩阵的有用颜色的定义。
- serialio.c/.h——该文件负责使用中断处理串行输入和输出。 它还映射 C 标准 IO 例程(例如 printf() 和 fgetc())以使用串行接口,因此您可以根据需要使用 printf() 等进行调试。 您不需要查看此文件,但您可能对它的工作原理以及用于输入和输出的缓冲区大小(以及缓冲区填满时发生的情况)感兴趣。
- terminalio.c/.h – 这封装了各种转义序列的发送,这些转义序列可以对终端外观和文本放置进行一些控制 – 您可以调用这些函数(在 terminalio.h 中声明)而不是记住各种转义序列。 有关终端 IO 的更多信息将在课程 Blackboard 网站上提供。
- spi.c./h——这个文件封装了所有的 SPI 通信。 请注意,默认情况下,所有 SPI 通信都使用忙等待(即轮询)——“发送”例程仅在发送数据时返回。 如果您需要 CPU 周期用于其他活动,您可能希望考虑将其转换为基于中断的 IO,类似于处理串行 IO 的方式。
- timer0.c/.h——设置一个定时器,用于每毫秒产生一个中断,并更新一个全局时间值,用于为各种游戏事件(如乒乓球运动)计时。
这对于实现需要精确计时的任何功能都非常有用。
…….
以上就是关于CSSE2010/CSSE7201 Assignment 2的部分作业内容,如有相关编程代写服务需求的,可直接跟我们客服联系,了解相关业务。