Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Call your state machine every 500000 us. Continuously blink SOS in Morse code on the green and red LEDs. If a button is pushed, toggle

Call your state machine every 500000 us. Continuously blink SOS in Morse code on the green and red LEDs. If a button is pushed, toggle the message between SOS and OK. Pushing the button in the middle of a message should NOT change the message until it is complete. For example, if you push the button while the O in SOS is being blinked out, the message will not change to OK until after the SOS message is completed. Remember in a previous module your work with UART included an example of how to turn an LED on or off (as opposed to toggle).

#include #include

/* Driver Header files */ #include

/* Driver configuration */ #include "ti_drivers_config.h"

#include void timerCallback(Timer_Handle myHandle, int_fast16_t status) { } void initTimer(void) { Timer_Handle timer0; Timer_Params params; Timer_init(); Timer_Params_init(¶ms); params.period = 500000; params.periodUnits = Timer_PERIOD_US; params.timerMode = Timer_CONTINUOUS_CALLBACK; params.timerCallback = timerCallback; timer0 = Timer_open(CONFIG_TIMER_0, ¶ms); if (timer0 == NULL) { /* Failed to initialized timer */ while (1) {} } if (Timer_start(timer0) == Timer_STATUS_ERROR) { /* Failed to start timer */ while (1) {} } }

/* * ======== gpioButtonFxn0 ======== * Callback function for the GPIO interrupt on CONFIG_GPIO_BUTTON_0. * * Note: GPIO interrupts are cleared prior to invoking callbacks. */ void gpioButtonFxn0(uint_least8_t index) { /* Toggle an LED */ GPIO_toggle(CONFIG_GPIO_LED_0); }

/* * ======== gpioButtonFxn1 ======== * Callback function for the GPIO interrupt on CONFIG_GPIO_BUTTON_1. * This may not be used for all boards. * * Note: GPIO interrupts are cleared prior to invoking callbacks. */ void gpioButtonFxn1(uint_least8_t index) { /* Toggle an LED */ GPIO_toggle(CONFIG_GPIO_LED_1); }

/* * ======== mainThread ======== */ void *mainThread(void *arg0) { /* Call driver init functions */ GPIO_init();

/* Configure the LED and button pins */ GPIO_setConfig(CONFIG_GPIO_LED_0, GPIO_CFG_OUT_STD | GPIO_CFG_OUT_LOW); GPIO_setConfig(CONFIG_GPIO_LED_1, GPIO_CFG_OUT_STD | GPIO_CFG_OUT_LOW); GPIO_setConfig(CONFIG_GPIO_BUTTON_0, GPIO_CFG_IN_PU | GPIO_CFG_IN_INT_FALLING);

/* Turn on user LED */ GPIO_write(CONFIG_GPIO_LED_0, CONFIG_GPIO_LED_ON);

/* Install Button callback */ GPIO_setCallback(CONFIG_GPIO_BUTTON_0, gpioButtonFxn0);

/* Enable interrupts */ GPIO_enableInt(CONFIG_GPIO_BUTTON_0);

/* * If more than one input pin is available for your device, interrupts * will be enabled on CONFIG_GPIO_BUTTON1. */ if (CONFIG_GPIO_BUTTON_0 != CONFIG_GPIO_BUTTON_1) { /* Configure BUTTON1 pin */ GPIO_setConfig(CONFIG_GPIO_BUTTON_1, GPIO_CFG_IN_PU | GPIO_CFG_IN_INT_FALLING);

/* Install Button callback */ GPIO_setCallback(CONFIG_GPIO_BUTTON_1, gpioButtonFxn1); GPIO_enableInt(CONFIG_GPIO_BUTTON_1); }

return (NULL); }

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

Accounting And Auditing Research And Databases Practitioner's Desk Reference

Authors: Thomas R. Weirich, Natalie Tatiana Churyk, Thomas C. Pearson

1st Edition

1118334426, 978-1118334423

More Books

Students also viewed these Databases questions

Question

=+ What will be done with the results?

Answered: 1 week ago

Question

Write short notes on Interviews.

Answered: 1 week ago