Question: Call your state machine every 500000 us. Continuously blink SOS in Morse code on the green and red LEDs. Using CC3220 Launchpad we need to

Call your state machine every 500000 us. Continuously blink SOS in Morse code on the green and red LEDs.

Using CC3220 Launchpad we need to write a code to make LED blink SOS

Dot = red LED on for 500ms

Dash = green LED on for 1500ms

3*500ms between characters (both LEDs off)

7*500ms between words (both LEDs off), for example SOS 3500ms SOS

GPIOINTERRUPT.c

The code is:

#include #include

/* Driver Header files */ #include #include

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

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 = 1000000; 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!