Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Modify/change the hw_hook.c and hw_asm.c files. . use A3 blinking lights as instruction guide for this assignment. The purpose of this assignment is to interact

Modify/change the hw_hook.c and hw_asm.c files. . use A3 blinking lights as instruction guide for this assignment. The purpose of this assignment is to interact with an stm32f303 board to make it blink in a n ubuntu(linux) shell.

hw_asm.c file

@ Test code for my own new function called from C

@ This is a comment. Anything after an @ symbol is ignored. @@ This is also a comment. Some people use double @@ symbols.

.code 16 @ This directive selects the instruction set being generated. @ The value 16 selects Thumb, with the value 32 selecting ARM.

.text @ Tell the assembler that the upcoming section is to be considered @ assembly language instructions - Code section (text -> ROM)

@@ Function Header Block .align 2 @ Code alignment - 2^n alignment (n=2) @ This causes the assembler to use 4 byte alignment

.syntax unified @ Sets the instruction set to the new unified ARM + THUMB @ instructions. The default is divided (separate instruction sets)

.global hw_led_demo @ Make the symbol name for the function visible to the linker

.code 16 @ 16bit THUMB code (BOTH .code and .thumb_func are required) .thumb_func @ Specifies that the following symbol is the name of a THUMB @ encoded function. Necessary for interlinking between ARM and THUMB code.

.type hw_led_demo , %function @ Declares that the symbol is a function (not strictly required)

@ Function Declaration : int hw_led_demo(int count, int delay) @ @ Input: r0, r1 (i.e. r0 holds count, r1 holds delay) @ Returns: r0 @

@ Here is the actual function hw_led_demo:

add r0, r0, r1

bx lr @ Return (Branch eXchange) to the address in the link register (lr)

.size hw_led_demo, .-hw_led_demo @@ - symbol size (not req)

@ Assembly file ended by single .end directive on its own line .end

hw_hook.c file

/*

* C to assembler menu hook

*

*/

#include

#include

#include

#include "common.h"

int hw_led_demo(int count, int delay);

void hwA2(uint32_t count , uint32_t delay )

{

int action = 0;

int fetch_status;

fetch_status = fetch_uint32_arg(&delay);

if(fetch_status)

{

// Use a default delay value

delay = 0xFFFFFF;

}

// defaults if the user does not provide one or both parameters

if (count == 0) count = 1;

if (delay == 0) delay = 1;

if(action==CMD_SHORT_HELP) return;

if(action==CMD_LONG_HELP)

{

printf("Addition Test This command tests delays in the function ");

return;

}

printf("hw_led_demo: %d ", hw_led_demo(88, 99) );

}

ADD_CMD("add", hwA2, "Test delays in the function")

PROG1360 Assignment 3 Blinking Lights

Individual or Pair

Please note: Copying and submitting work that is not your own is an academic violation, and will be dealt with as such.

Objectives

Structure your assembly code

Blink some lights

Major Tasks

Demonstration Building on Labs

This assignment builds on the labs and assignments so far.

The Demonstration section of this document outlines the items you are required to show.

Tasks

You will implement a simple game that uses the lights and button on the board.

Given the command below (where xx is your initials)

xxGame delay pattern target

your board will repeatedly blink the lights in the pattern you specify, until you push the button. If when you push the button the target light is on, the user wins and all the lights blink twice at the same time. If the user loses, only the target light is lit up.

Example:

jsGame 500 43567011 5

This would run the game with a delay of 500ms between lights (you will have to scale the delay) and cycle the lights in a pattern of 4, 3, 5, 6, 7, 0, 1, 1. If the user manages to push the button when the 5 light is lit up, they will win.

Requirements

No logic is to be implemented in your C hook code UNLESS it is related to removing the busy delay.

You may use library functions from the stm32 code to detect button state and parse input.

It is very important that you structure your code cleanly for this assignment.

You must name all functions and adapt any menu help instructions appropriately.

You will have to scale the delay to approximate milliseconds.

You will have to parse the input pattern and store it in a way that you can cycle through it repeatedly.

Demonstration

Please note that you must be prepared before offering to demonstrate your code. You must demonstrate the code that you have submitted to the eConestoga dropbox.

For this assignment, you will demonstrate the following items. You may use a lab PC or your own. If needed, you may use a classmates VM, but you MUST run your own code and only your own code. You must demonstrate in your regularly scheduled lab period. If you demonstrate modified code, you will receive a late penalty according to how long it has been since the dropbox deadline.

Your xx_hook.c and xx_asm.s code as taken directly from the drop box compiles.

Your code deploys with make program.

Your code runs with no parameters provided (sensible defaults).

Your code runs as specified.

You can demonstrate both cases that it is possible to both win and lose.

Code

The code you submit will be evaluated on the following criteria.

Functionality

Your program behaves as specified.

Proper use of Registers, the stack, and link register

Only necessary items (no more, no less) are pushed onto the stack. Your function calls use the link register appropriately.

Code Readability and Structure

Your code is properly indented, does not wrap or have long lines, and can be logically understood.

You use subroutines and memory appropriately.

Code comments

As this is assembly language, you must extensively comment any code that is unclear (i.e. nearly every line).

note: just modify the ARM assembly code and c code files to fit the requirements

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Concepts of Database Management

Authors: Philip J. Pratt, Joseph J. Adamski

7th edition

978-1111825911, 1111825912, 978-1133684374, 1133684378, 978-111182591

More Books

Students also viewed these Databases questions

Question

Select 4 numbers that are equal to 10 0.06 0.60 6% 60 60% 6 100 35

Answered: 1 week ago

Question

How can you defend against SQL injection attacks?

Answered: 1 week ago

Question

=+employee to take on the international assignment?

Answered: 1 week ago