Publicité

Can the below code be modified per these requirements � Call your s.pdf

sales88
1 Apr 2023
Can the below code be modified per these requirements � Call your s.pdf
Can the below code be modified per these requirements � Call your s.pdf
Can the below code be modified per these requirements � Call your s.pdf
Can the below code be modified per these requirements � Call your s.pdf
Publicité
Can the below code be modified per these requirements � Call your s.pdf
Prochain SlideShare
#MicroXplorer Configuration settings - do not modifyFile.Versio.docx#MicroXplorer Configuration settings - do not modifyFile.Versio.docx
Chargement dans ... 3
1 sur 5
Publicité

Contenu connexe

Plus de sales88(20)

Publicité

Can the below code be modified per these requirements � Call your s.pdf

  1. Can the below code be modified per these requirements? 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. The following guidance will help provide a base for the functionality you are creating: 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 ======== */ #include #include /* Driver Header files */ #include #include /* Driver configuration */ #include "ti_drivers_config.h" /* Morse Code for SOS */ #define SOS "***---***" /* Morse Code for OK */ #define OK "-.-.-" int SOS_state = 0; int OK_state = 0; int is_SOS = 1; /* LED Blink Timer Callback */ void timerCallback(Timer_Handle myHandle, int_fast16_t status) { if(is_SOS){ // Blink SOS switch(SOS_state){ case 0: GPIO_write(CONFIG_GPIO_LED_0, CONFIG_GPIO_LED_ON); GPIO_write(CONFIG_GPIO_LED_1, CONFIG_GPIO_LED_OFF); break; case 1:
  2. GPIO_write(CONFIG_GPIO_LED_0, CONFIG_GPIO_LED_OFF); GPIO_write(CONFIG_GPIO_LED_1, CONFIG_GPIO_LED_ON); break; case 2: GPIO_write(CONFIG_GPIO_LED_0, CONFIG_GPIO_LED_ON); GPIO_write(CONFIG_GPIO_LED_1, CONFIG_GPIO_LED_OFF); break; default: break; } SOS_state++; if(SOS_state >= strlen(SOS)){ SOS_state = 0; } }else{ // Blink OK switch(OK_state){ case 0: GPIO_write(CONFIG_GPIO_LED_0, CONFIG_GPIO_LED_ON); GPIO_write(CONFIG_GPIO_LED_1, CONFIG_GPIO_LED_OFF); break; case 1: GPIO_write(CONFIG_GPIO_LED_0, CONFIG_GPIO_LED_OFF); GPIO_write(CONFIG_GPIO_LED_1, CONFIG_GPIO_LED_ON); break; case 2: GPIO_write(CONFIG_GPIO_LED_0, CONFIG_GPIO_LED_OFF); GPIO_write(CONFIG_GPIO_LED_1, CONFIG_GPIO_LED_ON); break; case 3: GPIO_write(CONFIG_GPIO_LED_0, CONFIG_GPIO_LED_ON); GPIO_write(CONFIG_GPIO_LED_1, CONFIG_GPIO_LED_OFF); break; default: break; }
  3. OK_state++; if(OK_state >= strlen(OK)){ OK_state = 0; } } } /* * ======== 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 message between SOS and OK */ is_SOS = !is_SOS; } /* * ======== 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); /*
  4. * 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, gpioButtonFxn0); GPIO_enableInt(CONFIG_GPIO_BUTTON_1); } /* Initialize LED Blink Timer */ initTimer(); return (NULL); } /* Initialize LED Blink Timer */ void initTimer(void) { Timer_Handle timer0; Timer_Params params; Timer_init(); Timer_Params_init(&params); params.period = 500000; params.periodUnits = Timer_PERIOD_US; params.timerMode = Timer_CONTINUOUS_CALLBACK; params.timerCallback = timerCallback; timer0 = Timer_open(CONFIG_TIMER_0, &params); if (timer0 == NULL) { /* Failed to initialized timer */ while (1) { } } if (Timer_start(timer0) == Timer_STATUS_ERROR) {
  5. /* Failed to start timer */ while (1) { } } }
Publicité